[PATCH] rcar-du: add/rename DEFR6 TCON bits

2016-04-26 Thread Laurent Pinchart
Hi Geert,

On Monday 25 Apr 2016 09:25:30 Geert Uytterhoeven wrote:
> On Sat, Apr 23, 2016 at 12:56 AM, Sergei Shtylyov wrote:
> > The  TCNE2 bit  of the DEFR6 register was renamed to TCNE1 in the R-Car
> > gen2 manuals -- which makes more  sense as that bit controls whether DU1,
> > not DU2 is connected to TCON.
> > 
> > While at it, add the TCNE0 bit which controls whether DU0 is connected to
> > TCON.
> > 
> > Based on the large patch by Andrey Gusakov
> > .
> > 
> > Signed-off-by: Andrey Gusakov 
> > Signed-off-by: Sergei Shtylyov 
> 
> I hard a hard time finding this register, as it's actually called "DEF6R"...
> Care to update /DEFRx/DEFxR/ as well?

Inconsistent information between datasheet versions I'm afraid, and even 
between different registers in a single datasheet. We have DEFR0, DEFR1, and 
then DEFxR. I wonder if it's worth renaming the registers.

> Regardless:
> Reviewed-by: Geert Uytterhoeven 
> 
> > ---
> > The patch is against David Airlie's 'linux.git' repo's 'drm-next' branch.
> > 
> >  drivers/gpu/drm/rcar-du/rcar_du_regs.h |5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > Index: linux/drivers/gpu/drm/rcar-du/rcar_du_regs.h
> > ===
> > --- linux.orig/drivers/gpu/drm/rcar-du/rcar_du_regs.h
> > +++ linux/drivers/gpu/drm/rcar-du/rcar_du_regs.h
> > @@ -195,9 +195,10 @@
> > 
> >  #define DEFR6_ODPM12_DISP  (2 << 8)
> >  #define DEFR6_ODPM12_CDE   (3 << 8)
> >  #define DEFR6_ODPM12_MASK  (3 << 8)
> > 
> > -#define DEFR6_TCNE2(1 << 6)
> > +#define DEFR6_TCNE1(1 << 6)
> > +#define DEFR6_TCNE0(1 << 4)
> > 
> >  #define DEFR6_MLOS1(1 << 2)
> > 
> > -#define DEFR6_DEFAULT  (DEFR6_CODE | DEFR6_TCNE2)
> > +#define DEFR6_DEFAULT  (DEFR6_CODE | DEFR6_TCNE1)

-- 
Regards,

Laurent Pinchart



[PATCH] rcar-du: add/rename DEFR6 TCON bits

2016-04-26 Thread Laurent Pinchart
Hi Sergei,

Thank you for the patch.

On Saturday 23 Apr 2016 01:56:07 Sergei Shtylyov wrote:
> The  TCNE2 bit  of the DEFR6 register was renamed to TCNE1 in the R-Car gen2
> manuals -- which makes more  sense as that bit controls whether DU1, not
> DU2 is connected to TCON.
> 
> While at it, add the TCNE0 bit which controls whether DU0 is connected to
> TCON.
> 
> Based on the large patch by Andrey Gusakov
> .
> 
> Signed-off-by: Andrey Gusakov 
> Signed-off-by: Sergei Shtylyov 

Acked-by: Laurent Pinchart 

and applied to my tree.

> ---
> The patch is against David Airlie's 'linux.git' repo's 'drm-next' branch.
> 
>  drivers/gpu/drm/rcar-du/rcar_du_regs.h |5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> Index: linux/drivers/gpu/drm/rcar-du/rcar_du_regs.h
> ===
> --- linux.orig/drivers/gpu/drm/rcar-du/rcar_du_regs.h
> +++ linux/drivers/gpu/drm/rcar-du/rcar_du_regs.h
> @@ -195,9 +195,10 @@
>  #define DEFR6_ODPM12_DISP(2 << 8)
>  #define DEFR6_ODPM12_CDE (3 << 8)
>  #define DEFR6_ODPM12_MASK(3 << 8)
> -#define DEFR6_TCNE2  (1 << 6)
> +#define DEFR6_TCNE1  (1 << 6)
> +#define DEFR6_TCNE0  (1 << 4)
>  #define DEFR6_MLOS1  (1 << 2)
> -#define DEFR6_DEFAULT(DEFR6_CODE | DEFR6_TCNE2)
> +#define DEFR6_DEFAULT(DEFR6_CODE | DEFR6_TCNE1)
> 
>  /* 
>   * R8A7790-only Control Registers

-- 
Regards,

Laurent Pinchart



[PATCH v2 1/8] drm/rect: Add some drm_clip_rect utility functions

2016-04-26 Thread Laurent Pinchart
Hi Noralf,

On Monday 25 Apr 2016 20:35:18 Noralf Trønnes wrote:
> Den 25.04.2016 18:38, skrev Ville Syrjälä:
> > On Mon, Apr 25, 2016 at 06:05:20PM +0200, Daniel Vetter wrote:
> >> On Mon, Apr 25, 2016 at 06:09:44PM +0300, Ville Syrjälä wrote:
> >>> On Mon, Apr 25, 2016 at 04:03:13PM +0200, Noralf Trønnes wrote:
>  Den 25.04.2016 15:02, skrev Ville Syrjälä:
> > On Mon, Apr 25, 2016 at 02:55:52PM +0200, Noralf Trønnes wrote:
> >> Den 25.04.2016 14:39, skrev Ville Syrjälä:
> >>> On Sun, Apr 24, 2016 at 10:48:55PM +0200, Noralf Trønnes wrote:
>  Add some utility functions for struct drm_clip_rect.
> >>> 
> >>> Looks like mostly you're just duplicating the drm_rect stuff. Why
> >>> can't you use what's there already?
> >> 
> >> That's because the framebuffer flushing uses drm_clip_rect and not
> >> drm_rect:
> >
> > Converting to drm_rect is not an option?
>  
>  That's difficult or at least verbose to do because clips is an array.
>  I could use drm_rect on the calling side (fbdev) since it's only one
>  clip which the changes are merged into, and then convert it when I call
>  dirty(). But the driver can get zero or more clips from the dirty ioctl
>  so I don't see a clean way to convert this array to drm_rect without
>  more code than this proposal has.
> >>> 
> >>> Just some kind of simple drm_clip_rect_to_rect() thing should be enough
> >>> AFAICS.
> >>
> >> Yeah, drm_clip_rect is the uapi struct, drm_rect is the internal one.
> >> Similar case is drm_display_mode vs. drm_mode_modeinfo. We have
> >> umode_to_mode and mode_to_umode helpers to deal with that. I do agree
> >> that it would make sense to switch the internal ->dirty callback over to
> >> the internal drm_struct. Would need a kmalloc+copy in the dirtyfb ioctl,
> >> but since the structs actually match in their member names (just not the
> >> size/signedness, sigh) there shouldn't be any need for driver changes. So
> >> fairly simple patch.
> > 
> > Or if we want to avoid the malloc, then the merge() thing could just
> > internally convert one at a time on stack when going through them.
> > Though then someone might want to do a merge() with internal drm_rects,
> > and we'd be right where we started. But I'm not sure that will happen,
> > so perhaps it's just too much future proofing.
> > 
> >> Ofc you need to compile-test all the drivers (at least those using
> >> ->dirty hook) to make sure gcc is still happy with all the signed vs.
> >> unsigned stuff. Maybe that turns up something, but hopefully not.
> >> 
> >> Sorry for that late request, but I really didn't realize what's going on
> >> here :(
> 
> How about we just drop this patch?
> I couldn't find anyone else that merge these clips, they just loop and
> handle them individually.
> 
> The relevant part in drm_fb_helper would become:
> 
> static void drm_fb_helper_dirty_work(struct work_struct *work)
> {
>  struct drm_fb_helper *helper = container_of(work, struct drm_fb_helper,
> dirty_work);
>  struct drm_clip_rect *clip = &helper->dirty_clip;
>  struct drm_clip_rect clip_copy;
>  unsigned long flags;
> 
>  spin_lock_irqsave(&helper->dirty_lock, flags);
>  clip_copy = *clip;
>  clip->x1 = clip->y1 = ~0;
>  clip->x2 = clip->y2 = 0;
>  spin_unlock_irqrestore(&helper->dirty_lock, flags);
> 
>  helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, &clip_copy, 1);
> }
> 
> static void drm_fb_helper_dirty_init(struct drm_fb_helper *helper)
> {
>  spin_lock_init(&helper->dirty_lock);
>  INIT_WORK(&helper->dirty_work, drm_fb_helper_dirty_work);
>  helper->dirty_clip.x1 = helper->dirty_clip.y1 = ~0;
> }
> 
> static void drm_fb_helper_dirty(struct fb_info *info, u32 x, u32 y,
>  u32 width, u32 height)
> {
>  struct drm_fb_helper *helper = info->par;
>  struct drm_clip_rect *clip = &helper->dirty_clip;
>  unsigned long flags;
> 
>  if (!helper->fb->funcs->dirty)
>  return;
> 
>  spin_lock_irqsave(&helper->dirty_lock, flags);
>  clip->x1 = min(clip->x1, x);
>  clip->y1 = min(clip->y1, y);
>  clip->x2 = max(clip->x2, x + width);
>  clip->y2 = max(clip->y2, y + height);
>  spin_unlock_irqrestore(&helper->dirty_lock, flags);
> 
>  schedule_work(&helper->dirty_work);
> }
> 
> 
> And the driver would use this tinydrm function:
> 
> void tinydrm_merge_clips(struct drm_clip_rect *dst,
>   struct drm_clip_rect *src, unsigned num_clips,
>   unsigned flags, u32 width, u32 height)
> {
>  int i;

Nitpicking here, as i never takes negative values, could you make it an 
unsigned int ?

> 
>  if (!src || !num_clips) {
>  dst->x1 = 0;
>  dst->x2 = width;
>  dst->y1 = 0;
>  dst->y2 = height;
>  return;
>  }
> 
>  dst->x1 = dst->y1 = ~0;
>  dst->x2 = dst->y2 = 0;
> 
>  for (i = 0; i < num_clips; i++) {
>  if (flags 

[PATCH v2 00/13] R-Car VSP improvements for v4.7 - Round 2

2016-04-26 Thread Laurent Pinchart
Hello,

This patch series is the second version of the second (and most probably last)
round of vsp1 driver improvements for v4.7. In particular, it enables runtime
PM support (03/13 and 04/13), adds support for the FCP (01/13, 02/13 and
05/13), prepare for HGO (histogram) support (06/13 to 09/13) and update the
API towards the DRM driver (10/13 to 13/13).

The FCP is a companion module of video processing modules in the Renesas R-Car
Gen3 SoCs. It provides data compression and decompression, data caching, and
conversion of AXI transaction in order to reduce the memory bandwidth. The FCP
driver is not meant to be used standalone but provides an API to the video
processing modules to control the FCP.

The API towards the DRM driver is updated to store all configuration
parameters in a structure in order to improve readability and make future
updates easier. This series contain two R-Car DU DRM patches that update the
DU DRM driver to the new API. They would normally be merged through Dave
Airlie's tree, but due to dependencies on VSP1 patches queued up for v4.7 Dave
agreed to get them merged through the linux-media tree (hence his Acked-by for
the two patches). They should not conflict with any patch queued up for v4.7
through Dave's tree.

Note that patch 10/13 adds some macro magic to make the API transition easier.
Depending on your taste you will find the implementation beautiful or ugly,
but in any case patch 13/13 removes the macros and inline wrapper.

The code is based on top of the latest linux-media master branch. For
convenience I've pushed the patches to the following git tree branch.
patches on top of the latest Linux media master branch to

git://linuxtv.org/pinchartl/media.git vsp1/next

Changes since v1:

- Fixed typos
- Made rcar_fcp_enable() return a status
- Dropped the unneeded dependency on PM for the VSP driver

Cc: devicetree at vger.kernel.org
Cc: dri-devel at lists.freedesktop.org
Cc: Dave Airlie 

Laurent Pinchart (13):
  dt-bindings: Add Renesas R-Car FCP DT bindings
  v4l: Add Renesas R-Car FCP driver
  v4l: vsp1: Implement runtime PM support
  v4l: vsp1: Don't handle clocks manually
  v4l: vsp1: Add FCP support
  v4l: vsp1: Add output node value to routing table
  v4l: vsp1: Replace container_of() with dedicated macro
  v4l: vsp1: Make vsp1_entity_get_pad_compose() more generic
  v4l: vsp1: Move frame sequence number from video node to pipeline
  v4l: vsp1: Group DRM RPF parameters in a structure
  drm: rcar-du: Add alpha support for VSP planes
  drm: rcar-du: Add Z-order support for VSP planes
  v4l: vsp1: Remove deprecated DRM API

 .../devicetree/bindings/media/renesas,fcp.txt  |  31 
 .../devicetree/bindings/media/renesas,vsp1.txt |   5 +
 MAINTAINERS|  10 ++
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c  |  45 ++---
 drivers/gpu/drm/rcar-du/rcar_du_vsp.h  |   2 +
 drivers/media/platform/Kconfig |  14 ++
 drivers/media/platform/Makefile|   1 +
 drivers/media/platform/rcar-fcp.c  | 181 +
 drivers/media/platform/vsp1/vsp1.h |   6 +-
 drivers/media/platform/vsp1/vsp1_drm.c |  68 
 drivers/media/platform/vsp1/vsp1_drv.c | 120 +++---
 drivers/media/platform/vsp1/vsp1_entity.c  |  86 +++---
 drivers/media/platform/vsp1/vsp1_entity.h  |  12 +-
 drivers/media/platform/vsp1/vsp1_pipe.c|   4 +-
 drivers/media/platform/vsp1/vsp1_pipe.h|   2 +
 drivers/media/platform/vsp1/vsp1_rpf.c |   7 +-
 drivers/media/platform/vsp1/vsp1_video.c   |   4 +-
 drivers/media/platform/vsp1/vsp1_video.h   |   1 -
 include/media/rcar-fcp.h   |  37 +
 include/media/vsp1.h   |  29 ++--
 20 files changed, 494 insertions(+), 171 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/renesas,fcp.txt
 create mode 100644 drivers/media/platform/rcar-fcp.c
 create mode 100644 include/media/rcar-fcp.h

-- 
Regards,

Laurent Pinchart



[PATCH v2 11/13] drm: rcar-du: Add alpha support for VSP planes

2016-04-26 Thread Laurent Pinchart
Make the global alpha multiplier of VSP planes configurable through the
alpha property, exactly as for the native DU planes.

Signed-off-by: Laurent Pinchart 
Acked-by: Dave Airlie 
---
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 38 +--
 1 file changed, 19 insertions(+), 19 deletions(-)

Cc: dri-devel at lists.freedesktop.org

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c 
b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
index de7ef041182b..8c89a6401542 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
@@ -148,40 +148,41 @@ static void rcar_du_vsp_plane_setup(struct 
rcar_du_vsp_plane *plane)
struct rcar_du_vsp_plane_state *state =
to_rcar_vsp_plane_state(plane->plane.state);
struct drm_framebuffer *fb = plane->plane.state->fb;
-   struct v4l2_rect src;
-   struct v4l2_rect dst;
-   dma_addr_t paddr[2] = { 0, };
-   u32 pixelformat = 0;
+   struct vsp1_du_atomic_config cfg = {
+   .pixelformat = 0,
+   .pitch = fb->pitches[0],
+   .alpha = state->alpha,
+   .zpos = 0,
+   };
unsigned int i;

-   src.left = state->state.src_x >> 16;
-   src.top = state->state.src_y >> 16;
-   src.width = state->state.src_w >> 16;
-   src.height = state->state.src_h >> 16;
+   cfg.src.left = state->state.src_x >> 16;
+   cfg.src.top = state->state.src_y >> 16;
+   cfg.src.width = state->state.src_w >> 16;
+   cfg.src.height = state->state.src_h >> 16;

-   dst.left = state->state.crtc_x;
-   dst.top = state->state.crtc_y;
-   dst.width = state->state.crtc_w;
-   dst.height = state->state.crtc_h;
+   cfg.dst.left = state->state.crtc_x;
+   cfg.dst.top = state->state.crtc_y;
+   cfg.dst.width = state->state.crtc_w;
+   cfg.dst.height = state->state.crtc_h;

for (i = 0; i < state->format->planes; ++i) {
struct drm_gem_cma_object *gem;

gem = drm_fb_cma_get_gem_obj(fb, i);
-   paddr[i] = gem->paddr + fb->offsets[i];
+   cfg.mem[i] = gem->paddr + fb->offsets[i];
}

for (i = 0; i < ARRAY_SIZE(formats_kms); ++i) {
if (formats_kms[i] == state->format->fourcc) {
-   pixelformat = formats_v4l2[i];
+   cfg.pixelformat = formats_v4l2[i];
break;
}
}

-   WARN_ON(!pixelformat);
+   WARN_ON(!cfg.pixelformat);

-   vsp1_du_atomic_update(plane->vsp->vsp, plane->index, pixelformat,
- fb->pitches[0], paddr, &src, &dst);
+   vsp1_du_atomic_update(plane->vsp->vsp, plane->index, &cfg);
 }

 static int rcar_du_vsp_plane_atomic_check(struct drm_plane *plane,
@@ -220,8 +221,7 @@ static void rcar_du_vsp_plane_atomic_update(struct 
drm_plane *plane,
if (plane->state->crtc)
rcar_du_vsp_plane_setup(rplane);
else
-   vsp1_du_atomic_update(rplane->vsp->vsp, rplane->index, 0, 0, 0,
- NULL, NULL);
+   vsp1_du_atomic_update(rplane->vsp->vsp, rplane->index, NULL);
 }

 static const struct drm_plane_helper_funcs rcar_du_vsp_plane_helper_funcs = {
-- 
2.7.3



[PATCH v2 12/13] drm: rcar-du: Add Z-order support for VSP planes

2016-04-26 Thread Laurent Pinchart
Make the Z-order of VSP planes configurable through the zpos property,
exactly as for the native DU planes.

Signed-off-by: Laurent Pinchart 
Acked-by: Dave Airlie 
---
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 11 ---
 drivers/gpu/drm/rcar-du/rcar_du_vsp.h |  2 ++
 2 files changed, 10 insertions(+), 3 deletions(-)

Cc: dri-devel at lists.freedesktop.org

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c 
b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
index 8c89a6401542..4927fb3b8554 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
@@ -152,7 +152,7 @@ static void rcar_du_vsp_plane_setup(struct 
rcar_du_vsp_plane *plane)
.pixelformat = 0,
.pitch = fb->pitches[0],
.alpha = state->alpha,
-   .zpos = 0,
+   .zpos = state->zpos,
};
unsigned int i;

@@ -180,8 +180,6 @@ static void rcar_du_vsp_plane_setup(struct 
rcar_du_vsp_plane *plane)
}
}

-   WARN_ON(!cfg.pixelformat);
-
vsp1_du_atomic_update(plane->vsp->vsp, plane->index, &cfg);
 }

@@ -269,6 +267,7 @@ static void rcar_du_vsp_plane_reset(struct drm_plane *plane)
return;

state->alpha = 255;
+   state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;

plane->state = &state->state;
plane->state->plane = plane;
@@ -283,6 +282,8 @@ static int rcar_du_vsp_plane_atomic_set_property(struct 
drm_plane *plane,

if (property == rcdu->props.alpha)
rstate->alpha = val;
+   else if (property == rcdu->props.zpos)
+   rstate->zpos = val;
else
return -EINVAL;

@@ -299,6 +300,8 @@ static int rcar_du_vsp_plane_atomic_get_property(struct 
drm_plane *plane,

if (property == rcdu->props.alpha)
*val = rstate->alpha;
+   else if (property == rcdu->props.zpos)
+   *val = rstate->zpos;
else
return -EINVAL;

@@ -378,6 +381,8 @@ int rcar_du_vsp_init(struct rcar_du_vsp *vsp)

drm_object_attach_property(&plane->plane.base,
   rcdu->props.alpha, 255);
+   drm_object_attach_property(&plane->plane.base,
+  rcdu->props.zpos, 1);
}

return 0;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.h 
b/drivers/gpu/drm/rcar-du/rcar_du_vsp.h
index df3bf3805c69..510dcc9c6816 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.h
@@ -44,6 +44,7 @@ static inline struct rcar_du_vsp_plane 
*to_rcar_vsp_plane(struct drm_plane *p)
  * @state: base DRM plane state
  * @format: information about the pixel format used by the plane
  * @alpha: value of the plane alpha property
+ * @zpos: value of the plane zpos property
  */
 struct rcar_du_vsp_plane_state {
struct drm_plane_state state;
@@ -51,6 +52,7 @@ struct rcar_du_vsp_plane_state {
const struct rcar_du_format_info *format;

unsigned int alpha;
+   unsigned int zpos;
 };

 static inline struct rcar_du_vsp_plane_state *
-- 
2.7.3



[Bug 117131] vga_switcheroo does not switch IGP -> DIS ( IGP == i915 , DIS == radeon )

2016-04-26 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=117131

--- Comment #17 from Jason Vas Dias  ---
OK, I tried appending modprobe.blacklist=radeon to the kernel command line -
that had no effect - the radeon module is built-in ; only using 
radeon.runpm=0 stops the ACPI error messages .

RE: > I'd suggest updating the intel xorg driver or trying a different kernel 
> to get a different intel kernel driver.

The intel xorg driver is at its latest GIT version : 2.99.917 as is the 
X-Server : 1.18.3 . I have raised Freedesktop.org bug # 95140 :
https://bugs.freedesktop.org/show_bug.cgi?id=95140
about the failure of the latest version of the Xorg intel driver to work
with the latest version of the Xorg X-server .

What is the latest known version of Linux known to work with the 
Intel Integrated HD Graphics card ( PCI: 8086:0416 ) ?

Are you sure that card is capable of driving the display on its own on my
laptop?
I have never been able to get the display into graphics mode using any
other driver than FGLRX - all OS installers eg. anaconda / ARCH Linux 
also failed to even get it into VESA mode, forcing me to use the 
terminal dialog interface for configuration .
I don't like using FGLRX because it forces me to use a distro that is 100%
binary compatible with its OpenGL libraries 
and does not allow me to investigate OpenGL development with Mesa or to
build my own libraries or to use the latest Linux kernel .

It is a shame that it appears Linux has lost graphics capability 
in a large segment of the modern laptop market because of issues like this -
it always used to work fine up until @ 2010 .

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


[PATCH] drm/ttm: fix kref count mess in ttm_bo_move_to_lru_tail

2016-04-26 Thread Alex Deucher
Ping.  Any objections?


On Wed, Apr 20, 2016 at 1:52 PM, Alex Deucher  wrote:
> From: Flora Cui 
>
> Fixes the following scenario:
>
> 1. Page table bo allocated in vram and linked to man->lru.
>tbo->list_kref.refcount=2
> 2. Page table bo is swapped out and removed from man->lru.
>tbo->list_kref.refcount=1
> 3. Command submission from userspace.  Page table bo is moved
>to vram.  ttm_bo_move_to_lru_tail() link it to man->lru and
>don't increase the kref count.
>
> Signed-off-by: Flora Cui 
> Reviewed-by: Christian König 
> Signed-off-by: Alex Deucher 
> Cc: stable at vger.kernel.org
> ---
>  drivers/gpu/drm/ttm/ttm_bo.c | 17 -
>  1 file changed, 4 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 4cbf265..e3daafa 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -230,22 +230,13 @@ 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;
> +   int put_count = 0;
>
> lockdep_assert_held(&bo->resv->lock.base);
>
> -   if (bo->mem.placement & TTM_PL_FLAG_NO_EVICT) {
> -   list_del_init(&bo->swap);
> -   list_del_init(&bo->lru);
> -
> -   } else {
> -   if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG))
> -   list_move_tail(&bo->swap, &bo->glob->swap_lru);
> -
> -   man = &bdev->man[bo->mem.mem_type];
> -   list_move_tail(&bo->lru, &man->lru);
> -   }
> +   put_count = ttm_bo_del_from_lru(bo);
> +   ttm_bo_list_ref_sub(bo, put_count, true);
> +   ttm_bo_add_to_lru(bo);
>  }
>  EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);
>
> --
> 2.5.5
>


[RFC v2 0/8] drm: explicit fencing support

2016-04-26 Thread Daniel Vetter
On Mon, Apr 25, 2016 at 11:21:18PM +, Mike Lothian wrote:
> Hi
> 
> Out of interest will this allow tear free with PRIME?

Tear free with prime on the kernel side is already supported using
reservation objects/fences attached implicitly to dma-bufs. Just needs
driver support (which for the displaying side has landed in i915 in 4.6,
nouveau/radeon did manage things correctly on the render side since a long
time).

I think tear free needs some additional changes in X, and the patches are
pending review.

This is just the explicit fencing needed by android (and wanted by
others). Same thing overall idea, but different ABI in the details.
-Daniel

> 
> Thanks
> 
> Mike
> 
> On Tue, 26 Apr 2016, 12:33 a.m. Gustavo Padovan, 
> wrote:
> 
> > From: Gustavo Padovan 
> >
> > Hi,
> >
> > Currently the Linux Kernel only have an implicit fencing mechanism
> > where the fence are attached directly to buffers and userspace is unaware
> > of
> > what is happening. On the other hand explicit fencing which is not
> > supported
> > yet by Linux but it expose fences to the userspace to handle fencing
> > between
> > producer/consumer explicitely.
> >
> > For that we use the Android Sync Framework[1], a explicit fencing mechanism
> > that help the userspace handles fences directly. It has the concept of
> > sync_file (called sync_fence in Android) that expose the driver's fences to
> > userspace via file descriptors. File descriptors are useful because we can
> > pass
> > them around between process.
> >
> > The Sync Framework is currently in the staging tree and on the process to
> > be de-staged[2].
> >
> > With explicit fencing we have a global mechanism that optimizes the flow of
> > buffers between consumers and producers, avoid a lot of waiting. So instead
> > of waiting for a buffer to be processed by the GPU before sending it to DRM
> > in an Atomic IOCTL we can get a sync_file fd from the GPU driver at the
> > moment
> > we submit the buffer processing. The compositor then passes these fds to
> > DRM in
> > a atomic commit request, that will not be displayed until the fences
> > signal,
> > i.e, the GPU finished processing the buffer and it is ready to display. In
> > DRM
> > the fences we wait on before displaying a buffer are called in-fences.
> >
> > Vice-versa, we have out-fences, to sychronize the return of buffers to GPU
> > (producer) to be processed again. When DRM receives an atomic request with
> > a
> > special flag set it generates one fence per-crtc and attach it to a
> > per-crtc
> > sync_file.  It then returns the array of sync_file fds to userspace as an
> > atomic_ioctl out arg. With the fences available userspace can forward these
> > fences to the GPU, where it will wait the fence to signal before starting
> > to
> > process on buffer again.
> >
> > Explicit fencing with Sync Framework allows buffer suballocation. Userspace
> > get a large buffer and divides it into small ones and submit requests to
> > process them, each subbuffer gets and sync_file fd and can be processed in
> > parallel. This is not even possible with implicit fencing.
> >
> > While these are out-fences in DRM (the consumer) they become in-fences once
> > they get to the GPU (the producer).
> >
> > DRM explicit fences are opt-in, as the default will still be implicit
> > fencing.
> > To enable explicit in-fences one just need to pass a sync_file fd in the
> > FENCE_FD plane property. *In-fences are per-plane*, i.e., per framebuffer.
> >
> > For out-fences, just enabling DRM_MODE_ATOMIC_OUT_FENCE flag is enough.
> > *Out-fences are per-crtc*.
> >
> > In-fences
> > -
> >
> > In the first discussions on #dri-devel on IRC we decided to hide the Sync
> > Framework from DRM drivers to reduce complexity, so as soon we get the fd
> > via FENCE_FD plane property we convert the sync_file fd to a struct fence.
> > However a sync_file might contain more than one fence, so we created the
> > fence_collection concept. struct fence_collection is a subclass of struct
> > fence and stores a group of fences that needs to be waited together, in
> > other words, all the fences in the sync_file.
> >
> > Then we just use the already in place fence support to wait on those
> > fences.
> > Once the producer calls fence_signal() for all fences on wait we can
> > proceed
> > with the atomic commit and display the framebuffers. DRM drivers only
> > needs to
> > be converted to struct fence to make use of this feature.
> >
> > Out-fences
> > --
> >
> > Passing the DRM_MODE_ATOMIC_OUT_FENCE flag to an atomic request enables
> > out-fences. The kernel then creates a fence, attach it to a sync_file and
> > install this file on a unused fd for each crtc. Userspace get the fence
> > back
> > as an array of per-crtc sync_file fds.
> >
> > DRM core use the already in place drm_event infrastructure to help signal
> > fences, we've added a fence pointer to struct drm_pending_event. If the
> > atomic
> > update received requested an PAGE_FLIP_EVEN

[Bug 93551] Divinity: Original Sin Enhanced Edition(Native) crash on start

2016-04-26 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=93551

Jamey Sharp  changed:

   What|Removed |Added

 OS|Linux (All) |All
 CC||jamey at minilop.net
  Component|Drivers/Gallium/radeonsi|Mesa core
 QA Contact|dri-devel at lists.freedesktop |mesa-dev at 
lists.freedesktop.
   |.org|org
   Hardware|x86-64 (AMD64)  |All
   Assignee|dri-devel at lists.freedesktop |mesa-dev at 
lists.freedesktop.
   |.org|org

--- Comment #10 from Jamey Sharp  ---
(In reply to smidjar2.reg from comment #6)
> I disassembled ApplyConstants() where the game crashes when using OpenGL
> override to 4.2.

I spent a while poking at this crash in gdb, and I was definitely seeing the
same segfault at the same instruction and call-stack.

I've sent a (one-line!) patch to mesa-dev that fixes this segfault on startup:

https://lists.freedesktop.org/archives/mesa-dev/2016-April/114614.html

And a Piglit patch that tests for the non-conforming behavior that led to this
crash:

https://lists.freedesktop.org/archives/mesa-dev/2016-April/114613.html

Thanks to Karol Herbst's mesa-dev post, linked from comment #7, for pointing me
in the right direction to find this Mesa bug.

Granted, the game developers ought to check for errors returned from
glLinkProgram and fail more gracefully than a segfault, but I doubt we're going
to get them to do *that*...

I can now play this game somewhat successfully on i965 with
MESA_GL_VERSION_OVERRIDE=4.2. There are still plenty of rendering bugs I
haven't dug into yet, but I played for an hour without crashes, at least!

I don't have (or particularly want) a commit bit on Mesa or Piglit, so now we
need somebody to review and hopefully merge these patches.

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


[PATCH v4 03/25] io-mapping: Specify mapping size for io_mapping_map_wc()

2016-04-26 Thread Chris Wilson
The ioremap() hidden behind the io_mapping_map_wc() convenience helper
can be used for remapping multiple pages. Extend the helper so that
future callers can use it for larger ranges.

Signed-off-by: Chris Wilson 
Cc: Tvrtko Ursulin 
Cc: Daniel Vetter 
Cc: Jani Nikula 
Cc: David Airlie 
Cc: Yishai Hadas 
Cc: Dan Williams 
Cc: Ingo Molnar 
Cc: "Peter Zijlstra (Intel)" 
Cc: David Hildenbrand 
Cc: Luis R. Rodriguez 
Cc: intel-gfx at lists.freedesktop.org
Cc: dri-devel at lists.freedesktop.org
Cc: netdev at vger.kernel.org
Cc: linux-rdma at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Reviewed-by: Luis R. Rodriguez 
---
 drivers/gpu/drm/i915/intel_overlay.c|  3 ++-
 drivers/net/ethernet/mellanox/mlx4/pd.c |  4 +++-
 include/linux/io-mapping.h  | 10 +++---
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_overlay.c 
b/drivers/gpu/drm/i915/intel_overlay.c
index 06bcd6aee64f..8d5293644d05 100644
--- a/drivers/gpu/drm/i915/intel_overlay.c
+++ b/drivers/gpu/drm/i915/intel_overlay.c
@@ -198,7 +198,8 @@ intel_overlay_map_regs(struct intel_overlay *overlay)
regs = (struct overlay_registers __iomem 
*)overlay->reg_bo->phys_handle->vaddr;
else
regs = io_mapping_map_wc(ggtt->mappable,
-overlay->flip_addr);
+overlay->flip_addr,
+PAGE_SIZE);

return regs;
 }
diff --git a/drivers/net/ethernet/mellanox/mlx4/pd.c 
b/drivers/net/ethernet/mellanox/mlx4/pd.c
index b3cc3ab63799..6fc156a3918d 100644
--- a/drivers/net/ethernet/mellanox/mlx4/pd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/pd.c
@@ -205,7 +205,9 @@ int mlx4_bf_alloc(struct mlx4_dev *dev, struct mlx4_bf *bf, 
int node)
goto free_uar;
}

-   uar->bf_map = io_mapping_map_wc(priv->bf_mapping, uar->index << 
PAGE_SHIFT);
+   uar->bf_map = io_mapping_map_wc(priv->bf_mapping,
+   uar->index << PAGE_SHIFT,
+   PAGE_SIZE);
if (!uar->bf_map) {
err = -ENOMEM;
goto unamp_uar;
diff --git a/include/linux/io-mapping.h b/include/linux/io-mapping.h
index e399029b68c5..645ad06b5d52 100644
--- a/include/linux/io-mapping.h
+++ b/include/linux/io-mapping.h
@@ -100,14 +100,16 @@ io_mapping_unmap_atomic(void __iomem *vaddr)
 }

 static inline void __iomem *
-io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset)
+io_mapping_map_wc(struct io_mapping *mapping,
+ unsigned long offset,
+ unsigned long size)
 {
resource_size_t phys_addr;

BUG_ON(offset >= mapping->size);
phys_addr = mapping->base + offset;

-   return ioremap_wc(phys_addr, PAGE_SIZE);
+   return ioremap_wc(phys_addr, size);
 }

 static inline void
@@ -155,7 +157,9 @@ io_mapping_unmap_atomic(void __iomem *vaddr)

 /* Non-atomic map/unmap */
 static inline void __iomem *
-io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset)
+io_mapping_map_wc(struct io_mapping *mapping,
+ unsigned long offset,
+ unsigned long size)
 {
return ((char __force __iomem *) mapping) + offset;
 }
-- 
2.8.1



[Bug 71789] [r300g] Visuals not found in (default) depth = 24

2016-04-26 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=71789

--- Comment #16 from Mathieu Malaterre  ---
Created attachment 123267
  --> https://bugs.freedesktop.org/attachment.cgi?id=123267&action=edit
proposed patch

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


[PATCH 1/2] drm/dsi: Implement DCS get display mode

2016-04-26 Thread Vinay Simha
HI,

I have not got response from maintainers. Did i miss anything?

On Mon, Apr 18, 2016 at 2:52 PM, Vinay Simha BN  wrote:
> Provide a small convenience wrapper that transmits
> a DCS get_display_mode command.
>
> Signed-off-by: Vinay Simha BN 
> ---
>  drivers/gpu/drm/drm_mipi_dsi.c | 24 
>  include/drm/drm_mipi_dsi.h |  1 +
>  2 files changed, 25 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
> index f5d8083..2e032ea 100644
> --- a/drivers/gpu/drm/drm_mipi_dsi.c
> +++ b/drivers/gpu/drm/drm_mipi_dsi.c
> @@ -792,6 +792,30 @@ int mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device 
> *dsi, u8 *mode)
>  EXPORT_SYMBOL(mipi_dsi_dcs_get_power_mode);
>
>  /**
> + * mipi_dsi_dcs_get_display_mode() - query the display module's image mode
> + * @dsi: DSI peripheral device
> + * @mode: return location for the display image mode
> + *
> + * Return: 0 on success or a negative error code on failure.
> + */
> +int mipi_dsi_dcs_get_display_mode(struct mipi_dsi_device *dsi, u8 *mode)
> +{
> +   ssize_t err;
> +
> +   err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_DISPLAY_MODE, mode,
> +   sizeof(*mode));
> +   if (err <= 0) {
> +   if (err == 0)
> +   err = -ENODATA;
> +
> +   return err;
> +   }
> +
> +   return 0;
> +}
> +EXPORT_SYMBOL(mipi_dsi_dcs_get_display_mode);
> +
> +/**
>   * mipi_dsi_dcs_get_pixel_format() - gets the pixel format for the RGB image
>   *data used by the interface
>   * @dsi: DSI peripheral device
> diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
> index 7a9840f..48fcd65 100644
> --- a/include/drm/drm_mipi_dsi.h
> +++ b/include/drm/drm_mipi_dsi.h
> @@ -254,6 +254,7 @@ ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 
> cmd, void *data,
>  int mipi_dsi_dcs_nop(struct mipi_dsi_device *dsi);
>  int mipi_dsi_dcs_soft_reset(struct mipi_dsi_device *dsi);
>  int mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device *dsi, u8 *mode);
> +int mipi_dsi_dcs_get_display_mode(struct mipi_dsi_device *dsi, u8 *mode);
>  int mipi_dsi_dcs_get_pixel_format(struct mipi_dsi_device *dsi, u8 *format);
>  int mipi_dsi_dcs_enter_sleep_mode(struct mipi_dsi_device *dsi);
>  int mipi_dsi_dcs_exit_sleep_mode(struct mipi_dsi_device *dsi);
> --
> 2.1.2
>



-- 
Regards,

Vinay Simha.B.N.


[PATCH 2/2] drm/dsi: Implement DCS get display self diagnostic

2016-04-26 Thread Vinay Simha
HI,

I have not got response from maintainers. Did i miss anything?

On Mon, Apr 18, 2016 at 2:52 PM, Vinay Simha BN  wrote:
> Provide a small convenience wrapper that transmits
> a DCS get_diagnostic_result command.
>
> Signed-off-by: Vinay Simha BN 
> ---
>  drivers/gpu/drm/drm_mipi_dsi.c | 25 +
>  include/drm/drm_mipi_dsi.h |  1 +
>  2 files changed, 26 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
> index 2e032ea..e49b346 100644
> --- a/drivers/gpu/drm/drm_mipi_dsi.c
> +++ b/drivers/gpu/drm/drm_mipi_dsi.c
> @@ -816,6 +816,31 @@ int mipi_dsi_dcs_get_display_mode(struct mipi_dsi_device 
> *dsi, u8 *mode)
>  EXPORT_SYMBOL(mipi_dsi_dcs_get_display_mode);
>
>  /**
> + * mipi_dsi_dcs_get_diagnostic_result() - query the display module's 
> diagnostic
> + *result
> + * @dsi: DSI peripheral device
> + * @mode: return location for the display self diagnostic result
> + *
> + * Return: 0 on success or a negative error code on failure.
> + */
> +int mipi_dsi_dcs_get_diagnostic_result(struct mipi_dsi_device *dsi, u8 *mode)
> +{
> +   ssize_t err;
> +
> +   err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_DIAGNOSTIC_RESULT, mode,
> +   sizeof(*mode));
> +   if (err <= 0) {
> +   if (err == 0)
> +   err = -ENODATA;
> +
> +   return err;
> +   }
> +
> +   return 0;
> +}
> +EXPORT_SYMBOL(mipi_dsi_dcs_get_diagnostic_result);
> +
> +/**
>   * mipi_dsi_dcs_get_pixel_format() - gets the pixel format for the RGB image
>   *data used by the interface
>   * @dsi: DSI peripheral device
> diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
> index 48fcd65..61c375b 100644
> --- a/include/drm/drm_mipi_dsi.h
> +++ b/include/drm/drm_mipi_dsi.h
> @@ -255,6 +255,7 @@ int mipi_dsi_dcs_nop(struct mipi_dsi_device *dsi);
>  int mipi_dsi_dcs_soft_reset(struct mipi_dsi_device *dsi);
>  int mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device *dsi, u8 *mode);
>  int mipi_dsi_dcs_get_display_mode(struct mipi_dsi_device *dsi, u8 *mode);
> +int mipi_dsi_dcs_get_diagnostic_result(struct mipi_dsi_device *dsi, u8 
> *mode);
>  int mipi_dsi_dcs_get_pixel_format(struct mipi_dsi_device *dsi, u8 *format);
>  int mipi_dsi_dcs_enter_sleep_mode(struct mipi_dsi_device *dsi);
>  int mipi_dsi_dcs_exit_sleep_mode(struct mipi_dsi_device *dsi);
> --
> 2.1.2
>



-- 
Regards,

Vinay Simha.B.N.


[PATCH v14 2/8] drm/mediatek: Add DRM Driver for Mediatek SoC MT8173.

2016-04-26 Thread Philipp Zabel
>From 24982961a7406c9c6ed139329c9ee1263ddc92c2 Mon Sep 17 00:00:00 2001
From: CK Hu 
Date: Mon, 4 Jan 2016 18:36:34 +0100
Subject: [PATCH v14.5 2/8] drm/mediatek: Add DRM Driver for Mediatek SoC MT8173.

This patch adds an initial DRM driver for the Mediatek MT8173 DISP
subsystem. It currently supports two fixed output streams from the
OVL0/OVL1 sources to the DSI0/DPI0 sinks, respectively.

Signed-off-by: CK Hu 
Signed-off-by: YT Shen 
Signed-off-by: Daniel Kurtz 
Signed-off-by: Bibby Hsieh 
Signed-off-by: Mao Huang 
Signed-off-by: Philipp Zabel 
---
Changes since v14:
 - Fixed module build
---
 drivers/gpu/drm/Kconfig |   2 +
 drivers/gpu/drm/Makefile|   1 +
 drivers/gpu/drm/mediatek/Kconfig|  12 +
 drivers/gpu/drm/mediatek/Makefile   |  11 +
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 302 +++
 drivers/gpu/drm/mediatek/mtk_disp_rdma.c| 240 
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 582 
 drivers/gpu/drm/mediatek/mtk_drm_crtc.h |  32 ++
 drivers/gpu/drm/mediatek/mtk_drm_ddp.c  | 353 +
 drivers/gpu/drm/mediatek/mtk_drm_ddp.h  |  41 ++
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 225 +++
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 150 +++
 drivers/gpu/drm/mediatek/mtk_drm_drv.c  | 565 +++
 drivers/gpu/drm/mediatek/mtk_drm_drv.h  |  57 +++
 drivers/gpu/drm/mediatek/mtk_drm_fb.c   | 165 
 drivers/gpu/drm/mediatek/mtk_drm_fb.h   |  23 ++
 drivers/gpu/drm/mediatek/mtk_drm_gem.c  | 269 +
 drivers/gpu/drm/mediatek/mtk_drm_gem.h  |  59 +++
 drivers/gpu/drm/mediatek/mtk_drm_plane.c| 240 
 drivers/gpu/drm/mediatek/mtk_drm_plane.h|  59 +++
 20 files changed, 3388 insertions(+)
 create mode 100644 drivers/gpu/drm/mediatek/Kconfig
 create mode 100644 drivers/gpu/drm/mediatek/Makefile
 create mode 100644 drivers/gpu/drm/mediatek/mtk_disp_ovl.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_disp_rdma.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_crtc.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_crtc.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_ddp.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_ddp.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_drv.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_drv.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_fb.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_fb.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_gem.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_gem.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_plane.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_plane.h

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index f2a74d0..5482012 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -281,3 +281,5 @@ source "drivers/gpu/drm/imx/Kconfig"
 source "drivers/gpu/drm/vc4/Kconfig"

 source "drivers/gpu/drm/etnaviv/Kconfig"
+
+source "drivers/gpu/drm/mediatek/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 6eb94fc..02b1f3e 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -73,6 +73,7 @@ obj-$(CONFIG_DRM_MSM) += msm/
 obj-$(CONFIG_DRM_TEGRA) += tegra/
 obj-$(CONFIG_DRM_STI) += sti/
 obj-$(CONFIG_DRM_IMX) += imx/
+obj-$(CONFIG_DRM_MEDIATEK) += mediatek/
 obj-y  += i2c/
 obj-y  += panel/
 obj-y  += bridge/
diff --git a/drivers/gpu/drm/mediatek/Kconfig b/drivers/gpu/drm/mediatek/Kconfig
new file mode 100644
index 000..8dad892
--- /dev/null
+++ b/drivers/gpu/drm/mediatek/Kconfig
@@ -0,0 +1,12 @@
+config DRM_MEDIATEK
+   tristate "DRM Support for Mediatek SoCs"
+   depends on DRM
+   depends on ARCH_MEDIATEK || (ARM && COMPILE_TEST)
+   select DRM_KMS_HELPER
+   select IOMMU_DMA
+   select MTK_SMI
+   help
+ Choose this option if you have a Mediatek SoCs.
+ The module will be called mediatek-drm
+ This driver provides kernel mode setting and
+ buffer management to userspace.
diff --git a/drivers/gpu/drm/mediatek/Makefile 
b/drivers/gpu/drm/mediatek/Makefile
new file mode 100644
index 000..d4bde7c
--- /dev/null
+++ b/drivers/gpu/drm/mediatek/Makefile
@@ -0,0 +1,11 @@
+mediatek-drm-y := mtk_disp_ovl.o \
+ mtk_disp_rdma.o \
+ mtk_drm_crtc.o \
+ mtk_drm_ddp.o \
+ mtk_drm_ddp_comp.o \
+ mtk_drm_drv.o \
+ mtk_drm_fb.o \
+ mtk_drm_gem.o \
+ mtk_drm_plane.o
+
+obj-$(CONFIG_DRM_MEDIATEK) += mediatek-drm.o
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c 
b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
n

[GIT PULL v2] MT8173 DRM support

2016-04-26 Thread Philipp Zabel
Hi Dave,

second try. Please consider pulling this tag with initial MediaTek
MT8173 DRM support, fixed to allow compiling as modules and without the
device tree changes.

regards
Philipp

The following changes since commit 9735a22799b9214d17d3c231fe377fc852f042e9:

  Linux 4.6-rc2 (2016-04-03 09:09:40 -0500)

are available in the git repository at:

  git://git.pengutronix.de/git/pza/linux.git tags/mediatek-drm-2016-04-25

for you to fetch changes up to 72c60efb6d17106e980f3449abd4cc826a45460d:

  clk: mediatek: remove hdmitx_dig_cts from TOP clocks (2016-04-22 09:33:54 
+0200)


MT8173 DRM support

- device tree binding documentation for all MT8173 display
  subsystem components
- basic mediatek drm driver for MT8173 with two optional,
  currently fixed output paths:
- DSI encoder support for DSI and (via bridge) eDP panels
- DPI encoder support for output to HDMI bridge
- necessary clock tree changes for the DPI->HDMI path


CK Hu (3):
  dt-bindings: drm/mediatek: Add Mediatek display subsystem dts binding
  drm/mediatek: Add DRM Driver for Mediatek SoC MT8173.
  drm/mediatek: Add DSI sub driver

Jie Qiu (1):
  drm/mediatek: Add DPI sub driver

Philipp Zabel (3):
  clk: mediatek: make dpi0_sel propagate rate changes
  clk: mediatek: Add hdmi_ref HDMI PHY PLL reference clock output
  clk: mediatek: remove hdmitx_dig_cts from TOP clocks

 .../bindings/display/mediatek/mediatek,disp.txt| 203 +
 .../bindings/display/mediatek/mediatek,dpi.txt |  35 +
 .../bindings/display/mediatek/mediatek,dsi.txt |  60 ++
 drivers/clk/mediatek/clk-mt8173.c  |  12 +-
 drivers/clk/mediatek/clk-mtk.h |  15 +-
 drivers/gpu/drm/Kconfig|   2 +
 drivers/gpu/drm/Makefile   |   1 +
 drivers/gpu/drm/mediatek/Kconfig   |  14 +
 drivers/gpu/drm/mediatek/Makefile  |  14 +
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c| 302 +++
 drivers/gpu/drm/mediatek/mtk_disp_rdma.c   | 240 ++
 drivers/gpu/drm/mediatek/mtk_dpi.c | 769 +
 drivers/gpu/drm/mediatek/mtk_dpi_regs.h| 228 +
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c| 582 +
 drivers/gpu/drm/mediatek/mtk_drm_crtc.h|  32 +
 drivers/gpu/drm/mediatek/mtk_drm_ddp.c | 353 
 drivers/gpu/drm/mediatek/mtk_drm_ddp.h |  41 +
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c| 225 +
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h| 150 
 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 568 +
 drivers/gpu/drm/mediatek/mtk_drm_drv.h |  60 ++
 drivers/gpu/drm/mediatek/mtk_drm_fb.c  | 165 
 drivers/gpu/drm/mediatek/mtk_drm_fb.h  |  23 +
 drivers/gpu/drm/mediatek/mtk_drm_gem.c | 269 ++
 drivers/gpu/drm/mediatek/mtk_drm_gem.h |  59 ++
 drivers/gpu/drm/mediatek/mtk_drm_plane.c   | 240 ++
 drivers/gpu/drm/mediatek/mtk_drm_plane.h   |  59 ++
 drivers/gpu/drm/mediatek/mtk_dsi.c | 927 +
 drivers/gpu/drm/mediatek/mtk_mipi_tx.c | 463 ++
 include/dt-bindings/clock/mt8173-clk.h |   3 +-
 30 files changed, 6109 insertions(+), 5 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt
 create mode 100644 
Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt
 create mode 100644 
Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.txt
 create mode 100644 drivers/gpu/drm/mediatek/Kconfig
 create mode 100644 drivers/gpu/drm/mediatek/Makefile
 create mode 100644 drivers/gpu/drm/mediatek/mtk_disp_ovl.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_disp_rdma.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_dpi.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_dpi_regs.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_crtc.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_crtc.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_ddp.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_ddp.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_drv.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_drv.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_fb.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_fb.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_gem.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_gem.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_plane.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_plane.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_dsi.c
 

[Bug 95089] EON game ports black screen on RC410M [Mobility Radeon Xpress 200M]

2016-04-26 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=95089

--- Comment #2 from Emil Velikov  ---
The game seems to be trying to use GL_ARB_shader_texture_lod without checking
if the extension is available. I would report that with the game and/or EON
wrapper) developers - no program should ever do that.

Based on the gallium code PIPE_CAP_SM3 (the toggle used to control the
extension) is "/* Supported on r500 only. */". I'm not familiar with the
hardware capabilities, but I'm leaning that this might be it.

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


[PATCH v14 2/8] drm/mediatek: Add DRM Driver for Mediatek SoC MT8173.

2016-04-26 Thread Daniel Vetter
On Tue, Apr 26, 2016 at 10:05:22AM +0200, Philipp Zabel wrote:
> From 24982961a7406c9c6ed139329c9ee1263ddc92c2 Mon Sep 17 00:00:00 2001
> From: CK Hu 
> Date: Mon, 4 Jan 2016 18:36:34 +0100
> Subject: [PATCH v14.5 2/8] drm/mediatek: Add DRM Driver for Mediatek SoC 
> MT8173.
> 
> This patch adds an initial DRM driver for the Mediatek MT8173 DISP
> subsystem. It currently supports two fixed output streams from the
> OVL0/OVL1 sources to the DSI0/DPI0 sinks, respectively.
> 
> Signed-off-by: CK Hu 
> Signed-off-by: YT Shen 
> Signed-off-by: Daniel Kurtz 
> Signed-off-by: Bibby Hsieh 
> Signed-off-by: Mao Huang 
> Signed-off-by: Philipp Zabel 
> ---
> Changes since v14:
>  - Fixed module build
> ---
>  drivers/gpu/drm/Kconfig |   2 +
>  drivers/gpu/drm/Makefile|   1 +
>  drivers/gpu/drm/mediatek/Kconfig|  12 +
>  drivers/gpu/drm/mediatek/Makefile   |  11 +
>  drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 302 +++
>  drivers/gpu/drm/mediatek/mtk_disp_rdma.c| 240 
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 582 
> 
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.h |  32 ++
>  drivers/gpu/drm/mediatek/mtk_drm_ddp.c  | 353 +
>  drivers/gpu/drm/mediatek/mtk_drm_ddp.h  |  41 ++
>  drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 225 +++
>  drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 150 +++
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c  | 565 +++
>  drivers/gpu/drm/mediatek/mtk_drm_drv.h  |  57 +++
>  drivers/gpu/drm/mediatek/mtk_drm_fb.c   | 165 
>  drivers/gpu/drm/mediatek/mtk_drm_fb.h   |  23 ++
>  drivers/gpu/drm/mediatek/mtk_drm_gem.c  | 269 +
>  drivers/gpu/drm/mediatek/mtk_drm_gem.h  |  59 +++
>  drivers/gpu/drm/mediatek/mtk_drm_plane.c| 240 
>  drivers/gpu/drm/mediatek/mtk_drm_plane.h|  59 +++
>  20 files changed, 3388 insertions(+)
>  create mode 100644 drivers/gpu/drm/mediatek/Kconfig
>  create mode 100644 drivers/gpu/drm/mediatek/Makefile
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_disp_ovl.c
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_disp_rdma.c
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_crtc.c
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_crtc.h
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_ddp.c
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_ddp.h
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_drv.c
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_drv.h
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_fb.c
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_fb.h
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_gem.c
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_gem.h
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_plane.c
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_plane.h
> 
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index f2a74d0..5482012 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -281,3 +281,5 @@ source "drivers/gpu/drm/imx/Kconfig"
>  source "drivers/gpu/drm/vc4/Kconfig"
>  
>  source "drivers/gpu/drm/etnaviv/Kconfig"
> +
> +source "drivers/gpu/drm/mediatek/Kconfig"
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index 6eb94fc..02b1f3e 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -73,6 +73,7 @@ obj-$(CONFIG_DRM_MSM) += msm/
>  obj-$(CONFIG_DRM_TEGRA) += tegra/
>  obj-$(CONFIG_DRM_STI) += sti/
>  obj-$(CONFIG_DRM_IMX) += imx/
> +obj-$(CONFIG_DRM_MEDIATEK) += mediatek/
>  obj-y+= i2c/
>  obj-y+= panel/
>  obj-y+= bridge/
> diff --git a/drivers/gpu/drm/mediatek/Kconfig 
> b/drivers/gpu/drm/mediatek/Kconfig
> new file mode 100644
> index 000..8dad892
> --- /dev/null
> +++ b/drivers/gpu/drm/mediatek/Kconfig
> @@ -0,0 +1,12 @@
> +config DRM_MEDIATEK
> + tristate "DRM Support for Mediatek SoCs"
> + depends on DRM
> + depends on ARCH_MEDIATEK || (ARM && COMPILE_TEST)
> + select DRM_KMS_HELPER
> + select IOMMU_DMA
> + select MTK_SMI
> + help
> +   Choose this option if you have a Mediatek SoCs.
> +   The module will be called mediatek-drm
> +   This driver provides kernel mode setting and
> +   buffer management to userspace.
> diff --git a/drivers/gpu/drm/mediatek/Makefile 
> b/drivers/gpu/drm/mediatek/Makefile
> new file mode 100644
> index 000..d4bde7c
> --- /dev/null
> +++ b/drivers/gpu/drm/mediatek/Makefile
> @@ -0,0 +1,11 @@
> +mediatek-drm-y := mtk_disp_ovl.o \
> +   mtk_disp_rdma.o \
> +   mtk_drm_crtc.o \
> +   mtk_drm_ddp.o \
> +   mtk_drm_ddp_comp.o 

[PATCH v12 1/2] kernel.h: add u64_to_user_ptr()

2016-04-26 Thread Lucas Stach
Am Donnerstag, den 21.04.2016, 12:38 -0300 schrieb Gustavo Padovan:
> From: Gustavo Padovan 
> 
> This function had copies in 3 different files. Unify them in kernel.h.
> 
> Cc: Joe Perches 
> Cc: Andrew Morton 
> Cc: David Airlie 
> Cc: Daniel Vetter 
> Cc: Rob Clark 
> Signed-off-by: Gustavo Padovan 
> 
Though I normally prefer static inline functions, I see the benefits of
using the macro form here.

For the etnaviv part:
Acked-by: Lucas Stach 



[PATCH v4 05/11] drm: Add Allwinner A10 Display Engine support

2016-04-26 Thread Boris Brezillon
Hi Maxime,

On Mon, 25 Apr 2016 15:22:46 +0200
Maxime Ripard  wrote:

> The Allwinner A10 and subsequent SoCs share the same display pipeline, with
> variations in the number of controllers (1 or 2), or the presence or not of
> some output (HDMI, TV, VGA) or not.
> 
> Add a driver with a limited set of features for now, and we will hopefully
> support all of them eventually
> 
> Signed-off-by: Maxime Ripard 

Just 2 comments below. Once addressed you can add my

Reviewed-by: Boris Brezillon 

> ---

[...]

> +
> +static int sun4i_drv_connector_plug_all(struct drm_device *drm)
> +{
> + struct drm_connector *connector, *failed;
> + int ret;
> +
> + mutex_lock(&drm->mode_config.mutex);
> + list_for_each_entry(connector, &drm->mode_config.connector_list, head) {
> + ret = drm_connector_register(connector);
> + if (ret) {
> + failed = connector;
> + goto err;
> + }
> + }
> + mutex_unlock(&drm->mode_config.mutex);
> + return 0;
> +
> +err:
> + list_for_each_entry(connector, &drm->mode_config.connector_list, head) {
> + if (failed == connector)
> + break;
> +
> + drm_connector_unregister(connector);
> + }
> + mutex_unlock(&drm->mode_config.mutex);
> +
> + return ret;
> +}

You can use the generic drm_connector_register_all() to do that.

[...]

> +
> +static void sun4i_drv_unbind(struct device *dev)
> +{
> + struct drm_device *drm = dev_get_drvdata(dev);
> +

And you probably miss a call to drm_connector_unregister_all() here.

> + drm_dev_unregister(drm);
> + drm_kms_helper_poll_fini(drm);
> + sun4i_framebuffer_free(drm);
> + drm_vblank_cleanup(drm);
> + drm_dev_unref(drm);
> +}


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


[PATCH v4 06/11] drm: sun4i: Add RGB output

2016-04-26 Thread Boris Brezillon
On Mon, 25 Apr 2016 15:22:47 +0200
Maxime Ripard  wrote:

> One of the A10 display pipeline possible output is an RGB interface to
> drive LCD panels directly. This is done through the first channel of the
> TCON that will output our video signals directly.
> 
> Signed-off-by: Maxime Ripard 

Reviewed-by: Boris Brezillon 

> ---
>  drivers/gpu/drm/sun4i/Makefile |   1 +
>  drivers/gpu/drm/sun4i/sun4i_drv.c  |  24 
>  drivers/gpu/drm/sun4i/sun4i_rgb.c  | 250 
> +
>  drivers/gpu/drm/sun4i/sun4i_rgb.h  |  18 +++
>  drivers/gpu/drm/sun4i/sun4i_tcon.c |  61 -
>  drivers/gpu/drm/sun4i/sun4i_tcon.h |   2 +
>  6 files changed, 355 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/gpu/drm/sun4i/sun4i_rgb.c
>  create mode 100644 drivers/gpu/drm/sun4i/sun4i_rgb.h
> 
> diff --git a/drivers/gpu/drm/sun4i/Makefile b/drivers/gpu/drm/sun4i/Makefile
> index 6df3ef32732d..74f804b88ff5 100644
> --- a/drivers/gpu/drm/sun4i/Makefile
> +++ b/drivers/gpu/drm/sun4i/Makefile
> @@ -4,6 +4,7 @@ sun4i-drm-y += sun4i_framebuffer.o
>  sun4i-drm-y += sun4i_layer.o
>  
>  sun4i-tcon-y += sun4i_tcon.o
> +sun4i-tcon-y += sun4i_rgb.o
>  sun4i-tcon-y += sun4i_dotclock.o
>  
>  obj-$(CONFIG_DRM_SUN4I)  += sun4i-drm.o sun4i-tcon.o
> diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c 
> b/drivers/gpu/drm/sun4i/sun4i_drv.c
> index a081969673ac..891d434ea57f 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
> @@ -222,6 +222,11 @@ static bool sun4i_drv_node_is_frontend(struct 
> device_node *node)
>  "allwinner,sun5i-a13-display-frontend");
>  }
>  
> +static bool sun4i_drv_node_is_tcon(struct device_node *node)
> +{
> + return of_device_is_compatible(node, "allwinner,sun5i-a13-tcon");
> +}
> +
>  static int compare_of(struct device *dev, void *data)
>  {
>   DRM_DEBUG_DRIVER("Comparing of node %s with %s\n",
> @@ -270,6 +275,25 @@ static int sun4i_drv_add_endpoints(struct device *dev,
>   continue;
>   }
>  
> + /*
> +  * If the node is our TCON, the first port is used for our
> +  * panel, and will not be part of the
> +  * component framework.
> +  */
> + if (sun4i_drv_node_is_tcon(node)) {
> + struct of_endpoint endpoint;
> +
> + if (of_graph_parse_endpoint(ep, &endpoint)) {
> + DRM_DEBUG_DRIVER("Couldn't parse endpoint\n");
> + continue;
> + }
> +
> + if (!endpoint.id) {
> + DRM_DEBUG_DRIVER("Endpoint is our panel... 
> skipping\n");
> + continue;
> + }
> + }
> +
>   /* Walk down our tree */
>   count += sun4i_drv_add_endpoints(dev, match, remote);
>  
> diff --git a/drivers/gpu/drm/sun4i/sun4i_rgb.c 
> b/drivers/gpu/drm/sun4i/sun4i_rgb.c
> new file mode 100644
> index ..ab6494818050
> --- /dev/null
> +++ b/drivers/gpu/drm/sun4i/sun4i_rgb.c
> @@ -0,0 +1,250 @@
> +/*
> + * Copyright (C) 2015 Free Electrons
> + * Copyright (C) 2015 NextThing Co
> + *
> + * Maxime Ripard 
> + *
> + * 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.
> + */
> +
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "sun4i_drv.h"
> +#include "sun4i_tcon.h"
> +
> +struct sun4i_rgb {
> + struct drm_connectorconnector;
> + struct drm_encoder  encoder;
> +
> + struct sun4i_drv*drv;
> +};
> +
> +static inline struct sun4i_rgb *
> +drm_connector_to_sun4i_rgb(struct drm_connector *connector)
> +{
> + return container_of(connector, struct sun4i_rgb,
> + connector);
> +}
> +
> +static inline struct sun4i_rgb *
> +drm_encoder_to_sun4i_rgb(struct drm_encoder *encoder)
> +{
> + return container_of(encoder, struct sun4i_rgb,
> + encoder);
> +}
> +
> +static int sun4i_rgb_get_modes(struct drm_connector *connector)
> +{
> + struct sun4i_rgb *rgb =
> + drm_connector_to_sun4i_rgb(connector);
> + struct sun4i_drv *drv = rgb->drv;
> + struct sun4i_tcon *tcon = drv->tcon;
> +
> + return drm_panel_get_modes(tcon->panel);
> +}
> +
> +static int sun4i_rgb_mode_valid(struct drm_connector *connector,
> + struct drm_display_mode *mode)
> +{
> + u32 hsync = mode->hsync_end - mode->hsync_start;
> + u32 vsync = mode->vsync_end - mode->vsync_start;
> +
> + DRM_DEBUG_DRIVER("Validating modes...\n");
> +
> + if (hsync < 1)
> + return MODE_HSYNC_NARROW;
> +
> + if (hsync > 0x3ff)
> +   

[PATCH v4 07/11] drm: sun4i: Add composite output

2016-04-26 Thread Boris Brezillon
On Mon, 25 Apr 2016 15:22:48 +0200
Maxime Ripard  wrote:

> Some Allwinner SoCs have an IP called the TV encoder that is used to output
> composite and VGA signals. In such a case, we need to use the second TCON
> channel.
> 
> Add support for that TV encoder.
> 
> Signed-off-by: Maxime Ripard 

Reviewed-by: Boris Brezillon 

> ---
>  drivers/gpu/drm/sun4i/Makefile   |   2 +
>  drivers/gpu/drm/sun4i/sun4i_tv.c | 621 
> +++
>  2 files changed, 623 insertions(+)
>  create mode 100644 drivers/gpu/drm/sun4i/sun4i_tv.c
> 
> diff --git a/drivers/gpu/drm/sun4i/Makefile b/drivers/gpu/drm/sun4i/Makefile
> index 74f804b88ff5..58cd55149827 100644
> --- a/drivers/gpu/drm/sun4i/Makefile
> +++ b/drivers/gpu/drm/sun4i/Makefile
> @@ -9,3 +9,5 @@ sun4i-tcon-y += sun4i_dotclock.o
>  
>  obj-$(CONFIG_DRM_SUN4I)  += sun4i-drm.o sun4i-tcon.o
>  obj-$(CONFIG_DRM_SUN4I)  += sun4i_backend.o
> +
> +obj-$(CONFIG_DRM_SUN4I)  += sun4i_tv.o
> diff --git a/drivers/gpu/drm/sun4i/sun4i_tv.c 
> b/drivers/gpu/drm/sun4i/sun4i_tv.c
> new file mode 100644
> index ..78634dfc0f77
> --- /dev/null
> +++ b/drivers/gpu/drm/sun4i/sun4i_tv.c
> @@ -0,0 +1,621 @@
> +/*
> + * Copyright (C) 2015 Free Electrons
> + * Copyright (C) 2015 NextThing Co
> + *
> + * Maxime Ripard 
> + *
> + * 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.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "sun4i_backend.h"
> +#include "sun4i_drv.h"
> +#include "sun4i_tcon.h"
> +
> +#define SUN4I_TVE_EN_REG 0x000
> +#define SUN4I_TVE_EN_DAC_MAP_MASKGENMASK(19, 4)
> +#define SUN4I_TVE_EN_DAC_MAP(dac, out)   (((out) & 0xf) << (dac 
> + 1) * 4)
> +#define SUN4I_TVE_EN_ENABLE  BIT(0)
> +
> +#define SUN4I_TVE_CFG0_REG   0x004
> +#define SUN4I_TVE_CFG0_DAC_CONTROL_54M   BIT(26)
> +#define SUN4I_TVE_CFG0_CORE_DATAPATH_54M BIT(25)
> +#define SUN4I_TVE_CFG0_CORE_CONTROL_54M  BIT(24)
> +#define SUN4I_TVE_CFG0_YC_EN BIT(17)
> +#define SUN4I_TVE_CFG0_COMP_EN   BIT(16)
> +#define SUN4I_TVE_CFG0_RES(x)((x) & 0xf)
> +#define SUN4I_TVE_CFG0_RES_480i  SUN4I_TVE_CFG0_RES(0)
> +#define SUN4I_TVE_CFG0_RES_576i  SUN4I_TVE_CFG0_RES(1)
> +
> +#define SUN4I_TVE_DAC0_REG   0x008
> +#define SUN4I_TVE_DAC0_CLOCK_INVERT  BIT(24)
> +#define SUN4I_TVE_DAC0_LUMA(x)   (((x) & 3) << 20)
> +#define SUN4I_TVE_DAC0_LUMA_0_4  SUN4I_TVE_DAC0_LUMA(3)
> +#define SUN4I_TVE_DAC0_CHROMA(x) (((x) & 3) << 18)
> +#define SUN4I_TVE_DAC0_CHROMA_0_75   SUN4I_TVE_DAC0_CHROMA(3)
> +#define SUN4I_TVE_DAC0_INTERNAL_DAC(x)   (((x) & 3) << 16)
> +#define SUN4I_TVE_DAC0_INTERNAL_DAC_37_5_OHMS
> SUN4I_TVE_DAC0_INTERNAL_DAC(3)
> +#define SUN4I_TVE_DAC0_DAC_EN(dac)   BIT(dac)
> +
> +#define SUN4I_TVE_NOTCH_REG  0x00c
> +#define SUN4I_TVE_NOTCH_DAC0_TO_DAC_DLY(dac, x)  ((4 - (x)) << (dac * 3))
> +
> +#define SUN4I_TVE_CHROMA_FREQ_REG0x010
> +
> +#define SUN4I_TVE_PORCH_REG  0x014
> +#define SUN4I_TVE_PORCH_BACK(x)  ((x) << 16)
> +#define SUN4I_TVE_PORCH_FRONT(x) (x)
> +
> +#define SUN4I_TVE_LINE_REG   0x01c
> +#define SUN4I_TVE_LINE_FIRST(x)  ((x) << 16)
> +#define SUN4I_TVE_LINE_NUMBER(x) (x)
> +
> +#define SUN4I_TVE_LEVEL_REG  0x020
> +#define SUN4I_TVE_LEVEL_BLANK(x) ((x) << 16)
> +#define SUN4I_TVE_LEVEL_BLACK(x) (x)
> +
> +#define SUN4I_TVE_DAC1_REG   0x024
> +#define SUN4I_TVE_DAC1_AMPLITUDE(dac, x) ((x) << (dac * 8))
> +
> +#define SUN4I_TVE_DETECT_STA_REG 0x038
> +#define SUN4I_TVE_DETECT_STA_DAC(dac)BIT((dac * 8))
> +#define SUN4I_TVE_DETECT_STA_UNCONNECTED 0
> +#define SUN4I_TVE_DETECT_STA_CONNECTED   1
> +#define SUN4I_TVE_DETECT_STA_GROUND  2
> +
> +#define SUN4I_TVE_CB_CR_LVL_REG  0x10c
> +#define SUN4I_TVE_CB_CR_LVL_CR_BURST(x)  ((x) << 8)
> +#define SUN4I_TVE_CB_CR_LVL_CB_BURST(x)  (x)
> +
> +#define SUN4I_TVE_TINT_BURST_PHASE_REG   0x110
> +#define SUN4I_TVE_TINT_BURST_PHASE_CHROMA(x) (x)
> +
> +#define SUN4I_TVE_BURST_WIDTH_REG0x114
> +#define SUN4I_TVE_BURST_WIDTH_BREEZEWAY(x)   ((x) << 16)
> +#define SUN4I_TVE_BURST_WIDTH_BURST_WIDTH(x) ((x) << 8)
> +#define SUN4I_TVE_BURST_WIDTH_HSYNC_WIDTH(x) (x)
> +
> +#define SUN4I_TVE_CB_CR_GAIN_REG 0x118
> +#define SUN4I_TVE_CB_CR_GAIN_CR(x)   ((x) <

[PATCH v4 08/11] drm: sun4i: tv: Add PAL output standard

2016-04-26 Thread Boris Brezillon
On Mon, 25 Apr 2016 15:22:49 +0200
Maxime Ripard  wrote:

> Now that we have support for the composite output, we can start adding new
> supported standards. Start with PAL, and we will add other eventually.
> 
> Signed-off-by: Maxime Ripard 

Reviewed-by: Boris Brezillon 

> ---
>  drivers/gpu/drm/sun4i/sun4i_tv.c | 42 
> 
>  1 file changed, 42 insertions(+)
> 
> diff --git a/drivers/gpu/drm/sun4i/sun4i_tv.c 
> b/drivers/gpu/drm/sun4i/sun4i_tv.c
> index 78634dfc0f77..ccf275a90132 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_tv.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_tv.c
> @@ -178,7 +178,49 @@ struct sun4i_tv {
>   struct sun4i_drv*drv;
>  };
>  
> +struct video_levels pal_video_levels = {
> + .black = 252,   .blank = 252,
> +};
> +
> +struct burst_levels pal_burst_levels = {
> + .cb = 40,   .cr = 40,
> +};
> +
> +struct color_gains pal_color_gains = {
> + .cb = 224,  .cr = 224,
> +};
> +
> +struct resync_parameters pal_resync_parameters = {
> + .field = true,  .line = 13, .pixel = 12,
> +};
> +
>  struct tv_mode tv_modes[] = {
> + {
> + .name   = "PAL",
> + .mode   = SUN4I_TVE_CFG0_RES_576i,
> + .chroma_freq= 0x2a098acb,
> +
> + .back_porch = 138,
> + .front_porch= 24,
> + .line_number= 625,
> +
> + .hdisplay   = 720,
> + .hfront_porch   = 3,
> + .hsync_len  = 2,
> + .hback_porch= 139,
> +
> + .vdisplay   = 576,
> + .vfront_porch   = 28,
> + .vsync_len  = 2,
> + .vback_porch= 19,
> +
> + .vblank_level   = 252,
> +
> + .color_gains= &pal_color_gains,
> + .burst_levels   = &pal_burst_levels,
> + .video_levels   = &pal_video_levels,
> + .resync_params  = &pal_resync_parameters,
> + },
>  };
>  
>  static inline struct sun4i_tv *



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


[PATCH v4 09/11] drm: sun4i: tv: Add NTSC output standard

2016-04-26 Thread Boris Brezillon
On Mon, 25 Apr 2016 15:22:50 +0200
Maxime Ripard  wrote:

> Add the settings to support the NTSC standard.
> 
> Signed-off-by: Maxime Ripard 

Reviewed-by: Boris Brezillon 

> ---
>  drivers/gpu/drm/sun4i/sun4i_tv.c | 45 
> 
>  1 file changed, 45 insertions(+)
> 
> diff --git a/drivers/gpu/drm/sun4i/sun4i_tv.c 
> b/drivers/gpu/drm/sun4i/sun4i_tv.c
> index ccf275a90132..bc047f923508 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_tv.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_tv.c
> @@ -178,24 +178,69 @@ struct sun4i_tv {
>   struct sun4i_drv*drv;
>  };
>  
> +struct video_levels ntsc_video_levels = {
> + .black = 282,   .blank = 240,
> +};
> +
>  struct video_levels pal_video_levels = {
>   .black = 252,   .blank = 252,
>  };
>  
> +struct burst_levels ntsc_burst_levels = {
> + .cb = 79,   .cr = 0,
> +};
> +
>  struct burst_levels pal_burst_levels = {
>   .cb = 40,   .cr = 40,
>  };
>  
> +struct color_gains ntsc_color_gains = {
> + .cb = 160,  .cr = 160,
> +};
> +
>  struct color_gains pal_color_gains = {
>   .cb = 224,  .cr = 224,
>  };
>  
> +struct resync_parameters ntsc_resync_parameters = {
> + .field = false, .line = 14, .pixel = 12,
> +};
> +
>  struct resync_parameters pal_resync_parameters = {
>   .field = true,  .line = 13, .pixel = 12,
>  };
>  
>  struct tv_mode tv_modes[] = {
>   {
> + .name   = "NTSC",
> + .mode   = SUN4I_TVE_CFG0_RES_480i,
> + .chroma_freq= 0x21f07c1f,
> + .yc_en  = true,
> + .dac3_en= true,
> + .dac_bit25_en   = true,
> +
> + .back_porch = 118,
> + .front_porch= 32,
> + .line_number= 525,
> +
> + .hdisplay   = 720,
> + .hfront_porch   = 18,
> + .hsync_len  = 2,
> + .hback_porch= 118,
> +
> + .vdisplay   = 480,
> + .vfront_porch   = 26,
> + .vsync_len  = 2,
> + .vback_porch= 17,
> +
> + .vblank_level   = 240,
> +
> + .color_gains= &ntsc_color_gains,
> + .burst_levels   = &ntsc_burst_levels,
> + .video_levels   = &ntsc_video_levels,
> + .resync_params  = &ntsc_resync_parameters,
> + },
> + {
>   .name   = "PAL",
>   .mode   = SUN4I_TVE_CFG0_RES_576i,
>   .chroma_freq= 0x2a098acb,



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


[Bug 95101] Wrong colors in Coffin Dodgers demo with HD6950

2016-04-26 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=95101

--- Comment #5 from serge  ---
Daniel you where right, colors are now fine.

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


[Bug 95101] Wrong colors in Coffin Dodgers demo with HD6950

2016-04-26 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=95101

serge  changed:

   What|Removed |Added

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

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


[Bug 95101] Wrong colors in Coffin Dodgers demo with HD6950

2016-04-26 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=95101

serge  changed:

   What|Removed |Added

 Status|RESOLVED|CLOSED

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


[Bug 95026] Alien Isolation segfault after initial loading screen/video

2016-04-26 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=95026

--- Comment #14 from Christoph Haag  ---
(In reply to Nicolai H�hnle from comment #13)
> Created attachment 123256 [details] [review]
> Separate non-recursive part out of visit(ir_expression) to reduce stack
> explosion
> 
> Hi Christoph, could you try the attached patch? It fixes a similar crash for
> me.

Yes it helps, there is no crash with the Patch.

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


[RFC v2 5/8] drm/fence: add in-fences support

2016-04-26 Thread Ville Syrjälä
On Mon, Apr 25, 2016 at 07:33:25PM -0300, Gustavo Padovan wrote:
> From: Gustavo Padovan 
> 
> There is now a new property called FENCE_FD attached to every plane
> state that receives the sync_file fd from userspace via the atomic commit
> IOCTL.

I still don't like this property abuse. Also with atomic, all passed
fences must be waited upon before anything is done, so attaching them
to planes seems like it might just give people the wrong idea.

> 
> The fd is then translated to a fence (that may be a fence_collection
> subclass or just a normal fence) and then used by DRM to fence_wait() for
> all fences in the sync_file to signal. So it only commits when all
> framebuffers are ready to scanout.
> 
> Signed-off-by: Gustavo Padovan 
> 
> v2: Comments by Daniel Vetter:
>   - remove set state->fence = NULL in destroy phase
>   - accept fence -1 as valid and just return 0
>   - do not call fence_get() - sync_file_fences_get() already calls it
>   - fence_put() if state->fence is already set, in case userspace
>   set the property more than once.
> ---
>  drivers/gpu/drm/Kconfig |  1 +
>  drivers/gpu/drm/drm_atomic.c| 14 ++
>  drivers/gpu/drm/drm_atomic_helper.c |  3 +++
>  drivers/gpu/drm/drm_crtc.c  |  7 +++
>  include/drm/drm_crtc.h  |  1 +
>  5 files changed, 26 insertions(+)
> 
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index f2a74d0..3c987e3 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -12,6 +12,7 @@ menuconfig DRM
>   select I2C
>   select I2C_ALGOBIT
>   select DMA_SHARED_BUFFER
> + select SYNC_FILE
>   help
> Kernel-level support for the Direct Rendering Infrastructure (DRI)
> introduced in XFree86 4.0. If you say Y here, you need to select
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 8ee1db8..13674c7 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -30,6 +30,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  /**
>   * drm_atomic_state_default_release -
> @@ -680,6 +681,17 @@ int drm_atomic_plane_set_property(struct drm_plane 
> *plane,
>   drm_atomic_set_fb_for_plane(state, fb);
>   if (fb)
>   drm_framebuffer_unreference(fb);
> + } else if (property == config->prop_fence_fd) {
> + if (U642I64(val) == -1)
> + return 0;
> +
> + if (state->fence)
> + fence_put(state->fence);
> +
> + state->fence = sync_file_fences_get(val);
> + if (!state->fence)
> + return -EINVAL;
> +
>   } else if (property == config->prop_crtc_id) {
>   struct drm_crtc *crtc = drm_crtc_find(dev, val);
>   return drm_atomic_set_crtc_for_plane(state, crtc);
> @@ -737,6 +749,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
>  
>   if (property == config->prop_fb_id) {
>   *val = (state->fb) ? state->fb->base.id : 0;
> + } else if (property == config->prop_fence_fd) {
> + *val = -1;
>   } else if (property == config->prop_crtc_id) {
>   *val = (state->crtc) ? state->crtc->base.id : 0;
>   } else if (property == config->prop_crtc_x) {
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
> b/drivers/gpu/drm/drm_atomic_helper.c
> index f1cfcce..866f332 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -2696,6 +2696,9 @@ void __drm_atomic_helper_plane_destroy_state(struct 
> drm_plane *plane,
>  {
>   if (state->fb)
>   drm_framebuffer_unreference(state->fb);
> +
> + if (state->fence)
> + fence_put(state->fence);
>  }
>  EXPORT_SYMBOL(__drm_atomic_helper_plane_destroy_state);
>  
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 55ffde5..65212ce 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -1278,6 +1278,7 @@ int drm_universal_plane_init(struct drm_device *dev, 
> struct drm_plane *plane,
>  
>   if (drm_core_check_feature(dev, DRIVER_ATOMIC)) {
>   drm_object_attach_property(&plane->base, config->prop_fb_id, 0);
> + drm_object_attach_property(&plane->base, config->prop_fence_fd, 
> -1);
>   drm_object_attach_property(&plane->base, config->prop_crtc_id, 
> 0);
>   drm_object_attach_property(&plane->base, config->prop_crtc_x, 
> 0);
>   drm_object_attach_property(&plane->base, config->prop_crtc_y, 
> 0);
> @@ -1533,6 +1534,12 @@ static int drm_mode_create_standard_properties(struct 
> drm_device *dev)
>   return -ENOMEM;
>   dev->mode_config.prop_fb_id = prop;
>  
> + prop = drm_property_create_signed_range(dev, DRM_MODE_PROP_ATOMIC,
> + "FENCE_FD", -1, INT_MAX);
> + if (!prop)
> + ret

[RFC v2 7/8] drm/fence: add fence timeline to drm_crtc

2016-04-26 Thread Ville Syrjälä
On Mon, Apr 25, 2016 at 07:33:27PM -0300, Gustavo Padovan wrote:
> From: Gustavo Padovan 
> 
> Create one timeline context for each CRTC to be able to handle out-fences
> and signal them. It adds a few members to struct drm_crtc: fence_context,
> where we store the context we get from fence_context_alloc(), the
> fence seqno and the fence lock, that we pass in fence_init() to be
> used by the fence.
> 
> Signed-off-by: Gustavo Padovan 
> ---
>  drivers/gpu/drm/drm_crtc.c | 29 +
>  include/drm/drm_crtc.h | 19 +++
>  2 files changed, 48 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 65212ce..cf9750a 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -659,6 +659,32 @@ static unsigned int drm_num_crtcs(struct drm_device *dev)
>   return num;
>  }
>  
> +static const char *drm_crtc_fence_get_driver_name(struct fence *fence)
> +{
> + struct drm_crtc *crtc = fence_to_crtc(fence);
> +
> + return crtc->dev->driver->name;
> +}
> +
> +static const char *drm_crtc_fence_get_timeline_name(struct fence *fence)
> +{
> + struct drm_crtc *crtc = fence_to_crtc(fence);
> +
> + return crtc->name;
> +}

Is that exported to userspace? crtc->name is an internal thing, not
meant for outside consumption.

> +
> +static bool drm_crtc_fence_enable_signaling(struct fence *fence)
> +{
> + return true;
> +}
> +
> +const struct fence_ops drm_crtc_fence_ops = {
> + .get_driver_name = drm_crtc_fence_get_driver_name,
> + .get_timeline_name = drm_crtc_fence_get_timeline_name,
> + .enable_signaling = drm_crtc_fence_enable_signaling,
> + .wait = fence_default_wait,
> +};
> +
>  /**
>   * drm_crtc_init_with_planes - Initialise a new CRTC object with
>   *specified primary and cursor planes.
> @@ -709,6 +735,9 @@ int drm_crtc_init_with_planes(struct drm_device *dev, 
> struct drm_crtc *crtc,
>   return -ENOMEM;
>   }
>  
> + crtc->fence_context = fence_context_alloc(1);
> + spin_lock_init(&crtc->fence_lock);
> +
>   crtc->base.properties = &crtc->properties;
>  
>   list_add_tail(&crtc->head, &config->crtc_list);
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index 5ba3cda..d8c32c8 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -32,6 +32,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -715,6 +716,9 @@ struct drm_crtc_funcs {
>   * @helper_private: mid-layer private data
>   * @properties: property tracking for this CRTC
>   * @state: current atomic state for this CRTC
> + * @fence_context: context for fence signalling
> + * @fence_lock: fence lock for the fence context
> + * @fence_seqno: seqno variable to create fences
>   * @acquire_ctx: per-CRTC implicit acquire context used by atomic drivers for
>   *   legacy IOCTLs
>   *
> @@ -771,6 +775,11 @@ struct drm_crtc {
>  
>   struct drm_crtc_state *state;
>  
> + /* fence timelines info for DRM out-fences */
> + unsigned int fence_context;
> + spinlock_t fence_lock;
> + unsigned long fence_seqno;
> +
>   /*
>* For legacy crtc IOCTLs so that atomic drivers can get at the locking
>* acquire context.
> @@ -778,6 +787,16 @@ struct drm_crtc {
>   struct drm_modeset_acquire_ctx *acquire_ctx;
>  };
>  
> +extern const struct fence_ops drm_crtc_fence_ops;
> +
> +static inline struct drm_crtc *fence_to_crtc(struct fence *fence)
> +{
> + if (fence->ops != &drm_crtc_fence_ops)
> + return NULL;
> +
> + return container_of(fence->lock, struct drm_crtc, fence_lock);
> +}
> +
>  /**
>   * struct drm_connector_state - mutable connector state
>   * @connector: backpointer to the connector
> -- 
> 2.5.5
> 
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel OTC


[PATCH] drm/omap: check plane size

2016-04-26 Thread Tomi Valkeinen
At the moment we don't check the plane input/output sizes, which can
lead to DSS HW errors when invalid values are given from the userspace.

Add a check so that the sizes are > 0.

Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/omap_plane.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c 
b/drivers/gpu/drm/omapdrm/omap_plane.c
index 93ee538a99f5..fa9e5086eb65 100644
--- a/drivers/gpu/drm/omapdrm/omap_plane.c
+++ b/drivers/gpu/drm/omapdrm/omap_plane.c
@@ -168,6 +168,12 @@ static int omap_plane_atomic_check(struct drm_plane *plane,
if (IS_ERR(crtc_state))
return PTR_ERR(crtc_state);

+   if (state->src_w == 0 || state->src_h == 0)
+   return -EINVAL;
+
+   if (state->crtc_w == 0 || state->crtc_h == 0)
+   return -EINVAL;
+
if (state->crtc_x < 0 || state->crtc_y < 0)
return -EINVAL;

-- 
2.5.0



[PATCH 02/10] drm: Use dev->name as fallback for dev->unique

2016-04-26 Thread Daniel Vetter
On Wed, Mar 30, 2016 at 11:43:52AM +0100, Emil Velikov wrote:
> On 30 March 2016 at 10:45, Daniel Vetter  wrote:
> > Lots of arm drivers get this wrong and for most arm boards this is the
> > right thing actually. And anyway with most loaders you want to chase
> > sysfs links anyway to figure out which dri device you want.
> >
> > This will fix dmesg noise for rockchip and sti.
> >
> Fwiw I still hope to finish libdrm-2 (hint importing kernel headers),
> which will remove the biggest user of these legacy ioctls. This way we
> might even nuke all these lovelies from the kernel. I doubt you'll
> object against the idea, will you ?

We can't nuke this lovelies from the kernel for another 5-10 years since
old userspace needs to keep working :(

Feel like r-b-stamping this patch?
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH 03/10] drm/sysfs: Annote lockless show functions with READ_ONCE

2016-04-26 Thread Daniel Vetter
On Wed, Mar 30, 2016 at 11:45:13AM +0200, Daniel Vetter wrote:
> For documentation and paranoia.
> 
> Signed-off-by: Daniel Vetter 

Merged to drm-misc with Chris' irc ack - we just discussed the opposite
WRITE_ONCE in some other patches.
-Daniel

> ---
>  drivers/gpu/drm/drm_sysfs.c | 11 ---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> index d503f8e8c2d1..43875cb35691 100644
> --- a/drivers/gpu/drm/drm_sysfs.c
> +++ b/drivers/gpu/drm/drm_sysfs.c
> @@ -208,9 +208,12 @@ static ssize_t status_show(struct device *device,
>  char *buf)
>  {
>   struct drm_connector *connector = to_drm_connector(device);
> + enum drm_connector_status status;
> +
> + status = READ_ONCE(connector->status);
>  
>   return snprintf(buf, PAGE_SIZE, "%s\n",
> - drm_get_connector_status_name(connector->status));
> + drm_get_connector_status_name(status));
>  }
>  
>  static ssize_t dpms_show(struct device *device,
> @@ -231,9 +234,11 @@ static ssize_t enabled_show(struct device *device,
>  char *buf)
>  {
>   struct drm_connector *connector = to_drm_connector(device);
> + bool enabled;
> +
> + enabled = READ_ONCE(connector->encoder);
>  
> - return snprintf(buf, PAGE_SIZE, "%s\n", connector->encoder ? "enabled" :
> - "disabled");
> + return snprintf(buf, PAGE_SIZE, enabled ? "enabled\n" : "disabled\n");
>  }
>  
>  static ssize_t edid_show(struct file *filp, struct kobject *kobj,
> -- 
> 2.8.0.rc3
> 

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


[PATCH 1/3] drm/dp: Add definition for Display Control DPCD Registers capability size

2016-04-26 Thread Yetunde Adebisi
This is used when reading Display Control capability Registers on the sink
device.

cc: Jani Nikula 
cc: dri-devel at lists.freedesktop.org
Signed-off-by: Yetunde Adebisi 
Reviewed-by: Jani Nikula 
---
 include/drm/drm_dp_helper.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
index 1252108..92d9a52 100644
--- a/include/drm/drm_dp_helper.h
+++ b/include/drm/drm_dp_helper.h
@@ -621,6 +621,7 @@ u8 drm_dp_get_adjust_request_pre_emphasis(const u8 
link_status[DP_LINK_STATUS_SI
 #define DP_BRANCH_OUI_HEADER_SIZE  0xc
 #define DP_RECEIVER_CAP_SIZE   0xf
 #define EDP_PSR_RECEIVER_CAP_SIZE  2
+#define EDP_DISPLAY_CTL_CAP_SIZE   3

 void drm_dp_link_train_clock_recovery_delay(const u8 
dpcd[DP_RECEIVER_CAP_SIZE]);
 void drm_dp_link_train_channel_eq_delay(const u8 dpcd[DP_RECEIVER_CAP_SIZE]);
-- 
1.9.3



RFC: libdrm: Support Iris Graphics 540 & 550 (Skylake GT3e)

2016-04-26 Thread Thorsten Leemhuis
Lo! Below patch adds the PCI-ID for the Intel(R) Iris Graphics 550 (Skylake
GT3e mobile) to libdrm. It afaics is the last piece that is missing to
make those GPUs work properly, as Linux 4.6-rc(¹) and Mesa 11.2 already
support it – but without this patch I get a "error initializing buffer
manager" message from i965 when it tries to load. I tested it on a
laptop with a Core i5-6267U and it seems to work -- but I only did a
few quick tests so far.

Could someone @Intel please comment if this patch should be enough to
make libdrm support this GPU properly? And while at it could you please
tell me proper code identifiers for the Iris Graphics 540 and 550? Then I 
can update the patch to use a better name (I assume the "SKYLAKE_GT3E" I   
used in my patch is misleading) and add support for the 540 (0x1923) as 
well.

tia, cu, knurd

(¹)
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=7157bb27e79875db5603aa1e30f56e873a8300f9


diff -Naur libdrm-2.4.67.org/intel/intel_chipset.h 
libdrm-2.4.67/intel/intel_chipset.h
--- libdrm-2.4.67.org/intel/intel_chipset.h 2016-01-17 22:22:14.0 
+0100
+++ libdrm-2.4.67/intel/intel_chipset.h 2016-04-26 10:53:02.937389821 +0200
@@ -180,6 +180,7 @@
 #define PCI_CHIP_SKYLAKE_ULX_GT2   0x191E
 #define PCI_CHIP_SKYLAKE_MOBILE_GT20x1921 /* Reserved */
 #define PCI_CHIP_SKYLAKE_GT3   0x1926
+#define PCI_CHIP_SKYLAKE_GT3E  0x1927
 #define PCI_CHIP_SKYLAKE_HALO_GT3  0x192B /* Reserved */
 #define PCI_CHIP_SKYLAKE_SRV_GT4   0x192A
 #define PCI_CHIP_SKYLAKE_DT_GT40x1932
@@ -390,6 +391,7 @@
 (devid) == PCI_CHIP_SKYLAKE_MOBILE_GT2)

 #define IS_SKL_GT3(devid)  ((devid) == PCI_CHIP_SKYLAKE_GT3|| \
+(devid) == PCI_CHIP_SKYLAKE_GT3E   || \
 (devid) == PCI_CHIP_SKYLAKE_HALO_GT3)

 #define IS_SKL_GT4(devid)  ((devid) == PCI_CHIP_SKYLAKE_SRV_GT4|| \



[Bug 95089] EON game ports black screen on RC410M [Mobility Radeon Xpress 200M]

2016-04-26 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=95089

Alex Deucher  changed:

   What|Removed |Added

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

--- Comment #3 from Alex Deucher  ---
(In reply to Emil Velikov from comment #2)
> The game seems to be trying to use GL_ARB_shader_texture_lod without
> checking if the extension is available. I would report that with the game
> and/or EON wrapper) developers - no program should ever do that.
> 
> Based on the gallium code PIPE_CAP_SM3 (the toggle used to control the
> extension) is "/* Supported on r500 only. */". I'm not familiar with the
> hardware capabilities, but I'm leaning that this might be it.

Right.  Xpress 200M is r3xx based and doesn't support SM3 features.

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


[PATCH 00/12] drm/atomic: Rename async to nonblocking.

2016-04-26 Thread Maarten Lankhorst
Userspace calls the atomic ioctl with DRM_MODE_ATOMIC_NONBLOCK
when it doesn't want the ioctl to block for completion.

In the kernel it's called async commit, which is confusing. The legacy
pageflip and atomic ioctl also have a flag DRM_MODE_PAGE_FLIP_ASYNC
which means that the flip should happen as soon as possible,
even if it causes tearing.

Because of this we should rename async commit to nonblocking commit,
which should reduce a lot of the confusion.

This is done partially with a cocci script, and inspection by hand
because cocci doesn't patch comments.

Maarten Lankhorst (12):
  drm/atomic: Rename async parameter to nonblocking.
  drm/atomic: Rename drm_atomic_async_commit to nonblocking.
  drm/arm/hdlcd: Rename async to nonblock.
  drm/exynos: Rename async to nonblock.
  drm/msm: Rename async to nonblock.
  drm/omapdrm: Rename async to nonblock.
  drm/rcar-du: Rename async to nonblock.
  drm/sti: Rename async to nonblock.
  drm/tegra: Rename async to nonblock.
  drm/rockchip: Rename async to nonblock.
  drm/vc4: Rename async to nonblock.
  drm/i915: Rename async to nonblock.

 drivers/gpu/drm/arm/hdlcd_drv.c|  2 +-
 drivers/gpu/drm/drm_atomic.c   | 12 +--
 drivers/gpu/drm/drm_atomic_helper.c| 34 +++---
 drivers/gpu/drm/exynos/exynos_drm_drv.c|  4 ++--
 drivers/gpu/drm/exynos/exynos_drm_drv.h|  2 +-
 drivers/gpu/drm/i915/intel_display.c   | 16 +++---
 drivers/gpu/drm/msm/msm_atomic.c   |  9 
 drivers/gpu/drm/msm/msm_drv.h  |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c |  4 ++--
 drivers/gpu/drm/rcar-du/rcar_du_kms.c  |  5 +++--
 drivers/gpu/drm/rockchip/rockchip_drm_fb.c |  6 +++---
 drivers/gpu/drm/sti/sti_drv.c  |  6 +++---
 drivers/gpu/drm/tegra/drm.c|  6 +++---
 drivers/gpu/drm/vc4/vc4_kms.c  |  6 +++---
 include/drm/drm_atomic.h   |  2 +-
 include/drm/drm_atomic_helper.h|  2 +-
 include/drm/drm_crtc.h |  8 +++
 17 files changed, 63 insertions(+), 63 deletions(-)

-- 
2.5.5



[PATCH 02/12] drm/atomic: Rename drm_atomic_async_commit to nonblocking.

2016-04-26 Thread Maarten Lankhorst
Another step in renaming async to nonblocking for atomic commit.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/drm_atomic.c| 12 ++--
 drivers/gpu/drm/drm_atomic_helper.c |  4 ++--
 include/drm/drm_atomic.h|  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 8ee1db866e80..c5ebcdca67d4 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -143,7 +143,7 @@ void drm_atomic_state_default_clear(struct drm_atomic_state 
*state)
continue;

/*
-* FIXME: Async commits can race with connector unplugging and
+* FIXME: Nonblocking commits can race with connector 
unplugging and
 * there's currently nothing that prevents cleanup up state for
 * deleted connectors. As long as the callback doesn't look at
 * the connector we'll be fine though, so make sure that's the
@@ -1388,7 +1388,7 @@ int drm_atomic_commit(struct drm_atomic_state *state)
 EXPORT_SYMBOL(drm_atomic_commit);

 /**
- * drm_atomic_async_commit - atomic&async configuration commit
+ * drm_atomic_nonblocking_commit - atomic&nonblocking configuration commit
  * @state: atomic configuration to check
  *
  * Note that this function can return -EDEADLK if the driver needed to acquire
@@ -1403,7 +1403,7 @@ EXPORT_SYMBOL(drm_atomic_commit);
  * Returns:
  * 0 on success, negative error code on failure.
  */
-int drm_atomic_async_commit(struct drm_atomic_state *state)
+int drm_atomic_nonblocking_commit(struct drm_atomic_state *state)
 {
struct drm_mode_config *config = &state->dev->mode_config;
int ret;
@@ -1412,11 +1412,11 @@ int drm_atomic_async_commit(struct drm_atomic_state 
*state)
if (ret)
return ret;

-   DRM_DEBUG_ATOMIC("commiting %p asynchronously\n", state);
+   DRM_DEBUG_ATOMIC("commiting %p nonblocking\n", state);

return config->funcs->atomic_commit(state->dev, state, true);
 }
-EXPORT_SYMBOL(drm_atomic_async_commit);
+EXPORT_SYMBOL(drm_atomic_nonblocking_commit);

 /*
  * The big monstor ioctl
@@ -1685,7 +1685,7 @@ retry:
 */
ret = drm_atomic_check_only(state);
} else if (arg->flags & DRM_MODE_ATOMIC_NONBLOCK) {
-   ret = drm_atomic_async_commit(state);
+   ret = drm_atomic_nonblocking_commit(state);
} else {
ret = drm_atomic_commit(state);
}
diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index 297713bab549..b04662e0e608 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -2371,11 +2371,11 @@ retry:
goto fail;
}

-   ret = drm_atomic_async_commit(state);
+   ret = drm_atomic_nonblocking_commit(state);
if (ret != 0)
goto fail;

-   /* Driver takes ownership of state on successful async commit. */
+   /* Driver takes ownership of state on successful commit. */
return 0;
 fail:
if (ret == -EDEADLK)
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index d3eaa5df187a..92c84e9ab09a 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -137,7 +137,7 @@ drm_atomic_clean_old_fb(struct drm_device *dev, unsigned 
plane_mask, int ret);

 int __must_check drm_atomic_check_only(struct drm_atomic_state *state);
 int __must_check drm_atomic_commit(struct drm_atomic_state *state);
-int __must_check drm_atomic_async_commit(struct drm_atomic_state *state);
+int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);

 #define for_each_connector_in_state(state, connector, connector_state, __i) \
for ((__i) = 0; \
-- 
2.5.5



[PATCH 03/12] drm/arm/hdlcd: Rename async to nonblock.

2016-04-26 Thread Maarten Lankhorst
The async name is deprecated and should be changed to nonblocking.

Cc: Liviu Dudau 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/arm/hdlcd_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index 3ac1ae4d8caf..734899c4e4bb 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -113,7 +113,7 @@ static void hdlcd_fb_output_poll_changed(struct drm_device 
*drm)
 }

 static int hdlcd_atomic_commit(struct drm_device *dev,
-  struct drm_atomic_state *state, bool async)
+  struct drm_atomic_state *state, bool nonblock)
 {
return drm_atomic_helper_commit(dev, state, false);
 }
-- 
2.5.5



[PATCH 01/12] drm/atomic: Rename async parameter to nonblocking.

2016-04-26 Thread Maarten Lankhorst
This is the first step of renaming async commit to nonblocking commit.
The flag passed by userspace is NONBLOCKING, and async has a different
meaning for page flips, where it means as soon as possible.

Fixing up comments in drm core is done manually, to make sure I didn't
miss anything.

For drivers, the following cocci script is used to rename bool async to bool
nonblock:
@@
identifier I =~ "^async";
identifier func;
@@
func(..., bool
- I
+ nonblock
, ...)
{
<...
- I
+ nonblock
...>
}
@@
identifier func;
type T;
identifier I =~ "^async";
@@
T func(..., bool
- I
+ nonblock
, ...);

Thanks to Tvrtko Ursulin for the cocci script.

Cc: Tvrtko Ursulin 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/drm_atomic_helper.c | 30 +++---
 include/drm/drm_atomic_helper.h |  2 +-
 include/drm/drm_crtc.h  |  8 
 3 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index 40c7b268a9bc..297713bab549 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -1114,13 +1114,13 @@ EXPORT_SYMBOL(drm_atomic_helper_wait_for_vblanks);
  * drm_atomic_helper_commit - commit validated state object
  * @dev: DRM device
  * @state: the driver state object
- * @async: asynchronous commit
+ * @nonblocking: whether nonblocking behavior is requested.
  *
  * This function commits a with drm_atomic_helper_check() pre-validated state
  * object. This can still fail when e.g. the framebuffer reservation fails. For
- * now this doesn't implement asynchronous commits.
+ * now this doesn't implement nonblocking commits.
  *
- * Note that right now this function does not support async commits, and hence
+ * Note that right now this function does not support nonblocking commits, 
hence
  * driver writers must implement their own version for now. Also note that the
  * default ordering of how the various stages are called is to match the legacy
  * modeset helper library closest. One peculiarity of that is that it doesn't
@@ -1141,11 +1141,11 @@ EXPORT_SYMBOL(drm_atomic_helper_wait_for_vblanks);
  */
 int drm_atomic_helper_commit(struct drm_device *dev,
 struct drm_atomic_state *state,
-bool async)
+bool nonblock)
 {
int ret;

-   if (async)
+   if (nonblock)
return -EBUSY;

ret = drm_atomic_helper_prepare_planes(dev, state);
@@ -1195,20 +1195,20 @@ int drm_atomic_helper_commit(struct drm_device *dev,
 EXPORT_SYMBOL(drm_atomic_helper_commit);

 /**
- * DOC: implementing async commit
+ * DOC: implementing nonblocking commit
  *
- * For now the atomic helpers don't support async commit directly. If there is
- * real need it could be added though, using the dma-buf fence infrastructure
- * for generic synchronization with outstanding rendering.
+ * For now the atomic helpers don't support nonblocking commit directly. If
+ * there is real need it could be added though, using the dma-buf fence
+ * infrastructure for generic synchronization with outstanding rendering.
  *
- * For now drivers have to implement async commit themselves, with the 
following
- * sequence being the recommended one:
+ * For now drivers have to implement nonblocking commit themselves, with the
+ * following sequence being the recommended one:
  *
  * 1. Run drm_atomic_helper_prepare_planes() first. This is the only function
  * which commit needs to call which can fail, so we want to run it first and
  * synchronously.
  *
- * 2. Synchronize with any outstanding asynchronous commit worker threads which
+ * 2. Synchronize with any outstanding nonblocking commit worker threads which
  * might be affected the new state update. This can be done by either 
cancelling
  * or flushing the work items, depending upon whether the driver can deal with
  * cancelled updates. Note that it is important to ensure that the framebuffer
@@ -1222,9 +1222,9 @@ EXPORT_SYMBOL(drm_atomic_helper_commit);
  * 3. The software state is updated synchronously with
  * drm_atomic_helper_swap_state(). Doing this under the protection of all 
modeset
  * locks means concurrent callers never see inconsistent state. And doing this
- * while it's guaranteed that no relevant async worker runs means that async
- * workers do not need grab any locks. Actually they must not grab locks, for
- * otherwise the work flushing will deadlock.
+ * while it's guaranteed that no relevant nonblocking worker runs means that
+ * nonblocking workers do not need grab any locks. Actually they must not grab
+ * locks, for otherwise the work flushing will deadlock.
  *
  * 4. Schedule a work item to do all subsequent steps, using the split-out
  * commit helpers: a) pre-plane commit b) plane commit c) post-plane commit and
diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
index fe9d89c7d1ed..03642878bc51 10064

[PATCH 04/12] drm/exynos: Rename async to nonblock.

2016-04-26 Thread Maarten Lankhorst
The async name is deprecated and should be changed to nonblocking.

Cc: Inki Dae 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/exynos/exynos_drm_drv.c | 4 ++--
 drivers/gpu/drm/exynos/exynos_drm_drv.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c 
b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 5344940c8a07..8ff355ddcf51 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -270,7 +270,7 @@ static int commit_is_pending(struct exynos_drm_private 
*priv, u32 crtcs)
 }

 int exynos_atomic_commit(struct drm_device *dev, struct drm_atomic_state 
*state,
-bool async)
+bool nonblock)
 {
struct exynos_drm_private *priv = dev->dev_private;
struct exynos_atomic_commit *commit;
@@ -308,7 +308,7 @@ int exynos_atomic_commit(struct drm_device *dev, struct 
drm_atomic_state *state,

drm_atomic_helper_swap_state(dev, state);

-   if (async)
+   if (nonblock)
schedule_work(&commit->work);
else
exynos_atomic_commit_complete(commit);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h 
b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index 502f750bad2a..e50c09b4dce1 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -296,7 +296,7 @@ static inline int exynos_dpi_bind(struct drm_device *dev,
 #endif

 int exynos_atomic_commit(struct drm_device *dev, struct drm_atomic_state 
*state,
-bool async);
+bool nonblock);


 extern struct platform_driver fimd_driver;
-- 
2.5.5



[PATCH 05/12] drm/msm: Rename async to nonblock.

2016-04-26 Thread Maarten Lankhorst
The async name is deprecated and should be changed to nonblocking.

Also comments seem to be a bit outdated, as it looks like
nonblocking commit is supported by msm.

Cc: Rob Clark 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/msm/msm_atomic.c | 9 -
 drivers/gpu/drm/msm/msm_drv.h| 2 +-
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_atomic.c b/drivers/gpu/drm/msm/msm_atomic.c
index 7eb253bc24df..5c6130969f4d 100644
--- a/drivers/gpu/drm/msm/msm_atomic.c
+++ b/drivers/gpu/drm/msm/msm_atomic.c
@@ -190,17 +190,16 @@ int msm_atomic_check(struct drm_device *dev,
  * drm_atomic_helper_commit - commit validated state object
  * @dev: DRM device
  * @state: the driver state object
- * @async: asynchronous commit
+ * @nonblock: nonblocking commit
  *
  * This function commits a with drm_atomic_helper_check() pre-validated state
- * object. This can still fail when e.g. the framebuffer reservation fails. For
- * now this doesn't implement asynchronous commits.
+ * object. This can still fail when e.g. the framebuffer reservation fails.
  *
  * RETURNS
  * Zero for success or -errno.
  */
 int msm_atomic_commit(struct drm_device *dev,
-   struct drm_atomic_state *state, bool async)
+   struct drm_atomic_state *state, bool nonblock)
 {
int nplanes = dev->mode_config.num_total_plane;
int ncrtcs = dev->mode_config.num_crtc;
@@ -276,7 +275,7 @@ int msm_atomic_commit(struct drm_device *dev,
 * current layout.
 */

-   if (async) {
+   if (nonblock) {
msm_queue_fence_cb(dev, &c->fence_cb, c->fence);
return 0;
}
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index 870dbe58c259..0b8b0e630e42 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -174,7 +174,7 @@ void __msm_fence_worker(struct work_struct *work);
 int msm_atomic_check(struct drm_device *dev,
 struct drm_atomic_state *state);
 int msm_atomic_commit(struct drm_device *dev,
-   struct drm_atomic_state *state, bool async);
+   struct drm_atomic_state *state, bool nonblock);

 int msm_register_mmu(struct drm_device *dev, struct msm_mmu *mmu);

-- 
2.5.5



[PATCH 06/12] drm/omapdrm: Rename async to nonblock.

2016-04-26 Thread Maarten Lankhorst
The async name is deprecated and should be changed to nonblocking.

Cc: Tomi Valkeinen 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 80398a684cae..fe794980f1c8 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -138,7 +138,7 @@ static bool omap_atomic_is_pending(struct omap_drm_private 
*priv,
 }

 static int omap_atomic_commit(struct drm_device *dev,
- struct drm_atomic_state *state, bool async)
+ struct drm_atomic_state *state, bool nonblock)
 {
struct omap_drm_private *priv = dev->dev_private;
struct omap_atomic_state_commit *commit;
@@ -177,7 +177,7 @@ static int omap_atomic_commit(struct drm_device *dev,
/* Swap the state, this is the point of no return. */
drm_atomic_helper_swap_state(dev, state);

-   if (async)
+   if (nonblock)
schedule_work(&commit->work);
else
omap_atomic_complete(commit);
-- 
2.5.5



[PATCH 07/12] drm/rcar-du: Rename async to nonblock.

2016-04-26 Thread Maarten Lankhorst
The async name is deprecated and should be changed to nonblocking.

Cc: Laurent Pinchart 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c 
b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index 24725bf859b4..e70a4f33d970 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -283,7 +283,8 @@ static void rcar_du_atomic_work(struct work_struct *work)
 }

 static int rcar_du_atomic_commit(struct drm_device *dev,
-struct drm_atomic_state *state, bool async)
+struct drm_atomic_state *state,
+bool nonblock)
 {
struct rcar_du_device *rcdu = dev->dev_private;
struct rcar_du_commit *commit;
@@ -328,7 +329,7 @@ static int rcar_du_atomic_commit(struct drm_device *dev,
/* Swap the state, this is the point of no return. */
drm_atomic_helper_swap_state(dev, state);

-   if (async)
+   if (nonblock)
schedule_work(&commit->work);
else
rcar_du_atomic_complete(commit);
-- 
2.5.5



[PATCH 08/12] drm/sti: Rename async to nonblock.

2016-04-26 Thread Maarten Lankhorst
The async name is deprecated and should be changed to nonblocking.

Cc: Benjamin Gaignard 
Cc: Vincent Abriou 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/sti/sti_drv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index 6bd6abaa5a70..872495e72294 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -202,7 +202,7 @@ static void sti_atomic_work(struct work_struct *work)
 }

 static int sti_atomic_commit(struct drm_device *drm,
-struct drm_atomic_state *state, bool async)
+struct drm_atomic_state *state, bool nonblock)
 {
struct sti_private *private = drm->dev_private;
int err;
@@ -211,7 +211,7 @@ static int sti_atomic_commit(struct drm_device *drm,
if (err)
return err;

-   /* serialize outstanding asynchronous commits */
+   /* serialize outstanding nonblocking commits */
mutex_lock(&private->commit.lock);
flush_work(&private->commit.work);

@@ -223,7 +223,7 @@ static int sti_atomic_commit(struct drm_device *drm,

drm_atomic_helper_swap_state(drm, state);

-   if (async)
+   if (nonblock)
sti_atomic_schedule(private, state);
else
sti_atomic_complete(private, state);
-- 
2.5.5



[PATCH 09/12] drm/tegra: Rename async to nonblock.

2016-04-26 Thread Maarten Lankhorst
The async name is deprecated and should be changed to nonblocking.

Cc: Thierry Reding 
Cc: "Terje Bergström" 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/tegra/drm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 2be88eb0cb83..71a52f4e688b 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -74,7 +74,7 @@ static void tegra_atomic_work(struct work_struct *work)
 }

 static int tegra_atomic_commit(struct drm_device *drm,
-  struct drm_atomic_state *state, bool async)
+  struct drm_atomic_state *state, bool nonblock)
 {
struct tegra_drm *tegra = drm->dev_private;
int err;
@@ -83,7 +83,7 @@ static int tegra_atomic_commit(struct drm_device *drm,
if (err)
return err;

-   /* serialize outstanding asynchronous commits */
+   /* serialize outstanding nonblocking commits */
mutex_lock(&tegra->commit.lock);
flush_work(&tegra->commit.work);

@@ -95,7 +95,7 @@ static int tegra_atomic_commit(struct drm_device *drm,

drm_atomic_helper_swap_state(drm, state);

-   if (async)
+   if (nonblock)
tegra_atomic_schedule(tegra, state);
else
tegra_atomic_complete(tegra, state);
-- 
2.5.5



[PATCH 10/12] drm/rockchip: Rename async to nonblock.

2016-04-26 Thread Maarten Lankhorst
The async name is deprecated and should be changed to nonblocking.

Cc: Mark Yao 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
index 3b8f652698f8..8c10163a95bc 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
@@ -276,7 +276,7 @@ void rockchip_drm_atomic_work(struct work_struct *work)

 int rockchip_drm_atomic_commit(struct drm_device *dev,
   struct drm_atomic_state *state,
-  bool async)
+  bool nonblock)
 {
struct rockchip_drm_private *private = dev->dev_private;
struct rockchip_atomic_commit *commit = &private->commit;
@@ -286,7 +286,7 @@ int rockchip_drm_atomic_commit(struct drm_device *dev,
if (ret)
return ret;

-   /* serialize outstanding asynchronous commits */
+   /* serialize outstanding nonblocking commits */
mutex_lock(&commit->lock);
flush_work(&commit->work);

@@ -295,7 +295,7 @@ int rockchip_drm_atomic_commit(struct drm_device *dev,
commit->dev = dev;
commit->state = state;

-   if (async)
+   if (nonblock)
schedule_work(&commit->work);
else
rockchip_atomic_commit_complete(commit);
-- 
2.5.5



[PATCH 11/12] drm/vc4: Rename async to nonblock.

2016-04-26 Thread Maarten Lankhorst
The async name is deprecated and should be changed to nonblocking.

Cc: Eric Anholt 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/vc4/vc4_kms.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c
index 4718ae5176cc..d423ba10239a 100644
--- a/drivers/gpu/drm/vc4/vc4_kms.c
+++ b/drivers/gpu/drm/vc4/vc4_kms.c
@@ -93,7 +93,7 @@ static struct vc4_commit *commit_init(struct drm_atomic_state 
*state)
  * vc4_atomic_commit - commit validated state object
  * @dev: DRM device
  * @state: the driver state object
- * @async: asynchronous commit
+ * @nonblock: nonblocking commit
  *
  * This function commits a with drm_atomic_helper_check() pre-validated state
  * object. This can still fail when e.g. the framebuffer reservation fails. For
@@ -104,7 +104,7 @@ static struct vc4_commit *commit_init(struct 
drm_atomic_state *state)
  */
 static int vc4_atomic_commit(struct drm_device *dev,
 struct drm_atomic_state *state,
-bool async)
+bool nonblock)
 {
struct vc4_dev *vc4 = to_vc4_dev(dev);
int ret;
@@ -170,7 +170,7 @@ static int vc4_atomic_commit(struct drm_device *dev,
 * current layout.
 */

-   if (async) {
+   if (nonblock) {
vc4_queue_seqno_cb(dev, &c->cb, wait_seqno,
   vc4_atomic_complete_commit_seqno_cb);
} else {
-- 
2.5.5



[PATCH 12/12] drm/i915: Rename async to nonblock.

2016-04-26 Thread Maarten Lankhorst
The async name is deprecated and should be changed to nonblocking.

Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/i915/intel_display.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index 551541b3038c..5d29b838d8d7 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -13386,7 +13386,7 @@ static int intel_atomic_check(struct drm_device *dev,

 static int intel_atomic_prepare_commit(struct drm_device *dev,
   struct drm_atomic_state *state,
-  bool async)
+  bool nonblock)
 {
struct drm_i915_private *dev_priv = dev->dev_private;
struct drm_plane_state *plane_state;
@@ -13395,8 +13395,8 @@ static int intel_atomic_prepare_commit(struct 
drm_device *dev,
struct drm_crtc *crtc;
int i, ret;

-   if (async) {
-   DRM_DEBUG_KMS("i915 does not yet support async commit\n");
+   if (nonblock) {
+   DRM_DEBUG_KMS("i915 does not yet support nonblocking commit\n");
return -EINVAL;
}

@@ -13414,7 +13414,7 @@ static int intel_atomic_prepare_commit(struct 
drm_device *dev,
return ret;

ret = drm_atomic_helper_prepare_planes(dev, state);
-   if (!ret && !async && !i915_reset_in_progress(&dev_priv->gpu_error)) {
+   if (!ret && !nonblock && !i915_reset_in_progress(&dev_priv->gpu_error)) 
{
u32 reset_counter;

reset_counter = atomic_read(&dev_priv->gpu_error.reset_counter);
@@ -13519,21 +13519,21 @@ static bool needs_vblank_wait(struct intel_crtc_state 
*crtc_state)
  * intel_atomic_commit - commit validated state object
  * @dev: DRM device
  * @state: the top-level driver state object
- * @async: asynchronous commit
+ * @nonblock: nonblocking commit
  *
  * This function commits a top-level state object that has been validated
  * with drm_atomic_helper_check().
  *
  * FIXME:  Atomic modeset support for i915 is not yet complete.  At the moment
  * we can only handle plane-related operations and do not yet support
- * asynchronous commit.
+ * nonblocking commit.
  *
  * RETURNS
  * Zero for success or -errno.
  */
 static int intel_atomic_commit(struct drm_device *dev,
   struct drm_atomic_state *state,
-  bool async)
+  bool nonblock)
 {
struct intel_atomic_state *intel_state = to_intel_atomic_state(state);
struct drm_i915_private *dev_priv = dev->dev_private;
@@ -13545,7 +13545,7 @@ static int intel_atomic_commit(struct drm_device *dev,
unsigned long put_domains[I915_MAX_PIPES] = {};
unsigned crtc_vblank_mask = 0;

-   ret = intel_atomic_prepare_commit(dev, state, async);
+   ret = intel_atomic_prepare_commit(dev, state, nonblock);
if (ret) {
DRM_DEBUG_ATOMIC("Preparing state failed with %i\n", ret);
return ret;
-- 
2.5.5



[PATCH 00/12] drm/atomic: Rename async to nonblocking.

2016-04-26 Thread Daniel Vetter
On Tue, Apr 26, 2016 at 04:11:33PM +0200, Maarten Lankhorst wrote:
> Userspace calls the atomic ioctl with DRM_MODE_ATOMIC_NONBLOCK
> when it doesn't want the ioctl to block for completion.
> 
> In the kernel it's called async commit, which is confusing. The legacy
> pageflip and atomic ioctl also have a flag DRM_MODE_PAGE_FLIP_ASYNC
> which means that the flip should happen as soon as possible,
> even if it causes tearing.
> 
> Because of this we should rename async commit to nonblocking commit,
> which should reduce a lot of the confusion.
> 
> This is done partially with a cocci script, and inspection by hand
> because cocci doesn't patch comments.
> 
> Maarten Lankhorst (12):
>   drm/atomic: Rename async parameter to nonblocking.
>   drm/atomic: Rename drm_atomic_async_commit to nonblocking.
>   drm/arm/hdlcd: Rename async to nonblock.
>   drm/exynos: Rename async to nonblock.
>   drm/msm: Rename async to nonblock.
>   drm/omapdrm: Rename async to nonblock.
>   drm/rcar-du: Rename async to nonblock.
>   drm/sti: Rename async to nonblock.
>   drm/tegra: Rename async to nonblock.
>   drm/rockchip: Rename async to nonblock.
>   drm/vc4: Rename async to nonblock.
>   drm/i915: Rename async to nonblock.

Yeah, this clarifies stuff a lot imo. Bit a funny split-up in the first
two patches, but meh.

I think I'll apply it all to drm-misc once driver maintainers had some
time to ack, but will merge anyway if they miss.
-Daniel

> 
>  drivers/gpu/drm/arm/hdlcd_drv.c|  2 +-
>  drivers/gpu/drm/drm_atomic.c   | 12 +--
>  drivers/gpu/drm/drm_atomic_helper.c| 34 
> +++---
>  drivers/gpu/drm/exynos/exynos_drm_drv.c|  4 ++--
>  drivers/gpu/drm/exynos/exynos_drm_drv.h|  2 +-
>  drivers/gpu/drm/i915/intel_display.c   | 16 +++---
>  drivers/gpu/drm/msm/msm_atomic.c   |  9 
>  drivers/gpu/drm/msm/msm_drv.h  |  2 +-
>  drivers/gpu/drm/omapdrm/omap_drv.c |  4 ++--
>  drivers/gpu/drm/rcar-du/rcar_du_kms.c  |  5 +++--
>  drivers/gpu/drm/rockchip/rockchip_drm_fb.c |  6 +++---
>  drivers/gpu/drm/sti/sti_drv.c  |  6 +++---
>  drivers/gpu/drm/tegra/drm.c|  6 +++---
>  drivers/gpu/drm/vc4/vc4_kms.c  |  6 +++---
>  include/drm/drm_atomic.h   |  2 +-
>  include/drm/drm_atomic_helper.h|  2 +-
>  include/drm/drm_crtc.h |  8 +++
>  17 files changed, 63 insertions(+), 63 deletions(-)
> 
> -- 
> 2.5.5
> 
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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


[Bug 51381] [drm:atom_op_jump] *ERROR* atombios stuck in loop for more than 5secs aborting, when disabled via vgaswitcheroo

2016-04-26 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=51381

Peter Uchno  changed:

   What|Removed |Added

 CC||peter.uchno at gmail.com

--- Comment #41 from Peter Uchno  ---
I've started seeing this on a Dell Latitude E6540 with a Radeon 8790M and Intel
hybrid graphics. I'm using vgaswitcheroo to disable the Radeon in Linux. I'm on
Arch Linux, I wasn't seeing the problem in kernel 4.5.0 but I'm seeing it now
in 4.5.1. The kernel spits out errors about the atombios being stuck in a loop
and then fills dmesg with messages about "ring 3 stalled".
After about a full minute of this, X starts on the Intel GPU and the system
seems to run normally. The kernel continues to spit out error messages during
operation. Adding radeon.runpm=0 to the kernel parameters results in  a normal
boot, where the driver starts up normally and X starts up much more quickly. I
do see that a patch related to runtime PM
(e64c952efb8e0c15ae82cec8e455ab4910690ef1) went into the kernel recently.

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


[RFC v2 5/8] drm/fence: add in-fences support

2016-04-26 Thread Daniel Vetter
On Tue, Apr 26, 2016 at 11:14:22AM -0300, Gustavo Padovan wrote:
> 2016-04-26 Ville Syrjälä :
> 
> > On Mon, Apr 25, 2016 at 07:33:25PM -0300, Gustavo Padovan wrote:
> > > From: Gustavo Padovan 
> > > 
> > > There is now a new property called FENCE_FD attached to every plane
> > > state that receives the sync_file fd from userspace via the atomic commit
> > > IOCTL.
> > 
> > I still don't like this property abuse. Also with atomic, all passed
> > fences must be waited upon before anything is done, so attaching them
> > to planes seems like it might just give people the wrong idea.
> 
> I'm actually fine with this as property, but another solutions is use
> an array of {plane, fence_fd} and extend drm_atomic_ioctl args just like
> we have done for out fences. However the FENCE_FD property is easier to
> handle in userspace than the array. Any other idea?

Imo FENCE_FD is perfectly fine. But what's the concern around giving
people the wrong idea with attaching fences to planes? For nonblocking
commits we need to store them somewhere for the worker, drm_plane_state
seems like an as good place as any other.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH v12 1/2] kernel.h: add u64_to_user_ptr()

2016-04-26 Thread Joe Perches
On Tue, 2016-04-26 at 11:29 -0300, Gustavo Padovan wrote:
> 2016-04-26 Lucas Stach :
> > Am Donnerstag, den 21.04.2016, 12:38 -0300 schrieb Gustavo Padovan:
> > > From: Gustavo Padovan 
> > > 
> > > This function had copies in 3 different files. Unify them in kernel.h.
> > > 
> > > Cc: Joe Perches 
> > > Cc: Andrew Morton 
> > > Cc: David Airlie 
> > > Cc: Daniel Vetter 
> > > Cc: Rob Clark 
> > > Signed-off-by: Gustavo Padovan 
> > > 
> > Though I normally prefer static inline functions, I see the benefits of
> > using the macro form here.

An inline could still work
static inline void __user *u64_to_user_ptr(u64 address)
{
return (void __user *)(uintptr_t)address;
}
if the macro was
#define u64_to_user_ptr(x)  \
({  \
typecheck(u64, x);  \
(u64_to_user_ptr)(x);   \
})

the parenthesis around the u64_to_user_ptr
in the macro should prevent expansion.



[RFC v2 1/8] dma-buf/fence: add fence_collection fences

2016-04-26 Thread Daniel Vetter
On Mon, Apr 25, 2016 at 07:33:21PM -0300, Gustavo Padovan wrote:
> From: Gustavo Padovan 
> 
> struct fence_collection inherits from struct fence and carries a
> collection of fences that needs to be waited together.
> 
> It is useful to translate a sync_file to a fence to remove the complexity
> of dealing with sync_files on DRM drivers. So even if there are many
> fences in the sync_file that needs to waited for a commit to happen,
> they all get added to the fence_collection and passed for DRM use as
> a standard struct fence.
> 
> That means that no changes needed to any driver besides supporting fences.
> 
> fence_collection's fence doesn't belong to any timeline context, so
> fence_is_later() and fence_later() are not meant to be called with
> fence_collections fences.
> 
> v2: Comments by Daniel Vetter:
>   - merge fence_collection_init() and fence_collection_add()
>   - only add callbacks at ->enable_signalling()
>   - remove fence_collection_put()
>   - check for type on to_fence_collection()
>   - adjust fence_is_later() and fence_later() to WARN_ON() if they
>   are used with collection fences.
> 
> Signed-off-by: Gustavo Padovan 

FENCE_NO_CONTEXT semantics needs an ack from amdgpu maintainers. I'm not
entirely sure they might not hit the new WARN_ON by accident now. Please
cc Alex Deucher & Christian König.
-Daniel

> ---
>  drivers/dma-buf/Makefile   |   2 +-
>  drivers/dma-buf/fence-collection.c | 159 
> +
>  drivers/dma-buf/fence.c|   2 +-
>  include/linux/fence-collection.h   |  73 +
>  include/linux/fence.h  |   9 +++
>  5 files changed, 243 insertions(+), 2 deletions(-)
>  create mode 100644 drivers/dma-buf/fence-collection.c
>  create mode 100644 include/linux/fence-collection.h
> 
> diff --git a/drivers/dma-buf/Makefile b/drivers/dma-buf/Makefile
> index 4a424ec..52f818f 100644
> --- a/drivers/dma-buf/Makefile
> +++ b/drivers/dma-buf/Makefile
> @@ -1,2 +1,2 @@
> -obj-y := dma-buf.o fence.o reservation.o seqno-fence.o
> +obj-y := dma-buf.o fence.o reservation.o seqno-fence.o fence-collection.o
>  obj-$(CONFIG_SYNC_FILE)  += sync_file.o
> diff --git a/drivers/dma-buf/fence-collection.c 
> b/drivers/dma-buf/fence-collection.c
> new file mode 100644
> index 000..88872e5
> --- /dev/null
> +++ b/drivers/dma-buf/fence-collection.c
> @@ -0,0 +1,159 @@
> +/*
> + * fence-collection: aggregate fences to be waited together
> + *
> + * Copyright (C) 2016 Collabora Ltd
> + * Authors:
> + *   Gustavo Padovan 
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License version 2 as published 
> by
> + * the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful, but 
> WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> + * more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +
> +static const char *fence_collection_get_driver_name(struct fence *fence)
> +{
> + struct fence_collection *collection = to_fence_collection(fence);
> + struct fence *f = collection->fences[0].fence;
> +
> + return f->ops->get_driver_name(fence);
> +}
> +
> +static const char *fence_collection_get_timeline_name(struct fence *fence)
> +{
> + return "no context";
> +}
> +
> +static void collection_check_cb_func(struct fence *fence, struct fence_cb 
> *cb)
> +{
> + struct fence_collection_cb *f_cb;
> + struct fence_collection *collection;
> +
> + f_cb = container_of(cb, struct fence_collection_cb, cb);
> + collection = f_cb->collection;
> +
> + if (atomic_dec_and_test(&collection->num_pending_fences))
> + fence_signal(&collection->base);
> +}
> +
> +static bool fence_collection_enable_signaling(struct fence *fence)
> +{
> + struct fence_collection *collection = to_fence_collection(fence);
> + int i;
> +
> + for (i = 0 ; i < collection->num_fences ; i++) {
> + if (fence_add_callback(collection->fences[i].fence,
> +&collection->fences[i].cb,
> +collection_check_cb_func)) {
> + atomic_dec(&collection->num_pending_fences);
> + return false;
> + }
> + }
> +
> + return !!atomic_read(&collection->num_pending_fences);
> +}
> +
> +static bool fence_collection_signaled(struct fence *fence)
> +{
> + struct fence_collection *collection = to_fence_collection(fence);
> +
> + return (atomic_read(&collection->num_pending_fences) == 0);
> +}
> +
> +static void fence_collection_release(struct fence *fence)
> +{
> + struct fence_collection *collection = to_fence_collection(fence);
> + int i;
> +
> + for (i = 0 ; i < collection->num_fences ; i++)
> +

[Bug 116251] radeon 5a427809cd9143bef89ee3110f45e84f37484218 "drm/radeon: disable runtime pm on PX laptop" makes dGPU never stop

2016-04-26 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=116251

Kertesz Laszlo  changed:

   What|Removed |Added

 CC||laszlo.kertesz at gmail.com

--- Comment #6 from Kertesz Laszlo  ---
The issue is present on Dell Latitude E6540 (Debian Testing installed).

00:02.0 VGA compatible controller: Intel Corporation 4th Gen Core Processor
Integrated Graphics Controller (rev 06)
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Mars
XTX [Radeon HD 8790M] (rev ff)

Some more discussions about this here:
https://www.phoronix.com/forums/forum/linux-graphics-x-org-drivers/open-source-amd-linux/867738-kernel-4-5-radeon-runpm-not-working-properly-on-debian-testing

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


[Bug 116251] radeon 5a427809cd9143bef89ee3110f45e84f37484218 "drm/radeon: disable runtime pm on PX laptop" makes dGPU never stop

2016-04-26 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=116251

--- Comment #7 from Alex Deucher  ---
The patch has been reverted:
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=bfaddd9fc8ac048b99475f000dbef6f08297417f
and will be reverted in stable branches as well.

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


[RFC v2 8/8] drm/fence: add out-fences support

2016-04-26 Thread Daniel Vetter
On Mon, Apr 25, 2016 at 07:33:28PM -0300, Gustavo Padovan wrote:
> From: Gustavo Padovan 
> 
> Support DRM out-fences creating a sync_file with a fence for each crtc
> update with the DRM_MODE_ATOMIC_OUT_FENCE flag.
> 
> We then send an struct drm_out_fences array with the out-fences fds back in
> the drm_atomic_ioctl() as an out arg in the out_fences_ptr field.
> 
> struct drm_out_fences {
>   __u32   crtc_id;
>   __u32   fd;
> };
> 
> v2: Comment by Rob Clark:
>   - Squash commit that adds DRM_MODE_ATOMIC_OUT_FENCE flag here.
> 
> Comment by Daniel Vetter:
>   - Add clean up code for out_fences
> 
> Signed-off-by: Gustavo Padovan 
> ---
>  drivers/gpu/drm/drm_atomic.c | 163 
> +--
>  include/drm/drm_crtc.h   |  10 +++
>  include/uapi/drm/drm_mode.h  |  11 ++-
>  3 files changed, 179 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 5f9d434..06c6007 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -1566,6 +1566,133 @@ void drm_atomic_clean_old_fb(struct drm_device *dev,
>  }
>  EXPORT_SYMBOL(drm_atomic_clean_old_fb);
>  
> +static struct drm_out_fence_state *get_out_fence(struct drm_device *dev,
> +  struct drm_atomic_state *state,
> +  uint32_t __user 
> *out_fences_ptr,
> +  uint64_t count_out_fences,
> +  uint64_t user_data)
> +{
> + struct drm_crtc *crtc;
> + struct drm_crtc_state *crtc_state;
> + struct drm_out_fences *out_fences;
> + struct drm_out_fence_state *fence_state;
> + int num_fences = 0;
> + int i, ret;
> +
> + if (count_out_fences > dev->mode_config.num_crtc)
> + return ERR_PTR(-EINVAL);
> +
> + out_fences = kcalloc(count_out_fences, sizeof(*out_fences),
> +  GFP_KERNEL);
> + if (!out_fences)
> + return ERR_PTR(-ENOMEM);

A bit tricky, but the above kcalloc is the only thing that catches integer
overflows in count_out_fences. Needs a comment imo since this could be a
security exploit if we accidentally screw it up.

Also needs a testcase imo.

> +
> + fence_state = kcalloc(count_out_fences, sizeof(*fence_state),
> +  GFP_KERNEL);
> + if (!fence_state) {
> + kfree(out_fences);
> + return ERR_PTR(-ENOMEM);
> + }
> +
> + for (i = 0 ; i < count_out_fences ; i++)
> + fence_state[i].fd = -1;
> +
> + for_each_crtc_in_state(state, crtc, crtc_state, i) {
> + struct drm_pending_vblank_event *e;
> + struct fence *fence;
> + char name[32];
> +
> + fence = kzalloc(sizeof(*fence), GFP_KERNEL);
> + if (!fence) {
> + ret = -ENOMEM;
> + goto out;
> + }
> +
> + fence_init(fence, &drm_crtc_fence_ops, &crtc->fence_lock,
> +crtc->fence_context, crtc->fence_seqno);
> +
> + snprintf(name, sizeof(name), "crtc-%d_%lu",
> +  drm_crtc_index(crtc), crtc->fence_seqno++);

Hm ... fence_init_with_name? I'm kinda confused why we only name fences
that are exported though, and why not all of them. Debugging fence
deadlocks is real hard, so giving them all names might be a good idea.

Anyway, seems like more room for a bit more sync_file/struct fence
merging.

> +
> + fence_state[i].fd = get_unused_fd_flags(O_CLOEXEC);
> + if (fence_state[i].fd < 0) {
> + fence_put(fence);
> + ret = fence_state[i].fd;
> + goto out;
> + }
> +
> + fence_state[i].sync_file = sync_file_create(name, fence);
> + if(!fence_state[i].sync_file) {
> + fence_put(fence);
> + ret = -ENOMEM;
> + goto out;
> + }
> +
> + if (crtc_state->event) {
> + crtc_state->event->base.fence = fence;
> + } else {

This looks a bit funny - I'd change the create event logic to create an
event either if we have the either drm event or out-fence flag set.

> + e = create_vblank_event(dev, NULL, fence, user_data);
> + if (!e) {
> + ret = -ENOMEM;
> + goto out;
> + }
> +
> + crtc_state->event = e;
> + }
> +
> + out_fences[num_fences].crtc_id = crtc->base.id;
> + out_fences[num_fences].fd = fence_state[i].fd;
> + num_fences++;
> + }
> +
> + if (copy_to_user(out_fences_ptr, out_fences,
> +  num_fences * sizeof(*out_fences))) {
> + ret = -EFAULT;
> +  

[PATCH 03/12] drm/arm/hdlcd: Rename async to nonblock.

2016-04-26 Thread Liviu Dudau
On Tue, Apr 26, 2016 at 04:11:36PM +0200, Maarten Lankhorst wrote:
> The async name is deprecated and should be changed to nonblocking.
> 
> Cc: Liviu Dudau 
> Signed-off-by: Maarten Lankhorst 

Acked-by: Liviu Dudau 

> ---
>  drivers/gpu/drm/arm/hdlcd_drv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index 3ac1ae4d8caf..734899c4e4bb 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -113,7 +113,7 @@ static void hdlcd_fb_output_poll_changed(struct 
> drm_device *drm)
>  }
>  
>  static int hdlcd_atomic_commit(struct drm_device *dev,
> -struct drm_atomic_state *state, bool async)
> +struct drm_atomic_state *state, bool nonblock)
>  {
>   return drm_atomic_helper_commit(dev, state, false);
>  }
> -- 
> 2.5.5
> 
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 

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


[RFC v2 1/8] dma-buf/fence: add fence_collection fences

2016-04-26 Thread Chris Wilson
On Mon, Apr 25, 2016 at 07:33:21PM -0300, Gustavo Padovan wrote:
> +static const char *fence_collection_get_timeline_name(struct fence *fence)
> +{
> + return "no context";

"unbound" to distinguish from fence contexts within a timeline?

> +static bool fence_collection_enable_signaling(struct fence *fence)
> +{
> + struct fence_collection *collection = to_fence_collection(fence);
> + int i;
> +
> + for (i = 0 ; i < collection->num_fences ; i++) {
> + if (fence_add_callback(collection->fences[i].fence,
> +&collection->fences[i].cb,
> +collection_check_cb_func)) {
> + atomic_dec(&collection->num_pending_fences);
> + return false;

Don't stop, we need to enable all the others!

> + }
> + }
> +
> + return !!atomic_read(&collection->num_pending_fences);

Redundant !!

> +}
> +
> +static bool fence_collection_signaled(struct fence *fence)
> +{
> + struct fence_collection *collection = to_fence_collection(fence);
> +
> + return (atomic_read(&collection->num_pending_fences) == 0);

Redundant ()

> +static signed long fence_collection_wait(struct fence *fence, bool intr,
> +  signed long timeout)
> +{

What advantage does this have over fence_default_wait? You enable
signaling on all, then wait sequentially. The code looks redundant and
could just use fence_default_wait instead.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


[Bug 117131] vga_switcheroo does not switch IGP -> DIS ( IGP == i915 , DIS == radeon )

2016-04-26 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=117131

--- Comment #18 from Jason Vas Dias  ---
I think FGLRX is evidently able to run my laptop's display in 
dual-driver mode whereby the Intel IGP card runs the LCD in some sort of
"slave" mode under the control of the fglrx Radeon 8970M controller module,
to display frames produced by the Radeon card.

It would be nice if Linux would either 
A) fully support this configuration 
OR
B) detect that this configuration is not supported and refuse
   to attempt to go into graphics mode at all on the radeon card.
  - this would include things like vga_switcheroo complaining 
/ returning an error when asked to switch without a MUX .

Linux is evidently not doing either yet .

I'm not convinced the intel driver can "go it alone" either in this
scenario -
see: https://bugs.freedesktop.org/show_bug.cgi?id=95078

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


[PATCH v13 0/2] staging/android: Sync ABI rework

2016-04-26 Thread Gustavo Padovan
From: Gustavo Padovan 

Hi Greg, 

This patchset clean up the Sync ABI and then improve in to a more optimized
version.  Also it is now less likely to need changes in the future. This is not
breaking any upstream user of the sync framework, as no driver wired support
for it, so far Android is the only user. A patch to AOSP will be provided to
fix it there.

We've made the changes in a way that userspace can figure out if the new
versions are present and if not fallback to the older ABI version. More
information on patch 2 description.

To accomplish that we had to create a u64_to_user_ptr() macro so
patch 1 adds that and also fixes some places in the kernel that
were using (void __user *)(uintptr_t) cast directly. It already has Acks
from maintainers of drm drivers it changes.

Patch 2 is the actual rework and has Ack from the people interested in it,
including Android folks.

Gustavo Padovan (2):
  kernel.h: add u64_to_user_ptr()
  staging/android: refactor SYNC IOCTLs

 drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 11 ++--
 drivers/gpu/drm/i915/i915_drv.h  |  5 --
 drivers/gpu/drm/i915/i915_gem.c  | 14 ++---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c   | 14 ++---
 drivers/gpu/drm/msm/msm_gem_submit.c | 11 ++--
 drivers/staging/android/sync.c   | 76 +++-
 drivers/staging/android/uapi/sync.h  | 36 +
 include/linux/kernel.h   |  7 +++
 8 files changed, 94 insertions(+), 80 deletions(-)

-- 
2.5.5



[PATCH v13 1/2] kernel.h: add u64_to_user_ptr()

2016-04-26 Thread Gustavo Padovan
From: Gustavo Padovan 

This function had copies in 3 different files. Unify them in kernel.h.

Cc: Joe Perches 
Cc: Andrew Morton 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Rob Clark 
Signed-off-by: Gustavo Padovan 
Acked-by: Daniel Vetter [drm/i915/]
Acked-by: Rob Clark [drm/msm/]
Acked-by: Lucas Stach[drm/etinav/]
Acked-by: Maarten Lankhorst 

---
v2: add typecheck() (comment from Maarten Lankhorst)

v3: make u64_to_user_ptr() a macro (comment from Joe Perches)

v4: collect all Acked-bys
---
 drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 11 +++
 drivers/gpu/drm/i915/i915_drv.h  |  5 -
 drivers/gpu/drm/i915/i915_gem.c  | 14 +++---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c   | 14 +++---
 drivers/gpu/drm/msm/msm_gem_submit.c | 11 +++
 include/linux/kernel.h   |  7 +++
 6 files changed, 27 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c 
b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
index 236ada9..afdd55d 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
@@ -28,11 +28,6 @@
 #define BO_LOCKED   0x4000
 #define BO_PINNED   0x2000

-static inline void __user *to_user_ptr(u64 address)
-{
-   return (void __user *)(uintptr_t)address;
-}
-
 static struct etnaviv_gem_submit *submit_create(struct drm_device *dev,
struct etnaviv_gpu *gpu, size_t nr)
 {
@@ -347,21 +342,21 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void 
*data,
cmdbuf->exec_state = args->exec_state;
cmdbuf->ctx = file->driver_priv;

-   ret = copy_from_user(bos, to_user_ptr(args->bos),
+   ret = copy_from_user(bos, u64_to_user_ptr(args->bos),
 args->nr_bos * sizeof(*bos));
if (ret) {
ret = -EFAULT;
goto err_submit_cmds;
}

-   ret = copy_from_user(relocs, to_user_ptr(args->relocs),
+   ret = copy_from_user(relocs, u64_to_user_ptr(args->relocs),
 args->nr_relocs * sizeof(*relocs));
if (ret) {
ret = -EFAULT;
goto err_submit_cmds;
}

-   ret = copy_from_user(stream, to_user_ptr(args->stream),
+   ret = copy_from_user(stream, u64_to_user_ptr(args->stream),
 args->stream_size);
if (ret) {
ret = -EFAULT;
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 1048093..bb624cc 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3576,11 +3576,6 @@ static inline i915_reg_t i915_vgacntrl_reg(struct 
drm_device *dev)
return VGACNTRL;
 }

-static inline void __user *to_user_ptr(u64 address)
-{
-   return (void __user *)(uintptr_t)address;
-}
-
 static inline unsigned long msecs_to_jiffies_timeout(const unsigned int m)
 {
unsigned long j = msecs_to_jiffies(m);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index dabc089..2889716 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -324,7 +324,7 @@ i915_gem_phys_pwrite(struct drm_i915_gem_object *obj,
 {
struct drm_device *dev = obj->base.dev;
void *vaddr = obj->phys_handle->vaddr + args->offset;
-   char __user *user_data = to_user_ptr(args->data_ptr);
+   char __user *user_data = u64_to_user_ptr(args->data_ptr);
int ret = 0;

/* We manually control the domain here and pretend that it
@@ -605,7 +605,7 @@ i915_gem_shmem_pread(struct drm_device *dev,
int needs_clflush = 0;
struct sg_page_iter sg_iter;

-   user_data = to_user_ptr(args->data_ptr);
+   user_data = u64_to_user_ptr(args->data_ptr);
remain = args->size;

obj_do_bit17_swizzling = i915_gem_object_needs_bit17_swizzle(obj);
@@ -692,7 +692,7 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data,
return 0;

if (!access_ok(VERIFY_WRITE,
-  to_user_ptr(args->data_ptr),
+  u64_to_user_ptr(args->data_ptr),
   args->size))
return -EFAULT;

@@ -783,7 +783,7 @@ i915_gem_gtt_pwrite_fast(struct drm_device *dev,
if (ret)
goto out_unpin;

-   user_data = to_user_ptr(args->data_ptr);
+   user_data = u64_to_user_ptr(args->data_ptr);
remain = args->size;

offset = i915_gem_obj_ggtt_offset(obj) + args->offset;
@@ -907,7 +907,7 @@ i915_gem_shmem_pwrite(struct drm_device *dev,
int needs_clflush_before = 0;
struct sg_page_iter sg_iter;

-   user_data = to_user_ptr(args->data_ptr);
+   user_data = u64_to_user_ptr(args->data_ptr);
remain = args->size;

obj_do_bit17_swizzling = i915_gem_object_needs_bit17_swizzle(obj);
@@ -1036,12 +1036,12 @@ i915_gem_pwrite_ioctl

[PATCH v13 2/2] staging/android: refactor SYNC IOCTLs

2016-04-26 Thread Gustavo Padovan
From: Gustavo Padovan 

Change SYNC_IOC_FILE_INFO (former SYNC_IOC_FENCE_INFO) behaviour to avoid
future API breaks and optimize buffer allocation.

Now num_fences can be filled by the caller to inform how many fences it
wants to retrieve from the kernel. If the num_fences passed is greater
than zero info->sync_fence_info should point to a buffer with enough space
to fit all fences.

However if num_fences passed to the kernel is 0, the kernel will reply
with number of fences of the sync_file.

Sending first an ioctl with num_fences = 0 can optimize buffer allocation,
in a first call with num_fences = 0 userspace will receive the actual
number of fences in the num_fences filed.

Then it can allocate a buffer with the correct size on sync_fence_info and
call SYNC_IOC_FILE_INFO again, but now with the actual value of num_fences
in the sync_file.

info->sync_fence_info was converted to __u64 pointer to prevent 32bit
compatibility issues. And a flags member was added.

An example userspace code for the later would be:

struct sync_file_info *info;
int err, size, num_fences;

info = malloc(sizeof(*info));

info.flags = 0;
err = ioctl(fd, SYNC_IOC_FILE_INFO, info);
num_fences = info->num_fences;

if (num_fences) {
info.flags = 0;
size = sizeof(struct sync_fence_info) * num_fences;
info->num_fences = num_fences;
info->sync_fence_info = (uint64_t) calloc(num_fences,
  sizeof(struct 
sync_fence_info));

err = ioctl(fd, SYNC_IOC_FILE_INFO, info);
}

Finally the IOCTLs numbers were changed to avoid any potential old
userspace running the old API to get weird errors. Changing the opcodes
will make them fail right away. This is just a precaution, there no
upstream users of these interfaces yet and the only user is Android, but
we don't expect anyone trying to run android userspace and all it
dependencies on top of upstream kernels.

Signed-off-by: Gustavo Padovan 
Reviewed-by: Maarten Lankhorst 
Acked-by: Greg Hackmann 
Acked-by: Rob Clark 
Acked-by: Daniel Vetter 

---
v2: fix fence_info memory leak

v3: Comments from Emil Velikov
- improve commit message
- remove __u64 cast
- remove check for output fields in file_info
- clean up sync_fill_fence_info()

Comments from Maarten Lankhorst
- remove in.num_fences && !in.sync_fence_info check
- remove info->len and use only num_fences to calculate size

Comments from Dan Carpenter
- fix info->sync_fence_info documentation

v4: remove allocated struct sync_file_info (comment from Maarten)

v5: merge all commits that were changing the ABI

v6: fix -Wint-to-pointer-cast error on info.sync_fence_info
---
 drivers/staging/android/sync.c  | 76 -
 drivers/staging/android/uapi/sync.h | 36 +-
 2 files changed, 67 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index 3a8f210..f9c6094 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -445,6 +445,11 @@ static long sync_file_ioctl_merge(struct sync_file 
*sync_file,
goto err_put_fd;
}

+   if (data.flags || data.pad) {
+   err = -EINVAL;
+   goto err_put_fd;
+   }
+
fence2 = sync_file_fdget(data.fd2);
if (!fence2) {
err = -ENOENT;
@@ -479,13 +484,9 @@ err_put_fd:
return err;
 }

-static int sync_fill_fence_info(struct fence *fence, void *data, int size)
+static void sync_fill_fence_info(struct fence *fence,
+   struct sync_fence_info *info)
 {
-   struct sync_fence_info *info = data;
-
-   if (size < sizeof(*info))
-   return -ENOMEM;
-
strlcpy(info->obj_name, fence->ops->get_timeline_name(fence),
sizeof(info->obj_name));
strlcpy(info->driver_name, fence->ops->get_driver_name(fence),
@@ -495,58 +496,63 @@ static int sync_fill_fence_info(struct fence *fence, void 
*data, int size)
else
info->status = 0;
info->timestamp_ns = ktime_to_ns(fence->timestamp);
-
-   return sizeof(*info);
 }

 static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
unsigned long arg)
 {
-   struct sync_file_info *info;
+   struct sync_file_info info;
+   struct sync_fence_info *fence_info = NULL;
__u32 size;
-   __u32 len = 0;
int ret, i;

-   if (copy_from_user(&size, (void __user *)arg, sizeof(size)))
+   if (copy_from_user(&info, (void __user *)arg, sizeof(info)))
return -EFAULT;

-   if (size < sizeof(struct sync_file_info))
+   if (info.flags || info.pad)
return -EINVAL;

-   if (size > 4096)
-   

[Bug 117131] vga_switcheroo does not switch IGP -> DIS ( IGP == i915 , DIS == radeon )

2016-04-26 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=117131

--- Comment #19 from Jason Vas Dias  ---
Oops, the link should have been:
 https://bugs.freedesktop.org/show_bug.cgi?id=95140
but as it turns out, that other bug could be equally relevant.

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


[PATCH v2 4/8] drm/fb-helper: Add fb_deferred_io support

2016-04-26 Thread Noralf Trønnes

Den 25.04.2016 11:09, skrev Daniel Vetter:
> On Sun, Apr 24, 2016 at 10:48:58PM +0200, Noralf Trønnes wrote:
>> This adds deferred io support if CONFIG_FB_DEFERRED_IO is enabled.
>> The fbdev framebuffer changes are flushed using the callback
>> (struct drm_framebuffer *)->funcs->dirty() by a dedicated worker
>> ensuring that it always runs in process context.
>>
>> Signed-off-by: Noralf Trønnes 
>> ---
>>
>> Changes since v1:
>> - Use a dedicated worker to run the framebuffer flushing like qxl does
>> - Add parameter descriptions to drm_fb_helper_deferred_io
>>
>>   drivers/gpu/drm/drm_fb_helper.c | 127 
>> +++-
>>   include/drm/drm_fb_helper.h |  17 ++
>>   2 files changed, 143 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/drm_fb_helper.c 
>> b/drivers/gpu/drm/drm_fb_helper.c
>> index 855108e..46ee6f8 100644
>> --- a/drivers/gpu/drm/drm_fb_helper.c
>> +++ b/drivers/gpu/drm/drm_fb_helper.c
>> @@ -40,6 +40,7 @@
>>   #include 
>>   #include 
>>   #include 
>> +#include 
>>
>>   static bool drm_fbdev_emulation = true;
>>   module_param_named(fbdev_emulation, drm_fbdev_emulation, bool, 0600);
>> @@ -48,6 +49,10 @@ MODULE_PARM_DESC(fbdev_emulation,
>>
>>   static LIST_HEAD(kernel_fb_helper_list);
>>
>> +static void drm_fb_helper_dirty_init(struct drm_fb_helper *helper);
>> +static void drm_fb_helper_dirty(struct fb_info *info, u32 x, u32 y,
>> +u32 width, u32 height);
>> +
>>   /**
>>* DOC: fbdev helpers
>>*
>> @@ -84,6 +89,16 @@ static LIST_HEAD(kernel_fb_helper_list);
>>* and set up an initial configuration using the detected hardware, drivers
>>* should call drm_fb_helper_single_add_all_connectors() followed by
>>* drm_fb_helper_initial_config().
>> + *
>> + * If CONFIG_FB_DEFERRED_IO is enabled and
>> + * (struct drm_framebuffer *)->funcs->dirty is set, the
>> + * drm_fb_helper_{cfb,sys}_{write,fillrect,copyarea,imageblit} functions
>> + * will accumulate changes and schedule (struct fb_helper).dirty_work to run
>> + * right away. This worker then calls the dirty() function ensuring that it
>> + * will always run in process context since the fb_*() function could be
>> + * running in atomic context. If drm_fb_helper_deferred_io() is used as the
>> + * deferred_io callback it will also schedule dirty_work with the damage
>> + * collected from the mmap page writes.
> One thing to consider (and personally I don't care either way) is whether
> we shouldn't just select CONFIG_FB_DEFERRED_IO if the fbdev helpers are
> enabled. Pushing that out to drivers is imo a bit fragile.
>
> But like I said I'm ok with either way.

My concern was adding code and data that only a few drivers would
actually use. But of course there's the tradeoff with complexity.
I use this to enable it:
 select FB_DEFERRED_IO if DRM_KMS_FB_HELPER

I guess the maintainer has to make this choice between size and 
complexity :-)
I can enable it by default if you want, drm is both huge and complex so I
don't know what's best.

As a sidenote, I have also put all the fbdev code in a file of it's own to
make it simple with regards to the DRM_FBDEV_EMULATION user option:
tinydrm-$(CONFIG_DRM_KMS_FB_HELPER) += tinydrm-fbdev.o

>>*/
>>
>>   /**
>> @@ -401,11 +416,14 @@ backoff:
>>   static int restore_fbdev_mode(struct drm_fb_helper *fb_helper)
>>   {
>>  struct drm_device *dev = fb_helper->dev;
>> +struct fb_info *info = fb_helper->fbdev;
>>  struct drm_plane *plane;
>>  int i;
>>
>>  drm_warn_on_modeset_not_all_locked(dev);
>>
>> +drm_fb_helper_dirty(info, 0, 0, info->var.xres, info->var.yres);
> Why is this needed? If you do a modeset (or pageflip or whatever) drivers
> are supposed to re-upload the entire screen. We've talked about adding a
> dirty rectangle to atomic to allow userspace to optimize this, but there
> should _never_ be a need to do a dirtyfb call around a modeset. Probably
> just a driver bug in your panel drm drivers?

Ok, in tinydrm I now set a flag in &drm_simple_display_pipe_funcs
->plane_update to indicate that the next dirty() should do the whole
framebuffer which seems to work fine.
Should I actually perform the update as well?
If so I would need to add a worker in tinydrm to do that.


Noralf.

> With the above line removed:
>
> Reviewed-by: Daniel Vetter 
>
>> +
>>  if (fb_helper->atomic)
>>  return restore_fbdev_mode_atomic(fb_helper);
>>
>> @@ -650,6 +668,7 @@ void drm_fb_helper_prepare(struct drm_device *dev, 
>> struct drm_fb_helper *helper,
>> const struct drm_fb_helper_funcs *funcs)
>>   {
>>  INIT_LIST_HEAD(&helper->kernel_fb_list);
>> +drm_fb_helper_dirty_init(helper);
>>  helper->funcs = funcs;
>>  helper->dev = dev;
>>   }
>> @@ -834,6 +853,93 @@ void drm_fb_helper_unlink_fbi(struct drm_fb_helper 
>> *fb_helper)
>>   }
>>   EXPORT_SYMBOL(drm_fb_helper_unlink_fbi);
>>
>> +#ifdef CONFIG_FB_DEFERRED_IO
>> +stati

[RFC v2 5/8] drm/fence: add in-fences support

2016-04-26 Thread Ville Syrjälä
On Tue, Apr 26, 2016 at 11:14:22AM -0300, Gustavo Padovan wrote:
> 2016-04-26 Ville Syrjälä :
> 
> > On Mon, Apr 25, 2016 at 07:33:25PM -0300, Gustavo Padovan wrote:
> > > From: Gustavo Padovan 
> > > 
> > > There is now a new property called FENCE_FD attached to every plane
> > > state that receives the sync_file fd from userspace via the atomic commit
> > > IOCTL.
> > 
> > I still don't like this property abuse. Also with atomic, all passed
> > fences must be waited upon before anything is done, so attaching them
> > to planes seems like it might just give people the wrong idea.
> 
> I'm actually fine with this as property, but another solutions is use
> an array of {plane, fence_fd} and extend drm_atomic_ioctl args just like
> we have done for out fences.

Why do you want to associate these with planes?

> However the FENCE_FD property is easier to
> handle in userspace than the array. Any other idea?
> 
>   Gustavo

-- 
Ville Syrjälä
Intel OTC


[RFC v2 5/8] drm/fence: add in-fences support

2016-04-26 Thread Ville Syrjälä
On Tue, Apr 26, 2016 at 04:36:36PM +0200, Daniel Vetter wrote:
> On Tue, Apr 26, 2016 at 11:14:22AM -0300, Gustavo Padovan wrote:
> > 2016-04-26 Ville Syrjälä :
> > 
> > > On Mon, Apr 25, 2016 at 07:33:25PM -0300, Gustavo Padovan wrote:
> > > > From: Gustavo Padovan 
> > > > 
> > > > There is now a new property called FENCE_FD attached to every plane
> > > > state that receives the sync_file fd from userspace via the atomic 
> > > > commit
> > > > IOCTL.
> > > 
> > > I still don't like this property abuse. Also with atomic, all passed
> > > fences must be waited upon before anything is done, so attaching them
> > > to planes seems like it might just give people the wrong idea.
> > 
> > I'm actually fine with this as property, but another solutions is use
> > an array of {plane, fence_fd} and extend drm_atomic_ioctl args just like
> > we have done for out fences. However the FENCE_FD property is easier to
> > handle in userspace than the array. Any other idea?
> 
> Imo FENCE_FD is perfectly fine. But what's the concern around giving
> people the wrong idea with attaching fences to planes? For nonblocking
> commits we need to store them somewhere for the worker, drm_plane_state
> seems like an as good place as any other.

It gives the impression that each plane might flip as soon as its fence
signals.

-- 
Ville Syrjälä
Intel OTC


[PATCH v2 1/8] drm/rect: Add some drm_clip_rect utility functions

2016-04-26 Thread Noralf Trønnes

Den 25.04.2016 23:13, skrev Laurent Pinchart:
> Hi Noralf,
>
> On Monday 25 Apr 2016 20:35:18 Noralf Trønnes wrote:
>> Den 25.04.2016 18:38, skrev Ville Syrjälä:
>>> On Mon, Apr 25, 2016 at 06:05:20PM +0200, Daniel Vetter wrote:
 On Mon, Apr 25, 2016 at 06:09:44PM +0300, Ville Syrjälä wrote:
> On Mon, Apr 25, 2016 at 04:03:13PM +0200, Noralf Trønnes wrote:
>> Den 25.04.2016 15:02, skrev Ville Syrjälä:
>>> On Mon, Apr 25, 2016 at 02:55:52PM +0200, Noralf Trønnes wrote:
 Den 25.04.2016 14:39, skrev Ville Syrjälä:
> On Sun, Apr 24, 2016 at 10:48:55PM +0200, Noralf Trønnes wrote:
>> Add some utility functions for struct drm_clip_rect.

[...]

>> How about we just drop this patch?
>> I couldn't find anyone else that merge these clips, they just loop and
>> handle them individually.
>>
>> The relevant part in drm_fb_helper would become:
>>
>> static void drm_fb_helper_dirty_work(struct work_struct *work)
>> {
>>   struct drm_fb_helper *helper = container_of(work, struct drm_fb_helper,
>> dirty_work);
>>   struct drm_clip_rect *clip = &helper->dirty_clip;
>>   struct drm_clip_rect clip_copy;
>>   unsigned long flags;
>>
>>   spin_lock_irqsave(&helper->dirty_lock, flags);
>>   clip_copy = *clip;
>>   clip->x1 = clip->y1 = ~0;
>>   clip->x2 = clip->y2 = 0;
>>   spin_unlock_irqrestore(&helper->dirty_lock, flags);
>>
>>   helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, &clip_copy, 1);
>> }
>>
>> static void drm_fb_helper_dirty_init(struct drm_fb_helper *helper)
>> {
>>   spin_lock_init(&helper->dirty_lock);
>>   INIT_WORK(&helper->dirty_work, drm_fb_helper_dirty_work);
>>   helper->dirty_clip.x1 = helper->dirty_clip.y1 = ~0;
>> }
>>
>> static void drm_fb_helper_dirty(struct fb_info *info, u32 x, u32 y,
>>   u32 width, u32 height)
>> {
>>   struct drm_fb_helper *helper = info->par;
>>   struct drm_clip_rect *clip = &helper->dirty_clip;
>>   unsigned long flags;
>>
>>   if (!helper->fb->funcs->dirty)
>>   return;
>>
>>   spin_lock_irqsave(&helper->dirty_lock, flags);
>>   clip->x1 = min(clip->x1, x);
>>   clip->y1 = min(clip->y1, y);
>>   clip->x2 = max(clip->x2, x + width);
>>   clip->y2 = max(clip->y2, y + height);
>>   spin_unlock_irqrestore(&helper->dirty_lock, flags);
>>
>>   schedule_work(&helper->dirty_work);
>> }
>>
>>
>> And the driver would use this tinydrm function:
>>
>> void tinydrm_merge_clips(struct drm_clip_rect *dst,
>>struct drm_clip_rect *src, unsigned num_clips,
>>unsigned flags, u32 width, u32 height)
>> {
>>   int i;
> Nitpicking here, as i never takes negative values, could you make it an
> unsigned int ?

Sure.

>>   if (!src || !num_clips) {
>>   dst->x1 = 0;
>>   dst->x2 = width;
>>   dst->y1 = 0;
>>   dst->y2 = height;
>>   return;
>>   }
>>
>>   dst->x1 = dst->y1 = ~0;
>>   dst->x2 = dst->y2 = 0;
>>
>>   for (i = 0; i < num_clips; i++) {
>>   if (flags & DRM_MODE_FB_DIRTY_ANNOTATE_COPY)
>>   i++;
>>   dst->x1 = min(dst->x1, src[i].x1);
>>   dst->x2 = max(dst->x2, src[i].x2);
>>   dst->y1 = min(dst->y1, src[i].y1);
>>   dst->y2 = max(dst->y2, src[i].y2);
>>   }
>>
>>   if (dst->x2 > width || dst->y2 > height ||
>>   dst->x1 >= dst->x2 || dst->y1 >= dst->y2) {
>>   DRM_DEBUG_KMS("Illegal clip: x1=%u, x2=%u, y1=%u, y2=%u\n",
>> dst->x1, dst->x2, dst->y1, dst->y2);
>>   dst->x1 = dst->y1 = 0;
>>   dst->x2 = width;
>>   dst->y2 = height;
>>   }
>> }
>>
>> static int mipi_dbi_dirtyfb(struct drm_framebuffer *fb, void *vmem,
>>   unsigned flags, unsigned color,
>>   struct drm_clip_rect *clips, unsigned num_clips)
>> {
>>   struct drm_clip_rect clip;
>>
>>   tinydrm_merge_clips(&clip, clips, num_clips, flags,
>>   fb->width, fb->height);



[RFC v2 7/8] drm/fence: add fence timeline to drm_crtc

2016-04-26 Thread Ville Syrjälä
On Tue, Apr 26, 2016 at 11:23:06AM -0300, Gustavo Padovan wrote:
> 2016-04-26 Ville Syrjälä :
> 
> > On Mon, Apr 25, 2016 at 07:33:27PM -0300, Gustavo Padovan wrote:
> > > From: Gustavo Padovan 
> > > 
> > > Create one timeline context for each CRTC to be able to handle out-fences
> > > and signal them. It adds a few members to struct drm_crtc: fence_context,
> > > where we store the context we get from fence_context_alloc(), the
> > > fence seqno and the fence lock, that we pass in fence_init() to be
> > > used by the fence.
> > > 
> > > Signed-off-by: Gustavo Padovan 
> > > ---
> > >  drivers/gpu/drm/drm_crtc.c | 29 +
> > >  include/drm/drm_crtc.h | 19 +++
> > >  2 files changed, 48 insertions(+)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> > > index 65212ce..cf9750a 100644
> > > --- a/drivers/gpu/drm/drm_crtc.c
> > > +++ b/drivers/gpu/drm/drm_crtc.c
> > > @@ -659,6 +659,32 @@ static unsigned int drm_num_crtcs(struct drm_device 
> > > *dev)
> > >   return num;
> > >  }
> > >  
> > > +static const char *drm_crtc_fence_get_driver_name(struct fence *fence)
> > > +{
> > > + struct drm_crtc *crtc = fence_to_crtc(fence);
> > > +
> > > + return crtc->dev->driver->name;
> > > +}
> > > +
> > > +static const char *drm_crtc_fence_get_timeline_name(struct fence *fence)
> > > +{
> > > + struct drm_crtc *crtc = fence_to_crtc(fence);
> > > +
> > > + return crtc->name;
> > > +}
> > 
> > Is that exported to userspace? crtc->name is an internal thing, not
> > meant for outside consumption.
> 
> No. However it may be exported via debugfs at some point. Maybe have
> drm_crtc->timeline_name which has the obj_id instead, eg., "drm_crtc19" ?

I'm fine either way if it's an internal thing. So pick whichever makes
people's life easier I guess.

-- 
Ville Syrjälä
Intel OTC


[Bug 117131] vga_switcheroo does not switch IGP -> DIS ( IGP == i915 , DIS == radeon )

2016-04-26 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=117131

--- Comment #20 from Jason Vas Dias  ---
When I look at linux 4.5.0 boot dmesg log messages like :

[3.115380] vga_switcheroo: enabled
[3.115463] ATPX version 1, functions 0x0033
[3.115541] [drm] DMAR active, disabling use of stolen memory


I think 'you lie, Linux' !

vga_switcheroo can never be enabled on this platform because 
it has no MUX , and the logs above show the quality of the 
ACPI ATPX support.

I think this is the core linux relevant issue here - plus, I think it
should in the case where only one card has control of the actual
laptop display:

[3.115580] device: 'i2c-8': device_add
[3.115587] bus: 'i2c': add device i2c-8
[3.115598] PM: Adding info for i2c:i2c-8
[3.115607] i2c i2c-8: adapter [i915 gmbus ssc] registered
[3.115706] device: 'i2c-9': device_add
[3.115710] bus: 'i2c': add device i2c-9
[3.115720] PM: Adding info for i2c:i2c-9
[3.115724] i2c i2c-9: adapter [i915 gmbus vga] registered
[3.115730] device: 'i2c-10': device_add
[3.115734] bus: 'i2c': add device i2c-10
[3.115742] PM: Adding info for i2c:i2c-10
[3.115746] i2c i2c-10: adapter [i915 gmbus panel] registered
[3.115751] device: 'i2c-11': device_add
[3.115755] bus: 'i2c': add device i2c-11
[3.115762] PM: Adding info for i2c:i2c-11
[3.115767] i2c i2c-11: adapter [i915 gmbus dpc] registered
[3.115772] device: 'i2c-12': device_add
[3.115776] bus: 'i2c': add device i2c-12
[3.115784] PM: Adding info for i2c:i2c-12
[3.115787] i2c i2c-12: adapter [i915 gmbus dpb] registered
[3.115792] device: 'i2c-13': device_add
[3.115796] bus: 'i2c': add device i2c-13
[3.115804] PM: Adding info for i2c:i2c-13
[3.115807] i2c i2c-13: adapter [i915 gmbus dpd] registered
[3.115843] vgaarb: device changed decodes:
PCI::01:00.0,olddecodes=io+mem,decodes=none:owns=none
[3.115848] vgaarb: device changed decodes:
PCI::00:02.0,olddecodes=io+mem,decodes=none:owns=io+mem
[3.116170] device: 'card1-VGA-1': device_add
[3.116188] PM: Adding info for No Bus:card1-VGA-1
[3.116212] device: 'card1-eDP-1': device_add
[3.116231] PM: Adding info for No Bus:card1-eDP-1
[3.116251] device: 'i2c-14': device_add
[3.116257] bus: 'i2c': add device i2c-14
[3.116265] PM: Adding info for i2c:i2c-14
[3.116269] i2c i2c-14: adapter [DPDDC-A] registered
[3.116961] i2c i2c-14: master_xfer[0] W, addr=0x50, len=1
[3.116962] i2c i2c-14: master_xfer[1] R, addr=0x50, len=1
[3.118007] i2c i2c-14: master_xfer[0] W, addr=0x50, len=1
[3.118009] i2c i2c-14: master_xfer[1] R, addr=0x50, len=128
[3.137993] device: 'card1-DP-1': device_add
[3.138011] PM: Adding info for No Bus:card1-DP-1
[3.138023] device: 'i2c-15': device_add
[3.138028] bus: 'i2c': add device i2c-15
[3.138037] PM: Adding info for i2c:i2c-15
[3.138042] i2c i2c-15: adapter [DPDDC-B] registered
[3.138062] device: 'card1-HDMI-A-1': device_add
[3.138076] PM: Adding info for No Bus:card1-HDMI-A-1
[3.138091] device: 'card1-HDMI-A-2': device_add
[3.138104] PM: Adding info for No Bus:card1-HDMI-A-2
[3.138124] device: 'card1-DP-2': device_add
[3.138142] PM: Adding info for No Bus:card1-DP-2
[3.138154] device: 'i2c-16': device_add
[3.138162] bus: 'i2c': add device i2c-16
[3.138171] PM: Adding info for i2c:i2c-16
[3.138176] i2c i2c-16: adapter [DPDDC-D] registered
[3.138203] device: 'card1-HDMI-A-3': device_add
[3.138216] PM: Adding info for No Bus:card1-HDMI-A-3
[3.161200] device: 'intel_backlight': device_add
[3.161224] PM: Adding info for No Bus:intel_backlight
[3.161286] bus: 'acpi': add driver video
[3.161319] bus: 'acpi': driver_probe_device: matched device LNXVIDEO:00
with driver video
[3.161322] bus: 'acpi': really_probe: probing driver video with device
LNXVIDEO:00
[3.161327] video LNXVIDEO:00: no default pinctrl state
[3.161333] devices_kset: Moving LNXVIDEO:00 to end of list
[3.161349] [Firmware Bug]: ACPI(PEGP) defines _DOD but not _DOS
[3.161394] ACPI: Video Device [PEGP] (multi-head: yes  rom: no  post: no)
[3.161559] device: 'input4': device_add
[3.161597] PM: Adding info for No Bus:input4
[3.161615] input: Video Bus as
/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:4d/LNXVIDEO:00/input/input4
[3.161625] driver: 'video': driver_bound: bound to device 'LNXVIDEO:00'
[3.161627] bus: 'acpi': really_probe: bound device LNXVIDEO:00 to driver
video
[3.161631] bus: 'acpi': driver_probe_device: matched device LNXVIDEO:01
with driver video
[3.161633] bus: 'acpi': really_probe: probing driver video with device
LNXVIDEO:01
[3.161636] video LNXVIDEO:01: no default pinctrl state
[3.161640] devices_kset: Moving LNXVIDEO:01 to end of list
[3.161710] ACPI: Video Device [GFX0] (multi-head: yes  rom: no  post: no)
[3.161923] device: 'input5': device_add
[3.161959] PM: 

[PATCH v2 4/8] drm/fb-helper: Add fb_deferred_io support

2016-04-26 Thread Daniel Vetter
On Tue, Apr 26, 2016 at 06:24:54PM +0200, Noralf Trønnes wrote:
> 
> Den 25.04.2016 11:09, skrev Daniel Vetter:
> >On Sun, Apr 24, 2016 at 10:48:58PM +0200, Noralf Trønnes wrote:
> >>This adds deferred io support if CONFIG_FB_DEFERRED_IO is enabled.
> >>The fbdev framebuffer changes are flushed using the callback
> >>(struct drm_framebuffer *)->funcs->dirty() by a dedicated worker
> >>ensuring that it always runs in process context.
> >>
> >>Signed-off-by: Noralf Trønnes 
> >>---
> >>
> >>Changes since v1:
> >>- Use a dedicated worker to run the framebuffer flushing like qxl does
> >>- Add parameter descriptions to drm_fb_helper_deferred_io
> >>
> >>  drivers/gpu/drm/drm_fb_helper.c | 127 
> >> +++-
> >>  include/drm/drm_fb_helper.h |  17 ++
> >>  2 files changed, 143 insertions(+), 1 deletion(-)
> >>
> >>diff --git a/drivers/gpu/drm/drm_fb_helper.c 
> >>b/drivers/gpu/drm/drm_fb_helper.c
> >>index 855108e..46ee6f8 100644
> >>--- a/drivers/gpu/drm/drm_fb_helper.c
> >>+++ b/drivers/gpu/drm/drm_fb_helper.c
> >>@@ -40,6 +40,7 @@
> >>  #include 
> >>  #include 
> >>  #include 
> >>+#include 
> >>
> >>  static bool drm_fbdev_emulation = true;
> >>  module_param_named(fbdev_emulation, drm_fbdev_emulation, bool, 0600);
> >>@@ -48,6 +49,10 @@ MODULE_PARM_DESC(fbdev_emulation,
> >>
> >>  static LIST_HEAD(kernel_fb_helper_list);
> >>
> >>+static void drm_fb_helper_dirty_init(struct drm_fb_helper *helper);
> >>+static void drm_fb_helper_dirty(struct fb_info *info, u32 x, u32 y,
> >>+   u32 width, u32 height);
> >>+
> >>  /**
> >>   * DOC: fbdev helpers
> >>   *
> >>@@ -84,6 +89,16 @@ static LIST_HEAD(kernel_fb_helper_list);
> >>   * and set up an initial configuration using the detected hardware, 
> >> drivers
> >>   * should call drm_fb_helper_single_add_all_connectors() followed by
> >>   * drm_fb_helper_initial_config().
> >>+ *
> >>+ * If CONFIG_FB_DEFERRED_IO is enabled and
> >>+ * (struct drm_framebuffer *)->funcs->dirty is set, the
> >>+ * drm_fb_helper_{cfb,sys}_{write,fillrect,copyarea,imageblit} functions
> >>+ * will accumulate changes and schedule (struct fb_helper).dirty_work to 
> >>run
> >>+ * right away. This worker then calls the dirty() function ensuring that it
> >>+ * will always run in process context since the fb_*() function could be
> >>+ * running in atomic context. If drm_fb_helper_deferred_io() is used as the
> >>+ * deferred_io callback it will also schedule dirty_work with the damage
> >>+ * collected from the mmap page writes.
> >One thing to consider (and personally I don't care either way) is whether
> >we shouldn't just select CONFIG_FB_DEFERRED_IO if the fbdev helpers are
> >enabled. Pushing that out to drivers is imo a bit fragile.
> >
> >But like I said I'm ok with either way.
> 
> My concern was adding code and data that only a few drivers would
> actually use. But of course there's the tradeoff with complexity.
> I use this to enable it:
> select FB_DEFERRED_IO if DRM_KMS_FB_HELPER
> 
> I guess the maintainer has to make this choice between size and complexity
> :-)
> I can enable it by default if you want, drm is both huge and complex so I
> don't know what's best.
> 
> As a sidenote, I have also put all the fbdev code in a file of it's own to
> make it simple with regards to the DRM_FBDEV_EMULATION user option:
> tinydrm-$(CONFIG_DRM_KMS_FB_HELPER) += tinydrm-fbdev.o

Ok, if you ask maintainers then please nuke the #ifdef from .c files. If
you select CONFIG_DRM_KMS_FB_HELPER, then you get hdmi, edid, dp aux, dp
mst and whatever else helpers, even if you don't need them. Adding 3
functions for defio when you select fbdev helpers and maybe don't need
them is totally harmless. And removing the #ifdef will look so much better
;-)

> 
> >>   */
> >>
> >>  /**
> >>@@ -401,11 +416,14 @@ backoff:
> >>  static int restore_fbdev_mode(struct drm_fb_helper *fb_helper)
> >>  {
> >>struct drm_device *dev = fb_helper->dev;
> >>+   struct fb_info *info = fb_helper->fbdev;
> >>struct drm_plane *plane;
> >>int i;
> >>
> >>drm_warn_on_modeset_not_all_locked(dev);
> >>
> >>+   drm_fb_helper_dirty(info, 0, 0, info->var.xres, info->var.yres);
> >Why is this needed? If you do a modeset (or pageflip or whatever) drivers
> >are supposed to re-upload the entire screen. We've talked about adding a
> >dirty rectangle to atomic to allow userspace to optimize this, but there
> >should _never_ be a need to do a dirtyfb call around a modeset. Probably
> >just a driver bug in your panel drm drivers?
> 
> Ok, in tinydrm I now set a flag in &drm_simple_display_pipe_funcs
> ->plane_update to indicate that the next dirty() should do the whole
> framebuffer which seems to work fine.
> Should I actually perform the update as well?
> If so I would need to add a worker in tinydrm to do that.

Yes, plane update should always do a full update. Not sure how you get
away with delaying that to ->dirty, maybe modesetting isn't

[RFC v2 5/8] drm/fence: add in-fences support

2016-04-26 Thread Daniel Vetter
On Tue, Apr 26, 2016 at 07:26:21PM +0300, Ville Syrjälä wrote:
> On Tue, Apr 26, 2016 at 04:36:36PM +0200, Daniel Vetter wrote:
> > On Tue, Apr 26, 2016 at 11:14:22AM -0300, Gustavo Padovan wrote:
> > > 2016-04-26 Ville Syrjälä :
> > > 
> > > > On Mon, Apr 25, 2016 at 07:33:25PM -0300, Gustavo Padovan wrote:
> > > > > From: Gustavo Padovan 
> > > > > 
> > > > > There is now a new property called FENCE_FD attached to every plane
> > > > > state that receives the sync_file fd from userspace via the atomic 
> > > > > commit
> > > > > IOCTL.
> > > > 
> > > > I still don't like this property abuse. Also with atomic, all passed
> > > > fences must be waited upon before anything is done, so attaching them
> > > > to planes seems like it might just give people the wrong idea.
> > > 
> > > I'm actually fine with this as property, but another solutions is use
> > > an array of {plane, fence_fd} and extend drm_atomic_ioctl args just like
> > > we have done for out fences. However the FENCE_FD property is easier to
> > > handle in userspace than the array. Any other idea?
> > 
> > Imo FENCE_FD is perfectly fine. But what's the concern around giving
> > people the wrong idea with attaching fences to planes? For nonblocking
> > commits we need to store them somewhere for the worker, drm_plane_state
> > seems like an as good place as any other.
> 
> It gives the impression that each plane might flip as soon as its fence
> signals.

That wouldn't be atomic. Not sure how someone could come up with that
idea. I mean we could move FENCE_FD to the crtc (fence fds can be merged),
but that's just a needless difference to what hwc expects. I think
aligning with the only real-world users in this case here makes sense.

Plus docs in case someone has funny ideas.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH 00/35] Moar struct_mutex nuking

2016-04-26 Thread Daniel Vetter
Hi all,

First few patches are resends (reviews, pretty please), but most of this is all
new. After all this all the legacy code is guarded by DRIVER_* feature tests,
and struct_mutex is never even acquired for modern drivers (except nouveau,
because). And there's just 2 things left where struct_mutex actually matters for
modern drivers:

- master locking. I've handled the low-hanging fruit, the leftover paths touch
  the dreaded legacy-horros hw.lock. No idea how to get rid of that, but
  master_list and master status probably need to grow a separate lock.

- 4 drivers who use struct_mutex as their BKL: i915, omapdrm, msm & udl. Most of
  those will require serious amounts of work to fix, but for new drivers I'm
  postive we don't have to deal with struct_mutex ever again: Either pick ttm
  (if you're ok with midlayers), or implement the locking scheme from etnaviv
  (which is just plain gem with ww mutexes and fences).

23 drivers (most of those kms-only, using cma for gem) are now entirely
struct_mutex free!

Reviews, acks and comments highly welcome.

Cheers, Daniel

Benjamin Gaignard (1):
  drm: sti: remove useless call to dev->struct_mutex

Daniel Vetter (34):
  drm: Give drm_agp_clear drm_legacy_ prefix
  drm: Put legacy lastclose work into drm_legacy_dev_reinit
  drm: Move drm_getmap into drm_bufs.c and give it a legacy prefix
  drm: Forbid legacy MAP functions for DRIVER_MODESET
  drm: Push struct_mutex into ->master_destroy
  drm: Hide master MAP cleanup in drm_bufs.c
  drm: Make drm_vm_open/close_locked private to drm_vm.c
  drm: Protect dev->filelist with its own mutex
  drm/gem: support BO freeing without dev->struct_mutex
  drm/amdgpu: Use lockless gem BO free callback
  drm/armada: Use lockless gem BO free callback
  drm/ast: Use lockless gem BO free callback
  drm/atmel: Use lockless gem BO free callback
  drm/bochs: Use lockless gem BO free callback
  drm/cirrus: Use lockless gem BO free callback
  drm/etnaviv: Use lockless gem BO free callback
  drm/exynos: Use lockless gem BO free callback
  drm/fls-dcu: Use lockless gem BO free callback
  drm/imx: Use lockless gem BO free callback
  drm/mga200g: Use lockless gem BO free callback
  drm/nouveau: Use lockless gem BO free callback
  drm/qxl: Use lockless gem BO free callback
  drm/radeon: Use lockless gem BO free callback
  drm/rcar-du: Use lockless gem BO free callback
  drm/rockchip: Use lockless gem BO free callback
  drm/shmob: Use lockless gem BO free callback
  drm/tegra: Use lockless gem BO free callback
  drm/tilcdc: Use lockless gem BO free callback
  drm/vc4: Use drm_gem_object_unreference_unlocked
  drm/vc4: Use lockless gem BO free callback
  drm/vgem: Use lockless gem BO free callback
  drm/virtio: Use lockless gem BO free callback
  drm/virtio: Use lockless gem BO free callback
  drm/rockchip: Use cma gem vm ops

 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c  |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c  | 10 +--
 drivers/gpu/drm/armada/armada_drv.c  |  2 +-
 drivers/gpu/drm/ast/ast_drv.c|  2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c |  2 +-
 drivers/gpu/drm/bochs/bochs_drv.c|  2 +-
 drivers/gpu/drm/cirrus/cirrus_drv.c  |  2 +-
 drivers/gpu/drm/drm_agpsupport.c |  4 +-
 drivers/gpu/drm/drm_bufs.c   | 92 ++--
 drivers/gpu/drm/drm_drv.c| 11 +---
 drivers/gpu/drm/drm_fops.c   | 51 ---
 drivers/gpu/drm/drm_gem.c| 64 +++
 drivers/gpu/drm/drm_info.c   |  4 +-
 drivers/gpu/drm/drm_internal.h   |  4 +-
 drivers/gpu/drm/drm_ioctl.c  | 54 +---
 drivers/gpu/drm/drm_legacy.h |  2 +
 drivers/gpu/drm/drm_pci.c|  2 +-
 drivers/gpu/drm/drm_vm.c | 16 ++---
 drivers/gpu/drm/etnaviv/etnaviv_drv.c|  2 +-
 drivers/gpu/drm/exynos/exynos_drm_drv.c  |  2 +-
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c|  2 +-
 drivers/gpu/drm/i915/i915_debugfs.c  | 12 +++-
 drivers/gpu/drm/imx/imx-drm-core.c   |  2 +-
 drivers/gpu/drm/mgag200/mgag200_drv.c|  2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c|  2 +-
 drivers/gpu/drm/qxl/qxl_drv.c|  2 +-
 drivers/gpu/drm/radeon/radeon_drv.c  |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c|  2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c  |  9 +--
 drivers/gpu/drm/shmobile/shmob_drm_drv.c |  2 +-
 drivers/gpu/drm/sti/sti_cursor.c |  7 ---
 drivers/gpu/drm/sti/sti_drv.c|  8 +--
 drivers/gpu/drm/sti/sti_dvo.c|  7 ---
 drivers/gpu/drm/sti/sti_gdp.c| 14 -
 drivers/gpu/drm/sti/sti_hda.c|  7 ---
 drivers/gpu/drm/sti/sti_hdmi.c   |  7 ---
 drivers/gpu/drm/sti/sti_hqvdp.c  |  7 ---
 drivers/gpu/drm/sti/sti_mixer.c  |  7 ---
 drivers/gpu/dr

[PATCH 01/35] drm: Give drm_agp_clear drm_legacy_ prefix

2016-04-26 Thread Daniel Vetter
It has a  DRIVER_MODESET check to sure make it's not creating havoc
for drm drivers. Make that clear in the name too.

v2: Move misplaced hunk, spotted by 0day and Thierry.

Cc: Thierry Reding 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_agpsupport.c | 4 ++--
 drivers/gpu/drm/drm_fops.c   | 2 +-
 drivers/gpu/drm/drm_pci.c| 2 +-
 include/drm/drm_agpsupport.h | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
index a10ea6aec629..605bd243fb36 100644
--- a/drivers/gpu/drm/drm_agpsupport.c
+++ b/drivers/gpu/drm/drm_agpsupport.c
@@ -423,7 +423,7 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
 }

 /**
- * drm_agp_clear - Clear AGP resource list
+ * drm_legacy_agp_clear - Clear AGP resource list
  * @dev: DRM device
  *
  * Iterate over all AGP resources and remove them. But keep the AGP head
@@ -434,7 +434,7 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
  * resources from getting destroyed. Drivers are responsible of cleaning them 
up
  * during device shutdown.
  */
-void drm_agp_clear(struct drm_device *dev)
+void drm_legacy_agp_clear(struct drm_device *dev)
 {
struct drm_agp_mem *entry, *tempe;

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index aeef58ed359b..7b5a13cda7a6 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -413,7 +413,7 @@ int drm_lastclose(struct drm_device * dev)

mutex_lock(&dev->struct_mutex);

-   drm_agp_clear(dev);
+   drm_legacy_agp_clear(dev);

drm_legacy_sg_cleanup(dev);
drm_legacy_vma_flush(dev);
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index a1fff1179a97..29d5a548d07a 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -250,7 +250,7 @@ void drm_pci_agp_destroy(struct drm_device *dev)
 {
if (dev->agp) {
arch_phys_wc_del(dev->agp->agp_mtrr);
-   drm_agp_clear(dev);
+   drm_legacy_agp_clear(dev);
kfree(dev->agp);
dev->agp = NULL;
}
diff --git a/include/drm/drm_agpsupport.h b/include/drm/drm_agpsupport.h
index 193ef19dfc5c..b2d912670a7f 100644
--- a/include/drm/drm_agpsupport.h
+++ b/include/drm/drm_agpsupport.h
@@ -37,7 +37,7 @@ struct agp_memory *drm_agp_bind_pages(struct drm_device *dev,
uint32_t type);

 struct drm_agp_head *drm_agp_init(struct drm_device *dev);
-void drm_agp_clear(struct drm_device *dev);
+void drm_legacy_agp_clear(struct drm_device *dev);
 int drm_agp_acquire(struct drm_device *dev);
 int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
  struct drm_file *file_priv);
@@ -93,7 +93,7 @@ static inline struct drm_agp_head *drm_agp_init(struct 
drm_device *dev)
return NULL;
 }

-static inline void drm_agp_clear(struct drm_device *dev)
+static inline void drm_legacy_agp_clear(struct drm_device *dev)
 {
 }

-- 
2.8.1



[PATCH 02/35] drm: Put legacy lastclose work into drm_legacy_dev_reinit

2016-04-26 Thread Daniel Vetter
Except for the ->lasclose driver callback evrything in drm_lastclose()
is all legacy cruft and can be hidden. Which means another
dev->struct_mutex site disappears entirely for modern drivers!

Also while at it change the return value of drm_lastclose to void
since it will always succeed. No one checks the return value of
close() anyway, ever.

v2: Move misplaced hunk, spotted by 0day.

Cc: Thierry Reding 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_fops.c | 42 +++---
 drivers/gpu/drm/drm_internal.h |  2 +-
 2 files changed, 20 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 7b5a13cda7a6..c3d0aaac0669 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -381,14 +381,26 @@ static void drm_events_release(struct drm_file *file_priv)
  */
 static void drm_legacy_dev_reinit(struct drm_device *dev)
 {
-   if (drm_core_check_feature(dev, DRIVER_MODESET))
-   return;
+   if (dev->irq_enabled)
+   drm_irq_uninstall(dev);
+
+   mutex_lock(&dev->struct_mutex);
+
+   drm_legacy_agp_clear(dev);
+
+   drm_legacy_sg_cleanup(dev);
+   drm_legacy_vma_flush(dev);
+   drm_legacy_dma_takedown(dev);
+
+   mutex_unlock(&dev->struct_mutex);

dev->sigdata.lock = NULL;

dev->context_flag = 0;
dev->last_context = 0;
dev->if_version = 0;
+
+   DRM_DEBUG("lastclose completed\n");
 }

 /*
@@ -400,7 +412,7 @@ static void drm_legacy_dev_reinit(struct drm_device *dev)
  *
  * \sa drm_device
  */
-int drm_lastclose(struct drm_device * dev)
+void drm_lastclose(struct drm_device * dev)
 {
DRM_DEBUG("\n");

@@ -408,23 +420,8 @@ int drm_lastclose(struct drm_device * dev)
dev->driver->lastclose(dev);
DRM_DEBUG("driver lastclose completed\n");

-   if (dev->irq_enabled && !drm_core_check_feature(dev, DRIVER_MODESET))
-   drm_irq_uninstall(dev);
-
-   mutex_lock(&dev->struct_mutex);
-
-   drm_legacy_agp_clear(dev);
-
-   drm_legacy_sg_cleanup(dev);
-   drm_legacy_vma_flush(dev);
-   drm_legacy_dma_takedown(dev);
-
-   mutex_unlock(&dev->struct_mutex);
-
-   drm_legacy_dev_reinit(dev);
-
-   DRM_DEBUG("lastclose completed\n");
-   return 0;
+   if (!drm_core_check_feature(dev, DRIVER_MODESET))
+   drm_legacy_dev_reinit(dev);
 }

 /**
@@ -445,7 +442,6 @@ int drm_release(struct inode *inode, struct file *filp)
struct drm_file *file_priv = filp->private_data;
struct drm_minor *minor = file_priv->minor;
struct drm_device *dev = minor->dev;
-   int retcode = 0;

mutex_lock(&drm_global_mutex);

@@ -538,7 +534,7 @@ int drm_release(struct inode *inode, struct file *filp)
 */

if (!--dev->open_count) {
-   retcode = drm_lastclose(dev);
+   drm_lastclose(dev);
if (drm_device_is_unplugged(dev))
drm_put_dev(dev);
}
@@ -546,7 +542,7 @@ int drm_release(struct inode *inode, struct file *filp)

drm_minor_release(minor);

-   return retcode;
+   return 0;
 }
 EXPORT_SYMBOL(drm_release);

diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index 43cbda3306ac..c81ff4769e7b 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -26,7 +26,7 @@ extern unsigned int drm_timestamp_monotonic;

 /* drm_fops.c */
 extern struct mutex drm_global_mutex;
-int drm_lastclose(struct drm_device *dev);
+void drm_lastclose(struct drm_device *dev);

 /* drm_pci.c */
 int drm_pci_set_unique(struct drm_device *dev,
-- 
2.8.1



[PATCH 03/35] drm: Move drm_getmap into drm_bufs.c and give it a legacy prefix

2016-04-26 Thread Daniel Vetter
It belongs right next to the addmap and rmmap functions really. And
for OCD consistency name it drm_legacy_getmap_ioctl.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_bufs.c   | 52 ++
 drivers/gpu/drm/drm_ioctl.c  | 54 +---
 drivers/gpu/drm/drm_legacy.h |  2 ++
 3 files changed, 55 insertions(+), 53 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index f1a204d253cc..d92db7007f62 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -416,6 +416,58 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void 
*data,
return 0;
 }

+/*
+ * Get a mapping information.
+ *
+ * \param inode device inode.
+ * \param file_priv DRM file private.
+ * \param cmd command.
+ * \param arg user argument, pointing to a drm_map structure.
+ *
+ * \return zero on success or a negative number on failure.
+ *
+ * Searches for the mapping with the specified offset and copies its 
information
+ * into userspace
+ */
+int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
+   struct drm_file *file_priv)
+{
+   struct drm_map *map = data;
+   struct drm_map_list *r_list = NULL;
+   struct list_head *list;
+   int idx;
+   int i;
+
+   idx = map->offset;
+   if (idx < 0)
+   return -EINVAL;
+
+   i = 0;
+   mutex_lock(&dev->struct_mutex);
+   list_for_each(list, &dev->maplist) {
+   if (i == idx) {
+   r_list = list_entry(list, struct drm_map_list, head);
+   break;
+   }
+   i++;
+   }
+   if (!r_list || !r_list->map) {
+   mutex_unlock(&dev->struct_mutex);
+   return -EINVAL;
+   }
+
+   map->offset = r_list->map->offset;
+   map->size = r_list->map->size;
+   map->type = r_list->map->type;
+   map->flags = r_list->map->flags;
+   map->handle = (void *)(unsigned long) r_list->user_token;
+   map->mtrr = arch_phys_wc_index(r_list->map->mtrr);
+
+   mutex_unlock(&dev->struct_mutex);
+
+   return 0;
+}
+
 /**
  * Remove a map private from list and deallocate resources if the mapping
  * isn't in use.
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 3ecd1368c23a..24b941c3b561 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -148,58 +148,6 @@ static int drm_set_busid(struct drm_device *dev, struct 
drm_file *file_priv)
 }

 /*
- * Get a mapping information.
- *
- * \param inode device inode.
- * \param file_priv DRM file private.
- * \param cmd command.
- * \param arg user argument, pointing to a drm_map structure.
- *
- * \return zero on success or a negative number on failure.
- *
- * Searches for the mapping with the specified offset and copies its 
information
- * into userspace
- */
-static int drm_getmap(struct drm_device *dev, void *data,
-  struct drm_file *file_priv)
-{
-   struct drm_map *map = data;
-   struct drm_map_list *r_list = NULL;
-   struct list_head *list;
-   int idx;
-   int i;
-
-   idx = map->offset;
-   if (idx < 0)
-   return -EINVAL;
-
-   i = 0;
-   mutex_lock(&dev->struct_mutex);
-   list_for_each(list, &dev->maplist) {
-   if (i == idx) {
-   r_list = list_entry(list, struct drm_map_list, head);
-   break;
-   }
-   i++;
-   }
-   if (!r_list || !r_list->map) {
-   mutex_unlock(&dev->struct_mutex);
-   return -EINVAL;
-   }
-
-   map->offset = r_list->map->offset;
-   map->size = r_list->map->size;
-   map->type = r_list->map->type;
-   map->flags = r_list->map->flags;
-   map->handle = (void *)(unsigned long) r_list->user_token;
-   map->mtrr = arch_phys_wc_index(r_list->map->mtrr);
-
-   mutex_unlock(&dev->struct_mutex);
-
-   return 0;
-}
-
-/*
  * Get client information.
  *
  * \param inode device inode.
@@ -556,7 +504,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0),
DRM_IOCTL_DEF(DRM_IOCTL_GET_MAGIC, drm_getmagic, 0),
DRM_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_irq_by_busid, 
DRM_MASTER|DRM_ROOT_ONLY),
-   DRM_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_getmap, DRM_UNLOCKED),
+   DRM_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_legacy_getmap_ioctl, DRM_UNLOCKED),
DRM_IOCTL_DEF(DRM_IOCTL_GET_CLIENT, drm_getclient, DRM_UNLOCKED),
DRM_IOCTL_DEF(DRM_IOCTL_GET_STATS, drm_getstats, DRM_UNLOCKED),
DRM_IOCTL_DEF(DRM_IOCTL_GET_CAP, drm_getcap, 
DRM_UNLOCKED|DRM_RENDER_ALLOW),
diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
index 9b731786e4db..d3b6ee357a2b 100644
--- a/drivers/gpu/drm/drm_legacy.h
+++ b/drivers/gpu/drm/drm_legacy.h
@@ -63,6 +63,8 @@ int drm_le

[PATCH 04/35] drm: Forbid legacy MAP functions for DRIVER_MODESET

2016-04-26 Thread Daniel Vetter
Like in

commit 0e975980d435d58df2d430d688b8c18778b42218
Author: Peter Antoine 
Date:   Tue Jun 23 08:18:49 2015 +0100

drm: Turn off Legacy Context Functions

we need to again make an exception for nouveau, but everyone else
really doesn't need this.

Cc: Peter Antoine 
Cc: Ben Skeggs 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_bufs.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index d92db7007f62..e8a12a4fd400 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -396,6 +396,10 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void 
*data,
if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP || map->type == 
_DRM_SHM))
return -EPERM;

+   if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
+   drm_core_check_feature(dev, DRIVER_MODESET))
+   return -EINVAL;
+
err = drm_addmap_core(dev, map->offset, map->size, map->type,
  map->flags, &maplist);

@@ -438,6 +442,10 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void 
*data,
int idx;
int i;

+   if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
+   drm_core_check_feature(dev, DRIVER_MODESET))
+   return -EINVAL;
+
idx = map->offset;
if (idx < 0)
return -EINVAL;
@@ -569,6 +577,10 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void 
*data,
struct drm_map_list *r_list;
int ret;

+   if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
+   drm_core_check_feature(dev, DRIVER_MODESET))
+   return -EINVAL;
+
mutex_lock(&dev->struct_mutex);
list_for_each_entry(r_list, &dev->maplist, head) {
if (r_list->map &&
-- 
2.8.1



[PATCH 05/35] drm: Push struct_mutex into ->master_destroy

2016-04-26 Thread Daniel Vetter
Only two drivers implement this hook. vmwgfx (which doesn't need it
really) and legacy radeon (which since v1 has been nuked, yay).

v1: Rebase over radeon ums removal.

Cc: Thomas Hellstrom 
Cc: Alex Deucher 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index f8a7a6e66b7e..55273f8f3acb 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -123,10 +123,10 @@ static void drm_master_destroy(struct kref *kref)
struct drm_device *dev = master->minor->dev;
struct drm_map_list *r_list, *list_temp;

-   mutex_lock(&dev->struct_mutex);
if (dev->driver->master_destroy)
dev->driver->master_destroy(dev, master);

+   mutex_lock(&dev->struct_mutex);
list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) {
if (r_list->master == master) {
drm_legacy_rmmap_locked(dev, r_list->map);
-- 
2.8.1



[PATCH 06/35] drm: Hide master MAP cleanup in drm_bufs.c

2016-04-26 Thread Daniel Vetter
And again make sure it's a no-op for modern drivers, again with the
exception of nouveau. Another case of dev->struct_mutex gone for
modern drivers!

v2: Also add a DRIVER_* check like for all other maps functions to
really short-circuit the code. And give drm_legacy_rmmap used by the
dev unregister code the same treatment.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_bufs.c | 28 
 drivers/gpu/drm/drm_drv.c  | 10 +-
 include/drm/drm_legacy.h   |  4 +++-
 3 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index e8a12a4fd400..5a51633da033 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -542,18 +542,38 @@ int drm_legacy_rmmap_locked(struct drm_device *dev, 
struct drm_local_map *map)
 }
 EXPORT_SYMBOL(drm_legacy_rmmap_locked);

-int drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
+void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
 {
-   int ret;
+   if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
+   drm_core_check_feature(dev, DRIVER_MODESET))
+   return;

mutex_lock(&dev->struct_mutex);
-   ret = drm_legacy_rmmap_locked(dev, map);
+   drm_legacy_rmmap_locked(dev, map);
mutex_unlock(&dev->struct_mutex);

-   return ret;
+   return;
 }
 EXPORT_SYMBOL(drm_legacy_rmmap);

+void drm_legacy_master_rmmaps(struct drm_device *dev, struct drm_master 
*master)
+{
+   struct drm_map_list *r_list, *list_temp;
+
+   if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
+   drm_core_check_feature(dev, DRIVER_MODESET))
+   return;
+
+   mutex_lock(&dev->struct_mutex);
+   list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) {
+   if (r_list->master == master) {
+   drm_legacy_rmmap_locked(dev, r_list->map);
+   r_list = NULL;
+   }
+   }
+   mutex_unlock(&dev->struct_mutex);
+}
+
 /* The rmmap ioctl appears to be unnecessary.  All mappings are torn down on
  * the last close of the device, and this is necessary for cleanup when things
  * exit uncleanly.  Therefore, having userland manually remove mappings seems
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 55273f8f3acb..e1fb52d4f72c 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -121,19 +121,11 @@ static void drm_master_destroy(struct kref *kref)
 {
struct drm_master *master = container_of(kref, struct drm_master, 
refcount);
struct drm_device *dev = master->minor->dev;
-   struct drm_map_list *r_list, *list_temp;

if (dev->driver->master_destroy)
dev->driver->master_destroy(dev, master);

-   mutex_lock(&dev->struct_mutex);
-   list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) {
-   if (r_list->master == master) {
-   drm_legacy_rmmap_locked(dev, r_list->map);
-   r_list = NULL;
-   }
-   }
-   mutex_unlock(&dev->struct_mutex);
+   drm_legacy_master_rmmaps(dev, master);

idr_destroy(&master->magic_map);
kfree(master->unique);
diff --git a/include/drm/drm_legacy.h b/include/drm/drm_legacy.h
index 3e698038dc7b..a5ef2c7e40f8 100644
--- a/include/drm/drm_legacy.h
+++ b/include/drm/drm_legacy.h
@@ -154,8 +154,10 @@ struct drm_map_list {
 int drm_legacy_addmap(struct drm_device *d, resource_size_t offset,
  unsigned int size, enum drm_map_type type,
  enum drm_map_flags flags, struct drm_local_map **map_p);
-int drm_legacy_rmmap(struct drm_device *d, struct drm_local_map *map);
+void drm_legacy_rmmap(struct drm_device *d, struct drm_local_map *map);
 int drm_legacy_rmmap_locked(struct drm_device *d, struct drm_local_map *map);
+void drm_legacy_master_rmmaps(struct drm_device *dev,
+ struct drm_master *master);
 struct drm_local_map *drm_legacy_getsarea(struct drm_device *dev);
 int drm_legacy_mmap(struct file *filp, struct vm_area_struct *vma);

-- 
2.8.1



[PATCH 07/35] drm: Make drm_vm_open/close_locked private to drm_vm.c

2016-04-26 Thread Daniel Vetter
It's only used for legacy mmaping support now.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_internal.h |  2 --
 drivers/gpu/drm/drm_vm.c   | 16 
 2 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index c81ff4769e7b..902cf6a15212 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -37,8 +37,6 @@ int drm_irq_by_busid(struct drm_device *dev, void *data,

 /* drm_vm.c */
 int drm_vma_info(struct seq_file *m, void *data);
-void drm_vm_open_locked(struct drm_device *dev, struct vm_area_struct *vma);
-void drm_vm_close_locked(struct drm_device *dev, struct vm_area_struct *vma);

 /* drm_prime.c */
 int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index f90bd5fe35ba..ac9f4b3ec615 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -395,16 +395,8 @@ static const struct vm_operations_struct drm_vm_sg_ops = {
.close = drm_vm_close,
 };

-/**
- * \c open method for shared virtual memory.
- *
- * \param vma virtual memory area.
- *
- * Create a new drm_vma_entry structure as the \p vma private data entry and
- * add it to drm_device::vmalist.
- */
-void drm_vm_open_locked(struct drm_device *dev,
-   struct vm_area_struct *vma)
+static void drm_vm_open_locked(struct drm_device *dev,
+  struct vm_area_struct *vma)
 {
struct drm_vma_entry *vma_entry;

@@ -429,8 +421,8 @@ static void drm_vm_open(struct vm_area_struct *vma)
mutex_unlock(&dev->struct_mutex);
 }

-void drm_vm_close_locked(struct drm_device *dev,
-   struct vm_area_struct *vma)
+static void drm_vm_close_locked(struct drm_device *dev,
+   struct vm_area_struct *vma)
 {
struct drm_vma_entry *pt, *temp;

-- 
2.8.1



[PATCH 08/35] drm: Protect dev->filelist with its own mutex

2016-04-26 Thread Daniel Vetter
amdgpu gained dev->struct_mutex usage, and that's because it's walking
the dev->filelist list. Protect that list with it's own lock to take
one more step towards getting rid of struct_mutex usage in drivers
once and for all.

While doing the conversion I noticed that 2 debugfs files in i915
completely lacked appropriate locking. Fix that up too.

v2: don't forget to switch to drm_gem_object_unreference_unlocked.

Cc: Alex Deucher 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 10 +-
 drivers/gpu/drm/drm_drv.c   |  1 +
 drivers/gpu/drm/drm_fops.c  |  9 ++---
 drivers/gpu/drm/drm_info.c  |  4 ++--
 drivers/gpu/drm/i915/i915_debugfs.c | 12 ++--
 include/drm/drmP.h  |  1 +
 6 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index fa6a27bff298..a087b9638cde 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -93,7 +93,7 @@ void amdgpu_gem_force_release(struct amdgpu_device *adev)
struct drm_device *ddev = adev->ddev;
struct drm_file *file;

-   mutex_lock(&ddev->struct_mutex);
+   mutex_lock(&ddev->filelist_mutex);

list_for_each_entry(file, &ddev->filelist, lhead) {
struct drm_gem_object *gobj;
@@ -103,13 +103,13 @@ void amdgpu_gem_force_release(struct amdgpu_device *adev)
spin_lock(&file->table_lock);
idr_for_each_entry(&file->object_idr, gobj, handle) {
WARN_ONCE(1, "And also active allocations!\n");
-   drm_gem_object_unreference(gobj);
+   drm_gem_object_unreference_unlocked(gobj);
}
idr_destroy(&file->object_idr);
spin_unlock(&file->table_lock);
}

-   mutex_unlock(&ddev->struct_mutex);
+   mutex_unlock(&ddev->filelist_mutex);
 }

 /*
@@ -769,7 +769,7 @@ static int amdgpu_debugfs_gem_info(struct seq_file *m, void 
*data)
struct drm_file *file;
int r;

-   r = mutex_lock_interruptible(&dev->struct_mutex);
+   r = mutex_lock_interruptible(&dev->filelist_mutex);
if (r)
return r;

@@ -793,7 +793,7 @@ static int amdgpu_debugfs_gem_info(struct seq_file *m, void 
*data)
spin_unlock(&file->table_lock);
}

-   mutex_unlock(&dev->struct_mutex);
+   mutex_unlock(&dev->filelist_mutex);
return 0;
 }

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index e1fb52d4f72c..bff89226a344 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -590,6 +590,7 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
spin_lock_init(&dev->buf_lock);
spin_lock_init(&dev->event_lock);
mutex_init(&dev->struct_mutex);
+   mutex_init(&dev->filelist_mutex);
mutex_init(&dev->ctxlist_mutex);
mutex_init(&dev->master_mutex);

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index c3d0aaac0669..7af7f8bcb355 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -297,9 +297,9 @@ static int drm_open_helper(struct file *filp, struct 
drm_minor *minor)
}
mutex_unlock(&dev->master_mutex);

-   mutex_lock(&dev->struct_mutex);
+   mutex_lock(&dev->filelist_mutex);
list_add(&priv->lhead, &dev->filelist);
-   mutex_unlock(&dev->struct_mutex);
+   mutex_unlock(&dev->filelist_mutex);

 #ifdef __alpha__
/*
@@ -447,8 +447,11 @@ int drm_release(struct inode *inode, struct file *filp)

DRM_DEBUG("open_count = %d\n", dev->open_count);

-   mutex_lock(&dev->struct_mutex);
+   mutex_lock(&dev->filelist_mutex);
list_del(&file_priv->lhead);
+   mutex_unlock(&dev->filelist_mutex);
+
+   mutex_lock(&dev->struct_mutex);
if (file_priv->magic)
idr_remove(&file_priv->master->magic_map, file_priv->magic);
mutex_unlock(&dev->struct_mutex);
diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
index cbb4fc0fc969..5d469b2f26f4 100644
--- a/drivers/gpu/drm/drm_info.c
+++ b/drivers/gpu/drm/drm_info.c
@@ -174,7 +174,7 @@ int drm_clients_info(struct seq_file *m, void *data)
/* dev->filelist is sorted youngest first, but we want to present
 * oldest first (i.e. kernel, servers, clients), so walk backwardss.
 */
-   mutex_lock(&dev->struct_mutex);
+   mutex_lock(&dev->filelist_mutex);
list_for_each_entry_reverse(priv, &dev->filelist, lhead) {
struct task_struct *task;

@@ -190,7 +190,7 @@ int drm_clients_info(struct seq_file *m, void *data)
   priv->magic);
rcu_read_unlock();
}
-   mutex_unlock(&dev->struct_mutex);
+   mutex_unlock(&dev->filelist_mutex);
return 0;
 }

[PATCH 09/35] drm/gem: support BO freeing without dev->struct_mutex

2016-04-26 Thread Daniel Vetter
Finally all the core gem and a lot of drivers are entirely free of
dev->struct_mutex depencies, and we can start to have an entirely
lockless unref path.

To make sure that no one who touches the core code accidentally breaks
existing drivers which still require dev->struct_mutex I've made the
might_lock check unconditional.

While at it de-inline the ref/unref functions, they've become a bit
too big.

v2: Make it not leak like a sieve.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_gem.c | 64 ++-
 include/drm/drmP.h| 12 -
 include/drm/drm_gem.h | 45 ++---
 3 files changed, 65 insertions(+), 56 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 25dac31eef37..8f2eff448bb5 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -788,16 +788,7 @@ drm_gem_object_release(struct drm_gem_object *obj)
 }
 EXPORT_SYMBOL(drm_gem_object_release);

-/**
- * drm_gem_object_free - free a GEM object
- * @kref: kref of the object to free
- *
- * Called after the last reference to the object has been lost.
- * Must be called holding struct_ mutex
- *
- * Frees the object
- */
-void
+static void
 drm_gem_object_free(struct kref *kref)
 {
struct drm_gem_object *obj =
@@ -806,10 +797,59 @@ drm_gem_object_free(struct kref *kref)

WARN_ON(!mutex_is_locked(&dev->struct_mutex));

-   if (dev->driver->gem_free_object != NULL)
+   if (dev->driver->gem_free_object_unlocked != NULL)
+   dev->driver->gem_free_object_unlocked(obj);
+   else if (dev->driver->gem_free_object != NULL)
dev->driver->gem_free_object(obj);
 }
-EXPORT_SYMBOL(drm_gem_object_free);
+
+/**
+ * drm_gem_object_unreference_unlocked - release a GEM BO reference
+ * @obj: GEM buffer object
+ *
+ * This releases a reference to @obj. Callers must not hold the
+ * dev->struct_mutex lock when calling this function.
+ */
+void
+drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
+{
+   struct drm_device *dev;
+
+   if (!obj)
+   return;
+
+   dev = obj->dev;
+   might_lock(&dev->struct_mutex);
+
+   if (dev->driver->gem_free_object != NULL)
+   kref_put(&obj->refcount, drm_gem_object_free);
+   else if (kref_put_mutex(&obj->refcount, drm_gem_object_free,
+   &dev->struct_mutex))
+   mutex_unlock(&dev->struct_mutex);
+}
+EXPORT_SYMBOL(drm_gem_object_unreference_unlocked);
+
+/**
+ * drm_gem_object_unreference - release a GEM BO reference
+ * @obj: GEM buffer object
+ *
+ * This releases a reference to @obj. Callers must hold the dev->struct_mutex
+ * lock when calling this function, even when the driver doesn't use
+ * dev->struct_mutex for anything.
+ *
+ * For drivers not encumbered with legacy locking use
+ * drm_gem_object_unreference_unlocked() instead.
+ */
+void
+drm_gem_object_unreference(struct drm_gem_object *obj)
+{
+   if (obj != NULL) {
+   WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex));
+
+   kref_put(&obj->refcount, drm_gem_object_free);
+   }
+}
+EXPORT_SYMBOL(drm_gem_object_unreference);

 /**
  * drm_gem_vm_open - vma->ops->open implementation for GEM
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index c81dd2250fc6..7e30b3d2b25c 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -583,9 +583,19 @@ struct drm_driver {
 * Driver-specific constructor for drm_gem_objects, to set up
 * obj->driver_private.
 *
-* Returns 0 on success.
+* This is deprecated and should not be used by new drivers. Use
+* @gem_free_object_unlocked instead.
 */
void (*gem_free_object) (struct drm_gem_object *obj);
+
+   /**
+* Driver-specific constructor for drm_gem_objects, to set up
+* obj->driver_private. This is for drivers which are not encumbered
+* with dev->struct_mutex legacy locking schemes. Use this hook instead
+* of @gem_free_object.
+*/
+   void (*gem_free_object_unlocked) (struct drm_gem_object *obj);
+
int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);

diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
index 0b3e11ab8757..ae1c7f18eec0 100644
--- a/include/drm/drm_gem.h
+++ b/include/drm/drm_gem.h
@@ -175,7 +175,6 @@ struct drm_gem_object {
 };

 void drm_gem_object_release(struct drm_gem_object *obj);
-void drm_gem_object_free(struct kref *kref);
 int drm_gem_object_init(struct drm_device *dev,
struct drm_gem_object *obj, size_t size);
 void drm_gem_private_object_init(struct drm_device *dev,
@@ -199,48 +198,8 @@ drm_gem_object_reference(struct drm_gem_object *obj)
kref_get(&obj->refcount);
 }

-/**
- * drm_gem_object_unreference - release a GEM BO reference
-

[PATCH 10/35] drm/amdgpu: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Alex Deucher 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 93462aea9faa..44955f0f32d0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -514,7 +514,7 @@ static struct drm_driver kms_driver = {
.irq_uninstall = amdgpu_irq_uninstall,
.irq_handler = amdgpu_irq_handler,
.ioctls = amdgpu_ioctls_kms,
-   .gem_free_object = amdgpu_gem_object_free,
+   .gem_free_object_unlocked = amdgpu_gem_object_free,
.gem_open_object = amdgpu_gem_object_open,
.gem_close_object = amdgpu_gem_object_close,
.dumb_create = amdgpu_mode_dumb_create,
-- 
2.8.1



[PATCH 11/35] drm/armada: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

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

diff --git a/drivers/gpu/drm/armada/armada_drv.c 
b/drivers/gpu/drm/armada/armada_drv.c
index 82043c204b76..531fcb946346 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -198,7 +198,7 @@ static struct drm_driver armada_drm_driver = {
.debugfs_init   = armada_drm_debugfs_init,
.debugfs_cleanup= armada_drm_debugfs_cleanup,
 #endif
-   .gem_free_object= armada_gem_free_object,
+   .gem_free_object_unlocked = armada_gem_free_object,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_export   = armada_gem_prime_export,
-- 
2.8.1



[PATCH 12/35] drm/ast: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Dave Airlie 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/ast/ast_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index fcd9c0714836..f54afd2113a9 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -209,7 +209,7 @@ static struct drm_driver driver = {
.minor = DRIVER_MINOR,
.patchlevel = DRIVER_PATCHLEVEL,

-   .gem_free_object = ast_gem_free_object,
+   .gem_free_object_unlocked = ast_gem_free_object,
.dumb_create = ast_dumb_create,
.dumb_map_offset = ast_dumb_mmap_offset,
.dumb_destroy = drm_gem_dumb_destroy,
-- 
2.8.1



[PATCH 13/35] drm/atmel: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Boris Brezillon 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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



[PATCH 15/35] drm/cirrus: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Dave Airlie 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/cirrus/cirrus_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c 
b/drivers/gpu/drm/cirrus/cirrus_drv.c
index dc83f69da6f1..b05f7eae32ce 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.c
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
@@ -142,7 +142,7 @@ static struct drm_driver driver = {
.major = DRIVER_MAJOR,
.minor = DRIVER_MINOR,
.patchlevel = DRIVER_PATCHLEVEL,
-   .gem_free_object = cirrus_gem_free_object,
+   .gem_free_object_unlocked = cirrus_gem_free_object,
.dumb_create = cirrus_dumb_create,
.dumb_map_offset = cirrus_dumb_mmap_offset,
.dumb_destroy = drm_gem_dumb_destroy,
-- 
2.8.1



[PATCH 14/35] drm/bochs: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Gerd Hoffmann 
Cc: Dave Airlie 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/bochs/bochs_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bochs/bochs_drv.c 
b/drivers/gpu/drm/bochs/bochs_drv.c
index b332b4d3b0e2..abace82de6ea 100644
--- a/drivers/gpu/drm/bochs/bochs_drv.c
+++ b/drivers/gpu/drm/bochs/bochs_drv.c
@@ -89,7 +89,7 @@ static struct drm_driver bochs_driver = {
.date   = "20130925",
.major  = 1,
.minor  = 0,
-   .gem_free_object= bochs_gem_free_object,
+   .gem_free_object_unlocked = bochs_gem_free_object,
.dumb_create= bochs_dumb_create,
.dumb_map_offset= bochs_dumb_mmap_offset,
.dumb_destroy   = drm_gem_dumb_destroy,
-- 
2.8.1



[PATCH 16/35] drm/etnaviv: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Christian Gmeiner 
Cc: Russell King 
Cc: Lucas Stach 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/etnaviv/etnaviv_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c 
b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index e8858985f01e..c2f92e362812 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -497,7 +497,7 @@ static struct drm_driver etnaviv_drm_driver = {
.open   = etnaviv_open,
.preclose   = etnaviv_preclose,
.set_busid  = drm_platform_set_busid,
-   .gem_free_object= etnaviv_gem_free_object,
+   .gem_free_object_unlocked = etnaviv_gem_free_object,
.gem_vm_ops = &vm_ops,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
-- 
2.8.1



[PATCH 17/35] drm/exynos: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

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

diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c 
b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 5344940c8a07..f534ed62065e 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -418,7 +418,7 @@ static struct drm_driver exynos_drm_driver = {
.get_vblank_counter = drm_vblank_no_hw_counter,
.enable_vblank  = exynos_drm_crtc_enable_vblank,
.disable_vblank = exynos_drm_crtc_disable_vblank,
-   .gem_free_object= exynos_drm_gem_free_object,
+   .gem_free_object_unlocked = exynos_drm_gem_free_object,
.gem_vm_ops = &exynos_drm_gem_vm_ops,
.dumb_create= exynos_drm_gem_dumb_create,
.dumb_map_offset= exynos_drm_gem_dumb_map_offset,
-- 
2.8.1



[PATCH 18/35] drm/fls-dcu: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Jianwei Wang 
Cc: Stefan Agner 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 e8d9337a66d8..f96e8ea595e6 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
@@ -180,7 +180,7 @@ static struct drm_driver fsl_dcu_drm_driver = {
.get_vblank_counter = drm_vblank_no_hw_counter,
.enable_vblank  = fsl_dcu_drm_enable_vblank,
.disable_vblank = fsl_dcu_drm_disable_vblank,
-   .gem_free_object= drm_gem_cma_free_object,
+   .gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
-- 
2.8.1



[PATCH 19/35] drm/imx: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Sascha Hauer 
Cc: Philipp Zabel 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/imx/imx-drm-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c 
b/drivers/gpu/drm/imx/imx-drm-core.c
index e26dcdec2aba..2453fb1c68a7 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -411,7 +411,7 @@ static struct drm_driver imx_drm_driver = {
.unload = imx_drm_driver_unload,
.lastclose  = imx_drm_driver_lastclose,
.set_busid  = drm_platform_set_busid,
-   .gem_free_object= drm_gem_cma_free_object,
+   .gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.dumb_create= drm_gem_cma_dumb_create,
.dumb_map_offset= drm_gem_cma_dumb_map_offset,
-- 
2.8.1



[PATCH 20/35] drm/mga200g: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Dave Airlie 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/mgag200/mgag200_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c 
b/drivers/gpu/drm/mgag200/mgag200_drv.c
index ebb470ff7200..2b4b125eebc3 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -101,7 +101,7 @@ static struct drm_driver driver = {
.minor = DRIVER_MINOR,
.patchlevel = DRIVER_PATCHLEVEL,

-   .gem_free_object = mgag200_gem_free_object,
+   .gem_free_object_unlocked = mgag200_gem_free_object,
.dumb_create = mgag200_dumb_create,
.dumb_map_offset = mgag200_dumb_mmap_offset,
.dumb_destroy = drm_gem_dumb_destroy,
-- 
2.8.1



[PATCH 22/35] drm/qxl: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Dave Airlie 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/qxl/qxl_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index dc9df5fe50ba..460bbceae297 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -256,7 +256,7 @@ static struct drm_driver qxl_driver = {
.gem_prime_vmap = qxl_gem_prime_vmap,
.gem_prime_vunmap = qxl_gem_prime_vunmap,
.gem_prime_mmap = qxl_gem_prime_mmap,
-   .gem_free_object = qxl_gem_object_free,
+   .gem_free_object_unlocked = qxl_gem_object_free,
.gem_open_object = qxl_gem_object_open,
.gem_close_object = qxl_gem_object_close,
.fops = &qxl_fops,
-- 
2.8.1



[PATCH 21/35] drm/nouveau: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Ben Skeggs 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index db5c7d0cc25c..3a4af87fba0f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -970,7 +970,7 @@ driver_stub = {
.gem_prime_vmap = nouveau_gem_prime_vmap,
.gem_prime_vunmap = nouveau_gem_prime_vunmap,

-   .gem_free_object = nouveau_gem_object_del,
+   .gem_free_object_unlocked = nouveau_gem_object_del,
.gem_open_object = nouveau_gem_object_open,
.gem_close_object = nouveau_gem_object_close,

-- 
2.8.1



[PATCH 23/35] drm/radeon: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Alex Deucher 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/radeon/radeon_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/radeon_drv.c 
b/drivers/gpu/drm/radeon/radeon_drv.c
index 5d44ed0d104a..b9f74e68527e 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -525,7 +525,7 @@ static struct drm_driver kms_driver = {
.irq_uninstall = radeon_driver_irq_uninstall_kms,
.irq_handler = radeon_driver_irq_handler_kms,
.ioctls = radeon_ioctls_kms,
-   .gem_free_object = radeon_gem_object_free,
+   .gem_free_object_unlocked = radeon_gem_object_free,
.gem_open_object = radeon_gem_object_open,
.gem_close_object = radeon_gem_object_close,
.dumb_create = radeon_mode_dumb_create,
-- 
2.8.1



[PATCH 25/35] drm/rockchip: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Mark Yao 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index f556a8f4fde6..903202224057 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -308,7 +308,7 @@ static struct drm_driver rockchip_drm_driver = {
.enable_vblank  = rockchip_drm_crtc_enable_vblank,
.disable_vblank = rockchip_drm_crtc_disable_vblank,
.gem_vm_ops = &rockchip_drm_vm_ops,
-   .gem_free_object= rockchip_gem_free_object,
+   .gem_free_object_unlocked = rockchip_gem_free_object,
.dumb_create= rockchip_gem_dumb_create,
.dumb_map_offset= rockchip_gem_dumb_map_offset,
.dumb_destroy   = drm_gem_dumb_destroy,
-- 
2.8.1



[PATCH 24/35] drm/rcar-du: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/rcar-du/rcar_du_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index fb9242d27883..48ec4b6e8b26 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -217,7 +217,7 @@ static struct drm_driver rcar_du_driver = {
.get_vblank_counter = drm_vblank_no_hw_counter,
.enable_vblank  = rcar_du_enable_vblank,
.disable_vblank = rcar_du_disable_vblank,
-   .gem_free_object= drm_gem_cma_free_object,
+   .gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
-- 
2.8.1



[PATCH 26/35] drm/shmob: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/shmobile/shmob_drm_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c 
b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index 7700ff172079..ee79264b5b6a 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -264,7 +264,7 @@ static struct drm_driver shmob_drm_driver = {
.get_vblank_counter = drm_vblank_no_hw_counter,
.enable_vblank  = shmob_drm_enable_vblank,
.disable_vblank = shmob_drm_disable_vblank,
-   .gem_free_object= drm_gem_cma_free_object,
+   .gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
-- 
2.8.1



[PATCH 27/35] drm/tegra: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Thierry Reding 
Cc: Terje Bergström 
Cc: linux-tegra at vger.kernel.org
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/tegra/drm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 2be88eb0cb83..3d9241482f81 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -932,7 +932,7 @@ static struct drm_driver tegra_drm_driver = {
.debugfs_cleanup = tegra_debugfs_cleanup,
 #endif

-   .gem_free_object = tegra_bo_free_object,
+   .gem_free_object_unlocked = tegra_bo_free_object,
.gem_vm_ops = &tegra_bo_vm_ops,

.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
-- 
2.8.1



  1   2   >