[PATCH 00/24] drm: add extern C guard for the UAPI headers

2016-04-27 Thread Emil Velikov
On 27 April 2016 at 10:47, Russell King - ARM Linux
 wrote:
> On Thu, Apr 21, 2016 at 09:17:13PM +0100, Emil Velikov wrote:
>> Dave Airlie pointed out that "polluting" the headers in a manner as seen
>> with this series might not be too wise. David H, can we hear your view
>> on the topic ?
>
> For armada and etnaviv, it seems sensible, so I'd be happy to see the
> change go in if it means less work for others.
>
> Hence, for patch 2 and 4,
>
> Acked-by: Russell King 
>
Thank you Russel !


Dave, David H,

So far we've got 6 (if we count the one Rob gave over IRC) acks on the topic.

How do we proceed with this - would you like me to elaborate more on
the topic, do you see some serious downfalls with the proposal ? [And
yes I agree that tweaking the generator scripts to produce these might
be better but that's a bit out of my reach atm]

If you are OK should we merge the series via drm-next or danvet's
drm-misc ? ... once I we hear from a few more people of course -
mainly AMD and Ben.

Regards,
Emil


[PATCH] drm/dp: Allow signals to interrupt drm_aux-dev reads/writes

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

Let's be nice and interrupt the dpcd aux-dev reads/writes when there's
a signal pending. Much nicer if the user can hit ^C instead of having to
sit around waiting for the read/write to finish.

time dd if=/dev/drm_dp_aux0 bs=$((1024*1024))
^C

before:
 real   0m34.681s
 user   0m0.003s
 sys0m6.880s

after:
 real   0m0.222s
 user   0m0.006s
 sys0m0.057s

Cc: Rafael Antognolli 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/drm_dp_aux_dev.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/drm_dp_aux_dev.c b/drivers/gpu/drm/drm_dp_aux_dev.c
index f73b38b33a8e..3334baacf43d 100644
--- a/drivers/gpu/drm/drm_dp_aux_dev.c
+++ b/drivers/gpu/drm/drm_dp_aux_dev.c
@@ -159,6 +159,12 @@ static ssize_t auxdev_read(struct file *file, char __user 
*buf, size_t count,
uint8_t localbuf[DP_AUX_MAX_PAYLOAD_BYTES];
ssize_t todo = min_t(size_t, bytes_pending, sizeof(localbuf));

+   if (signal_pending(current)) {
+   res = num_bytes_processed ?
+   num_bytes_processed : -ERESTARTSYS;
+   goto out;
+   }
+
res = drm_dp_dpcd_read(aux_dev->aux, *offset, localbuf, todo);
if (res <= 0) {
res = num_bytes_processed ? num_bytes_processed : res;
@@ -202,6 +208,12 @@ static ssize_t auxdev_write(struct file *file, const char 
__user *buf,
uint8_t localbuf[DP_AUX_MAX_PAYLOAD_BYTES];
ssize_t todo = min_t(size_t, bytes_pending, sizeof(localbuf));

+   if (signal_pending(current)) {
+   res = num_bytes_processed ?
+   num_bytes_processed : -ERESTARTSYS;
+   goto out;
+   }
+
if (__copy_from_user(localbuf,
 buf + num_bytes_processed, todo)) {
res = num_bytes_processed ?
-- 
2.7.4



[PATCH 19/24] drm/sis: add missing include drm.h for the UAPI header

2016-04-27 Thread Emil Velikov
On 27 April 2016 at 00:37, Dave Airlie  wrote:
> On 22 April 2016 at 18:37, Daniel Vetter  wrote:
>> On Thu, Apr 21, 2016 at 09:17:32PM +0100, Emil Velikov wrote:
>>> Signed-off-by: Emil Velikov 
>>
>> If the extern C stuff falls through, maybe we want to pull this one out
>> ahead?
>
> I've pulled this and the qxl one into -next as I was driving past.
>
Nice one. Thanks Dave.

-Emil


[GIT PULL] drm-hisilicon-next-2016-04-18 for 4.7

2016-04-27 Thread Xinliang Liu
On 27 April 2016 at 07:43, Dave Airlie  wrote:
> On 19 April 2016 at 19:03, Xinliang Liu  wrote:
>> Hi Dave,
>>
>> This is the first pull request from drm-hisilicon and for 4.7.
>>
>> The patches add new hisilicon drm driver.
>>
>> The patches were reviewed here:
>> http://www.spinics.net/lists/dri-devel/msg104437.html
>>
>> DT binding docs were acked by Rob Herring  here:
>> https://lists.freedesktop.org/archives/dri-devel/2016-March/102135.html
>>
>> Please kindly let me know if there is any problem.
>
>  CC [M]  drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.o
> /home/airlied/devel/kernel/drm-next/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c:
> In function ‘ade_init’:
> /home/airlied/devel/kernel/drm-next/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c:169:134:
> warning: left shift count >= width of type [-Wshift-count-overflow]
> /home/airlied/devel/kernel/drm-next/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c:170:134:
> warning: left shift count >= width of type [-Wshift-count-overflow]
> /home/airlied/devel/kernel/drm-next/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c:171:134:
> warning: left shift count >= width of type [-Wshift-count-overflow]
> /home/airlied/devel/kernel/drm-next/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c:172:134:
> warning: left shift count >= width of type [-Wshift-count-overflow]
>   DTC drivers/gpu/drm/tilcdc/tilcdc_slave_compat.dtb
>   LD [M]  drivers/gpu/drm/hisilicon/kirin/kirin-drm.o
> drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.o: In function `init_module':
> dw_drm_dsi.c:(.init.text+0x0): multiple definition of `init_module'
> drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.o:kirin_drm_drv.c:(.init.text+0x0):
> first defined here
> drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.o: In function `cleanup_module':
> dw_drm_dsi.c:(.exit.text+0x0): multiple definition of `cleanup_module'
> drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.o:kirin_drm_drv.c:(.exit.text+0x0):
> first defined here
> /home/airlied/devel/kernel/drm-next/scripts/Makefile.build:428: recipe
> for target 'drivers/gpu/drm/hisilicon/kirin/kirin-drm.o' failed
> make[6]: *** [drivers/gpu/drm/hisilicon/kirin/kirin-drm.o] Error 1
> /home/airlied/devel/kernel/drm-next/scripts/Makefile.build:440: recipe
> for target 'drivers/gpu/drm/hisilicon/kirin' fai
>
> Please fix module compilation and the above warnings and resubmit.

OK, will fix and resubmit soon.

Best,
-xinliang

>
> Dave.


[PATCH v3 0/7] drm: Add fbdev deferred io support to helpers

2016-04-27 Thread Noralf Trønnes

Den 27.04.2016 21:24, skrev Daniel Vetter:
> On Wed, Apr 27, 2016 at 08:16:29PM +0200, Noralf Trønnes wrote:
>> This patchset adds fbdev deferred io support to drm_fb_helper and
>> drm_fb_cma_helper.
>>
>> It channels fbdev mmap and fb_{write,fillrect,copyarea,imageblit} damage
>> through the (struct drm_framebuffer_funcs)->dirty callback on the
>> fb_helper framebuffer which will always run in process context.
>>
>> I have also added patches that converts qxl and udl to use this
>> deferred io support. I have only compile tested it, no functional testing.
>> I know that qxl is purely a software thing so I could actually test it, but
>> I have never used qemu so I'm not keen on spending a lot of time on that.
>>
>> This was originally part of the tinydrm patchset.
>>
>> Changes since v2:
>> - drm/rect: Add some drm_clip_rect utility functions
>>- This patch is dropped
>> - drm/fb-helper: Add fb_deferred_io support
>>- FB_DEFERRED_IO is now always selected by DRM_KMS_FB_HELPER, ifdef 
>> removed
>>- The drm_clip_rect utility functions are dropped, so open code it
>>- docs: use & to denote structs
>> - drm/qxl: Use drm_fb_helper deferred_io support
>>- The drm_clip_rect_{width/height} functions are dropped, so open code it
> Found two tiny nit in the drm fbdev helper patch. Otherwise I think just needs
> an ack from Tomi for the fbdev patch, and from Laurent Pinchart for the
> cma one (you've forgotten to cc him) and this is good to land imo.
> -Daniel

Laurent has been cc'ed on the entire patchset.
Should I have added cc: laurent.pinchart at ideasonboard.com in the
cma commit message instead?

I'm not sure who should get what in a patchset like this.
I use git send-email, and have included all parties for the entire patchset,
but should Tomi for instance have received only the fbdev patch and
nothing else?

Noralf.

>> Changes since v1:
>> - drm/fb-helper: Add fb_deferred_io support
>>- Use a dedicated worker to run the framebuffer flushing like qxl does
>>- Add parameter descriptions to drm_fb_helper_deferred_io
>> - fbdev: fb_defio: Export fb_deferred_io_mmap
>>- Expand commit message
>> - drm/qxl: Use drm_fb_helper deferred_io support
>>- Add FIXME about special dirty() callback for fbdev
>>- Remove note in commit message about deferred worker, drm_fb_helper
>>  is similar to qxl now.
>> - drm/udl: Use drm_fb_helper deferred_io support
>>- No need to enable deferred_io by default since drm_fb_helper uses
>>  a dedicated worker for flushing
>>
>> Changes since RFC:
>> - Fix drm_clip_rect use to be exclusive on x2/y2
>> - Put drm_clip_rect functions in drm_rect.{h,c}
>> - Take into account that (struct fb_ops *)->fb_{write,...}() can be called
>>from atomic context (spin_lock_irqsave)
>> - Export fb_deferred_io_mmap()
>> - Add some more documentation
>> - Add qxl and udl patches
>>
>> Noralf Trønnes (7):
>>drm/udl: Change drm_fb_helper_sys_*() calls to sys_*()
>>drm/qxl: Change drm_fb_helper_sys_*() calls to sys_*()
>>drm/fb-helper: Add fb_deferred_io support
>>fbdev: fb_defio: Export fb_deferred_io_mmap
>>drm/fb-cma-helper: Add fb_deferred_io support
>>drm/qxl: Use drm_fb_helper deferred_io support
>>drm/udl: Use drm_fb_helper deferred_io support
>>
>>   drivers/gpu/drm/Kconfig |   1 +
>>   drivers/gpu/drm/drm_fb_cma_helper.c | 178 ++--
>>   drivers/gpu/drm/drm_fb_helper.c | 109 +-
>>   drivers/gpu/drm/qxl/qxl_display.c   |   9 +-
>>   drivers/gpu/drm/qxl/qxl_drv.h   |   7 +-
>>   drivers/gpu/drm/qxl/qxl_fb.c| 223 
>> +---
>>   drivers/gpu/drm/qxl/qxl_kms.c   |   4 -
>>   drivers/gpu/drm/udl/udl_drv.h   |   2 -
>>   drivers/gpu/drm/udl/udl_fb.c| 140 +-
>>   drivers/video/fbdev/core/fb_defio.c |   3 +-
>>   include/drm/drm_fb_cma_helper.h |  14 +++
>>   include/drm/drm_fb_helper.h |  15 +++
>>   include/linux/fb.h  |   1 +
>>   13 files changed, 378 insertions(+), 328 deletions(-)
>>
>> --
>> 2.2.2
>>



[PATCH v2 1/3] dt/bindings: display: Add DT bindings for Mali Display Processors.

2016-04-27 Thread Rob Herring
On Mon, Apr 25, 2016 at 03:19:22PM +0100, Liviu Dudau wrote:
> Add DT bindings documentation for the Mali Display Processor. The bindings
> describe the Mali DP500, DP550 and DP650 processors from ARM Ltd.
> 
> Cc: Rob Herring 
> Cc: Pawel Moll 
> Cc: Mark Rutland 
> Cc: Ian Campbell 
> Cc: Kumar Gala 
> 
> Signed-off-by: Liviu Dudau 
> ---
>  .../devicetree/bindings/display/arm,malidp.txt | 65 
> ++
>  1 file changed, 65 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/display/arm,malidp.txt

Acked-by: Rob Herring 


[PATCH v4 04/11] drm: sun4i: Add DT bindings documentation

2016-04-27 Thread Rob Herring
On Mon, Apr 25, 2016 at 03:22:45PM +0200, Maxime Ripard wrote:
> The display pipeline of the Allwinner A10 is involving several loosely
> coupled components.
> 
> Add a documentation for the bindings.
> 
> Signed-off-by: Maxime Ripard 
> ---
>  .../bindings/display/sunxi/sun4i-drm.txt   | 258 
> +
>  1 file changed, 258 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt

> +The display engine pipeline (and its entry point, since it can be
> +either directly the backend or the frontend) is represented as an
> +extra node.
> +
> +Required properties:
> +  - compatible: value must be one of:
> +* allwinner,sun5i-a13-display-engine
> +
> +  - allwinner,pipelines: list of phandle to the display engine
> +frontends available.


> +display-engine {
> + compatible = "allwinner,sun5i-a13-display-engine";
> + pipelines = <>;

Missing allwinner prefix.

Otherwise,

Acked-by: Rob Herring 


[PATCH 2/2] drm/etnaviv: fix mmap operations for userptr and dma-buf objects

2016-04-27 Thread Russell King - ARM Linux
On Wed, Apr 27, 2016 at 02:39:21PM +0200, Lucas Stach wrote:
> +static int etnaviv_gem_userptr_mmap_obj(struct etnaviv_gem_object 
> *etnaviv_obj,
> + struct vm_area_struct *vma)
> +{
> + return -EPERM;
> +}

   EPERM  The prot argument asks for PROT_EXEC but the mapped area belongs
  to a file on a file system that was mounted no-exec.

It seems this error code is not suitable for this application - it
doesn't fit the spirit of EPERM.  The universal EINVAL would probably
be better.

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


[PATCH v3 3/7] drm/fb-helper: Add fb_deferred_io support

2016-04-27 Thread Noralf Trønnes

Den 27.04.2016 21:20, skrev Daniel Vetter:
> On Wed, Apr 27, 2016 at 08:16:32PM +0200, Noralf Trønnes wrote:
>> This adds deferred io support to drm_fb_helper.
>> 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 v2:
>> - FB_DEFERRED_IO is now always selected by DRM_KMS_FB_HELPER, ifdef removed
>> - The drm_clip_rect utility functions are dropped, so open code it
>> - docs: use & to denote structs
>>
>> 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/Kconfig |   1 +
>>   drivers/gpu/drm/drm_fb_helper.c | 109 
>> +++-
>>   include/drm/drm_fb_helper.h |  15 ++
>>   3 files changed, 124 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
>> index 9e4f2f1..8e6f34b 100644
>> --- a/drivers/gpu/drm/Kconfig
>> +++ b/drivers/gpu/drm/Kconfig
>> @@ -52,6 +52,7 @@ config DRM_KMS_FB_HELPER
>>  select FB_CFB_FILLRECT
>>  select FB_CFB_COPYAREA
>>  select FB_CFB_IMAGEBLIT
>> +select FB_DEFERRED_IO
>>  help
>>FBDEV helpers for KMS drivers.
>>
>> diff --git a/drivers/gpu/drm/drm_fb_helper.c 
>> b/drivers/gpu/drm/drm_fb_helper.c
>> index 855108e..5112b5d 100644
>> --- a/drivers/gpu/drm/drm_fb_helper.c
>> +++ b/drivers/gpu/drm/drm_fb_helper.c
>> @@ -48,6 +48,8 @@ MODULE_PARM_DESC(fbdev_emulation,
>>
>>   static LIST_HEAD(kernel_fb_helper_list);
>>
>> +static void drm_fb_helper_dirty_init(struct drm_fb_helper *helper);
> Instead of this forward decl just inline the few setup commands into
> drm_fb_helper_prepare.

That would mean that I have to forward declare drm_fb_helper_dirty_work()
instead. Is that better?
Or should I relocate the functions?

>> +
>>   /**
>>* DOC: fbdev helpers
>>*
>> @@ -84,6 +86,15 @@ 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 _framebuffer_funcs ->dirty is
>> + * set, the drm_fb_helper_{cfb,sys}_{write,fillrect,copyarea,imageblit}
>> + * functions will accumulate changes and schedule _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.
>>*/
>>
>>   /**
>> @@ -650,6 +661,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(>kernel_fb_list);
>> +drm_fb_helper_dirty_init(helper);
>>  helper->funcs = funcs;
>>  helper->dev = dev;
>>   }
>> @@ -834,6 +846,82 @@ void drm_fb_helper_unlink_fbi(struct drm_fb_helper 
>> *fb_helper)
>>   }
>>   EXPORT_SYMBOL(drm_fb_helper_unlink_fbi);
>>
>> +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 = >dirty_clip;
>> +struct drm_clip_rect clip_copy;
>> +unsigned long flags;
>> +
>> +spin_lock_irqsave(>dirty_lock, flags);
>> +clip_copy = *clip;
>> +clip->x1 = clip->y1 = ~0;
>> +clip->x2 = clip->y2 = 0;
>> +spin_unlock_irqrestore(>dirty_lock, flags);
>> +
>> +helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, _copy, 1);
>> +}
>> +
>> +static void drm_fb_helper_dirty_init(struct drm_fb_helper *helper)
>> +{
>> +spin_lock_init(>dirty_lock);
>> +INIT_WORK(>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 = >dirty_clip;
>> +unsigned long flags;
>> +
>> +if (!helper->fb->funcs->dirty)
>> +return;
>> +
>> +spin_lock_irqsave(>dirty_lock, flags);
>> +clip->x1 = min_t(u32, clip->x1, x);
>> +clip->y1 = min_t(u32, clip->y1, y);
>> +clip->x2 = max_t(u32, clip->x2, x + width);
>> +clip->y2 = max_t(u32, clip->y2, y + height);
>> +spin_unlock_irqrestore(>dirty_lock, flags);
>> +
>> +schedule_work(>dirty_work);
>> +}
>> +
>> +/**
>> + * 

[PATCH v3 0/7] drm: Add fbdev deferred io support to helpers

2016-04-27 Thread Daniel Vetter
On Wed, Apr 27, 2016 at 08:16:29PM +0200, Noralf Trønnes wrote:
> This patchset adds fbdev deferred io support to drm_fb_helper and
> drm_fb_cma_helper.
> 
> It channels fbdev mmap and fb_{write,fillrect,copyarea,imageblit} damage
> through the (struct drm_framebuffer_funcs)->dirty callback on the
> fb_helper framebuffer which will always run in process context.
> 
> I have also added patches that converts qxl and udl to use this
> deferred io support. I have only compile tested it, no functional testing.
> I know that qxl is purely a software thing so I could actually test it, but
> I have never used qemu so I'm not keen on spending a lot of time on that.
> 
> This was originally part of the tinydrm patchset.
> 
> Changes since v2:
> - drm/rect: Add some drm_clip_rect utility functions
>   - This patch is dropped
> - drm/fb-helper: Add fb_deferred_io support
>   - FB_DEFERRED_IO is now always selected by DRM_KMS_FB_HELPER, ifdef removed
>   - The drm_clip_rect utility functions are dropped, so open code it
>   - docs: use & to denote structs
> - drm/qxl: Use drm_fb_helper deferred_io support
>   - The drm_clip_rect_{width/height} functions are dropped, so open code it

Found two tiny nit in the drm fbdev helper patch. Otherwise I think just needs
an ack from Tomi for the fbdev patch, and from Laurent Pinchart for the
cma one (you've forgotten to cc him) and this is good to land imo.
-Daniel

> 
> Changes since v1:
> - drm/fb-helper: Add fb_deferred_io support
>   - Use a dedicated worker to run the framebuffer flushing like qxl does
>   - Add parameter descriptions to drm_fb_helper_deferred_io
> - fbdev: fb_defio: Export fb_deferred_io_mmap
>   - Expand commit message
> - drm/qxl: Use drm_fb_helper deferred_io support
>   - Add FIXME about special dirty() callback for fbdev
>   - Remove note in commit message about deferred worker, drm_fb_helper
> is similar to qxl now.
> - drm/udl: Use drm_fb_helper deferred_io support
>   - No need to enable deferred_io by default since drm_fb_helper uses
> a dedicated worker for flushing
> 
> Changes since RFC:
> - Fix drm_clip_rect use to be exclusive on x2/y2
> - Put drm_clip_rect functions in drm_rect.{h,c}
> - Take into account that (struct fb_ops *)->fb_{write,...}() can be called
>   from atomic context (spin_lock_irqsave)
> - Export fb_deferred_io_mmap()
> - Add some more documentation
> - Add qxl and udl patches
> 
> Noralf Trønnes (7):
>   drm/udl: Change drm_fb_helper_sys_*() calls to sys_*()
>   drm/qxl: Change drm_fb_helper_sys_*() calls to sys_*()
>   drm/fb-helper: Add fb_deferred_io support
>   fbdev: fb_defio: Export fb_deferred_io_mmap
>   drm/fb-cma-helper: Add fb_deferred_io support
>   drm/qxl: Use drm_fb_helper deferred_io support
>   drm/udl: Use drm_fb_helper deferred_io support
> 
>  drivers/gpu/drm/Kconfig |   1 +
>  drivers/gpu/drm/drm_fb_cma_helper.c | 178 ++--
>  drivers/gpu/drm/drm_fb_helper.c | 109 +-
>  drivers/gpu/drm/qxl/qxl_display.c   |   9 +-
>  drivers/gpu/drm/qxl/qxl_drv.h   |   7 +-
>  drivers/gpu/drm/qxl/qxl_fb.c| 223 
> +---
>  drivers/gpu/drm/qxl/qxl_kms.c   |   4 -
>  drivers/gpu/drm/udl/udl_drv.h   |   2 -
>  drivers/gpu/drm/udl/udl_fb.c| 140 +-
>  drivers/video/fbdev/core/fb_defio.c |   3 +-
>  include/drm/drm_fb_cma_helper.h |  14 +++
>  include/drm/drm_fb_helper.h |  15 +++
>  include/linux/fb.h  |   1 +
>  13 files changed, 378 insertions(+), 328 deletions(-)
> 
> --
> 2.2.2
> 

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


[PATCH v3 6/7] drm/qxl: Use drm_fb_helper deferred_io support

2016-04-27 Thread Daniel Vetter
On Wed, Apr 27, 2016 at 08:16:35PM +0200, Noralf Trønnes wrote:
> Use the fbdev deferred io support in drm_fb_helper which mirrors the
> one qxl has had.
> This patch has only been compile tested.
> 
> Signed-off-by: Noralf Trønnes 
> ---
> 
> Changes since v2:
> - The drm_clip_rect_{width/height} functions are dropped, so open code it

Reviewed-by: Daniel Vetter  still applies.

> 
> Changes since v1:
> - Add FIXME about special dirty() callback for fbdev
> - Remove note in commit message about deferred worker, drm_fb_helper
>   is similar to qxl now.
> 
>  drivers/gpu/drm/qxl/qxl_display.c |   9 +-
>  drivers/gpu/drm/qxl/qxl_drv.h |   7 +-
>  drivers/gpu/drm/qxl/qxl_fb.c  | 223 
> ++
>  drivers/gpu/drm/qxl/qxl_kms.c |   4 -
>  4 files changed, 65 insertions(+), 178 deletions(-)
> 
> diff --git a/drivers/gpu/drm/qxl/qxl_display.c 
> b/drivers/gpu/drm/qxl/qxl_display.c
> index 030409a..9a03524 100644
> --- a/drivers/gpu/drm/qxl/qxl_display.c
> +++ b/drivers/gpu/drm/qxl/qxl_display.c
> @@ -465,7 +465,7 @@ static const struct drm_crtc_funcs qxl_crtc_funcs = {
>   .page_flip = qxl_crtc_page_flip,
>  };
> 
> -static void qxl_user_framebuffer_destroy(struct drm_framebuffer *fb)
> +void qxl_user_framebuffer_destroy(struct drm_framebuffer *fb)
>  {
>   struct qxl_framebuffer *qxl_fb = to_qxl_framebuffer(fb);
> 
> @@ -527,12 +527,13 @@ int
>  qxl_framebuffer_init(struct drm_device *dev,
>struct qxl_framebuffer *qfb,
>const struct drm_mode_fb_cmd2 *mode_cmd,
> -  struct drm_gem_object *obj)
> +  struct drm_gem_object *obj,
> +  const struct drm_framebuffer_funcs *funcs)
>  {
>   int ret;
> 
>   qfb->obj = obj;
> - ret = drm_framebuffer_init(dev, >base, _fb_funcs);
> + ret = drm_framebuffer_init(dev, >base, funcs);
>   if (ret) {
>   qfb->obj = NULL;
>   return ret;
> @@ -999,7 +1000,7 @@ qxl_user_framebuffer_create(struct drm_device *dev,
>   if (qxl_fb == NULL)
>   return NULL;
> 
> - ret = qxl_framebuffer_init(dev, qxl_fb, mode_cmd, obj);
> + ret = qxl_framebuffer_init(dev, qxl_fb, mode_cmd, obj, _fb_funcs);
>   if (ret) {
>   kfree(qxl_fb);
>   drm_gem_object_unreference_unlocked(obj);
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
> index 3f3897e..3ad6604 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.h
> +++ b/drivers/gpu/drm/qxl/qxl_drv.h
> @@ -324,8 +324,6 @@ struct qxl_device {
>   struct workqueue_struct *gc_queue;
>   struct work_struct gc_work;
> 
> - struct work_struct fb_work;
> -
>   struct drm_property *hotplug_mode_update_property;
>   int monitors_config_width;
>   int monitors_config_height;
> @@ -389,11 +387,13 @@ int qxl_get_handle_for_primary_fb(struct qxl_device 
> *qdev,
>  void qxl_fbdev_set_suspend(struct qxl_device *qdev, int state);
> 
>  /* qxl_display.c */
> +void qxl_user_framebuffer_destroy(struct drm_framebuffer *fb);
>  int
>  qxl_framebuffer_init(struct drm_device *dev,
>struct qxl_framebuffer *rfb,
>const struct drm_mode_fb_cmd2 *mode_cmd,
> -  struct drm_gem_object *obj);
> +  struct drm_gem_object *obj,
> +  const struct drm_framebuffer_funcs *funcs);
>  void qxl_display_read_client_monitors_config(struct qxl_device *qdev);
>  void qxl_send_monitors_config(struct qxl_device *qdev);
>  int qxl_create_monitors_object(struct qxl_device *qdev);
> @@ -553,7 +553,6 @@ int qxl_irq_init(struct qxl_device *qdev);
>  irqreturn_t qxl_irq_handler(int irq, void *arg);
> 
>  /* qxl_fb.c */
> -int qxl_fb_init(struct qxl_device *qdev);
>  bool qxl_fbdev_qobj_is_fb(struct qxl_device *qdev, struct qxl_bo *qobj);
> 
>  int qxl_debugfs_add_files(struct qxl_device *qdev,
> diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c
> index 3f7c543..739a08c 100644
> --- a/drivers/gpu/drm/qxl/qxl_fb.c
> +++ b/drivers/gpu/drm/qxl/qxl_fb.c
> @@ -46,15 +46,6 @@ struct qxl_fbdev {
>   struct list_head delayed_ops;
>   void *shadow;
>   int size;
> -
> - /* dirty memory logging */
> - struct {
> - spinlock_t lock;
> - unsigned x1;
> - unsigned y1;
> - unsigned x2;
> - unsigned y2;
> - } dirty;
>  };
> 
>  static void qxl_fb_image_init(struct qxl_fb_image *qxl_fb_image,
> @@ -82,169 +73,18 @@ static void qxl_fb_image_init(struct qxl_fb_image 
> *qxl_fb_image,
>   }
>  }
> 
> -static void qxl_fb_dirty_flush(struct fb_info *info)
> -{
> - struct qxl_fbdev *qfbdev = info->par;
> - struct qxl_device *qdev = qfbdev->qdev;
> - struct qxl_fb_image qxl_fb_image;
> - struct fb_image *image = _fb_image.fb_image;
> - unsigned long flags;
> - u32 x1, x2, y1, y2;
> -
> - /* TODO: hard coding 32 bpp */
> - int stride 

[PATCH v3 3/7] drm/fb-helper: Add fb_deferred_io support

2016-04-27 Thread Daniel Vetter
On Wed, Apr 27, 2016 at 08:16:32PM +0200, Noralf Trønnes wrote:
> This adds deferred io support to drm_fb_helper.
> 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 v2:
> - FB_DEFERRED_IO is now always selected by DRM_KMS_FB_HELPER, ifdef removed
> - The drm_clip_rect utility functions are dropped, so open code it
> - docs: use & to denote structs
> 
> 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/Kconfig |   1 +
>  drivers/gpu/drm/drm_fb_helper.c | 109 
> +++-
>  include/drm/drm_fb_helper.h |  15 ++
>  3 files changed, 124 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index 9e4f2f1..8e6f34b 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -52,6 +52,7 @@ config DRM_KMS_FB_HELPER
>   select FB_CFB_FILLRECT
>   select FB_CFB_COPYAREA
>   select FB_CFB_IMAGEBLIT
> + select FB_DEFERRED_IO
>   help
> FBDEV helpers for KMS drivers.
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 855108e..5112b5d 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -48,6 +48,8 @@ MODULE_PARM_DESC(fbdev_emulation,
> 
>  static LIST_HEAD(kernel_fb_helper_list);
> 
> +static void drm_fb_helper_dirty_init(struct drm_fb_helper *helper);

Instead of this forward decl just inline the few setup commands into
drm_fb_helper_prepare.

> +
>  /**
>   * DOC: fbdev helpers
>   *
> @@ -84,6 +86,15 @@ 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 _framebuffer_funcs ->dirty is
> + * set, the drm_fb_helper_{cfb,sys}_{write,fillrect,copyarea,imageblit}
> + * functions will accumulate changes and schedule _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.
>   */
> 
>  /**
> @@ -650,6 +661,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(>kernel_fb_list);
> + drm_fb_helper_dirty_init(helper);
>   helper->funcs = funcs;
>   helper->dev = dev;
>  }
> @@ -834,6 +846,82 @@ void drm_fb_helper_unlink_fbi(struct drm_fb_helper 
> *fb_helper)
>  }
>  EXPORT_SYMBOL(drm_fb_helper_unlink_fbi);
> 
> +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 = >dirty_clip;
> + struct drm_clip_rect clip_copy;
> + unsigned long flags;
> +
> + spin_lock_irqsave(>dirty_lock, flags);
> + clip_copy = *clip;
> + clip->x1 = clip->y1 = ~0;
> + clip->x2 = clip->y2 = 0;
> + spin_unlock_irqrestore(>dirty_lock, flags);
> +
> + helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, _copy, 1);
> +}
> +
> +static void drm_fb_helper_dirty_init(struct drm_fb_helper *helper)
> +{
> + spin_lock_init(>dirty_lock);
> + INIT_WORK(>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 = >dirty_clip;
> + unsigned long flags;
> +
> + if (!helper->fb->funcs->dirty)
> + return;
> +
> + spin_lock_irqsave(>dirty_lock, flags);
> + clip->x1 = min_t(u32, clip->x1, x);
> + clip->y1 = min_t(u32, clip->y1, y);
> + clip->x2 = max_t(u32, clip->x2, x + width);
> + clip->y2 = max_t(u32, clip->y2, y + height);
> + spin_unlock_irqrestore(>dirty_lock, flags);
> +
> + schedule_work(>dirty_work);
> +}
> +
> +/**
> + * drm_fb_helper_deferred_io() - fbdev deferred_io callback function
> + * @info: fb_info struct pointer
> + * @pagelist: list of dirty mmap framebuffer pages
> + *
> + * This function is used as the _deferred_io ->deferred_io
> + * callback function for flushing the fbdev mmap writes.
> + */
> +void 

[PATCH 00/12] De-stage Sync File Framework

2016-04-27 Thread Daniel Vetter
On Wed, Apr 27, 2016 at 01:27:07PM -0300, Gustavo Padovan wrote:
> From: Gustavo Padovan 
> 
> Hi,
> 
> This patchset sits on top of Sync ABI Rework v13:
> 
> https://www.spinics.net/lists/dri-devel/msg105667.html
> 
> The first eight clean up and prepare sync_file for de-staging. The last four
> patches do the de-staging, moving files to drivers/dma-buf/ and include/linux/
> plus adding Documentation.
> 
> As the de-stage depends upon many changes on the staging tree it would
> be good to get all the patches merged through the staging tree if Sumit
> agrees with that.
> 
> The next step on the Sync de-stage is clean up the remaining bits 
> of the Sync Framework, mainly SW_SYNC, which is only used for testing.

Ok I looked once more at all this stuff, and there's some nitpicks I
discussed with Gustavo on irc. But really their small, and I think
perfectly ok to address them once sync_file is destaged. Especially since
there's a lot more work pending on top of this, so we really want to get
sync_file.[hc] destaged in 4.7. It'll take us a few iterations and a few
drivers using this in anger in upstream to perfect the internal interfaces
anyway, but let's get this started.

Had some real nitpicks on the docs patch, but that can also be merged
later on imo. Except for that patch, on the series:

Reviewed-by: Daniel Vetter 

> 
> Thanks,
> 
>   Gustavo
> 
> ---
> Gustavo Padovan (12):
>   staging/android: remove redundant comments on sync_merge_data
>   staging/android: drop sync_file_install() and sync_file_put()
>   staging/android: move sync_file functions comments to sync.c
>   staging/android: make sync_file_merge() static
>   staging/android: make sync_file_fdget() static
>   staging/android: prepare sync_file for de-staging
>   staging/android: improve documentation for sync_file
>   staging/android: style fix: alignment to match the open parenthesis
>   dma-buf/sync_file: de-stage sync_file headers
>   dma-buf/sync_file: de-stage sync_file
>   Documentation: include sync_file into DocBook
>   Documentation: add Sync File doc
> 
>  Documentation/DocBook/device-drivers.tmpl |   2 +
>  Documentation/dma-buf-sync_file.txt   |  65 +
>  drivers/Kconfig   |   2 +
>  drivers/dma-buf/Kconfig   |  11 +
>  drivers/dma-buf/Makefile  |   1 +
>  drivers/dma-buf/sync_file.c   | 394 
> ++
>  drivers/staging/android/Kconfig   |   1 +
>  drivers/staging/android/sync.c| 362 ---
>  drivers/staging/android/sync.h|  91 +--
>  drivers/staging/android/sync_debug.c  |   5 +-
>  drivers/staging/android/uapi/sync.h   | 100 
>  include/linux/sync_file.h |  57 +
>  include/uapi/linux/sync_file.h| 100 
>  13 files changed, 638 insertions(+), 553 deletions(-)
>  create mode 100644 Documentation/dma-buf-sync_file.txt
>  create mode 100644 drivers/dma-buf/Kconfig
>  create mode 100644 drivers/dma-buf/sync_file.c
>  delete mode 100644 drivers/staging/android/uapi/sync.h
>  create mode 100644 include/linux/sync_file.h
>  create mode 100644 include/uapi/linux/sync_file.h
> 
> -- 
> 2.5.5
> 

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


[PATCH 12/12] Documentation: add Sync File doc

2016-04-27 Thread Daniel Vetter
On Wed, Apr 27, 2016 at 01:27:19PM -0300, Gustavo Padovan wrote:
> From: Gustavo Padovan 
> 
> Add sync_file documentation on dma-buf-sync_file.txt
> ---
>  Documentation/dma-buf-sync_file.txt | 65 
> +
>  1 file changed, 65 insertions(+)
>  create mode 100644 Documentation/dma-buf-sync_file.txt
> 
> diff --git a/Documentation/dma-buf-sync_file.txt 
> b/Documentation/dma-buf-sync_file.txt
> new file mode 100644
> index 000..aa7320f
> --- /dev/null
> +++ b/Documentation/dma-buf-sync_file.txt
> @@ -0,0 +1,65 @@
> +  DMA Buffer Sync File API Guide
> +  ~~

Strictly speaking you can use sync_file fences without dma-bufs. E.g. when
your gpu uses something like shared virtual memory and directly access the
userspace address space there's not buffer handles involved, but you still
might want to pass around fences between drivers and/or processes. So
please drop dma-buf from the filename and everything else in here. It's ok
to mention that this is used together with buffers/processing, just as an
example.

> +
> + Gustavo Padovan
> +   
> +
> +This document serves as a guide for device drivers writers on what is the
> +dma-buf sync_file API, and how drivers can support it. Sync file is the

"... on what the sync_file API _is_, ..."

> +carrier of the fences(struct fence) that needs to synchronized between 
> drivers.

"... between drivers or across process boundaries."

Android wants/needs both.

> +
> +The sync_file API is meant to be used to send and receive fence information
> +to/from userspace. It enables userspace to do explicit fencing, where instead
> +of attaching a fence to the buffer a Producer driver (such as GPU or V4L

_p_roducer

"(such as _a_ GPU ...)"

> +driver) it sends the fence related to the buffer to userspace. The fence then

s/it//

> +can be sent to the Consumer (DRM driver for example), that will not use the

_c_onsumer

> +buffer for anything before the fence signals, i.e., the driver that issued 
> the
> +fence is not using/processing the buffer anymore, so it signals that the 
> buffer
> +is ready to use. And vice-versa for the Consumer -> Producer part of the 
> cycle.

A bit a run-on sentence above. Might want to split it.

> +Sync files allows userspace awareness on the DMA buffer sharing 
> synchronization
> +between drivers.
> +
> +Sync file was originally added in the Android kernel but current Linux 
> Desktop
> +can benefit a lot from it.
> +
> +in-fences and out-fences
> +
> +
> +Sync files can go either to or from userspace. When a sync_file is sent from
> +the driver to userspace we call the fences it contains 'out-fences'. They are
> +related to a buffer that the driver is processing or is going to process, so
> +the driver create out-fences to be able to notify, through fence_signal(), 
> when

"... create_s_ _an_ out fence ..."

> +it has finished using (or processing) that buffer. Out-fences are fences that
> +the driver creates.
> +
> +On the other hand if the driver receives fence(s) through a sync_file from
> +userspace we call these fence(s) 'in-fences'. Receiveing in-fences means that
> +we need to wait for the fence(s) to signal before using any buffer related to
> +the in-fences.
> +
> +Creating Sync Files
> +---
> +
> +When a driver needs to send an out-fence userspace it creates a sync_file.
> +
> +Interface:
> + struct sync_file *sync_file_create(const char *name, struct fence 
> *fence);
> +
> +The caller pass the name and the out-fence and gets back the sync_file. That 
> is
> +just the first step, next it needs to install an fd on sync_file->file. So it
> +gets an fd:
> +
> + fd = get_unused_fd_flags(O_CLOEXEC);
> +
> +and installs it on sync_file->file:
> +
> + fd_install(fd, sync_file->file);
> +
> +The sync_file fd now can be sent to userspace.
> +
> +If the creation process fail, or the sync_file needs to be released by any
> +other reason fput(sync_file->file) should be used.

With the above nitpicks fixed:

Reviewed-by: Daniel Vetter 
> +
> +References:
> +[1] struct sync_file in include/linux/sync_file.h
> +[2] All interfaces mentioned above defined in include/linux/sync_file.h
> -- 
> 2.5.5
> 

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


i915: screen flicker

2016-04-27 Thread Mihai Donțu
On Wed, 27 Apr 2016 20:36:13 +0300 Mihai Donțu wrote:
> On Wed, 27 Apr 2016 08:28:20 -0700 Rodrigo Vivi wrote:
> > Hi Mihai,
> > 
> > What platform do you have? HSW or BDW?  
> 
> I have an i7, Haswell CPU.
> 
> > If you don't know please provide lspci -nn  
> 
> I have attached the output of lspci, just in case. :-)
> 
> > What happens if you boot with i915.enable_psr=2?  
> 
> I'll try now.

The behaviour is worse now. The screen flickers every couple of seconds.

> > In case it helps, could you please boot with default
> > i915.enable_psr=-1 appying this patch to your kernel to know what your
> > VBT recommends:
> > diff --git a/drivers/gpu/drm/i915/intel_psr.c
> > b/drivers/gpu/drm/i915/intel_psr.c
> > index c3abae4..68bc405 100644
> > --- a/drivers/gpu/drm/i915/intel_psr.c
> > +++ b/drivers/gpu/drm/i915/intel_psr.c
> > @@ -798,6 +798,8 @@ void intel_psr_init(struct drm_device *dev)
> > /* For new platforms let's respect VBT back again */
> > dev_priv->psr.link_standby =
> > dev_priv->vbt.psr.full_link;
> > 
> > +   DRM_ERROR("PSR: VBT recommends link_standby %d, using %d\n",
> > dev_priv->vbt.psr.full_link, dev_priv->psr.link_standby);
> > +
> > /* Override link_standby x link_off defaults */
> > if (i915.enable_psr == 2 && !dev_priv->psr.link_standby) {
> > DRM_DEBUG_KMS("PSR: Forcing link standby\n");
> >   
> 
> I applied your patch and booted with enable_psr=-1
> 
> [0.763651] [drm:intel_psr_init] *ERROR* PSR: VBT recommends link_standby 
> 0, using 0

-- 
Mihai Donțu


i915: screen flicker

2016-04-27 Thread Mihai Donțu
On Wed, 27 Apr 2016 08:28:20 -0700 Rodrigo Vivi wrote:
> Hi Mihai,
> 
> What platform do you have? HSW or BDW?

I have an i7, Haswell CPU.

> If you don't know please provide lspci -nn

I have attached the output of lspci, just in case. :-)

> What happens if you boot with i915.enable_psr=2?

I'll try now.

> In case it helps, could you please boot with default
> i915.enable_psr=-1 appying this patch to your kernel to know what your
> VBT recommends:
> diff --git a/drivers/gpu/drm/i915/intel_psr.c
> b/drivers/gpu/drm/i915/intel_psr.c
> index c3abae4..68bc405 100644
> --- a/drivers/gpu/drm/i915/intel_psr.c
> +++ b/drivers/gpu/drm/i915/intel_psr.c
> @@ -798,6 +798,8 @@ void intel_psr_init(struct drm_device *dev)
> /* For new platforms let's respect VBT back again */
> dev_priv->psr.link_standby =
> dev_priv->vbt.psr.full_link;
> 
> +   DRM_ERROR("PSR: VBT recommends link_standby %d, using %d\n",
> dev_priv->vbt.psr.full_link, dev_priv->psr.link_standby);
> +
> /* Override link_standby x link_off defaults */
> if (i915.enable_psr == 2 && !dev_priv->psr.link_standby) {
> DRM_DEBUG_KMS("PSR: Forcing link standby\n");
> 

I applied your patch and booted with enable_psr=-1

[0.763651] [drm:intel_psr_init] *ERROR* PSR: VBT recommends link_standby 0, 
using 0

-- 
Mihai Donțu
-- next part --
An embedded and charset-unspecified text was scrubbed...
Name: lspci.txt
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160427/e594bf28/attachment.txt>


[PATCH] drm/omap: check plane size

2016-04-27 Thread Ville Syrjälä
On Wed, Apr 27, 2016 at 06:30:19PM +0300, Laurent Pinchart wrote:
> Hi Tomi,
> 
> (CC'ing Daniel)
> 
> Thank you for the patch.
> 
> On Tuesday 26 Apr 2016 13:16:42 Tomi Valkeinen wrote:
> > 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 
> 
> I don't think it makes sense to have an empty source or destination rectangle 
> for any driver, not just omapdrm. Shouldn't this check be added to 
> drm_atomic_plane_check() instead ?

It's perfectly legal. Just means you're supposed to turn the plane off.

> 
> > ---
> >  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;
> 
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel OTC


[PATCH v3 7/7] drm/udl: Use drm_fb_helper deferred_io support

2016-04-27 Thread Noralf Trønnes
Use the fbdev deferred io support in drm_fb_helper.
The (struct fb_ops *)->fb_{fillrect,copyarea,imageblit} functions will
now schedule a worker instead of being flushed directly like it was
previously (recorded when in atomic).

This patch has only been compile tested.

Signed-off-by: Noralf Trønnes 
Reviewed-by: Daniel Vetter 
---

Changes since v1:
- No need to enable deferred_io by default since drm_fb_helper uses
  a dedicated worker for flushing

 drivers/gpu/drm/udl/udl_drv.h |   2 -
 drivers/gpu/drm/udl/udl_fb.c  | 140 ++
 2 files changed, 6 insertions(+), 136 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index 4a064ef..0b03d34 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -81,8 +81,6 @@ struct udl_framebuffer {
struct drm_framebuffer base;
struct udl_gem_object *obj;
bool active_16; /* active on the 16-bit channel */
-   int x1, y1, x2, y2; /* dirty rect */
-   spinlock_t dirty_lock;
 };

 #define to_udl_fb(x) container_of(x, struct udl_framebuffer, base)
diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
index a52de2f..4a9b432 100644
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ b/drivers/gpu/drm/udl/udl_fb.c
@@ -77,68 +77,6 @@ static uint16_t rgb16(uint32_t col)
 }
 #endif

-/*
- * NOTE: fb_defio.c is holding info->fbdefio.mutex
- *   Touching ANY framebuffer memory that triggers a page fault
- *   in fb_defio will cause a deadlock, when it also tries to
- *   grab the same mutex.
- */
-static void udlfb_dpy_deferred_io(struct fb_info *info,
- struct list_head *pagelist)
-{
-   struct page *cur;
-   struct fb_deferred_io *fbdefio = info->fbdefio;
-   struct udl_fbdev *ufbdev = info->par;
-   struct drm_device *dev = ufbdev->ufb.base.dev;
-   struct udl_device *udl = dev->dev_private;
-   struct urb *urb;
-   char *cmd;
-   cycles_t start_cycles, end_cycles;
-   int bytes_sent = 0;
-   int bytes_identical = 0;
-   int bytes_rendered = 0;
-
-   if (!fb_defio)
-   return;
-
-   start_cycles = get_cycles();
-
-   urb = udl_get_urb(dev);
-   if (!urb)
-   return;
-
-   cmd = urb->transfer_buffer;
-
-   /* walk the written page list and render each to device */
-   list_for_each_entry(cur, >pagelist, lru) {
-
-   if (udl_render_hline(dev, (ufbdev->ufb.base.bits_per_pixel / 8),
-, (char *) info->fix.smem_start,
-, cur->index << PAGE_SHIFT,
-cur->index << PAGE_SHIFT,
-PAGE_SIZE, _identical, _sent))
-   goto error;
-   bytes_rendered += PAGE_SIZE;
-   }
-
-   if (cmd > (char *) urb->transfer_buffer) {
-   /* Send partial buffer remaining before exiting */
-   int len = cmd - (char *) urb->transfer_buffer;
-   udl_submit_urb(dev, urb, len);
-   bytes_sent += len;
-   } else
-   udl_urb_completion(urb);
-
-error:
-   atomic_add(bytes_sent, >bytes_sent);
-   atomic_add(bytes_identical, >bytes_identical);
-   atomic_add(bytes_rendered, >bytes_rendered);
-   end_cycles = get_cycles();
-   atomic_add(((unsigned int) ((end_cycles - start_cycles)
-   >> 10)), /* Kcycles */
-  >cpu_kcycles_used);
-}
-
 int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
  int width, int height)
 {
@@ -152,9 +90,6 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int 
y,
struct urb *urb;
int aligned_x;
int bpp = (fb->base.bits_per_pixel / 8);
-   int x2, y2;
-   bool store_for_later = false;
-   unsigned long flags;

if (!fb->active_16)
return 0;
@@ -180,38 +115,6 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, 
int y,
(y + height > fb->base.height))
return -EINVAL;

-   /* if we are in atomic just store the info
-  can't test inside spin lock */
-   if (in_atomic())
-   store_for_later = true;
-
-   x2 = x + width - 1;
-   y2 = y + height - 1;
-
-   spin_lock_irqsave(>dirty_lock, flags);
-
-   if (fb->y1 < y)
-   y = fb->y1;
-   if (fb->y2 > y2)
-   y2 = fb->y2;
-   if (fb->x1 < x)
-   x = fb->x1;
-   if (fb->x2 > x2)
-   x2 = fb->x2;
-
-   if (store_for_later) {
-   fb->x1 = x;
-   fb->x2 = x2;
-   fb->y1 = y;
-   fb->y2 = y2;
-   spin_unlock_irqrestore(>dirty_lock, flags);
-   return 0;
-   }
-
-   fb->x1 = fb->y1 = INT_MAX;
-   fb->x2 = fb->y2 = 0;
-
-   spin_unlock_irqrestore(>dirty_lock, flags);
  

[PATCH v3 6/7] drm/qxl: Use drm_fb_helper deferred_io support

2016-04-27 Thread Noralf Trønnes
Use the fbdev deferred io support in drm_fb_helper which mirrors the
one qxl has had.
This patch has only been compile tested.

Signed-off-by: Noralf Trønnes 
---

Changes since v2:
- The drm_clip_rect_{width/height} functions are dropped, so open code it

Changes since v1:
- Add FIXME about special dirty() callback for fbdev
- Remove note in commit message about deferred worker, drm_fb_helper
  is similar to qxl now.

 drivers/gpu/drm/qxl/qxl_display.c |   9 +-
 drivers/gpu/drm/qxl/qxl_drv.h |   7 +-
 drivers/gpu/drm/qxl/qxl_fb.c  | 223 ++
 drivers/gpu/drm/qxl/qxl_kms.c |   4 -
 4 files changed, 65 insertions(+), 178 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_display.c 
b/drivers/gpu/drm/qxl/qxl_display.c
index 030409a..9a03524 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -465,7 +465,7 @@ static const struct drm_crtc_funcs qxl_crtc_funcs = {
.page_flip = qxl_crtc_page_flip,
 };

-static void qxl_user_framebuffer_destroy(struct drm_framebuffer *fb)
+void qxl_user_framebuffer_destroy(struct drm_framebuffer *fb)
 {
struct qxl_framebuffer *qxl_fb = to_qxl_framebuffer(fb);

@@ -527,12 +527,13 @@ int
 qxl_framebuffer_init(struct drm_device *dev,
 struct qxl_framebuffer *qfb,
 const struct drm_mode_fb_cmd2 *mode_cmd,
-struct drm_gem_object *obj)
+struct drm_gem_object *obj,
+const struct drm_framebuffer_funcs *funcs)
 {
int ret;

qfb->obj = obj;
-   ret = drm_framebuffer_init(dev, >base, _fb_funcs);
+   ret = drm_framebuffer_init(dev, >base, funcs);
if (ret) {
qfb->obj = NULL;
return ret;
@@ -999,7 +1000,7 @@ qxl_user_framebuffer_create(struct drm_device *dev,
if (qxl_fb == NULL)
return NULL;

-   ret = qxl_framebuffer_init(dev, qxl_fb, mode_cmd, obj);
+   ret = qxl_framebuffer_init(dev, qxl_fb, mode_cmd, obj, _fb_funcs);
if (ret) {
kfree(qxl_fb);
drm_gem_object_unreference_unlocked(obj);
diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
index 3f3897e..3ad6604 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.h
+++ b/drivers/gpu/drm/qxl/qxl_drv.h
@@ -324,8 +324,6 @@ struct qxl_device {
struct workqueue_struct *gc_queue;
struct work_struct gc_work;

-   struct work_struct fb_work;
-
struct drm_property *hotplug_mode_update_property;
int monitors_config_width;
int monitors_config_height;
@@ -389,11 +387,13 @@ int qxl_get_handle_for_primary_fb(struct qxl_device *qdev,
 void qxl_fbdev_set_suspend(struct qxl_device *qdev, int state);

 /* qxl_display.c */
+void qxl_user_framebuffer_destroy(struct drm_framebuffer *fb);
 int
 qxl_framebuffer_init(struct drm_device *dev,
 struct qxl_framebuffer *rfb,
 const struct drm_mode_fb_cmd2 *mode_cmd,
-struct drm_gem_object *obj);
+struct drm_gem_object *obj,
+const struct drm_framebuffer_funcs *funcs);
 void qxl_display_read_client_monitors_config(struct qxl_device *qdev);
 void qxl_send_monitors_config(struct qxl_device *qdev);
 int qxl_create_monitors_object(struct qxl_device *qdev);
@@ -553,7 +553,6 @@ int qxl_irq_init(struct qxl_device *qdev);
 irqreturn_t qxl_irq_handler(int irq, void *arg);

 /* qxl_fb.c */
-int qxl_fb_init(struct qxl_device *qdev);
 bool qxl_fbdev_qobj_is_fb(struct qxl_device *qdev, struct qxl_bo *qobj);

 int qxl_debugfs_add_files(struct qxl_device *qdev,
diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c
index 3f7c543..739a08c 100644
--- a/drivers/gpu/drm/qxl/qxl_fb.c
+++ b/drivers/gpu/drm/qxl/qxl_fb.c
@@ -46,15 +46,6 @@ struct qxl_fbdev {
struct list_head delayed_ops;
void *shadow;
int size;
-
-   /* dirty memory logging */
-   struct {
-   spinlock_t lock;
-   unsigned x1;
-   unsigned y1;
-   unsigned x2;
-   unsigned y2;
-   } dirty;
 };

 static void qxl_fb_image_init(struct qxl_fb_image *qxl_fb_image,
@@ -82,169 +73,18 @@ static void qxl_fb_image_init(struct qxl_fb_image 
*qxl_fb_image,
}
 }

-static void qxl_fb_dirty_flush(struct fb_info *info)
-{
-   struct qxl_fbdev *qfbdev = info->par;
-   struct qxl_device *qdev = qfbdev->qdev;
-   struct qxl_fb_image qxl_fb_image;
-   struct fb_image *image = _fb_image.fb_image;
-   unsigned long flags;
-   u32 x1, x2, y1, y2;
-
-   /* TODO: hard coding 32 bpp */
-   int stride = qfbdev->qfb.base.pitches[0];
-
-   spin_lock_irqsave(>dirty.lock, flags);
-
-   x1 = qfbdev->dirty.x1;
-   x2 = qfbdev->dirty.x2;
-   y1 = qfbdev->dirty.y1;
-   y2 = qfbdev->dirty.y2;
-   qfbdev->dirty.x1 = 0;
-   qfbdev->dirty.x2 = 0;
-   

[PATCH v3 5/7] drm/fb-cma-helper: Add fb_deferred_io support

2016-04-27 Thread Noralf Trønnes
This adds fbdev deferred io support if CONFIG_FB_DEFERRED_IO is enabled.
The driver has to provide a (struct drm_framebuffer_funcs *)->dirty()
callback to get notification of fbdev framebuffer changes.
If the dirty() hook is set, then fb_deferred_io is set up automatically
by the helper.

Two functions have been added so that the driver can provide a dirty()
function:
- drm_fbdev_cma_init_with_funcs()
  This makes it possible for the driver to provided a custom
  (struct drm_fb_helper_funcs *)->fb_probe() function.
- drm_fbdev_cma_create_with_funcs()
  This is used by the .fb_probe hook to set a driver provided
  (struct drm_framebuffer_funcs *)->dirty() function.

Signed-off-by: Noralf Trønnes 
---

Changes since v2:
- FB_DEFERRED_IO is now always selected by DRM_KMS_FB_HELPER, ifdef removed

 drivers/gpu/drm/drm_fb_cma_helper.c | 178 +---
 include/drm/drm_fb_cma_helper.h |  14 +++
 2 files changed, 180 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c 
b/drivers/gpu/drm/drm_fb_cma_helper.c
index bb88e3d..086f600 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -25,6 +25,8 @@
 #include 
 #include 

+#define DEFAULT_FBDEFIO_DELAY_MS 50
+
 struct drm_fb_cma {
struct drm_framebuffer  fb;
struct drm_gem_cma_object   *obj[4];
@@ -35,6 +37,61 @@ struct drm_fbdev_cma {
struct drm_fb_cma   *fb;
 };

+/**
+ * DOC: framebuffer cma helper functions
+ *
+ * Provides helper functions for creating a cma (contiguous memory allocator)
+ * backed framebuffer.
+ *
+ * drm_fb_cma_create() is used in the
+ * (struct drm_mode_config_funcs *)->fb_create callback function to create the
+ * cma backed framebuffer.
+ *
+ * An fbdev framebuffer backed by cma is also available by calling
+ * drm_fbdev_cma_init(). drm_fbdev_cma_fini() tears it down.
+ * If CONFIG_FB_DEFERRED_IO is enabled and the callback
+ * (struct drm_framebuffer_funcs)->dirty is set, fb_deferred_io
+ * will be set up automatically. dirty() is called by
+ * drm_fb_helper_deferred_io() in process context (struct delayed_work).
+ *
+ * Example fbdev deferred io code:
+ *
+ * static int driver_fbdev_fb_dirty(struct drm_framebuffer *fb,
+ *  struct drm_file *file_priv,
+ *  unsigned flags, unsigned color,
+ *  struct drm_clip_rect *clips,
+ *  unsigned num_clips)
+ * {
+ * struct drm_gem_cma_object *cma = drm_fb_cma_get_gem_obj(fb, 0);
+ * ... push changes ...
+ * return 0;
+ * }
+ *
+ * static struct drm_framebuffer_funcs driver_fbdev_fb_funcs = {
+ * .destroy   = drm_fb_cma_destroy,
+ * .create_handle = drm_fb_cma_create_handle,
+ * .dirty = driver_fbdev_fb_dirty,
+ * };
+ *
+ * static int driver_fbdev_create(struct drm_fb_helper *helper,
+ * struct drm_fb_helper_surface_size *sizes)
+ * {
+ * return drm_fbdev_cma_create_with_funcs(helper, sizes,
+ *_fbdev_fb_funcs);
+ * }
+ *
+ * static const struct drm_fb_helper_funcs driver_fb_helper_funcs = {
+ * .fb_probe = driver_fbdev_create,
+ * };
+ *
+ * Initialize:
+ * fbdev = drm_fbdev_cma_init_with_funcs(dev, 16,
+ *   dev->mode_config.num_crtc,
+ *   dev->mode_config.num_connector,
+ *   _fb_helper_funcs);
+ *
+ */
+
 static inline struct drm_fbdev_cma *to_fbdev_cma(struct drm_fb_helper *helper)
 {
return container_of(helper, struct drm_fbdev_cma, fb_helper);
@@ -45,7 +102,7 @@ static inline struct drm_fb_cma *to_fb_cma(struct 
drm_framebuffer *fb)
return container_of(fb, struct drm_fb_cma, fb);
 }

-static void drm_fb_cma_destroy(struct drm_framebuffer *fb)
+void drm_fb_cma_destroy(struct drm_framebuffer *fb)
 {
struct drm_fb_cma *fb_cma = to_fb_cma(fb);
int i;
@@ -58,8 +115,9 @@ static void drm_fb_cma_destroy(struct drm_framebuffer *fb)
drm_framebuffer_cleanup(fb);
kfree(fb_cma);
 }
+EXPORT_SYMBOL(drm_fb_cma_destroy);

-static int drm_fb_cma_create_handle(struct drm_framebuffer *fb,
+int drm_fb_cma_create_handle(struct drm_framebuffer *fb,
struct drm_file *file_priv, unsigned int *handle)
 {
struct drm_fb_cma *fb_cma = to_fb_cma(fb);
@@ -67,6 +125,7 @@ static int drm_fb_cma_create_handle(struct drm_framebuffer 
*fb,
return drm_gem_handle_create(file_priv,
_cma->obj[0]->base, handle);
 }
+EXPORT_SYMBOL(drm_fb_cma_create_handle);

 static struct drm_framebuffer_funcs drm_fb_cma_funcs = {
.destroy= drm_fb_cma_destroy,
@@ -76,7 +135,7 @@ static struct drm_framebuffer_funcs drm_fb_cma_funcs = {
 static struct drm_fb_cma 

[PATCH v3 4/7] fbdev: fb_defio: Export fb_deferred_io_mmap

2016-04-27 Thread Noralf Trønnes
Export fb_deferred_io_mmap so drivers can change vma->vm_page_prot.
When the framebuffer memory is allocated using dma_alloc_writecombine()
instead of vmalloc(), I get cache syncing problems on ARM.
This solves it:

static int drm_fbdev_cma_deferred_io_mmap(struct fb_info *info,
  struct vm_area_struct *vma)
{
fb_deferred_io_mmap(info, vma);
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);

return 0;
}

Could this have been done in the core?
Drivers that don't set (struct fb_ops *)->fb_mmap, gets a call to
fb_pgprotect() at the end of the default fb_mmap implementation
(drivers/video/fbdev/core/fbmem.c). This is an architecture specific
function that on many platforms uses pgprot_writecombine(), but not on
all. And looking at some of the fb_mmap implementations, some of them
sets vm_page_prot to nocache for instance, so I think the safest bet is
to do this in the driver and not in the fbdev core. And we can't call
fb_pgprotect() from fb_deferred_io_mmap() either because we don't have
access to the file pointer that powerpc needs.

Signed-off-by: Noralf Trønnes 
---

Changes since v1:
- Expand commit message

 drivers/video/fbdev/core/fb_defio.c | 3 ++-
 include/linux/fb.h  | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/core/fb_defio.c 
b/drivers/video/fbdev/core/fb_defio.c
index 57721c7..74b5bca 100644
--- a/drivers/video/fbdev/core/fb_defio.c
+++ b/drivers/video/fbdev/core/fb_defio.c
@@ -164,7 +164,7 @@ static const struct address_space_operations 
fb_deferred_io_aops = {
.set_page_dirty = fb_deferred_io_set_page_dirty,
 };

-static int fb_deferred_io_mmap(struct fb_info *info, struct vm_area_struct 
*vma)
+int fb_deferred_io_mmap(struct fb_info *info, struct vm_area_struct *vma)
 {
vma->vm_ops = _deferred_io_vm_ops;
vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
@@ -173,6 +173,7 @@ static int fb_deferred_io_mmap(struct fb_info *info, struct 
vm_area_struct *vma)
vma->vm_private_data = info;
return 0;
 }
+EXPORT_SYMBOL(fb_deferred_io_mmap);

 /* workqueue callback */
 static void fb_deferred_io_work(struct work_struct *work)
diff --git a/include/linux/fb.h b/include/linux/fb.h
index dfe8835..a964d07 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -673,6 +673,7 @@ static inline void __fb_pad_aligned_buffer(u8 *dst, u32 
d_pitch,
 }

 /* drivers/video/fb_defio.c */
+int fb_deferred_io_mmap(struct fb_info *info, struct vm_area_struct *vma);
 extern void fb_deferred_io_init(struct fb_info *info);
 extern void fb_deferred_io_open(struct fb_info *info,
struct inode *inode,
--
2.2.2



[PATCH v3 3/7] drm/fb-helper: Add fb_deferred_io support

2016-04-27 Thread Noralf Trønnes
This adds deferred io support to drm_fb_helper.
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 v2:
- FB_DEFERRED_IO is now always selected by DRM_KMS_FB_HELPER, ifdef removed
- The drm_clip_rect utility functions are dropped, so open code it
- docs: use & to denote structs

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/Kconfig |   1 +
 drivers/gpu/drm/drm_fb_helper.c | 109 +++-
 include/drm/drm_fb_helper.h |  15 ++
 3 files changed, 124 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 9e4f2f1..8e6f34b 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -52,6 +52,7 @@ config DRM_KMS_FB_HELPER
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
select FB_CFB_IMAGEBLIT
+   select FB_DEFERRED_IO
help
  FBDEV helpers for KMS drivers.

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 855108e..5112b5d 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -48,6 +48,8 @@ MODULE_PARM_DESC(fbdev_emulation,

 static LIST_HEAD(kernel_fb_helper_list);

+static void drm_fb_helper_dirty_init(struct drm_fb_helper *helper);
+
 /**
  * DOC: fbdev helpers
  *
@@ -84,6 +86,15 @@ 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 _framebuffer_funcs ->dirty is
+ * set, the drm_fb_helper_{cfb,sys}_{write,fillrect,copyarea,imageblit}
+ * functions will accumulate changes and schedule _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.
  */

 /**
@@ -650,6 +661,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(>kernel_fb_list);
+   drm_fb_helper_dirty_init(helper);
helper->funcs = funcs;
helper->dev = dev;
 }
@@ -834,6 +846,82 @@ void drm_fb_helper_unlink_fbi(struct drm_fb_helper 
*fb_helper)
 }
 EXPORT_SYMBOL(drm_fb_helper_unlink_fbi);

+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 = >dirty_clip;
+   struct drm_clip_rect clip_copy;
+   unsigned long flags;
+
+   spin_lock_irqsave(>dirty_lock, flags);
+   clip_copy = *clip;
+   clip->x1 = clip->y1 = ~0;
+   clip->x2 = clip->y2 = 0;
+   spin_unlock_irqrestore(>dirty_lock, flags);
+
+   helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, _copy, 1);
+}
+
+static void drm_fb_helper_dirty_init(struct drm_fb_helper *helper)
+{
+   spin_lock_init(>dirty_lock);
+   INIT_WORK(>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 = >dirty_clip;
+   unsigned long flags;
+
+   if (!helper->fb->funcs->dirty)
+   return;
+
+   spin_lock_irqsave(>dirty_lock, flags);
+   clip->x1 = min_t(u32, clip->x1, x);
+   clip->y1 = min_t(u32, clip->y1, y);
+   clip->x2 = max_t(u32, clip->x2, x + width);
+   clip->y2 = max_t(u32, clip->y2, y + height);
+   spin_unlock_irqrestore(>dirty_lock, flags);
+
+   schedule_work(>dirty_work);
+}
+
+/**
+ * drm_fb_helper_deferred_io() - fbdev deferred_io callback function
+ * @info: fb_info struct pointer
+ * @pagelist: list of dirty mmap framebuffer pages
+ *
+ * This function is used as the _deferred_io ->deferred_io
+ * callback function for flushing the fbdev mmap writes.
+ */
+void drm_fb_helper_deferred_io(struct fb_info *info,
+  struct list_head *pagelist)
+{
+   unsigned long start, end, min, max;
+   struct page *page;
+   u32 y1, y2;
+
+   min = ULONG_MAX;
+   max = 0;
+   list_for_each_entry(page, pagelist, lru) {
+   start = page->index << PAGE_SHIFT;
+

[PATCH v3 2/7] drm/qxl: Change drm_fb_helper_sys_*() calls to sys_*()

2016-04-27 Thread Noralf Trønnes
Now that drm_fb_helper gets deferred io support, the
drm_fb_helper_sys_{fillrect,copyarea,imageblit} functions will schedule
a worker that will call the (struct drm_framebuffer *)->funcs->dirty()
function. This will break this driver so use the
sys_{fillrect,copyarea,imageblit} functions directly.

Signed-off-by: Noralf Trønnes 
Reviewed-by: Daniel Vetter 
---
 drivers/gpu/drm/qxl/qxl_fb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c
index bb7ce07..3f7c543 100644
--- a/drivers/gpu/drm/qxl/qxl_fb.c
+++ b/drivers/gpu/drm/qxl/qxl_fb.c
@@ -199,7 +199,7 @@ static void qxl_fb_fillrect(struct fb_info *info,
 {
struct qxl_fbdev *qfbdev = info->par;

-   drm_fb_helper_sys_fillrect(info, rect);
+   sys_fillrect(info, rect);
qxl_dirty_update(qfbdev, rect->dx, rect->dy, rect->width,
 rect->height);
 }
@@ -209,7 +209,7 @@ static void qxl_fb_copyarea(struct fb_info *info,
 {
struct qxl_fbdev *qfbdev = info->par;

-   drm_fb_helper_sys_copyarea(info, area);
+   sys_copyarea(info, area);
qxl_dirty_update(qfbdev, area->dx, area->dy, area->width,
 area->height);
 }
@@ -219,7 +219,7 @@ static void qxl_fb_imageblit(struct fb_info *info,
 {
struct qxl_fbdev *qfbdev = info->par;

-   drm_fb_helper_sys_imageblit(info, image);
+   sys_imageblit(info, image);
qxl_dirty_update(qfbdev, image->dx, image->dy, image->width,
 image->height);
 }
-- 
2.2.2



[PATCH v3 1/7] drm/udl: Change drm_fb_helper_sys_*() calls to sys_*()

2016-04-27 Thread Noralf Trønnes
Now that drm_fb_helper gets deferred io support, the
drm_fb_helper_sys_{fillrect,copyarea,imageblit} functions will schedule
a worker that will call the (struct drm_framebuffer *)->funcs->dirty()
function. This will break this driver so use the
sys_{fillrect,copyarea,imageblit} functions directly.

Signed-off-by: Noralf Trønnes 
Reviewed-by: Daniel Vetter 
---
 drivers/gpu/drm/udl/udl_fb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
index fd1eb9d..a52de2f 100644
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ b/drivers/gpu/drm/udl/udl_fb.c
@@ -287,7 +287,7 @@ static void udl_fb_fillrect(struct fb_info *info, const 
struct fb_fillrect *rect
 {
struct udl_fbdev *ufbdev = info->par;

-   drm_fb_helper_sys_fillrect(info, rect);
+   sys_fillrect(info, rect);

udl_handle_damage(>ufb, rect->dx, rect->dy, rect->width,
  rect->height);
@@ -297,7 +297,7 @@ static void udl_fb_copyarea(struct fb_info *info, const 
struct fb_copyarea *regi
 {
struct udl_fbdev *ufbdev = info->par;

-   drm_fb_helper_sys_copyarea(info, region);
+   sys_copyarea(info, region);

udl_handle_damage(>ufb, region->dx, region->dy, region->width,
  region->height);
@@ -307,7 +307,7 @@ static void udl_fb_imageblit(struct fb_info *info, const 
struct fb_image *image)
 {
struct udl_fbdev *ufbdev = info->par;

-   drm_fb_helper_sys_imageblit(info, image);
+   sys_imageblit(info, image);

udl_handle_damage(>ufb, image->dx, image->dy, image->width,
  image->height);
-- 
2.2.2



[PATCH v3 0/7] drm: Add fbdev deferred io support to helpers

2016-04-27 Thread Noralf Trønnes
This patchset adds fbdev deferred io support to drm_fb_helper and
drm_fb_cma_helper.

It channels fbdev mmap and fb_{write,fillrect,copyarea,imageblit} damage
through the (struct drm_framebuffer_funcs)->dirty callback on the
fb_helper framebuffer which will always run in process context.

I have also added patches that converts qxl and udl to use this
deferred io support. I have only compile tested it, no functional testing.
I know that qxl is purely a software thing so I could actually test it, but
I have never used qemu so I'm not keen on spending a lot of time on that.

This was originally part of the tinydrm patchset.

Changes since v2:
- drm/rect: Add some drm_clip_rect utility functions
  - This patch is dropped
- drm/fb-helper: Add fb_deferred_io support
  - FB_DEFERRED_IO is now always selected by DRM_KMS_FB_HELPER, ifdef removed
  - The drm_clip_rect utility functions are dropped, so open code it
  - docs: use & to denote structs
- drm/qxl: Use drm_fb_helper deferred_io support
  - The drm_clip_rect_{width/height} functions are dropped, so open code it

Changes since v1:
- drm/fb-helper: Add fb_deferred_io support
  - Use a dedicated worker to run the framebuffer flushing like qxl does
  - Add parameter descriptions to drm_fb_helper_deferred_io
- fbdev: fb_defio: Export fb_deferred_io_mmap
  - Expand commit message
- drm/qxl: Use drm_fb_helper deferred_io support
  - Add FIXME about special dirty() callback for fbdev
  - Remove note in commit message about deferred worker, drm_fb_helper
is similar to qxl now.
- drm/udl: Use drm_fb_helper deferred_io support
  - No need to enable deferred_io by default since drm_fb_helper uses
a dedicated worker for flushing

Changes since RFC:
- Fix drm_clip_rect use to be exclusive on x2/y2
- Put drm_clip_rect functions in drm_rect.{h,c}
- Take into account that (struct fb_ops *)->fb_{write,...}() can be called
  from atomic context (spin_lock_irqsave)
- Export fb_deferred_io_mmap()
- Add some more documentation
- Add qxl and udl patches

Noralf Trønnes (7):
  drm/udl: Change drm_fb_helper_sys_*() calls to sys_*()
  drm/qxl: Change drm_fb_helper_sys_*() calls to sys_*()
  drm/fb-helper: Add fb_deferred_io support
  fbdev: fb_defio: Export fb_deferred_io_mmap
  drm/fb-cma-helper: Add fb_deferred_io support
  drm/qxl: Use drm_fb_helper deferred_io support
  drm/udl: Use drm_fb_helper deferred_io support

 drivers/gpu/drm/Kconfig |   1 +
 drivers/gpu/drm/drm_fb_cma_helper.c | 178 ++--
 drivers/gpu/drm/drm_fb_helper.c | 109 +-
 drivers/gpu/drm/qxl/qxl_display.c   |   9 +-
 drivers/gpu/drm/qxl/qxl_drv.h   |   7 +-
 drivers/gpu/drm/qxl/qxl_fb.c| 223 +---
 drivers/gpu/drm/qxl/qxl_kms.c   |   4 -
 drivers/gpu/drm/udl/udl_drv.h   |   2 -
 drivers/gpu/drm/udl/udl_fb.c| 140 +-
 drivers/video/fbdev/core/fb_defio.c |   3 +-
 include/drm/drm_fb_cma_helper.h |  14 +++
 include/drm/drm_fb_helper.h |  15 +++
 include/linux/fb.h  |   1 +
 13 files changed, 378 insertions(+), 328 deletions(-)

--
2.2.2



[PATCH v15 8/8] memory: mtk-smi: export mtk_smi_larb_get/put

2016-04-27 Thread Matthias Brugger


On 27/04/16 17:05, Philipp Zabel wrote:
> To allow building mediatek-drm.ko as a module, the
> mtk_smi_larb_get and mtk_smi_larb_put symbols have
> to be exported.
>
> Signed-off-by: Philipp Zabel 

Signed-off-by: Matthias Brugger 

> ---
>   drivers/memory/mtk-smi.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c
> index 089091f..f6b5757 100644
> --- a/drivers/memory/mtk-smi.c
> +++ b/drivers/memory/mtk-smi.c
> @@ -91,6 +91,7 @@ int mtk_smi_larb_get(struct device *larbdev)
>
>   return 0;
>   }
> +EXPORT_SYMBOL_GPL(mtk_smi_larb_get);
>
>   void mtk_smi_larb_put(struct device *larbdev)
>   {
> @@ -106,6 +107,7 @@ void mtk_smi_larb_put(struct device *larbdev)
>   mtk_smi_disable(>smi);
>   mtk_smi_disable(common);
>   }
> +EXPORT_SYMBOL_GPL(mtk_smi_larb_put);
>
>   static int
>   mtk_smi_larb_bind(struct device *dev, struct device *master, void *data)
>


[PATCH 2/2] drm/vmwgfx: Report vmwgfx version to vmware.log

2016-04-27 Thread Sinclair Yeh
When tracking down a customer issue, it is useful to know exactly
which version of the vmwgfx they are using.  Since vmware.log is
often the only available debug log, report vmwgfx version in there.

Signed-off-by: Sinclair Yeh 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/.gitignore   |  2 ++
 drivers/gpu/drm/vmwgfx/Makefile |  7 ++-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 20 +++-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h |  6 ++
 4 files changed, 33 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/vmwgfx/.gitignore

diff --git a/drivers/gpu/drm/vmwgfx/.gitignore 
b/drivers/gpu/drm/vmwgfx/.gitignore
new file mode 100644
index 000..7193109
--- /dev/null
+++ b/drivers/gpu/drm/vmwgfx/.gitignore
@@ -0,0 +1,2 @@
+vmwgfx_version.h
+
diff --git a/drivers/gpu/drm/vmwgfx/Makefile b/drivers/gpu/drm/vmwgfx/Makefile
index d281575..fd6f47f 100644
--- a/drivers/gpu/drm/vmwgfx/Makefile
+++ b/drivers/gpu/drm/vmwgfx/Makefile
@@ -8,6 +8,11 @@ vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_kms.o 
vmwgfx_drv.o \
vmwgfx_fence.o vmwgfx_dmabuf.o vmwgfx_scrn.o vmwgfx_context.o \
vmwgfx_surface.o vmwgfx_prime.o vmwgfx_mob.o vmwgfx_shader.o \
vmwgfx_cmdbuf_res.o vmwgfx_cmdbuf.o vmwgfx_stdu.o \
-   vmwgfx_cotable.o vmwgfx_so.o vmwgfx_binding.o
+   vmwgfx_cotable.o vmwgfx_so.o vmwgfx_binding.o vmwgfx_msg.o
+
+$(obj)/vmwgfx_drv.o: $(src)/vmwgfx_version.h
+
+$(src)/vmwgfx_version.h:
+   @echo "#define VMWGFX_GIT_VERSION \""`git rev-parse --short HEAD`"\"" > 
$(src)/vmwgfx_version.h

 obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index e7335a48..b37f388 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -1,6 +1,6 @@
 /**
  *
- * Copyright © 2009-2015 VMware, Inc., Palo Alto, CA., USA
+ * Copyright © 2009-2016 VMware, Inc., Palo Alto, CA., USA
  * All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include "vmwgfx_version.h"

 #define VMWGFX_DRIVER_NAME "vmwgfx"
 #define VMWGFX_DRIVER_DESC "Linux drm driver for VMware graphics devices"
@@ -44,6 +45,12 @@
 #define VMW_MIN_INITIAL_WIDTH 800
 #define VMW_MIN_INITIAL_HEIGHT 600

+#ifndef VMWGFX_GIT_VERSION
+#define VMWGFX_GIT_VERSION "Unknown"
+#endif
+
+#define VMWGFX_REPO "In Tree"
+

 /**
  * Fully encoded drm commands. Might move to vmw_drm.h
@@ -613,6 +620,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned 
long chipset)
uint32_t svga_id;
enum vmw_res_type i;
bool refuse_dma = false;
+   char host_log[100] = {0};

dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
if (unlikely(dev_priv == NULL)) {
@@ -873,6 +881,16 @@ static int vmw_driver_load(struct drm_device *dev, 
unsigned long chipset)

DRM_INFO("DX: %s\n", dev_priv->has_dx ? "yes." : "no.");

+   snprintf(host_log, sizeof(host_log), "vmwgfx: %s-%s",
+   VMWGFX_REPO, VMWGFX_GIT_VERSION);
+   vmw_host_log(host_log);
+
+   memset(host_log, 0, sizeof(host_log));
+   snprintf(host_log, sizeof(host_log), "vmwgfx: Module Version: %d.%d.%d",
+   VMWGFX_DRIVER_MAJOR, VMWGFX_DRIVER_MINOR,
+   VMWGFX_DRIVER_PATCHLEVEL);
+   vmw_host_log(host_log);
+
if (dev_priv->enable_fb) {
vmw_fifo_resource_inc(dev_priv);
vmw_svga_enable(dev_priv);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 019a6ca..6715d4a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -1234,4 +1234,10 @@ static inline void vmw_mmio_write(u32 value, u32 *addr)
 {
WRITE_ONCE(*addr, value);
 }
+
+/**
+ * Add vmw_msg module function
+ */
+extern int vmw_host_log(const char *log);
+
 #endif
-- 
1.9.1



[PATCH 1/2] drm/vmwgfx: Add VMWare host messaging capability

2016-04-27 Thread Sinclair Yeh
This patch adds capabilities for a VMWare guest to send and
receive messages from the host, and adds functions to sending log
messages to vmware.log and to request device settings that aren't
available through the virtual hardware, e.g. certain settings in
the VMX file.

Signed-off-by: Sinclair Yeh 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 418 
 drivers/gpu/drm/vmwgfx/vmwgfx_msg.h | 192 +
 2 files changed, 610 insertions(+)
 create mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
 create mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_msg.h

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
new file mode 100644
index 000..9c2bb21
--- /dev/null
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
@@ -0,0 +1,418 @@
+/*
+ * Copyright © 2016 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+
+#include 
+#include 
+#include 
+#include 
+#include "drmP.h"
+#include "vmwgfx_msg.h"
+
+
+#define MESSAGE_STATUS_SUCCESS  0x0001
+#define MESSAGE_STATUS_DORECV   0x0002
+#define MESSAGE_STATUS_CPT  0x0010
+#define MESSAGE_STATUS_HB   0x0080
+
+#define RPCI_PROTOCOL_NUM   0x49435052
+#define GUESTMSG_FLAG_COOKIE0x8000
+
+#define RETRIES 3
+
+#define VMW_HYPERVISOR_MAGIC0x564D5868
+#define VMW_HYPERVISOR_PORT 0x5658
+#define VMW_HYPERVISOR_HB_PORT  0x5659
+
+#define VMW_PORT_CMD_MSG30
+#define VMW_PORT_CMD_HB_MSG 0
+#define VMW_PORT_CMD_OPEN_CHANNEL  (MSG_TYPE_OPEN << 16 | VMW_PORT_CMD_MSG)
+#define VMW_PORT_CMD_CLOSE_CHANNEL (MSG_TYPE_CLOSE << 16 | VMW_PORT_CMD_MSG)
+#define VMW_PORT_CMD_SENDSIZE   (MSG_TYPE_SENDSIZE << 16 | VMW_PORT_CMD_MSG)
+#define VMW_PORT_CMD_RECVSIZE   (MSG_TYPE_RECVSIZE << 16 | VMW_PORT_CMD_MSG)
+#define VMW_PORT_CMD_RECVSTATUS (MSG_TYPE_RECVSTATUS << 16 | VMW_PORT_CMD_MSG)
+
+#define HIGH_WORD(X) ((X & 0x) >> 16)
+
+static u32 vmw_msg_enabled = 1;
+
+enum rpc_msg_type {
+   MSG_TYPE_OPEN,
+   MSG_TYPE_SENDSIZE,
+   MSG_TYPE_SENDPAYLOAD,
+   MSG_TYPE_RECVSIZE,
+   MSG_TYPE_RECVPAYLOAD,
+   MSG_TYPE_RECVSTATUS,
+   MSG_TYPE_CLOSE,
+};
+
+struct rpc_channel {
+   u16 channel_id;
+   u32 cookie_high;
+   u32 cookie_low;
+};
+
+
+
+/**
+ * vmw_open_channel
+ *
+ * @channel: RPC channel
+ * @protocol:
+ *
+ * Returns: 0 on success
+ */
+static int vmw_open_channel(struct rpc_channel *channel, unsigned protocol)
+{
+   unsigned long eax, ebx, ecx, edx, si = 0, di = 0;
+
+   VMW_PORT(VMW_PORT_CMD_OPEN_CHANNEL,
+   (protocol | GUESTMSG_FLAG_COOKIE), si, di,
+   VMW_HYPERVISOR_PORT,
+   VMW_HYPERVISOR_MAGIC,
+   eax, ebx, ecx, edx, si, di);
+
+   if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0)
+   return -EINVAL;
+
+   channel->channel_id  = HIGH_WORD(edx);
+   channel->cookie_high = si;
+   channel->cookie_low  = di;
+
+   return 0;
+}
+
+
+
+/**
+ * vmw_close_channel
+ *
+ * @channel: RPC channel
+ *
+ * Returns: 0 on success
+ */
+static int vmw_close_channel(struct rpc_channel *channel)
+{
+   unsigned long eax, ebx, ecx, edx, si, di;
+
+   /* Set up additional parameters */
+   si  = channel->cookie_high;
+   di  = channel->cookie_low;
+
+   VMW_PORT(VMW_PORT_CMD_CLOSE_CHANNEL,
+   0, si, di,
+   (VMW_HYPERVISOR_PORT | (channel->channel_id << 16)),
+   VMW_HYPERVISOR_MAGIC,
+   eax, ebx, ecx, edx, si, di);
+
+   if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0)
+   return -EINVAL;
+
+   return 0;
+}
+
+
+
+/**
+ * vmw_send_msg: Sends a message to the host
+ *
+ * @channel: RPC channel
+ * @logmsg: NULL terminated string
+ *
+ * Returns: 0 on success
+ */

[Bug 86351] HDMI audio garbled output on Radeon R9 280X

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

haakobja at gmail.com changed:

   What|Removed |Added

 CC||haakobja at gmail.com

--- Comment #25 from haakobja at gmail.com ---
I'm currently experiencing the same issue using a Radeon R9 270X. I've tried
some of the tips discussed in the Arch Linux forums
(https://bbs.archlinux.org/viewtopic.php?id=181764), but I've not been able to
get it to work.

If I remember correctly, the driver bundled with the Radeon Catalyst-driver
fixed the issue. Due to the recent kernel I'm running, the driver will not
install. I'm currently running the 4.5.2-kernel.

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


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

2016-04-27 Thread Laurent Pinchart
Hi Maarten,

Thank you for the patch.

On Tuesday 26 Apr 2016 16:11:40 Maarten Lankhorst wrote:
> The async name is deprecated and should be changed to nonblocking.
> 
> Cc: Laurent Pinchart 
> Signed-off-by: Maarten Lankhorst 

Acked-by: Laurent Pinchart 

> ---
>  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(>work);
>   else
>   rcar_du_atomic_complete(commit);

-- 
Regards,

Laurent Pinchart



[PATCH] drm/omap: check plane size

2016-04-27 Thread Laurent Pinchart
Hi Tomi,

(CC'ing Daniel)

Thank you for the patch.

On Tuesday 26 Apr 2016 13:16:42 Tomi Valkeinen wrote:
> 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 

I don't think it makes sense to have an empty source or destination rectangle 
for any driver, not just omapdrm. Shouldn't this check be added to 
drm_atomic_plane_check() instead ?

> ---
>  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;

-- 
Regards,

Laurent Pinchart



[ANNOUNCE] libdrm 2.4.68

2016-04-27 Thread Kenneth Graunke
Chih-Wei Huang (1):
  android: add virgl to be a valid driver

Daniel Vetter (7):
  headers: Remove _DRM_GEM
  tests/kms-steal-crtc: Use correct includes
  headers: Update drm_i915.h
  headers: Update drm_sarea.h
  headers: Update drm_fourcc.h
  headers: Update drm_mode.h
  headers: Update drm.h

Emil Velikov (1):
  proptest: print signed values correctly

Eric Engestrom (6):
  amdgpu: Fix spelling mistakes
  exynos: Fix spelling mistake
  freedreno: Fix spelling mistakes
  intel: Fix spelling mistakes
  tests: Fix spelling mistakes
  xf86drm: Fix spelling mistakes

Gustavo Padovan (3):
  tests: add virtio_gpu to the driver list
  gitignore: ignore kms-steal-crtc and kms-universal-planes
  modetest: print signed values correctly

Kenneth Graunke (1):
  Bump version for release

Michał Winiarski (1):
  intel/skl: Add missing SKL PCI IDs

Nicolas Dechesne (1):
  freedreno: add dummy fd_bo_from_fbdev implementation when KGSL is 
disabled

Rob Clark (3):
  add libdrm_vc4.pc to .gitignore
  freedreno: update uapi
  freedreno: add support for FD_TIMESTAMP

Rodrigo Vivi (1):
  intel: Adding missing Broxton PCI IDs.

Sonny Jiang (1):
  amdgpu/tests: fix tests for asics with one VCE instance

Thierry Reding (1):
  tegra: Sync with Linux kernel UAPI header

Thomas Hellstrom (1):
  vmwgfx: update uapi

git tag: libdrm-2.4.68

http://dri.freedesktop.org/libdrm/libdrm-2.4.68.tar.bz2
MD5:  bcc96848d969cecf28223f668eeff354  libdrm-2.4.68.tar.bz2
SHA1: cb906b715dd2e9a5fc3c231d9790a5effea64482  libdrm-2.4.68.tar.bz2
SHA256: 5b4bd9a5922929bc716411cb74061fbf31b06ba36feb89bc1358a91a8d0ca9df  
libdrm-2.4.68.tar.bz2
PGP:  http://dri.freedesktop.org/libdrm/libdrm-2.4.68.tar.bz2.sig

http://dri.freedesktop.org/libdrm/libdrm-2.4.68.tar.gz
MD5:  36d5adc539c266e243535f0cf626f163  libdrm-2.4.68.tar.gz
SHA1: d7b8ae0a7347be7155901438df343079ec094ae8  libdrm-2.4.68.tar.gz
SHA256: 092e870b7ecf64e07df9b8f96dee78adbfe3310d562105fddbb3ee7f35a76eff  
libdrm-2.4.68.tar.gz
PGP:  http://dri.freedesktop.org/libdrm/libdrm-2.4.68.tar.gz.sig

-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160427/6d62ecf1/attachment.sig>


[Bug 95177] *ERROR* radeon: failed testing IB on ring 5 (-35)

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

--- Comment #2 from yaroslav.sapozhnik at gmail.com ---
dmesg:
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Mars
XTX [Radeon HD 8790M] (prog-if 00 [VGA controller])

-- 
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/20160427/d89f60c4/attachment-0001.html>


[Bug 95177] *ERROR* radeon: failed testing IB on ring 5 (-35)

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

--- Comment #1 from yaroslav.sapozhnik at gmail.com ---
Started seeing this alongside with "radeon :01:00.0: VCE init error (-110)"
on kernel 4.4.7-300.fc23.x86_64.

-- 
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/20160427/8860601c/attachment-0001.html>


[Intel-gfx] RFC: libdrm: Support Iris Graphics 540 & 550 (Skylake GT3e)

2016-04-27 Thread Kenneth Graunke
On Wednesday, April 27, 2016 9:37:07 AM PDT Thorsten Leemhuis wrote:
> Thorsten Leemhuis wrote on 26.04.2016 13:41:
> > 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.
> 
> Forget that patch -- a way better one was submitted weeks ago my Michal
> already:
> https://lists.freedesktop.org/archives/intel-gfx/2016-February/087819.html
> 
> Did that patch simply fall through the cracks or is there a reason why
> it wasn't applied to libdrm master? It is pretty obvious it would fix
> the problem I saw and tried to address with that rough patch I send
> yesterday.
> 
> CU, knurd
> 
> P.S.: Added intel-gfx and michal.winiarski to CC

It looks like it fell through the cracks.  Roland just mentioned this on
IRC...I've reviewed and pushed the patch to master.  I'm also making a
release.
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160427/72ae5d58/attachment.sig>


[PATCH 2/2] ARC: [axs10x] Specify reserved memory for frame buffer

2016-04-27 Thread Alexey Brodkin
Allocation of a frame buffer memory in a special memory region
allows bypassing of so-called IO Coherency aperture
which is typically set as a range 0x8z-0xAz.

I.e. all data traffic to PGU bypasses IO Coherency block
and saves its bandwidth for other peripherals.

Even though for AXS101 (which sorts ARC770 CPU) IOC is not
an option for a sake of keeping one DT description for the
base-board (axs10x_mb.dtsi) we're still defining reserved
memory location in the very end of DDR.

Signed-off-by: Alexey Brodkin 
Cc: devicetree at vger.kernel.org
---
 arch/arc/boot/dts/axc001.dtsi | 20 +++-
 arch/arc/boot/dts/axc003.dtsi | 14 ++
 arch/arc/boot/dts/axc003_idu.dtsi | 14 ++
 arch/arc/boot/dts/axs10x_mb.dtsi  |  2 +-
 4 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/arch/arc/boot/dts/axc001.dtsi b/arch/arc/boot/dts/axc001.dtsi
index 420dcfd..ae6162d 100644
--- a/arch/arc/boot/dts/axc001.dtsi
+++ b/arch/arc/boot/dts/axc001.dtsi
@@ -95,6 +95,24 @@
#size-cells = <1>;
ranges = <0x 0x8000 0x4000>;
device_type = "memory";
-   reg = <0x8000 0x2000>;  /* 512MiB */
+   reg = <0x8000 0x1f00>;  /* 512 - 16 MiB */
+   };
+
+   reserved-memory {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges;
+   /*
+* We just move frame buffer area to the very end of
+* available DDR. And even though in case of ARC770 there's
+* no strict requirement for a frame-buffer to be in any
+* particular location it allows us to use the same
+* base board's DT node for ARC PGU as for ARc HS38.
+*/
+   frame_buffer: frame_buffer at 9f00 {
+   compatible = "shared-dma-pool";
+   reg = <0x9f00 0x100>;
+   no-map;
+   };
};
 };
diff --git a/arch/arc/boot/dts/axc003.dtsi b/arch/arc/boot/dts/axc003.dtsi
index f90fadf..c7a95c2 100644
--- a/arch/arc/boot/dts/axc003.dtsi
+++ b/arch/arc/boot/dts/axc003.dtsi
@@ -100,4 +100,18 @@
device_type = "memory";
reg = <0x8000 0x2000>;  /* 512MiB */
};
+
+   reserved-memory {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges;
+   /*
+* Move frame buffer out of IOC aperture (0x8z-0xAz).
+*/
+   frame_buffer: frame_buffer at a000 {
+   compatible = "shared-dma-pool";
+   reg = <0xa000 0x100>;
+   no-map;
+   };
+   };
 };
diff --git a/arch/arc/boot/dts/axc003_idu.dtsi 
b/arch/arc/boot/dts/axc003_idu.dtsi
index 06a9f29..929ec8c 100644
--- a/arch/arc/boot/dts/axc003_idu.dtsi
+++ b/arch/arc/boot/dts/axc003_idu.dtsi
@@ -123,4 +123,18 @@
device_type = "memory";
reg = <0x8000 0x2000>;  /* 512MiB */
};
+
+   reserved-memory {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges;
+   /*
+* Move frame buffer out of IOC aperture (0x8z-0xAz).
+*/
+   frame_buffer: frame_buffer at a000 {
+   compatible = "shared-dma-pool";
+   reg = <0xa000 0x100>;
+   no-map;
+   };
+   };
 };
diff --git a/arch/arc/boot/dts/axs10x_mb.dtsi b/arch/arc/boot/dts/axs10x_mb.dtsi
index 823f15c..64b063d 100644
--- a/arch/arc/boot/dts/axs10x_mb.dtsi
+++ b/arch/arc/boot/dts/axs10x_mb.dtsi
@@ -283,7 +283,7 @@
encoder-slave = <>;
clocks = <>;
clock-names = "pxlclk";
-
+   memory-region = <_buffer>;
port {
pgu_output: endpoint {
remote-endpoint = <_input>;
-- 
2.5.5



[PATCH 1/2] drm/arcpgu: use dedicated memory area for frame buffer

2016-04-27 Thread Alexey Brodkin
Now when ARC supports reserved memory areas and
per-device coherent DMA allocations we may switch ARC PGU
to use of those dedicated areas.

One of the benefits we may move frame-buffer area out
from IO Coherency aperture and so significantly
reduce IOC utilization allowing less demanding
peripherals to use all perks of IOC.

Signed-off-by: Alexey Brodkin 
Cc: Dave Airlie 
Cc: Daniel Vetter 
---
 drivers/gpu/drm/arc/arcpgu_drv.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index 5b35e5db..76e187a 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "arcpgu.h"
 #include "arcpgu_regs.h"
@@ -135,6 +136,11 @@ static int arcpgu_load(struct drm_device *drm)
dev_info(drm->dev, "arc_pgu ID: 0x%x\n",
 arc_pgu_read(arcpgu, ARCPGU_REG_ID));

+   /* Get the optional framebuffer memory resource */
+   ret = of_reserved_mem_device_init(drm->dev);
+   if (ret && ret != -ENODEV)
+   return ret;
+
if (dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32)))
return -ENODEV;

-- 
2.5.5



[PATCH 0/2] drm/arcpgu: Get use of dedicated memory area for frame buffer

2016-04-27 Thread Alexey Brodkin
This mini-series allows to allocate frame buffer memory in desired
location. Allocation of a frame buffer memory in a special memory region
allows bypassing of so-called IO Coherency aperture which is typically set
as a range 0x8z-0xAz.

I.e. all data traffic to PGU bypasses IO Coherency block
and saves its bandwidth for other peripherals.

Cc: Cc: Dave Airlie 
Cc: Daniel Vetter 
Cc: devicetree at vger.kernel.org

Alexey Brodkin (2):
  drm/arcpgu: use dedicated memory area for frame buffer
  ARC: [axs10x] Specify reserved memory for frame buffer

 arch/arc/boot/dts/axc001.dtsi | 20 +++-
 arch/arc/boot/dts/axc003.dtsi | 14 ++
 arch/arc/boot/dts/axc003_idu.dtsi | 14 ++
 arch/arc/boot/dts/axs10x_mb.dtsi  |  2 +-
 drivers/gpu/drm/arc/arcpgu_drv.c  |  6 ++
 5 files changed, 54 insertions(+), 2 deletions(-)

-- 
2.5.5



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

2016-04-27 Thread Thomas Hellstrom
LGTM

Reviewed-by: Thomas Hellstrom 


On 04/26/2016 06:50 AM, Alex Deucher wrote:
> 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(>resv->lock.base);
>>
>> -   if (bo->mem.placement & TTM_PL_FLAG_NO_EVICT) {
>> -   list_del_init(>swap);
>> -   list_del_init(>lru);
>> -
>> -   } else {
>> -   if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG))
>> -   list_move_tail(>swap, >glob->swap_lru);
>> -
>> -   man = >man[bo->mem.mem_type];
>> -   list_move_tail(>lru, >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
>>



[PATCH] drm/etnaviv: don't move linear memory window on 3D cores without MC2.0

2016-04-27 Thread Christian Gmeiner
2016-04-21 14:51 GMT+02:00 Lucas Stach :
> On cores with MC1.0 the memory window offset is not properly respected
> by all engines in the core, leading to different views of the memory
> if the offset in non-zero. This causes relocs for those engines to be
> wrong and might lead to other subtile problems.
>
> Rather than trying to work around this, just disable the linear memory
> window offset for those cores.
>
> Suggested-by: Russell King 
> Signed-off-by: Lucas Stach 

Reviewed-by: Christian Gmeiner 

> ---
>  drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 31 ++-
>  1 file changed, 18 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c 
> b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> index a30d1c2b0f13..049d00d8ded5 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> @@ -572,6 +572,24 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
> goto fail;
> }
>
> +   /*
> +* Set the GPU linear window to be at the end of the DMA window, where
> +* the CMA area is likely to reside. This ensures that we are able to
> +* map the command buffers while having the linear window overlap as
> +* much RAM as possible, so we can optimize mappings for other 
> buffers.
> +*
> +* For 3D cores only do this if MC2.0 is present, as with MC1.0 it 
> leads
> +* to different views of the memory on the individual engines.
> +*/
> +   if (!(gpu->identity.features & chipFeatures_PIPE_3D) ||
> +   (gpu->identity.minor_features0 & chipMinorFeatures0_MC20)) {
> +   u32 dma_mask = (u32)dma_get_required_mask(gpu->dev);
> +   if (dma_mask < PHYS_OFFSET + SZ_2G)
> +   gpu->memory_base = PHYS_OFFSET;
> +   else
> +   gpu->memory_base = dma_mask - SZ_2G + 1;
> +   }
> +
> ret = etnaviv_hw_reset(gpu);
> if (ret)
> goto fail;
> @@ -1566,7 +1584,6 @@ static int etnaviv_gpu_platform_probe(struct 
> platform_device *pdev)
>  {
> struct device *dev = >dev;
> struct etnaviv_gpu *gpu;
> -   u32 dma_mask;
> int err = 0;
>
> gpu = devm_kzalloc(dev, sizeof(*gpu), GFP_KERNEL);
> @@ -1576,18 +1593,6 @@ static int etnaviv_gpu_platform_probe(struct 
> platform_device *pdev)
> gpu->dev = >dev;
> mutex_init(>lock);
>
> -   /*
> -* Set the GPU linear window to be at the end of the DMA window, where
> -* the CMA area is likely to reside. This ensures that we are able to
> -* map the command buffers while having the linear window overlap as
> -* much RAM as possible, so we can optimize mappings for other 
> buffers.
> -*/
> -   dma_mask = (u32)dma_get_required_mask(dev);
> -   if (dma_mask < PHYS_OFFSET + SZ_2G)
> -   gpu->memory_base = PHYS_OFFSET;
> -   else
> -   gpu->memory_base = dma_mask - SZ_2G + 1;
> -
> /* Map registers: */
> gpu->mmio = etnaviv_ioremap(pdev, NULL, dev_name(gpu->dev));
> if (IS_ERR(gpu->mmio))
> --
> 2.8.0.rc3
>


bug in autoloading of imx-ipuv3-crtc

2016-04-27 Thread Philipp Zabel
Am Mittwoch, den 27.04.2016, 08:59 +1000 schrieb Dave Airlie:
> > I reverted the 4 patches in that series
> >
> > 407c9eba drm/imx: Remove of_node assignment from ipuv3-crtc driver probe
> > 304e6be6 gpu: ipu-v3: Assign of_node of child platform devices to
> > corresponding ports
> > 99ae78c3 gpu: ipu-v3: Remove reg_offset field
> > c3ede03c gpu: ipu-v3: drop unused dmfc field from client platform data
> >
> > and it then worked again.
> 
> Should I be reverting these upstream as it's some sort of regression?

I will send an imx-drm/fixes pull request with the issue fixed.

regards
Philipp



[PATCH 04/24] drm/etnaviv: add extern C guard for the UAPI header

2016-04-27 Thread Christian Gmeiner
2016-04-21 22:17 GMT+02:00 Emil Velikov :
> Cc: Christian Gmeiner 
> Cc: Russell King 
> Cc: Lucas Stach 
> Signed-off-by: Emil Velikov 

Acked-by: Christian Gmeiner 

> ---
>  include/uapi/drm/etnaviv_drm.h | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/include/uapi/drm/etnaviv_drm.h b/include/uapi/drm/etnaviv_drm.h
> index f95e1c4..2584c1c 100644
> --- a/include/uapi/drm/etnaviv_drm.h
> +++ b/include/uapi/drm/etnaviv_drm.h
> @@ -19,6 +19,10 @@
>
>  #include "drm.h"
>
> +#if defined(__cplusplus)
> +extern "C" {
> +#endif
> +
>  /* Please note that modifications to all structs defined here are
>   * subject to backwards-compatibility constraints:
>   *  1) Do not use pointers, use __u64 instead for 32 bit / 64 bit
> @@ -222,4 +226,8 @@ struct drm_etnaviv_gem_wait {
>  #define DRM_IOCTL_ETNAVIV_GEM_USERPTR  DRM_IOWR(DRM_COMMAND_BASE + 
> DRM_ETNAVIV_GEM_USERPTR, struct drm_etnaviv_gem_userptr)
>  #define DRM_IOCTL_ETNAVIV_GEM_WAIT DRM_IOW(DRM_COMMAND_BASE + 
> DRM_ETNAVIV_GEM_WAIT, struct drm_etnaviv_gem_wait)
>
> +#if defined(__cplusplus)
> +}
> +#endif
> +
>  #endif /* __ETNAVIV_DRM_H__ */
> --
> 2.6.2
>


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

2016-04-27 Thread Dave Airlie
>> Hm, I thought the referenced commit explained this, but now that I recheck
>> it doesn't. I'm not too sure again myself why I thought nouveau needs
>> this. The legacy ctx stuff is required because of some old kms nouveau ddx
>> that still used that stuff. I thought it also used legacy maps ... I'll
>> double check once more.
>
> Ok, nouveau ddx indeed used legacy addmap and friends, but that code is
> nuked since 2006. That's 10 years, which is the rule of thumb for when we
> can drop support. I'll respin this patch.
> -Daniel

Nope,

commit b1a630b48210d6a3c44994fce1b73273000ace5c
Author: Dave Airlie 
Date:   Wed Nov 7 14:45:14 2012 +1000

nouveau: drop DRI1 device open interface.

Was when it was fixed.

Dave.


[PATCH v15 8/8] memory: mtk-smi: export mtk_smi_larb_get/put

2016-04-27 Thread Philipp Zabel
To allow building mediatek-drm.ko as a module, the
mtk_smi_larb_get and mtk_smi_larb_put symbols have
to be exported.

Signed-off-by: Philipp Zabel 
---
 drivers/memory/mtk-smi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c
index 089091f..f6b5757 100644
--- a/drivers/memory/mtk-smi.c
+++ b/drivers/memory/mtk-smi.c
@@ -91,6 +91,7 @@ int mtk_smi_larb_get(struct device *larbdev)

return 0;
 }
+EXPORT_SYMBOL_GPL(mtk_smi_larb_get);

 void mtk_smi_larb_put(struct device *larbdev)
 {
@@ -106,6 +107,7 @@ void mtk_smi_larb_put(struct device *larbdev)
mtk_smi_disable(>smi);
mtk_smi_disable(common);
 }
+EXPORT_SYMBOL_GPL(mtk_smi_larb_put);

 static int
 mtk_smi_larb_bind(struct device *dev, struct device *master, void *data)
-- 
2.8.0.rc3



[PATCH v15 7/8] clk: mediatek: remove hdmitx_dig_cts from TOP clocks

2016-04-27 Thread Philipp Zabel
The hdmitx_dig_cts clock signal is not a child of tvdpll_445p5m,
but is routed out of the HDMI PHY module.

Signed-off-by: Philipp Zabel 
Acked-by: Stephen Boyd 
---
 drivers/clk/mediatek/clk-mt8173.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/clk/mediatek/clk-mt8173.c 
b/drivers/clk/mediatek/clk-mt8173.c
index cf4fcb6..10c9860 100644
--- a/drivers/clk/mediatek/clk-mt8173.c
+++ b/drivers/clk/mediatek/clk-mt8173.c
@@ -61,7 +61,6 @@ static const struct mtk_fixed_factor top_divs[] __initconst = 
{
FACTOR(CLK_TOP_CLKRTC_INT, "clkrtc_int", "clk26m", 1, 793),
FACTOR(CLK_TOP_FPC, "fpc_ck", "clk26m", 1, 1),

-   FACTOR(CLK_TOP_HDMITX_DIG_CTS, "hdmitx_dig_cts", "tvdpll_445p5m", 1, 3),
FACTOR(CLK_TOP_HDMITXPLL_D2, "hdmitxpll_d2", "hdmitx_dig_cts", 1, 2),
FACTOR(CLK_TOP_HDMITXPLL_D3, "hdmitxpll_d3", "hdmitx_dig_cts", 1, 3),

-- 
2.8.0.rc3



[PATCH v15 6/8] clk: mediatek: Add hdmi_ref HDMI PHY PLL reference clock output

2016-04-27 Thread Philipp Zabel
The configurable hdmi_ref output of the PLL block is derived from
the tvdpll_594m clock signal via a configurable PLL post-divider.
It is used as the PLL reference input to the HDMI PHY module.

Signed-off-by: Philipp Zabel 
Acked-by: James Liao 
Acked-by: Stephen Boyd 
---
 drivers/clk/mediatek/clk-mt8173.c  | 5 +
 include/dt-bindings/clock/mt8173-clk.h | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/mediatek/clk-mt8173.c 
b/drivers/clk/mediatek/clk-mt8173.c
index 85c0bfc..cf4fcb6 100644
--- a/drivers/clk/mediatek/clk-mt8173.c
+++ b/drivers/clk/mediatek/clk-mt8173.c
@@ -1095,6 +1095,11 @@ static void __init mtk_apmixedsys_init(struct 
device_node *node)
clk_data->clks[cku->id] = clk;
}

+   clk = clk_register_divider(NULL, "hdmi_ref", "tvdpll_594m", 0,
+  base + 0x40, 16, 3, CLK_DIVIDER_POWER_OF_TWO,
+  NULL);
+   clk_data->clks[CLK_APMIXED_HDMI_REF] = clk;
+
r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
if (r)
pr_err("%s(): could not register clock provider: %d\n",
diff --git a/include/dt-bindings/clock/mt8173-clk.h 
b/include/dt-bindings/clock/mt8173-clk.h
index 7956ba1..6094bf7 100644
--- a/include/dt-bindings/clock/mt8173-clk.h
+++ b/include/dt-bindings/clock/mt8173-clk.h
@@ -176,7 +176,8 @@
 #define CLK_APMIXED_LVDSPLL13
 #define CLK_APMIXED_MSDCPLL2   14
 #define CLK_APMIXED_REF2USB_TX 15
-#define CLK_APMIXED_NR_CLK 16
+#define CLK_APMIXED_HDMI_REF   16
+#define CLK_APMIXED_NR_CLK 17

 /* INFRA_SYS */

-- 
2.8.0.rc3



[PATCH v15 5/8] clk: mediatek: make dpi0_sel propagate rate changes

2016-04-27 Thread Philipp Zabel
This mux is supposed to select a fitting divider after the PLL
is already set to the correct rate.

Signed-off-by: Philipp Zabel 
Acked-by: James Liao 
Acked-by: Stephen Boyd 
---
 drivers/clk/mediatek/clk-mt8173.c |  6 +-
 drivers/clk/mediatek/clk-mtk.h| 15 +--
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt8173.c 
b/drivers/clk/mediatek/clk-mt8173.c
index 227e356..85c0bfc 100644
--- a/drivers/clk/mediatek/clk-mt8173.c
+++ b/drivers/clk/mediatek/clk-mt8173.c
@@ -558,7 +558,11 @@ static const struct mtk_composite top_muxes[] __initconst 
= {
MUX_GATE(CLK_TOP_ATB_SEL, "atb_sel", atb_parents, 0x0090, 16, 2, 23),
MUX_GATE(CLK_TOP_VENC_LT_SEL, "venclt_sel", venc_lt_parents, 0x0090, 
24, 4, 31),
/* CLK_CFG_6 */
-   MUX_GATE(CLK_TOP_DPI0_SEL, "dpi0_sel", dpi0_parents, 0x00a0, 0, 3, 7),
+   /*
+* The dpi0_sel clock should not propagate rate changes to its parent
+* clock so the dpi driver can have full control over PLL and divider.
+*/
+   MUX_GATE_FLAGS(CLK_TOP_DPI0_SEL, "dpi0_sel", dpi0_parents, 0x00a0, 0, 
3, 7, 0),
MUX_GATE(CLK_TOP_IRDA_SEL, "irda_sel", irda_parents, 0x00a0, 8, 2, 15),
MUX_GATE(CLK_TOP_CCI400_SEL, "cci400_sel", cci400_parents, 0x00a0, 16, 
3, 23),
MUX_GATE(CLK_TOP_AUD_1_SEL, "aud_1_sel", aud_1_parents, 0x00a0, 24, 2, 
31),
diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h
index 32d2e45..9f24fcf 100644
--- a/drivers/clk/mediatek/clk-mtk.h
+++ b/drivers/clk/mediatek/clk-mtk.h
@@ -83,7 +83,11 @@ struct mtk_composite {
signed char num_parents;
 };

-#define MUX_GATE(_id, _name, _parents, _reg, _shift, _width, _gate) {  \
+/*
+ * In case the rate change propagation to parent clocks is undesirable,
+ * this macro allows to specify the clock flags manually.
+ */
+#define MUX_GATE_FLAGS(_id, _name, _parents, _reg, _shift, _width, _gate, 
_flags) {\
.id = _id,  \
.name = _name,  \
.mux_reg = _reg,\
@@ -94,9 +98,16 @@ struct mtk_composite {
.divider_shift = -1,\
.parent_names = _parents,   \
.num_parents = ARRAY_SIZE(_parents),\
-   .flags = CLK_SET_RATE_PARENT,   \
+   .flags = _flags,\
}

+/*
+ * Unless necessary, all MUX_GATE clocks propagate rate changes to their
+ * parent clock by default.
+ */
+#define MUX_GATE(_id, _name, _parents, _reg, _shift, _width, _gate)\
+   MUX_GATE_FLAGS(_id, _name, _parents, _reg, _shift, _width, _gate, 
CLK_SET_RATE_PARENT)
+
 #define MUX(_id, _name, _parents, _reg, _shift, _width) {  \
.id = _id,  \
.name = _name,  \
-- 
2.8.0.rc3



[PATCH v15 4/8] drm/mediatek: Add DPI sub driver

2016-04-27 Thread Philipp Zabel
From: Jie Qiu 

Add DPI connector/encoder to support HDMI output via the
attached HDMI bridge.

Signed-off-by: Jie Qiu 
Signed-off-by: Philipp Zabel 
---
 drivers/gpu/drm/mediatek/Makefile   |   3 +-
 drivers/gpu/drm/mediatek/mtk_dpi.c  | 769 
 drivers/gpu/drm/mediatek/mtk_dpi_regs.h | 228 ++
 drivers/gpu/drm/mediatek/mtk_drm_drv.c  |   1 +
 drivers/gpu/drm/mediatek/mtk_drm_drv.h  |   1 +
 5 files changed, 1001 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/mediatek/mtk_dpi.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_dpi_regs.h

diff --git a/drivers/gpu/drm/mediatek/Makefile 
b/drivers/gpu/drm/mediatek/Makefile
index e781db5a..5fcf58e 100644
--- a/drivers/gpu/drm/mediatek/Makefile
+++ b/drivers/gpu/drm/mediatek/Makefile
@@ -8,6 +8,7 @@ mediatek-drm-y := mtk_disp_ovl.o \
  mtk_drm_gem.o \
  mtk_drm_plane.o \
  mtk_dsi.o \
- mtk_mipi_tx.o
+ mtk_mipi_tx.o \
+ mtk_dpi.o

 obj-$(CONFIG_DRM_MEDIATEK) += mediatek-drm.o
diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c 
b/drivers/gpu/drm/mediatek/mtk_dpi.c
new file mode 100644
index 000..d05ca79
--- /dev/null
+++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
@@ -0,0 +1,769 @@
+/*
+ * Copyright (c) 2014 MediaTek Inc.
+ * Author: Jie Qiu 
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mtk_dpi_regs.h"
+#include "mtk_drm_ddp_comp.h"
+
+enum mtk_dpi_out_bit_num {
+   MTK_DPI_OUT_BIT_NUM_8BITS,
+   MTK_DPI_OUT_BIT_NUM_10BITS,
+   MTK_DPI_OUT_BIT_NUM_12BITS,
+   MTK_DPI_OUT_BIT_NUM_16BITS
+};
+
+enum mtk_dpi_out_yc_map {
+   MTK_DPI_OUT_YC_MAP_RGB,
+   MTK_DPI_OUT_YC_MAP_CYCY,
+   MTK_DPI_OUT_YC_MAP_YCYC,
+   MTK_DPI_OUT_YC_MAP_CY,
+   MTK_DPI_OUT_YC_MAP_YC
+};
+
+enum mtk_dpi_out_channel_swap {
+   MTK_DPI_OUT_CHANNEL_SWAP_RGB,
+   MTK_DPI_OUT_CHANNEL_SWAP_GBR,
+   MTK_DPI_OUT_CHANNEL_SWAP_BRG,
+   MTK_DPI_OUT_CHANNEL_SWAP_RBG,
+   MTK_DPI_OUT_CHANNEL_SWAP_GRB,
+   MTK_DPI_OUT_CHANNEL_SWAP_BGR
+};
+
+enum mtk_dpi_out_color_format {
+   MTK_DPI_COLOR_FORMAT_RGB,
+   MTK_DPI_COLOR_FORMAT_RGB_FULL,
+   MTK_DPI_COLOR_FORMAT_YCBCR_444,
+   MTK_DPI_COLOR_FORMAT_YCBCR_422,
+   MTK_DPI_COLOR_FORMAT_XV_YCC,
+   MTK_DPI_COLOR_FORMAT_YCBCR_444_FULL,
+   MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL
+};
+
+struct mtk_dpi {
+   struct mtk_ddp_comp ddp_comp;
+   struct drm_encoder encoder;
+   void __iomem *regs;
+   struct device *dev;
+   struct clk *engine_clk;
+   struct clk *pixel_clk;
+   struct clk *tvd_clk;
+   int irq;
+   struct drm_display_mode mode;
+   enum mtk_dpi_out_color_format color_format;
+   enum mtk_dpi_out_yc_map yc_map;
+   enum mtk_dpi_out_bit_num bit_num;
+   enum mtk_dpi_out_channel_swap channel_swap;
+   bool power_sta;
+   u8 power_ctl;
+};
+
+static inline struct mtk_dpi *mtk_dpi_from_encoder(struct drm_encoder *e)
+{
+   return container_of(e, struct mtk_dpi, encoder);
+}
+
+enum mtk_dpi_polarity {
+   MTK_DPI_POLARITY_RISING,
+   MTK_DPI_POLARITY_FALLING,
+};
+
+enum mtk_dpi_power_ctl {
+   DPI_POWER_START = BIT(0),
+   DPI_POWER_ENABLE = BIT(1),
+};
+
+struct mtk_dpi_polarities {
+   enum mtk_dpi_polarity de_pol;
+   enum mtk_dpi_polarity ck_pol;
+   enum mtk_dpi_polarity hsync_pol;
+   enum mtk_dpi_polarity vsync_pol;
+};
+
+struct mtk_dpi_sync_param {
+   u32 sync_width;
+   u32 front_porch;
+   u32 back_porch;
+   bool shift_half_line;
+};
+
+struct mtk_dpi_yc_limit {
+   u16 y_top;
+   u16 y_bottom;
+   u16 c_top;
+   u16 c_bottom;
+};
+
+static void mtk_dpi_mask(struct mtk_dpi *dpi, u32 offset, u32 val, u32 mask)
+{
+   u32 tmp = readl(dpi->regs + offset) & ~mask;
+
+   tmp |= (val & mask);
+   writel(tmp, dpi->regs + offset);
+}
+
+static void mtk_dpi_sw_reset(struct mtk_dpi *dpi, bool reset)
+{
+   mtk_dpi_mask(dpi, DPI_RET, reset ? RST : 0, RST);
+}
+
+static void mtk_dpi_enable(struct mtk_dpi *dpi)
+{
+   mtk_dpi_mask(dpi, DPI_EN, EN, EN);
+}
+
+static void mtk_dpi_disable(struct mtk_dpi *dpi)
+{
+   mtk_dpi_mask(dpi, DPI_EN, 0, EN);
+}
+
+static void mtk_dpi_config_hsync(struct mtk_dpi *dpi,
+struct mtk_dpi_sync_param *sync)
+{
+   mtk_dpi_mask(dpi, DPI_TGEN_HWIDTH,
+   

[PATCH v15 3/8] drm/mediatek: Add DSI sub driver

2016-04-27 Thread Philipp Zabel
From: CK Hu 

This patch add a drm encoder/connector driver for the MIPI DSI function
block of the Mediatek display subsystem and a phy driver for the MIPI TX
D-PHY control module.

Signed-off-by: Jitao Shi 
Signed-off-by: Philipp Zabel 
---
Changes since v15:
 - use div_u64 to avoid "__aeabi_uldivmod undefined" error when
   building as module
---
 drivers/gpu/drm/mediatek/Kconfig   |   2 +
 drivers/gpu/drm/mediatek/Makefile  |   4 +-
 drivers/gpu/drm/mediatek/mtk_drm_drv.c |   2 +
 drivers/gpu/drm/mediatek/mtk_drm_drv.h |   2 +
 drivers/gpu/drm/mediatek/mtk_dsi.c | 927 +
 drivers/gpu/drm/mediatek/mtk_mipi_tx.c | 463 
 6 files changed, 1399 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/mediatek/mtk_dsi.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_mipi_tx.c

diff --git a/drivers/gpu/drm/mediatek/Kconfig b/drivers/gpu/drm/mediatek/Kconfig
index 30e5371..eeefc97 100644
--- a/drivers/gpu/drm/mediatek/Kconfig
+++ b/drivers/gpu/drm/mediatek/Kconfig
@@ -4,6 +4,8 @@ config DRM_MEDIATEK
depends on ARCH_MEDIATEK || (ARM && COMPILE_TEST)
select DRM_GEM_CMA_HELPER
select DRM_KMS_HELPER
+   select DRM_MIPI_DSI
+   select DRM_PANEL
select IOMMU_DMA
select MEMORY
select MTK_SMI
diff --git a/drivers/gpu/drm/mediatek/Makefile 
b/drivers/gpu/drm/mediatek/Makefile
index d4bde7c..e781db5a 100644
--- a/drivers/gpu/drm/mediatek/Makefile
+++ b/drivers/gpu/drm/mediatek/Makefile
@@ -6,6 +6,8 @@ mediatek-drm-y := mtk_disp_ovl.o \
  mtk_drm_drv.o \
  mtk_drm_fb.o \
  mtk_drm_gem.o \
- mtk_drm_plane.o
+ mtk_drm_plane.o \
+ mtk_dsi.o \
+ mtk_mipi_tx.o

 obj-$(CONFIG_DRM_MEDIATEK) += mediatek-drm.o
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c 
b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index 4aa09a1..20b178d 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -517,6 +517,8 @@ static struct platform_driver * const mtk_drm_drivers[] = {
_ddp_driver,
_disp_ovl_driver,
_disp_rdma_driver,
+   _dsi_driver,
+   _mipi_tx_driver,
 };

 static int __init mtk_drm_init(void)
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.h 
b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
index 27dc8fa..ac6c92b 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.h
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
@@ -53,5 +53,7 @@ struct mtk_drm_private {
 extern struct platform_driver mtk_ddp_driver;
 extern struct platform_driver mtk_disp_ovl_driver;
 extern struct platform_driver mtk_disp_rdma_driver;
+extern struct platform_driver mtk_dsi_driver;
+extern struct platform_driver mtk_mipi_tx_driver;

 #endif /* MTK_DRM_DRV_H */
diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c 
b/drivers/gpu/drm/mediatek/mtk_dsi.c
new file mode 100644
index 000..54e8ff5
--- /dev/null
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
@@ -0,0 +1,927 @@
+/*
+ * Copyright (c) 2015 MediaTek Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mtk_drm_ddp_comp.h"
+
+#define DSI_VIDEO_FIFO_DEPTH   (1920 / 4)
+#define DSI_HOST_FIFO_DEPTH64
+
+#define DSI_START  0x00
+
+#define DSI_CON_CTRL   0x10
+#define DSI_RESET  BIT(0)
+#define DSI_EN BIT(1)
+
+#define DSI_MODE_CTRL  0x14
+#define MODE   (3)
+#define CMD_MODE   0
+#define SYNC_PULSE_MODE1
+#define SYNC_EVENT_MODE2
+#define BURST_MODE 3
+#define FRM_MODE   BIT(16)
+#define MIX_MODE   BIT(17)
+
+#define DSI_TXRX_CTRL  0x18
+#define VC_NUM (2 << 0)
+#define LANE_NUM   (0xf << 2)
+#define DIS_EOTBIT(6)
+#define NULL_ENBIT(7)
+#define TE_FREERUN BIT(8)
+#define EXT_TE_EN  BIT(9)
+#define EXT_TE_EDGEBIT(10)
+#define MAX_RTN_SIZE   (0xf << 12)
+#define HSTX_CKLP_EN   BIT(16)
+
+#define DSI_PSCTRL 0x1c
+#define DSI_PS_WC  0x3fff
+#define DSI_PS_SEL (3 << 16)
+#define 

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

2016-04-27 Thread Philipp Zabel
From: CK Hu 

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
 - Select DRM_GEM_CMA_HELPER and use drm_gem_cma_vm_ops
 - Select MEMORY so that select MTK_SMI works properly
 - Rebase onto drm-next so we can use drm_connector_unregister_all()
 - Remove deprecated unload hook
---
 drivers/gpu/drm/Kconfig |   2 +
 drivers/gpu/drm/Makefile|   1 +
 drivers/gpu/drm/mediatek/Kconfig|  14 +
 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  | 558 ++
 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, 3383 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 9e4f2f1..8ce035c 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -283,3 +283,5 @@ source "drivers/gpu/drm/vc4/Kconfig"
 source "drivers/gpu/drm/etnaviv/Kconfig"

 source "drivers/gpu/drm/arc/Kconfig"
+
+source "drivers/gpu/drm/mediatek/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index c338d04..472ef5d 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..30e5371
--- /dev/null
+++ b/drivers/gpu/drm/mediatek/Kconfig
@@ -0,0 +1,14 @@
+config DRM_MEDIATEK
+   tristate "DRM Support for Mediatek SoCs"
+   depends on DRM
+   depends on ARCH_MEDIATEK || (ARM && COMPILE_TEST)
+   select DRM_GEM_CMA_HELPER
+   select DRM_KMS_HELPER
+   select IOMMU_DMA
+   select MEMORY
+   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) += 

[PATCH v15 1/8] dt-bindings: drm/mediatek: Add Mediatek display subsystem dts binding

2016-04-27 Thread Philipp Zabel
From: CK Hu 

Add device tree binding documentation for the display subsystem in
Mediatek MT8173 SoCs.

Signed-off-by: CK Hu 
Signed-off-by: Philipp Zabel 
Acked-by: Rob Herring 
---
 .../bindings/display/mediatek/mediatek,disp.txt| 203 +
 .../bindings/display/mediatek/mediatek,dpi.txt |  35 
 .../bindings/display/mediatek/mediatek,dsi.txt |  60 ++
 3 files changed, 298 insertions(+)
 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

diff --git 
a/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt 
b/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt
new file mode 100644
index 000..db6e77e
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt
@@ -0,0 +1,203 @@
+Mediatek display subsystem
+==
+
+The Mediatek display subsystem consists of various DISP function blocks in the
+MMSYS register space. The connections between them can be configured by output
+and input selectors in the MMSYS_CONFIG register space. Pixel clock and start
+of frame signal are distributed to the other function blocks by a DISP_MUTEX
+function block.
+
+All DISP device tree nodes must be siblings to the central MMSYS_CONFIG node.
+For a description of the MMSYS_CONFIG binding, see
+Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt.
+
+DISP function blocks
+
+
+A display stream starts at a source function block that reads pixel data from
+memory and ends with a sink function block that drives pixels on a display
+interface, or writes pixels back to memory. All DISP function blocks have
+their own register space, interrupt, and clock gate. The blocks that can
+access memory additionally have to list the IOMMU and local arbiter they are
+connected to.
+
+For a description of the display interface sink function blocks, see
+Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.txt and
+Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt.
+
+Required properties (all function blocks):
+- compatible: "mediatek,-disp-", one of
+   "mediatek,-disp-ovl"   - overlay (4 layers, blending, csc)
+   "mediatek,-disp-rdma"  - read DMA / line buffer
+   "mediatek,-disp-wdma"  - write DMA
+   "mediatek,-disp-color" - color processor
+   "mediatek,-disp-aal"   - adaptive ambient light controller
+   "mediatek,-disp-gamma" - gamma correction
+   "mediatek,-disp-merge" - merge streams from two RDMA sources
+   "mediatek,-disp-split" - split stream to two encoders
+   "mediatek,-disp-ufoe"  - data compression engine
+   "mediatek,-dsi"- DSI controller, see mediatek,dsi.txt
+   "mediatek,-dpi"- DPI controller, see mediatek,dpi.txt
+   "mediatek,-disp-mutex" - display mutex
+   "mediatek,-disp-od"- overdrive
+- reg: Physical base address and length of the function block register space
+- interrupts: The interrupt signal from the function block (required, except 
for
+  merge and split function blocks).
+- clocks: device clocks
+  See Documentation/devicetree/bindings/clock/clock-bindings.txt for details.
+  For most function blocks this is just a single clock input. Only the DSI and
+  DPI controller nodes have multiple clock inputs. These are documented in
+  mediatek,dsi.txt and mediatek,dpi.txt, respectively.
+
+Required properties (DMA function blocks):
+- compatible: Should be one of
+   "mediatek,-disp-ovl"
+   "mediatek,-disp-rdma"
+   "mediatek,-disp-wdma"
+- larb: Should contain a phandle pointing to the local arbiter device as 
defined
+  in Documentation/devicetree/bindings/soc/mediatek/mediatek,smi-larb.txt
+- iommus: Should point to the respective IOMMU block with master port as
+  argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
+  for details.
+
+Examples:
+
+mmsys: clock-controller at 1400 {
+   compatible = "mediatek,mt8173-mmsys", "syscon";
+   reg = <0 0x1400 0 0x1000>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   #clock-cells = <1>;
+};
+
+ovl0: ovl at 1400c000 {
+   compatible = "mediatek,mt8173-disp-ovl";
+   reg = <0 0x1400c000 0 0x1000>;
+   interrupts = ;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   clocks = < CLK_MM_DISP_OVL0>;
+   iommus = < M4U_PORT_DISP_OVL0>;
+   mediatek,larb = <>;
+};
+
+ovl1: ovl at 1400d000 {
+   compatible = "mediatek,mt8173-disp-ovl";
+   reg = <0 0x1400d000 0 0x1000>;
+   interrupts = ;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   clocks = < CLK_MM_DISP_OVL1>;
+   iommus = < M4U_PORT_DISP_OVL1>;
+   mediatek,larb = <>;
+};
+
+rdma0: rdma at 1400e000 {
+   compatible = 

[PATCH v15 0/8] MT8173 DRM support

2016-04-27 Thread Philipp Zabel
Rebased onto drm-next, fixed building as a module, removed the
driver unload hook, custom vm_ops, and the dts patch.

Changes since v14:
 - Fixed module build
 - Select DRM_GEM_CMA_HELPER and use drm_gem_cma_vm_ops
 - Select MEMORY so that select MTK_SMI works properly
 - Rebase onto drm-next so we can use drm_connector_unregister_all()
 - Remove deprecated unload hook
 - use div_u64 to avoid "__aeabi_uldivmod undefined" error when
   building as module
 - Dropped the dts patch, Matthias will pick it up separately
 - Added a patch to export mtk_smi_larb_get/put

regards
Philipp

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 (4):
  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
  memory: mtk-smi: export mtk_smi_larb_get/put

 .../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   |  16 +
 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 | 561 +
 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 ++
 drivers/memory/mtk-smi.c   |   2 +
 include/dt-bindings/clock/mt8173-clk.h |   3 +-
 31 files changed, 6106 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
 create mode 100644 drivers/gpu/drm/mediatek/mtk_mipi_tx.c

-- 
2.8.0.rc3



[Bug 93548] Grid Autosport causes a hard system crash

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

--- Comment #7 from serge  ---
i'm affected of the same bug, i also filled a bug report here:

https://bugs.freedesktop.org/show_bug.cgi?id=93353

After a request to the Feral support, i tested the patch but the GPU still
stall when the game is loading at the end of the qualifications.

-- 
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/20160427/50f682c6/attachment-0001.html>


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

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

--- Comment #19 from Nathan-J. Hirschauer  ---
Applied the patch on top of 43f46caf769b0a6d661850ce2fa64b6f4b085b9f, but
unfortunately it didn't work. Tested on a PowerBook G4 5,6 with Linux 4.6-rc4
(5f44abd041c5f3be76d57579ab254d78e601315b) / Debian Sid.

-- 
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/20160427/92d019ff/attachment.html>


[PATCH] drm/msm: Move call to PTR_ERR_OR_ZERO after reassignment

2016-04-27 Thread Vaishali Thakkar
Here, a location is reset to NULL before being passed to PTR_ERR.
So, PTR_ERR should be called before its argument is reassigned
to NULL. Further to simplify things use PTR_ERR_OR_ZERO instead
of PTR_ERR and IS_ERR.

Problem found using Coccinelle.

Signed-off-by: Vaishali Thakkar 
---
 drivers/gpu/drm/msm/edp/edp_ctrl.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/msm/edp/edp_ctrl.c 
b/drivers/gpu/drm/msm/edp/edp_ctrl.c
index 81200e9..7816541 100644
--- a/drivers/gpu/drm/msm/edp/edp_ctrl.c
+++ b/drivers/gpu/drm/msm/edp/edp_ctrl.c
@@ -302,21 +302,23 @@ static void edp_clk_disable(struct edp_ctrl *ctrl, u32 
clk_mask)
 static int edp_regulator_init(struct edp_ctrl *ctrl)
 {
struct device *dev = >pdev->dev;
+   int ret;

DBG("");
ctrl->vdda_vreg = devm_regulator_get(dev, "vdda");
-   if (IS_ERR(ctrl->vdda_vreg)) {
+   ret = PTR_ERR_OR_ZERO(ctrl->vdda_vreg);
+   if (ret) {
pr_err("%s: Could not get vdda reg, ret = %ld\n", __func__,
-   PTR_ERR(ctrl->vdda_vreg));
+   ret);
ctrl->vdda_vreg = NULL;
-   return PTR_ERR(ctrl->vdda_vreg);
+   return ret;
}
ctrl->lvl_vreg = devm_regulator_get(dev, "lvl-vdd");
-   if (IS_ERR(ctrl->lvl_vreg)) {
-   pr_err("Could not get lvl-vdd reg, %ld",
-   PTR_ERR(ctrl->lvl_vreg));
+   ret = PTR_ERR_OR_ZERO(ctrl->lvl_vreg);
+   if (ret) {
+   pr_err("Could not get lvl-vdd reg, %ld", ret);
ctrl->lvl_vreg = NULL;
-   return PTR_ERR(ctrl->lvl_vreg);
+   return ret;
}

return 0;
-- 
2.1.4



[PATCH v4 02/12] mm: migrate: support non-lru movable page migration

2016-04-27 Thread Minchan Kim
We have allowed migration for only LRU pages until now and it was
enough to make high-order pages. But recently, embedded system(e.g.,
webOS, android) uses lots of non-movable pages(e.g., zram, GPU memory)
so we have seen several reports about troubles of small high-order
allocation. For fixing the problem, there were several efforts
(e,g,. enhance compaction algorithm, SLUB fallback to 0-order page,
reserved memory, vmalloc and so on) but if there are lots of
non-movable pages in system, their solutions are void in the long run.

So, this patch is to support facility to change non-movable pages
with movable. For the feature, this patch introduces functions related
to migration to address_space_operations as well as some page flags.

If a driver want to make own pages movable, it should define three functions
which are function pointers of struct address_space_operations.

1. bool (*isolate_page) (struct page *page, isolate_mode_t mode);

What VM expects on isolate_page function of driver is to return *true*
if driver isolates page successfully. On returing true, VM marks the page
as PG_isolated so concurrent isolation in several CPUs skip the page
for isolation. If a driver cannot isolate the page, it should return *false*.

Once page is successfully isolated, VM uses page.lru fields so driver
shouldn't expect to preserve values in that fields.

2. int (*migratepage) (struct address_space *mapping,
struct page *newpage, struct page *oldpage, enum migrate_mode);

After isolation, VM calls migratepage of driver with isolated page.
The function of migratepage is to move content of the old page to new page
and set up fields of struct page newpage. Keep in mind that you should
clear PG_movable of oldpage via __ClearPageMovable under page_lock if you
migrated the oldpage successfully and returns MIGRATEPAGE_SUCCESS.
If driver cannot migrate the page at the moment, driver can return -EAGAIN.
On -EAGAIN, VM will retry page migration in a short time because VM interprets
-EAGAIN as "temporal migration failure". On returning any error except -EAGAIN,
VM will give up the page migration without retrying in this time.

Driver shouldn't touch page.lru field VM using in the functions.

3. void (*putback_page)(struct page *);

If migration fails on isolated page, VM should return the isolated page
to the driver so VM calls driver's putback_page with migration failed page.
In this function, driver should put the isolated page back to the own data
structure.

4. non-lru movable page flags

There are two page flags for supporting non-lru movable page.

* PG_movable

Driver should use the below function to make page movable under page_lock.

void __SetPageMovable(struct page *page, struct address_space *mapping)

It needs argument of address_space for registering migration family functions
which will be called by VM. Exactly speaking, PG_movable is not a real flag of
struct page. Rather than, VM reuses page->mapping's lower bits to represent it.

#define PAGE_MAPPING_MOVABLE 0x2
page->mapping = page->mapping | PAGE_MAPPING_MOVABLE;

so driver shouldn't access page->mapping directly. Instead, driver should
use page_mapping which mask off the low two bits of page->mapping so it can get
right struct address_space.

For testing of non-lru movable page, VM supports __PageMovable function.
However, it doesn't guarantee to identify non-lru movable page because
page->mapping field is unified with other variables in struct page.
As well, if driver releases the page after isolation by VM, page->mapping
doesn't have stable value although it has PAGE_MAPPING_MOVABLE
(Look at __ClearPageMovable). But __PageMovable is cheap to catch whether
page is LRU or non-lru movable once the page has been isolated. Because
LRU pages never can have PAGE_MAPPING_MOVABLE in page->mapping. It is also
good for just peeking to test non-lru movable pages before more expensive
checking with lock_page in pfn scanning to select victim.

For guaranteeing non-lru movable page, VM provides PageMovable function.
Unlike __PageMovable, PageMovable functions validates page->mapping and
mapping->a_ops->isolate_page under lock_page. The lock_page prevents sudden
destroying of page->mapping.

Driver using __SetPageMovable should clear the flag via __ClearMovablePage
under page_lock before the releasing the page.

* PG_isolated

To prevent concurrent isolation among several CPUs, VM marks isolated page
as PG_isolated under lock_page. So if a CPU encounters PG_isolated non-lru
movable page, it can skip it. Driver doesn't need to manipulate the flag
because VM will set/clear it automatically. Keep in mind that if driver
sees PG_isolated page, it means the page have been isolated by VM so it
shouldn't touch page.lru field.
PG_isolated is alias with PG_reclaim flag so driver shouldn't use the flag
for own purpose.

Cc: Rik van Riel 
Cc: Vlastimil Babka 
Cc: Joonsoo Kim 
Cc: Mel Gorman 
Cc: Hugh Dickins 
Cc: Rafael Aquini 
Cc: 

[PATCH v4 00/13] Support non-lru page migration

2016-04-27 Thread Minchan Kim
Recently, I got many reports about perfermance degradation in embedded
system(Android mobile phone, webOS TV and so on) and easy fork fail.

The problem was fragmentation caused by zram and GPU driver mainly.
With memory pressure, their pages were spread out all of pageblock and
it cannot be migrated with current compaction algorithm which supports
only LRU pages. In the end, compaction cannot work well so reclaimer
shrinks all of working set pages. It made system very slow and even to
fail to fork easily which requires order-[2 or 3] allocations.

Other pain point is that they cannot use CMA memory space so when OOM
kill happens, I can see many free pages in CMA area, which is not
memory efficient. In our product which has big CMA memory, it reclaims
zones too exccessively to allocate GPU and zram page although there are
lots of free space in CMA so system becomes very slow easily.

To solve these problem, this patch tries to add facility to migrate
non-lru pages via introducing new functions and page flags to help
migration.


struct address_space_operations {
..
..
bool (*isolate_page)(struct page *, isolate_mode_t);
void (*putback_page)(struct page *);
..
}

new page flags

PG_movable
PG_isolated

For details, please read description in "mm: migrate: support non-lru
movable page migration".

Originally, Gioh Kim had tried to support this feature but he moved so
I took over the work. I took many code from his work and changed a little
bit and Konstantin Khlebnikov helped Gioh a lot so he should deserve to have
many credit, too.

Thanks, Gioh and Konstantin!

This patchset consists of five parts.

1. clean up migration
  mm: use put_page to free page instead of putback_lru_page

2. add non-lru page migration feature
  mm: migrate: support non-lru movable page migration

3. rework KVM memory-ballooning
  mm: balloon: use general non-lru movable page feature

4. zsmalloc refactoring for preparing page migration
  zsmalloc: keep max_object in size_class
  zsmalloc: use bit_spin_lock
  zsmalloc: use accessor
  zsmalloc: factor page chain functionality out
  zsmalloc: introduce zspage structure
  zsmalloc: separate free_zspage from putback_zspage
  zsmalloc: use freeobj for index

5. zsmalloc page migration
  zsmalloc: page migration support
  zram: use __GFP_MOVABLE for memory allocation

* From v3
  * rebase on mmotm-2016-04-06-20-40
  * fix swap_info deadlock - Chulmin
  * race without page_lock - Vlastimil
  * no use page._mapcount for potential user-mapped page driver - Vlastimil
  * fix and enhance doc/description - Vlastimil
  * use page->mapping lower bits to represent PG_movable
  * make driver side's rule simple.

* From v2
  * rebase on mmotm-2016-03-29-15-54-16
  * check PageMovable before lock_page - Joonsoo
  * check PageMovable before PageIsolated checking - Joonsoo
  * add more description about rule

* From v1
  * rebase on v4.5-mmotm-2016-03-17-15-04
  * reordering patches to merge clean-up patches first
  * add Acked-by/Reviewed-by from Vlastimil and Sergey
  * use each own mount model instead of reusing anon_inode_fs - Al Viro
  * small changes - YiPing, Gioh

Cc: Vlastimil Babka 
Cc: dri-devel at lists.freedesktop.org
Cc: Hugh Dickins 
Cc: John Einar Reitan 
Cc: Jonathan Corbet 
Cc: Joonsoo Kim 
Cc: Konstantin Khlebnikov 
Cc: Mel Gorman 
Cc: Naoya Horiguchi 
Cc: Rafael Aquini 
Cc: Rik van Riel 
Cc: Sergey Senozhatsky 
Cc: virtualization at lists.linux-foundation.org
Cc: Gioh Kim 
Cc: Chan Gyun Jeong 
Cc: Sangseok Lee 
Cc: Kyeongdon Kim 
Cc: Chulmin Kim 

Minchan Kim (12):
  mm: use put_page to free page instead of  putback_lru_page
  mm: migrate: support non-lru movable page migration
  mm: balloon: use general non-lru movable page feature
  zsmalloc: keep max_object in size_class
  zsmalloc: use bit_spin_lock
  zsmalloc: use accessor
  zsmalloc: factor page chain functionality out
  zsmalloc: introduce zspage structure
  zsmalloc: separate free_zspage from putback_zspage
  zsmalloc: use freeobj for index
  zsmalloc: page migration support
  zram: use __GFP_MOVABLE for memory allocation

 Documentation/filesystems/Locking  |4 +
 Documentation/filesystems/vfs.txt  |   11 +
 Documentation/vm/page_migration|  107 +++-
 drivers/block/zram/zram_drv.c  |3 +-
 drivers/virtio/virtio_balloon.c|   52 +-
 include/linux/balloon_compaction.h |   51 +-
 include/linux/fs.h |2 +
 include/linux/ksm.h|3 +-
 include/linux/migrate.h|5 +
 include/linux/mm.h |1 +
 include/linux/page-flags.h |   23 +-
 include/uapi/linux/magic.h |2 +
 mm/balloon_compaction.c|   94 +--
 mm/compaction.c|   40 +-
 mm/ksm.c   |4 +-
 mm/migrate.c   |  287 +++--
 mm/page_alloc.c|4 +-
 mm/util.c  |6 +-
 mm/vmscan.c  

[Intel-gfx] i951 ERRORs and WARN_ON()s (was: blank screen on boot with i915/DRM_FBDEV_EMULATION)

2016-04-27 Thread Jani Nikula
On Wed, 27 Apr 2016, Florian Zumbiehl  wrote:
>> Florian, if you're using drm-intel-nigthly submit a bug at
>> https://bugs.freedesktop.org/enter_bug.cgi?product=DRI, with DRM/intel
>> as component. This way we can track some kind of progress/regress. The FIFO
>
> Gee ... is there any way without "creating an account"? Having to create
> accounts everywhere to be able to communicate with people just sucks. I
> mean, do you want to create an account in my todo tracker and use my todo
> tracker's web interface to coordinate the bug investigation? Use whatever
> software you like for managing your todo lists, but please, don't bother me
> with having to use it for you.

The Bugzilla at https://bugs.freedesktop.org is our tool of choice for
tracking bugs in drm/i915. It's your choice to not create an account
there, but please, don't expect us to work as a proxy between you and
bugzilla either. It's a much bigger and unscalable inconvenience for us
than it is for you to create that account.

I won't claim your bug will be fixed any faster if you choose to create
an account, but it's much more likely it won't get lost and forgotten in
the never ending stream of emails we all get.

> You mean the ones I reported a month ago should be fixed? Should I try a
> newer nightly to check?

Yes, please.

I'd also like to get a full dmesg from you, with drm.debug=14 module
parameter set, all the way from boot to the problem.

However, personally I find it a bit obnoxious to send big logs by mail
to hundreds or thousands of other people on the lists who really aren't
at all interested in them. Maybe you don't mind bothering them? It's
also not good to hide it away in my private inbox alone, because there
are other developers who will be interested. It has also proven to be
problematic to upload files to pastebins etc. where they expire at some
point in time, usually when we'd like to have a look.

Again, the obvious solution to the above is to file that bug and attach
the dmesg there, at the unfortunate slight inconvenience of you creating
an account there.

Your call.


BR,
Jani.


-- 
Jani Nikula, Intel Open Source Technology Center


[PATCH v3 2/2] dt-bindings: imx: ldb: Add ddc-i2c-bus property

2016-04-27 Thread Akshay Bhat
Document the ddc-i2c-bus property used by imx-ldb driver to read EDID
information via I2C interface.

Signed-off-by: Akshay Bhat 
---

v3:
Newly added.

 Documentation/devicetree/bindings/display/imx/ldb.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/display/imx/ldb.txt 
b/Documentation/devicetree/bindings/display/imx/ldb.txt
index 0a175d9..a407462 100644
--- a/Documentation/devicetree/bindings/display/imx/ldb.txt
+++ b/Documentation/devicetree/bindings/display/imx/ldb.txt
@@ -62,6 +62,7 @@ Required properties:
display-timings are used instead.

 Optional properties (required if display-timings are used):
+ - ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing
  - display-timings : A node that describes the display timings as defined in
Documentation/devicetree/bindings/display/display-timing.txt.
  - fsl,data-mapping : should be "spwg" or "jeida"
-- 
2.8.1



[PATCH v3 1/2] drm/imx: imx-ldb: Add DDC support

2016-04-27 Thread Akshay Bhat
From: Steve Longerbeam 

Add support for reading EDID over Display Data Channel. If no DDC
adapter is available, falls back to hardcoded EDID or display-timings
node as before.

Signed-off-by: Steve Longerbeam 
Signed-off-by: Akshay Bhat 
Acked-by: Philipp Zabel 
---

Hi Philipp,

I have addressed all your comments on v2 Patch.

Thanks,
Akshay

v3:
Move ddc_node pointer definition 
Warn and perform a probe deferral on failing to get ddc i2c adapter by node

v2:
Rebase to 4.6-rc5
Add check for channel->panel before fallback to display-timings node 

 drivers/gpu/drm/imx/imx-ldb.c | 42 ++
 1 file changed, 34 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
index a58eee5..f506e8d 100644
--- a/drivers/gpu/drm/imx/imx-ldb.c
+++ b/drivers/gpu/drm/imx/imx-ldb.c
@@ -59,6 +59,7 @@ struct imx_ldb_channel {
struct drm_encoder encoder;
struct drm_panel *panel;
struct device_node *child;
+   struct i2c_adapter *ddc;
int chno;
void *edid;
int edid_len;
@@ -107,6 +108,9 @@ static int imx_ldb_connector_get_modes(struct drm_connector 
*connector)
return num_modes;
}

+   if (!imx_ldb_ch->edid && imx_ldb_ch->ddc)
+   imx_ldb_ch->edid = drm_get_edid(connector, imx_ldb_ch->ddc);
+
if (imx_ldb_ch->edid) {
drm_mode_connector_update_edid_property(connector,
imx_ldb_ch->edid);
@@ -553,6 +557,7 @@ static int imx_ldb_bind(struct device *dev, struct device 
*master, void *data)

for_each_child_of_node(np, child) {
struct imx_ldb_channel *channel;
+   struct device_node *ddc_node;
struct device_node *port;

ret = of_property_read_u32(child, "reg", );
@@ -595,14 +600,34 @@ static int imx_ldb_bind(struct device *dev, struct device 
*master, void *data)
}
}

-   edidp = of_get_property(child, "edid", >edid_len);
-   if (edidp) {
-   channel->edid = kmemdup(edidp, channel->edid_len,
-   GFP_KERNEL);
-   } else if (!channel->panel) {
-   ret = of_get_drm_display_mode(child, >mode, 0);
-   if (!ret)
-   channel->mode_valid = 1;
+   ddc_node = of_parse_phandle(child, "ddc-i2c-bus", 0);
+   if (ddc_node) {
+   channel->ddc = of_find_i2c_adapter_by_node(ddc_node);
+   of_node_put(ddc_node);
+   if (!channel->ddc) {
+   dev_warn(dev, "failed to get ddc i2c 
adapter\n");
+   return -EPROBE_DEFER;
+   }
+   }
+
+   if (!channel->ddc) {
+   /* if no DDC available, fallback to hardcoded EDID */
+   dev_dbg(dev, "no ddc available\n");
+
+   edidp = of_get_property(child, "edid",
+   >edid_len);
+   if (edidp) {
+   channel->edid = kmemdup(edidp,
+   channel->edid_len,
+   GFP_KERNEL);
+   } else if (!channel->panel) {
+   /* fallback to display-timings node */
+   ret = of_get_drm_display_mode(child,
+ >mode,
+ 0);
+   if (!ret)
+   channel->mode_valid = 1;
+   }
}

channel->bus_format = of_get_bus_format(dev, child);
@@ -647,6 +672,7 @@ static void imx_ldb_unbind(struct device *dev, struct 
device *master,
channel->encoder.funcs->destroy(>encoder);

kfree(channel->edid);
+   i2c_put_adapter(channel->ddc);
}
 }

-- 
2.8.1



[Bug 93767] Glitches with soft shadows and MSAA in Knights of the Old Republic 2

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

Nicolai H�hnle  changed:

   What|Removed |Added

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

--- Comment #11 from Nicolai H�hnle  ---
The workaround is now in Mesa master, commit
8c43c06e0463515c1339d44cbb8f78169e6a06fb

-- 
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/20160427/8cf7fd6b/attachment.html>


[PATCH] gpu: ipu-v3: Fix imx-ipuv3-crtc module autoloading

2016-04-27 Thread Philipp Zabel
Am Mittwoch, den 27.04.2016, 08:54 -0500 schrieb Dennis Gilmore:
> Thanks Philipp,
> 
> I tested and module loading worked correctly
> 
> Dennis
> 
> On 2016-04-27 03:29, Philipp Zabel wrote:
> > If of_node is set before calling platform_device_add, the driver core
> > will try to use of: modalias matching, which fails because the device
> > tree nodes don't have a compatible property set. This patch fixes
> > imx-ipuv3-crtc module autoloading by setting the of_node property only
> > after the platform modalias is set.
> > 
> > Fixes: 304e6be652e2 ("gpu: ipu-v3: Assign of_node of child platform
> > devices to corresponding ports")
> > Reported-by: Dennis Gilmore 
> > Signed-off-by: Philipp Zabel 
> Tested-By: Dennis Gilmore 

Thank you.

regards
Philipp



[PATCH 1/9] drm: Add drm_mode_debug_printmodeline_raw

2016-04-27 Thread Jani Nikula
On Wed, 27 Apr 2016, Tvrtko Ursulin  wrote:
> From: Tvrtko Ursulin 
>
> Purpose is to enable drivers to print out just the mode
> string with their own formatting.

Some alternatives that preserve the use of a single printk(), avoiding
garbled console output due to races (as discussed on intel-gfx in reply
to the cover letter [1]):

1) Simply add a prefix string parameter to use in
   drm_mode_debug_printmodeline(). Really easy and covers most
   needs. Maybe wrap this in a macro to use the caller's function name.

2) Model drm_mode_debug_printmodeline() after drm_ut_debug_printk(),
   adding a mode parameter. Maybe wrap this in a macro to use the
   caller's function name.

3) Add char *drm_mode_line(mode) that kmallocs a mode line string, or a
   drm_mode_line(mode, buf, bufsize) that prints the mode string to a
   statically allocated buffer.

BR,
Jani.


[1] http://mid.gmane.org/87fuu7jp8x.fsf at intel.com

>
> Existing drm_mode_debug_printmodeline calls the new
> helper and the format is unchanged in this patch.
>
> Signed-off-by: Tvrtko Ursulin 
> Cc: Daniel Vetter 
> Cc: dri-devel at lists.freedesktop.org
> ---
>  drivers/gpu/drm/drm_modes.c | 29 ++---
>  include/drm/drm_modes.h |  1 +
>  2 files changed, 23 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> index 7def3d58da18..fd4795e2c8db 100644
> --- a/drivers/gpu/drm/drm_modes.c
> +++ b/drivers/gpu/drm/drm_modes.c
> @@ -42,6 +42,24 @@
>  #include "drm_crtc_internal.h"
>  
>  /**
> + * drm_mode_debug_printmodeline_raw - print a mode raw string to dmesg
> + * @mode: mode to print
> + *
> + * Describe @mode using DRM_DEBUG without the loglevel, drm prefix and 
> newline.
> + */
> +void drm_mode_debug_printmodeline_raw(const struct drm_display_mode *mode)
> +{
> + if (drm_debug & DRM_UT_KMS)
> + printk("%d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x",
> +mode->base.id, mode->name, mode->vrefresh, mode->clock,
> +mode->hdisplay, mode->hsync_start,
> +mode->hsync_end, mode->htotal,
> +mode->vdisplay, mode->vsync_start,
> +mode->vsync_end, mode->vtotal, mode->type, mode->flags);
> +}
> +EXPORT_SYMBOL(drm_mode_debug_printmodeline_raw);
> +
> +/**
>   * drm_mode_debug_printmodeline - print a mode to dmesg
>   * @mode: mode to print
>   *
> @@ -49,13 +67,10 @@
>   */
>  void drm_mode_debug_printmodeline(const struct drm_display_mode *mode)
>  {
> - DRM_DEBUG_KMS("Modeline %d:\"%s\" %d %d %d %d %d %d %d %d %d %d "
> - "0x%x 0x%x\n",
> - mode->base.id, mode->name, mode->vrefresh, mode->clock,
> - mode->hdisplay, mode->hsync_start,
> - mode->hsync_end, mode->htotal,
> - mode->vdisplay, mode->vsync_start,
> - mode->vsync_end, mode->vtotal, mode->type, mode->flags);
> + DRM_DEBUG_KMS("Modeline ");
> + drm_mode_debug_printmodeline_raw(mode);
> + if (drm_debug & DRM_UT_KMS)
> + printk("\n");
>  }
>  EXPORT_SYMBOL(drm_mode_debug_printmodeline);
>  
> diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
> index 625966a906f2..9bb0cd06b80e 100644
> --- a/include/drm/drm_modes.h
> +++ b/include/drm/drm_modes.h
> @@ -437,6 +437,7 @@ int drm_mode_convert_umode(struct drm_display_mode *out,
>  const struct drm_mode_modeinfo *in);
>  void drm_mode_probed_add(struct drm_connector *connector, struct 
> drm_display_mode *mode);
>  void drm_mode_debug_printmodeline(const struct drm_display_mode *mode);
> +void drm_mode_debug_printmodeline_raw(const struct drm_display_mode *mode);
>  
>  struct drm_display_mode *drm_cvt_mode(struct drm_device *dev,
> int hdisplay, int vdisplay, int vrefresh,

-- 
Jani Nikula, Intel Open Source Technology Center


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

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

--- Comment #18 from Dan DeVoto  ---
Same here.  Glxinfo says r300 fails to load.

dan at powerbook2:~$ glxinfo
name of display: :0.0
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: r300
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
Error: couldn't find RGB GLX visual or fbconfig

...

-- 
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/20160427/b4bd19d1/attachment.html>


[Intel-gfx] i951 ERRORs and WARN_ON()s (was: blank screen on boot with i915/DRM_FBDEV_EMULATION)

2016-04-27 Thread Florian Zumbiehl
Hi,

> Florian, if you're using drm-intel-nigthly submit a bug at
> https://bugs.freedesktop.org/enter_bug.cgi?product=DRI, with DRM/intel
> as component. This way we can track some kind of progress/regress. The FIFO

Gee ... is there any way without "creating an account"? Having to create
accounts everywhere to be able to communicate with people just sucks. I
mean, do you want to create an account in my todo tracker and use my todo
tracker's web interface to coordinate the bug investigation? Use whatever
software you like for managing your todo lists, but please, don't bother me
with having to use it for you.

> underruns should've have been fixed, but maybe there's something related
> to your platform.

You mean the ones I reported a month ago should be fixed? Should I try a
newer nightly to check?

What about the Xv stuttering?

Regards, Florian


[PATCH 2/2] drm/etnaviv: fix mmap operations for userptr and dma-buf objects

2016-04-27 Thread Lucas Stach
Add an indirect object operations call to allow distinct implementations
of the mmap operation based on the type of the object.

This ensures that the exporter is called to set up the mmap for imported
dma-bufs and disallows mapping of userptr objects through the DRM file,
as this might lead to serious corruption of kernel internal state.

Signed-off-by: Lucas Stach 
---
 drivers/gpu/drm/etnaviv/etnaviv_gem.c   | 10 +-
 drivers/gpu/drm/etnaviv/etnaviv_gem.h   |  1 +
 drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c |  7 +++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c 
b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
index 4d2277f6de03..1f919f5ca978 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
@@ -172,7 +172,7 @@ int etnaviv_gem_mmap(struct file *filp, struct 
vm_area_struct *vma)
}

obj = to_etnaviv_bo(vma->vm_private_data);
-   return etnaviv_gem_mmap_obj(obj, vma);
+   return obj->ops->mmap(obj, vma);
 }

 int etnaviv_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
@@ -544,6 +544,7 @@ static const struct etnaviv_gem_ops etnaviv_gem_shmem_ops = 
{
.get_pages = etnaviv_gem_shmem_get_pages,
.release = etnaviv_gem_shmem_release,
.vmap = etnaviv_gem_vmap_impl,
+   .mmap = etnaviv_gem_mmap_obj,
 };

 void etnaviv_gem_free_object(struct drm_gem_object *obj)
@@ -885,10 +886,17 @@ static void etnaviv_gem_userptr_release(struct 
etnaviv_gem_object *etnaviv_obj)
put_task_struct(etnaviv_obj->userptr.task);
 }

+static int etnaviv_gem_userptr_mmap_obj(struct etnaviv_gem_object *etnaviv_obj,
+   struct vm_area_struct *vma)
+{
+   return -EPERM;
+}
+
 static const struct etnaviv_gem_ops etnaviv_gem_userptr_ops = {
.get_pages = etnaviv_gem_userptr_get_pages,
.release = etnaviv_gem_userptr_release,
.vmap = etnaviv_gem_vmap_impl,
+   .mmap = etnaviv_gem_userptr_mmap_obj,
 };

 int etnaviv_gem_new_userptr(struct drm_device *dev, struct drm_file *file,
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.h 
b/drivers/gpu/drm/etnaviv/etnaviv_gem.h
index 02665d8c10ee..e63ff116a3b3 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem.h
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.h
@@ -79,6 +79,7 @@ struct etnaviv_gem_ops {
int (*get_pages)(struct etnaviv_gem_object *);
void (*release)(struct etnaviv_gem_object *);
void *(*vmap)(struct etnaviv_gem_object *);
+   int (*mmap)(struct etnaviv_gem_object *, struct vm_area_struct *);
 };

 static inline bool is_active(struct etnaviv_gem_object *etnaviv_obj)
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c 
b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
index 4e67395f5fa1..b93618c1aa69 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
@@ -84,10 +84,17 @@ static void *etnaviv_gem_prime_vmap_impl(struct 
etnaviv_gem_object *etnaviv_obj)
return dma_buf_vmap(etnaviv_obj->base.import_attach->dmabuf);
 }

+static int etnaviv_gem_prime_mmap_obj(struct etnaviv_gem_object *etnaviv_obj,
+   struct vm_area_struct *vma)
+{
+   return dma_buf_mmap(etnaviv_obj->base.dma_buf, vma, 0);
+}
+
 static const struct etnaviv_gem_ops etnaviv_gem_prime_ops = {
/* .get_pages should never be called */
.release = etnaviv_gem_prime_release,
.vmap = etnaviv_gem_prime_vmap_impl,
+   .mmap = etnaviv_gem_prime_mmap_obj,
 };

 struct drm_gem_object *etnaviv_gem_prime_import_sg_table(struct drm_device 
*dev,
-- 
2.8.0.rc3



[PATCH 1/2] drm/etnaviv: take etnaviv_gem_obj in etnaviv_gem_mmap_obj

2016-04-27 Thread Lucas Stach
This function will be changed to be called indirectly and this
prototype change brings it in line with all the other indirect
object calls.

Signed-off-by: Lucas Stach 
---
 drivers/gpu/drm/etnaviv/etnaviv_gem.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c 
b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
index 281c6eca20a8..4d2277f6de03 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
@@ -129,10 +129,9 @@ void etnaviv_gem_put_pages(struct etnaviv_gem_object 
*etnaviv_obj)
/* when we start tracking the pin count, then do something here */
 }

-static int etnaviv_gem_mmap_obj(struct drm_gem_object *obj,
+static int etnaviv_gem_mmap_obj(struct etnaviv_gem_object *etnaviv_obj,
struct vm_area_struct *vma)
 {
-   struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj);
pgprot_t vm_page_prot;

vma->vm_flags &= ~VM_PFNMAP;
@@ -151,9 +150,9 @@ static int etnaviv_gem_mmap_obj(struct drm_gem_object *obj,
 * in particular in the case of mmap'd dmabufs)
 */
fput(vma->vm_file);
-   get_file(obj->filp);
+   get_file(etnaviv_obj->base.filp);
vma->vm_pgoff = 0;
-   vma->vm_file  = obj->filp;
+   vma->vm_file  = etnaviv_obj->base.filp;

vma->vm_page_prot = vm_page_prot;
}
@@ -173,7 +172,7 @@ int etnaviv_gem_mmap(struct file *filp, struct 
vm_area_struct *vma)
}

obj = to_etnaviv_bo(vma->vm_private_data);
-   return etnaviv_gem_mmap_obj(vma->vm_private_data, vma);
+   return etnaviv_gem_mmap_obj(obj, vma);
 }

 int etnaviv_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
-- 
2.8.0.rc3



[PATCH] drm/etnaviv: remove BUG_ON in MMU unmap path

2016-04-27 Thread Lucas Stach
If the MMU map fails caused by an unaligned SG entry, the unmap path
is called to undo all already setup SG mappings. When encountering the
unaligned SG the unmap path hangs the kernel with a BUG(), while the
error is recoverable by just failing the submit that references the
faulty object.

Signed-off-by: Lucas Stach 
---
 drivers/gpu/drm/etnaviv/etnaviv_mmu.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_mmu.c 
b/drivers/gpu/drm/etnaviv/etnaviv_mmu.c
index 29a723fabc17..ebbb31ec9feb 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_mmu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_mmu.c
@@ -83,8 +83,6 @@ int etnaviv_iommu_unmap(struct etnaviv_iommu *iommu, u32 iova,

VERB("unmap[%d]: %08x(%zx)", i, iova, bytes);

-   BUG_ON(!PAGE_ALIGNED(bytes));
-
da += bytes;
}

-- 
2.8.0.rc3



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

2016-04-27 Thread Daniel Vetter
On Wed, Apr 27, 2016 at 12:58:51PM +0100, Chris Wilson wrote:
> On Wed, Apr 27, 2016 at 01:50:00PM +0200, Daniel Vetter wrote:
> > 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.
> > 
> > v3: Review from Lucas:
> > - drop != NULL in pointer checks.
> > - fixup copypasted kerneldoc to actually match the functions.
> > 
> > Cc: Chris Wilson 
> > Cc: Alex Deucher 
> > Cc: Lucas Stach 
> > Reviewed-by: Lucas Stach 
> > Signed-off-by: Daniel Vetter 
> > ---
> >  drivers/gpu/drm/drm_gem.c | 64 
> > ++-
> >  include/drm/drmP.h| 15 ---
> >  include/drm/drm_gem.h | 45 ++---
> >  3 files changed, 66 insertions(+), 58 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> > index 25dac31eef37..a4684a306c48 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(>struct_mutex));
> >  
> > -   if (dev->driver->gem_free_object != NULL)
> > +   if (dev->driver->gem_free_object_unlocked)
> > +   dev->driver->gem_free_object_unlocked(obj);
> > +   else if (dev->driver->gem_free_object)
> > dev->driver->gem_free_object(obj);
> >  }
> > -EXPORT_SYMBOL(drm_gem_object_free);
> 
> With my plan, I want to keep drm_gem_object_free exported.
> The plan being a __drm_gem_object_free_lockless fastpath.

Yeah, but I think we can reexport again in the patch that adds
__drm_gem_object_free_lockless. Just not much personally a friend of
sprawling EXPORT_SYMBOL when not needed. But I can drop that part too if
you feel strongly.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


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

2016-04-27 Thread Philipp Zabel
Am Mittwoch, den 27.04.2016, 13:21 +0200 schrieb Daniel Vetter:
> On Wed, Apr 27, 2016 at 12:29:34PM +0200, Philipp Zabel wrote:
> > Am Dienstag, den 26.04.2016, 19:29 +0200 schrieb 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 = _gem_cma_vm_ops,
> > >   .dumb_create= drm_gem_cma_dumb_create,
> > >   .dumb_map_offset= drm_gem_cma_dumb_map_offset,
> > 
> > Applied to imx-drm/fixes, thank you.
> 
> And that compiles for you? Might want to drop the patch again before
> someone notices ;-)

Nope, dropped. Nobody will have to.



[pull] radeon and amdgpu drm-fixes-4.6

2016-04-27 Thread Alex Deucher
Hi Dave,

A few fixes for 4.6.
- revert amdgpu PX commit that was previously reverted on the radeon side
- cleaned up version of the NI+ MC update display fix for radeon
- TTM kref fix

The following changes since commit 18cdfe751f26ffa610f2a7b59775c5cc4c1c9619:

  Merge branch 'drm-fixes-4.6' of git://people.freedesktop.org/~agd5f/linux 
into drm-fixes (2016-04-22 10:39:26 +1000)

are available in the git repository at:

  git://people.freedesktop.org/~agd5f/linux drm-fixes-4.6

for you to fetch changes up to afc4542105f2b5a3bc6f0f3530d7ccbc94ca90fb:

  drm/amdgpu: disable vm interrupts with vm_fault_stop=2 (2016-04-27 12:27:10 
-0400)


Alex Deucher (2):
  Revert "drm/amdgpu: disable runtime pm on PX laptops without dGPU power 
control"
  drm/amdgpu: print a message if ATPX dGPU power control is missing

Flora Cui (2):
  drm/ttm: fix kref count mess in ttm_bo_move_to_lru_tail
  drm/amdgpu: disable vm interrupts with vm_fault_stop=2

Vitaly Prosyak (1):
  drm/radeon: fix vertical bars appear on monitor (v2)

 drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c |  11 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c   |   8 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c|   5 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c|   5 +-
 drivers/gpu/drm/radeon/evergreen.c   | 154 ++-
 drivers/gpu/drm/radeon/evergreen_reg.h   |  46 +++
 drivers/gpu/drm/ttm/ttm_bo.c |  17 +--
 7 files changed, 219 insertions(+), 27 deletions(-)


[PATCH 1/9] drm: Add drm_mode_debug_printmodeline_raw

2016-04-27 Thread Tvrtko Ursulin

On 27/04/16 13:35, Jani Nikula wrote:
> On Wed, 27 Apr 2016, Tvrtko Ursulin  wrote:
>> From: Tvrtko Ursulin 
>>
>> Purpose is to enable drivers to print out just the mode
>> string with their own formatting.
>
> Some alternatives that preserve the use of a single printk(), avoiding
> garbled console output due to races (as discussed on intel-gfx in reply
> to the cover letter [1]):
>
> 1) Simply add a prefix string parameter to use in
> drm_mode_debug_printmodeline(). Really easy and covers most
> needs. Maybe wrap this in a macro to use the caller's function name.
>
> 2) Model drm_mode_debug_printmodeline() after drm_ut_debug_printk(),
> adding a mode parameter. Maybe wrap this in a macro to use the
> caller's function name.

This sounds good to me...

> 3) Add char *drm_mode_line(mode) that kmallocs a mode line string, or a
> drm_mode_line(mode, buf, bufsize) that prints the mode string to a
> statically allocated buffer.

...but it only solved the modeline part of the story. Unless something 
like 3), which I specifically wanted to avoid. String handling etc.. 
best to be avoided in general if possible and more so for debug code 
only. Any potential bug in those is best avoided if they do not exist. 
And some of them log external input so even more so.

Something like debug_start/debug_print/debug_end would solve all that 
but that would be bigger and core.

I'll try to do 2) and see what to do with the rest...

Regards,

Tvrtko


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

2016-04-27 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.

v3: Review from Lucas:
- drop != NULL in pointer checks.
- fixup copypasted kerneldoc to actually match the functions.

Cc: Chris Wilson 
Cc: Alex Deucher 
Cc: Lucas Stach 
Reviewed-by: Lucas Stach 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_gem.c | 64 ++-
 include/drm/drmP.h| 15 ---
 include/drm/drm_gem.h | 45 ++---
 3 files changed, 66 insertions(+), 58 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 25dac31eef37..a4684a306c48 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(>struct_mutex));

-   if (dev->driver->gem_free_object != NULL)
+   if (dev->driver->gem_free_object_unlocked)
+   dev->driver->gem_free_object_unlocked(obj);
+   else if (dev->driver->gem_free_object)
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(>struct_mutex);
+
+   if (dev->driver->gem_free_object)
+   kref_put(>refcount, drm_gem_object_free);
+   else if (kref_put_mutex(>refcount, drm_gem_object_free,
+   >struct_mutex))
+   mutex_unlock(>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) {
+   WARN_ON(!mutex_is_locked(>dev->struct_mutex));
+
+   kref_put(>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..bd7b262d7af0 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -580,12 +580,21 @@ struct drm_driver {
void (*debugfs_cleanup)(struct drm_minor *minor);

/**
-* Driver-specific constructor for drm_gem_objects, to set up
-* obj->driver_private.
+* @gem_free_object: deconstructor for drm_gem_objects
 *
-* 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);
+
+   /**
+* @gem_free_object_unlocked: deconstructor for drm_gem_objects
+*
+* 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, 

[PATCH 3/3] drm/msm: Nuke dummy fb->dirty callback

2016-04-27 Thread Daniel Vetter
It's an optional hook.

Cc: Rob Clark 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/msm/msm_fb.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_fb.c b/drivers/gpu/drm/msm/msm_fb.c
index 17e0c9eb1900..672d8b1c2d09 100644
--- a/drivers/gpu/drm/msm/msm_fb.c
+++ b/drivers/gpu/drm/msm/msm_fb.c
@@ -56,17 +56,9 @@ static void msm_framebuffer_destroy(struct drm_framebuffer 
*fb)
kfree(msm_fb);
 }

-static int msm_framebuffer_dirty(struct drm_framebuffer *fb,
-   struct drm_file *file_priv, unsigned flags, unsigned color,
-   struct drm_clip_rect *clips, unsigned num_clips)
-{
-   return 0;
-}
-
 static const struct drm_framebuffer_funcs msm_framebuffer_funcs = {
.create_handle = msm_framebuffer_create_handle,
.destroy = msm_framebuffer_destroy,
-   .dirty = msm_framebuffer_dirty,
 };

 #ifdef CONFIG_DEBUG_FS
-- 
2.8.1



[PATCH 2/3] drm/exynos: Nuke dummy fb->dirty callback

2016-04-27 Thread Daniel Vetter
It's an optional hook. Might be needed for frontbuffer rendering on
manual upload displays, but a simple TODO doesn't explain at all what
needs to be done or why.

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

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c 
b/drivers/gpu/drm/exynos/exynos_drm_fb.c
index 81cc5537cf25..f851a40ac6cb 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fb.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c
@@ -97,20 +97,9 @@ static int exynos_drm_fb_create_handle(struct 
drm_framebuffer *fb,
 _fb->exynos_gem[0]->base, handle);
 }

-static int exynos_drm_fb_dirty(struct drm_framebuffer *fb,
-   struct drm_file *file_priv, unsigned flags,
-   unsigned color, struct drm_clip_rect *clips,
-   unsigned num_clips)
-{
-   /* TODO */
-
-   return 0;
-}
-
 static const struct drm_framebuffer_funcs exynos_drm_fb_funcs = {
.destroy= exynos_drm_fb_destroy,
.create_handle  = exynos_drm_fb_create_handle,
-   .dirty  = exynos_drm_fb_dirty,
 };

 struct drm_framebuffer *
-- 
2.8.1



[PATCH 1/3] drm/rockchip: Use cma gem vm ops

2016-04-27 Thread Daniel Vetter
No need to reinvent this little wheel.

v2: Like, try to make it compile even.

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

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index 903202224057..02fe3748bcc3 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -292,11 +293,6 @@ static const struct file_operations 
rockchip_drm_driver_fops = {
.release = drm_release,
 };

-const struct vm_operations_struct rockchip_drm_vm_ops = {
-   .open = drm_gem_vm_open,
-   .close = drm_gem_vm_close,
-};
-
 static struct drm_driver rockchip_drm_driver = {
.driver_features= DRIVER_MODESET | DRIVER_GEM |
  DRIVER_PRIME | DRIVER_ATOMIC,
@@ -307,7 +303,7 @@ static struct drm_driver rockchip_drm_driver = {
.get_vblank_counter = drm_vblank_no_hw_counter,
.enable_vblank  = rockchip_drm_crtc_enable_vblank,
.disable_vblank = rockchip_drm_crtc_disable_vblank,
-   .gem_vm_ops = _drm_vm_ops,
+   .gem_vm_ops = _gem_cma_vm_ops,
.gem_free_object_unlocked = rockchip_gem_free_object,
.dumb_create= rockchip_gem_dumb_create,
.dumb_map_offset= rockchip_gem_dumb_map_offset,
-- 
2.8.1



i915: screen flicker

2016-04-27 Thread Jani Nikula
On Wed, 27 Apr 2016, Mihai Donțu  wrote:
> On Wed, 27 Apr 2016 10:09:32 +0300 Jani Nikula wrote:
>> On Wed, 27 Apr 2016, Mihai Donțu wrote:
>> > I noticed that since I started using 4.6.0-rcX, my screen flickers once
>> > or twice after I stop using my laptop for ~1min or so. Given the
>> > behavior, my prime suspect is the PSR feature that you have announced
>> > for this release:
>> >
>> >   http://blog.ffwll.ch/2016/03/neat-drmi915-stuff-for-46.html
>> >
>> > Is 'enable_psr' the right knob to use to turn this feature off and see
>> > if my suspicions are correct? Or is there a patch floating around that
>> > I can test?  
>> 
>> i915.enable_psr=0 is the one to try, yes.
>
> I can confirm that with PSR off, the flicker goes away.

Please file a bug at [1] and assign to Rodrigo (Cc'd).

BR,
Jani.

[1] https://bugs.freedesktop.org/enter_bug.cgi?product=DRI=DRM/Intel


-- 
Jani Nikula, Intel Open Source Technology Center


[PATCH] drm/i915: Fix enc_to_dig_port() for MST encoders

2016-04-27 Thread Lyude
For MST encoders, the encoder struct is stored in the intel_dp_mst
struct, not a intel_digital_port struct.

This fixes issues with hotplugging MST displays that support MST audio,
where hotplugging had a surprisingly good chance of accidentally
overwriting other parts of the kernel leading to seemingly unrelated
backtraces in sysfs, ext4, etc.

Cc: stable at vger.kernel.org
Signed-off-by: Lyude 
---
 drivers/gpu/drm/i915/intel_drv.h | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 4c027d6..81f2212 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -918,18 +918,23 @@ intel_attached_encoder(struct drm_connector *connector)
return to_intel_connector(connector)->encoder;
 }

-static inline struct intel_digital_port *
-enc_to_dig_port(struct drm_encoder *encoder)
-{
-   return container_of(encoder, struct intel_digital_port, base.base);
-}
-
 static inline struct intel_dp_mst_encoder *
 enc_to_mst(struct drm_encoder *encoder)
 {
return container_of(encoder, struct intel_dp_mst_encoder, base.base);
 }

+static inline struct intel_digital_port *
+enc_to_dig_port(struct drm_encoder *encoder)
+{
+   if (encoder->encoder_type == DRM_MODE_ENCODER_DPMST)
+   return enc_to_mst(encoder)->primary;
+   else {
+   return container_of(encoder, struct intel_digital_port,
+   base.base);
+   }
+}
+
 static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
 {
return _to_dig_port(encoder)->dp;
-- 
2.5.5



[PATCH 12/12] Documentation: add Sync File doc

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

Add sync_file documentation on dma-buf-sync_file.txt
---
 Documentation/dma-buf-sync_file.txt | 65 +
 1 file changed, 65 insertions(+)
 create mode 100644 Documentation/dma-buf-sync_file.txt

diff --git a/Documentation/dma-buf-sync_file.txt 
b/Documentation/dma-buf-sync_file.txt
new file mode 100644
index 000..aa7320f
--- /dev/null
+++ b/Documentation/dma-buf-sync_file.txt
@@ -0,0 +1,65 @@
+DMA Buffer Sync File API Guide
+~~
+
+   Gustavo Padovan
+ 
+
+This document serves as a guide for device drivers writers on what is the
+dma-buf sync_file API, and how drivers can support it. Sync file is the
+carrier of the fences(struct fence) that needs to synchronized between drivers.
+
+The sync_file API is meant to be used to send and receive fence information
+to/from userspace. It enables userspace to do explicit fencing, where instead
+of attaching a fence to the buffer a Producer driver (such as GPU or V4L
+driver) it sends the fence related to the buffer to userspace. The fence then
+can be sent to the Consumer (DRM driver for example), that will not use the
+buffer for anything before the fence signals, i.e., the driver that issued the
+fence is not using/processing the buffer anymore, so it signals that the buffer
+is ready to use. And vice-versa for the Consumer -> Producer part of the cycle.
+Sync files allows userspace awareness on the DMA buffer sharing synchronization
+between drivers.
+
+Sync file was originally added in the Android kernel but current Linux Desktop
+can benefit a lot from it.
+
+in-fences and out-fences
+
+
+Sync files can go either to or from userspace. When a sync_file is sent from
+the driver to userspace we call the fences it contains 'out-fences'. They are
+related to a buffer that the driver is processing or is going to process, so
+the driver create out-fences to be able to notify, through fence_signal(), when
+it has finished using (or processing) that buffer. Out-fences are fences that
+the driver creates.
+
+On the other hand if the driver receives fence(s) through a sync_file from
+userspace we call these fence(s) 'in-fences'. Receiveing in-fences means that
+we need to wait for the fence(s) to signal before using any buffer related to
+the in-fences.
+
+Creating Sync Files
+---
+
+When a driver needs to send an out-fence userspace it creates a sync_file.
+
+Interface:
+   struct sync_file *sync_file_create(const char *name, struct fence 
*fence);
+
+The caller pass the name and the out-fence and gets back the sync_file. That is
+just the first step, next it needs to install an fd on sync_file->file. So it
+gets an fd:
+
+   fd = get_unused_fd_flags(O_CLOEXEC);
+
+and installs it on sync_file->file:
+
+   fd_install(fd, sync_file->file);
+
+The sync_file fd now can be sent to userspace.
+
+If the creation process fail, or the sync_file needs to be released by any
+other reason fput(sync_file->file) should be used.
+
+References:
+[1] struct sync_file in include/linux/sync_file.h
+[2] All interfaces mentioned above defined in include/linux/sync_file.h
-- 
2.5.5



[PATCH 11/12] Documentation: include sync_file into DocBook

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

Add entry in device-drivers.tmpl for sync_file documentation.

Signed-off-by: Gustavo Padovan 
---
 Documentation/DocBook/device-drivers.tmpl | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/DocBook/device-drivers.tmpl 
b/Documentation/DocBook/device-drivers.tmpl
index 184f3c7..509a187 100644
--- a/Documentation/DocBook/device-drivers.tmpl
+++ b/Documentation/DocBook/device-drivers.tmpl
@@ -136,6 +136,8 @@ X!Edrivers/base/interface.c
 !Iinclude/linux/seqno-fence.h
 !Edrivers/dma-buf/reservation.c
 !Iinclude/linux/reservation.h
+!Edrivers/dma-buf/sync_file.c
+!Iinclude/linux/sync_file.h
 !Edrivers/base/dma-coherent.c
 !Edrivers/base/dma-mapping.c
  
-- 
2.5.5



[PATCH 10/12] dma-buf/sync_file: de-stage sync_file

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

sync_file is useful to connect one or more fences to the file. The file is
used by userspace to track fences between drivers that share DMA bufs.

Signed-off-by: Gustavo Padovan 
---
 drivers/Kconfig  |  2 ++
 drivers/dma-buf/Kconfig  | 11 +++
 drivers/dma-buf/Makefile |  1 +
 drivers/{staging/android => dma-buf}/sync_file.c |  0
 drivers/staging/android/Kconfig  |  1 +
 drivers/staging/android/Makefile |  2 +-
 6 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 drivers/dma-buf/Kconfig
 rename drivers/{staging/android => dma-buf}/sync_file.c (100%)

diff --git a/drivers/Kconfig b/drivers/Kconfig
index d2ac339..430f761 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -114,6 +114,8 @@ source "drivers/rtc/Kconfig"

 source "drivers/dma/Kconfig"

+source "drivers/dma-buf/Kconfig"
+
 source "drivers/dca/Kconfig"

 source "drivers/auxdisplay/Kconfig"
diff --git a/drivers/dma-buf/Kconfig b/drivers/dma-buf/Kconfig
new file mode 100644
index 000..9824bc4
--- /dev/null
+++ b/drivers/dma-buf/Kconfig
@@ -0,0 +1,11 @@
+menu "DMABUF options"
+
+config SYNC_FILE
+   bool "sync_file support for fences"
+   default n
+   select ANON_INODES
+   select DMA_SHARED_BUFFER
+   ---help---
+ This option enables the fence framework synchronization to export
+ sync_files to userspace that can represent one or more fences.
+endmenu
diff --git a/drivers/dma-buf/Makefile b/drivers/dma-buf/Makefile
index 57a675f..4a424ec 100644
--- a/drivers/dma-buf/Makefile
+++ b/drivers/dma-buf/Makefile
@@ -1 +1,2 @@
 obj-y := dma-buf.o fence.o reservation.o seqno-fence.o
+obj-$(CONFIG_SYNC_FILE)+= sync_file.o
diff --git a/drivers/staging/android/sync_file.c b/drivers/dma-buf/sync_file.c
similarity index 100%
rename from drivers/staging/android/sync_file.c
rename to drivers/dma-buf/sync_file.c
diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig
index 4244821..7a3a77e 100644
--- a/drivers/staging/android/Kconfig
+++ b/drivers/staging/android/Kconfig
@@ -38,6 +38,7 @@ config SW_SYNC
bool "Software synchronization objects"
default n
depends on SYNC
+   depends on SYNC_FILE
---help---
  A sync object driver that uses a 32bit counter to coordinate
  synchronization.  Useful when there is no hardware primitive backing
diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile
index ebc2df1..980d6dc 100644
--- a/drivers/staging/android/Makefile
+++ b/drivers/staging/android/Makefile
@@ -4,5 +4,5 @@ obj-y   += ion/

 obj-$(CONFIG_ASHMEM)   += ashmem.o
 obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER)+= lowmemorykiller.o
-obj-$(CONFIG_SYNC) += sync_file.o sync.o sync_debug.o
+obj-$(CONFIG_SYNC) += sync.o sync_debug.o
 obj-$(CONFIG_SW_SYNC)  += sw_sync.o
-- 
2.5.5



[PATCH 09/12] dma-buf/sync_file: de-stage sync_file headers

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

Move sync_file headers file to include/ dir.

Signed-off-by: Gustavo Padovan 
---
 drivers/staging/android/sync.h   | 4 ++--
 drivers/staging/android/sync_debug.c | 2 +-
 drivers/staging/android/sync_file.c  | 4 ++--
 {drivers/staging/android => include/linux}/sync_file.h   | 0
 {drivers/staging/android/uapi => include/uapi/linux}/sync_file.h | 0
 5 files changed, 5 insertions(+), 5 deletions(-)
 rename {drivers/staging/android => include/linux}/sync_file.h (100%)
 rename {drivers/staging/android/uapi => include/uapi/linux}/sync_file.h (100%)

diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h
index df44abb..b56885c 100644
--- a/drivers/staging/android/sync.h
+++ b/drivers/staging/android/sync.h
@@ -20,8 +20,8 @@
 #include 
 #include 

-#include "sync_file.h"
-#include "uapi/sync_file.h"
+#include 
+#include 

 struct sync_timeline;

diff --git a/drivers/staging/android/sync_debug.c 
b/drivers/staging/android/sync_debug.c
index 6589aba..9ce3c5d 100644
--- a/drivers/staging/android/sync_debug.c
+++ b/drivers/staging/android/sync_debug.c
@@ -26,7 +26,7 @@
 #include 
 #include 
 #include 
-#include "sync_file.h"
+#include 
 #include "sw_sync.h"

 #ifdef CONFIG_DEBUG_FS
diff --git a/drivers/staging/android/sync_file.c 
b/drivers/staging/android/sync_file.c
index 0862c7f..c4eec1c 100644
--- a/drivers/staging/android/sync_file.c
+++ b/drivers/staging/android/sync_file.c
@@ -23,8 +23,8 @@
 #include 
 #include 
 #include 
-#include "sync_file.h"
-#include "uapi/sync_file.h"
+#include 
+#include 

 static const struct file_operations sync_file_fops;

diff --git a/drivers/staging/android/sync_file.h b/include/linux/sync_file.h
similarity index 100%
rename from drivers/staging/android/sync_file.h
rename to include/linux/sync_file.h
diff --git a/drivers/staging/android/uapi/sync_file.h 
b/include/uapi/linux/sync_file.h
similarity index 100%
rename from drivers/staging/android/uapi/sync_file.h
rename to include/uapi/linux/sync_file.h
-- 
2.5.5



[PATCH 08/12] staging/android: style fix: alignment to match the open parenthesis

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

Fix checks reported by checkpatch.pl.

Signed-off-by: Gustavo Padovan 
---
 drivers/staging/android/sync_file.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/android/sync_file.c 
b/drivers/staging/android/sync_file.c
index 5d77c08..0862c7f 100644
--- a/drivers/staging/android/sync_file.c
+++ b/drivers/staging/android/sync_file.c
@@ -241,7 +241,7 @@ static unsigned int sync_file_poll(struct file *file, 
poll_table *wait)
 }

 static long sync_file_ioctl_merge(struct sync_file *sync_file,
-  unsigned long arg)
+ unsigned long arg)
 {
int fd = get_unused_fd_flags(O_CLOEXEC);
int err;
@@ -296,7 +296,7 @@ err_put_fd:
 }

 static void sync_fill_fence_info(struct fence *fence,
-   struct sync_fence_info *info)
+struct sync_fence_info *info)
 {
strlcpy(info->obj_name, fence->ops->get_timeline_name(fence),
sizeof(info->obj_name));
@@ -310,7 +310,7 @@ static void sync_fill_fence_info(struct fence *fence,
 }

 static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
-   unsigned long arg)
+  unsigned long arg)
 {
struct sync_file_info info;
struct sync_fence_info *fence_info = NULL;
@@ -369,7 +369,7 @@ out:
 }

 static long sync_file_ioctl(struct file *file, unsigned int cmd,
-unsigned long arg)
+   unsigned long arg)
 {
struct sync_file *sync_file = file->private_data;

-- 
2.5.5



[PATCH 07/12] staging/android: improve documentation for sync_file

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

num_fences was missing a colon mark and sync_file_create() now have
better description.

Signed-off-by: Gustavo Padovan 
---
 drivers/staging/android/sync_file.c | 3 ++-
 drivers/staging/android/sync_file.h | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/android/sync_file.c 
b/drivers/staging/android/sync_file.c
index 3902538..5d77c08 100644
--- a/drivers/staging/android/sync_file.c
+++ b/drivers/staging/android/sync_file.c
@@ -71,7 +71,8 @@ static void fence_check_cb_func(struct fence *f, struct 
fence_cb *cb)
  * @fence: fence to add to the sync_fence
  *
  * Creates a sync_file containg @fence. Once this is called, the sync_file
- * takes ownership of @fence.
+ * takes ownership of @fence. The sync_file can be released with
+ * fput(sync_file->file). Returns the sync_file or NULL in case of error.
  */
 struct sync_file *sync_file_create(const char *name, struct fence *fence)
 {
diff --git a/drivers/staging/android/sync_file.h 
b/drivers/staging/android/sync_file.h
index a53259c..003db09 100644
--- a/drivers/staging/android/sync_file.h
+++ b/drivers/staging/android/sync_file.h
@@ -32,7 +32,7 @@ struct sync_file_cb {
  * @kref:  reference count on fence.
  * @name:  name of sync_file.  Useful for debugging
  * @sync_file_list:membership in global file list
- * @num_fences number of sync_pts in the fence
+ * @num_fences:number of sync_pts in the fence
  * @wq:wait queue for fence signaling
  * @status:0: signaled, >0:active, <0: error
  * @cbs:   sync_pts callback information
-- 
2.5.5



[PATCH 06/12] staging/android: prepare sync_file for de-staging

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

Move its functions and structs to their own file. Also moves function's
docs to the .c file.

Signed-off-by: Gustavo Padovan 
---
 drivers/staging/android/Makefile   |   2 +-
 drivers/staging/android/sync.c | 373 ---
 drivers/staging/android/sync.h |  38 +-
 drivers/staging/android/sync_debug.c   |   1 +
 drivers/staging/android/sync_file.c| 393 +
 drivers/staging/android/sync_file.h|  57 +++
 .../staging/android/uapi/{sync.h => sync_file.h}   |   0
 7 files changed, 454 insertions(+), 410 deletions(-)
 create mode 100644 drivers/staging/android/sync_file.c
 create mode 100644 drivers/staging/android/sync_file.h
 rename drivers/staging/android/uapi/{sync.h => sync_file.h} (100%)

diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile
index 980d6dc..ebc2df1 100644
--- a/drivers/staging/android/Makefile
+++ b/drivers/staging/android/Makefile
@@ -4,5 +4,5 @@ obj-y   += ion/

 obj-$(CONFIG_ASHMEM)   += ashmem.o
 obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER)+= lowmemorykiller.o
-obj-$(CONFIG_SYNC) += sync.o sync_debug.o
+obj-$(CONFIG_SYNC) += sync_file.o sync.o sync_debug.o
 obj-$(CONFIG_SW_SYNC)  += sw_sync.o
diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index 1239684..1d14c83 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -16,10 +16,7 @@

 #include 
 #include 
-#include 
-#include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -32,7 +29,6 @@
 #include "trace/sync.h"

 static const struct fence_ops android_fence_ops;
-static const struct file_operations sync_file_fops;

 struct sync_timeline *sync_timeline_create(const struct sync_timeline_ops *ops,
   int size, const char *name)
@@ -136,181 +132,6 @@ struct fence *sync_pt_create(struct sync_timeline *obj, 
int size)
 }
 EXPORT_SYMBOL(sync_pt_create);

-static struct sync_file *sync_file_alloc(int size, const char *name)
-{
-   struct sync_file *sync_file;
-
-   sync_file = kzalloc(size, GFP_KERNEL);
-   if (!sync_file)
-   return NULL;
-
-   sync_file->file = anon_inode_getfile("sync_file", _file_fops,
-sync_file, 0);
-   if (IS_ERR(sync_file->file))
-   goto err;
-
-   kref_init(_file->kref);
-   strlcpy(sync_file->name, name, sizeof(sync_file->name));
-
-   init_waitqueue_head(_file->wq);
-
-   return sync_file;
-
-err:
-   kfree(sync_file);
-   return NULL;
-}
-
-static void fence_check_cb_func(struct fence *f, struct fence_cb *cb)
-{
-   struct sync_file_cb *check;
-   struct sync_file *sync_file;
-
-   check = container_of(cb, struct sync_file_cb, cb);
-   sync_file = check->sync_file;
-
-   if (atomic_dec_and_test(_file->status))
-   wake_up_all(_file->wq);
-}
-
-/**
- * sync_fence_create() - creates a sync fence
- * @name:  name of fence to create
- * @fence: fence to add to the sync_fence
- *
- * Creates a sync_file containg @fence. Once this is called, the sync_file
- * takes ownership of @fence.
- */
-struct sync_file *sync_file_create(const char *name, struct fence *fence)
-{
-   struct sync_file *sync_file;
-
-   sync_file = sync_file_alloc(offsetof(struct sync_file, cbs[1]),
-   name);
-   if (!sync_file)
-   return NULL;
-
-   sync_file->num_fences = 1;
-   atomic_set(_file->status, 1);
-
-   sync_file->cbs[0].fence = fence;
-   sync_file->cbs[0].sync_file = sync_file;
-   if (fence_add_callback(fence, _file->cbs[0].cb,
-  fence_check_cb_func))
-   atomic_dec(_file->status);
-
-   sync_file_debug_add(sync_file);
-
-   return sync_file;
-}
-EXPORT_SYMBOL(sync_file_create);
-
-/**
- * sync_file_fdget() - get a sync_file from an fd
- * @fd:fd referencing a fence
- *
- * Ensures @fd references a valid sync_file, increments the refcount of the
- * backing file. Returns the sync_file or NULL in case of error.
- */
-static struct sync_file *sync_file_fdget(int fd)
-{
-   struct file *file = fget(fd);
-
-   if (!file)
-   return NULL;
-
-   if (file->f_op != _file_fops)
-   goto err;
-
-   return file->private_data;
-
-err:
-   fput(file);
-   return NULL;
-}
-
-static void sync_file_add_pt(struct sync_file *sync_file, int *i,
-struct fence *fence)
-{
-   sync_file->cbs[*i].fence = fence;
-   sync_file->cbs[*i].sync_file = sync_file;
-
-   if (!fence_add_callback(fence, _file->cbs[*i].cb,
-   fence_check_cb_func)) {

[PATCH 05/12] staging/android: make sync_file_fdget() static

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

There is no plan in the near future to use this function outside of this
file so keep it as static.

Signed-off-by: Gustavo Padovan 
---
 drivers/staging/android/sync.c | 3 +--
 drivers/staging/android/sync.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index c441fde..1239684 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -212,7 +212,7 @@ EXPORT_SYMBOL(sync_file_create);
  * Ensures @fd references a valid sync_file, increments the refcount of the
  * backing file. Returns the sync_file or NULL in case of error.
  */
-struct sync_file *sync_file_fdget(int fd)
+static struct sync_file *sync_file_fdget(int fd)
 {
struct file *file = fget(fd);

@@ -228,7 +228,6 @@ err:
fput(file);
return NULL;
 }
-EXPORT_SYMBOL(sync_file_fdget);

 static void sync_file_add_pt(struct sync_file *sync_file, int *i,
 struct fence *fence)
diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h
index ffc6df6..1f164df 100644
--- a/drivers/staging/android/sync.h
+++ b/drivers/staging/android/sync.h
@@ -168,7 +168,6 @@ void sync_timeline_signal(struct sync_timeline *obj);
 struct fence *sync_pt_create(struct sync_timeline *parent, int size);

 struct sync_file *sync_file_create(const char *name, struct fence *fence);
-struct sync_file *sync_file_fdget(int fd);

 #ifdef CONFIG_DEBUG_FS

-- 
2.5.5



[PATCH 04/12] staging/android: make sync_file_merge() static

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

There is no plan in the near future to use this function outside of this
file so keep it as static.

Signed-off-by: Gustavo Padovan 
---
 drivers/staging/android/sync.c | 4 ++--
 drivers/staging/android/sync.h | 2 --
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index a89ded0..c441fde 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -253,8 +253,8 @@ static void sync_file_add_pt(struct sync_file *sync_file, 
int *i,
  * @a and @b.  @a and @b remain valid, independent sync_file. Returns the
  * new merged sync_file or NULL in case of error.
  */
-struct sync_file *sync_file_merge(const char *name,
- struct sync_file *a, struct sync_file *b)
+static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
+struct sync_file *b)
 {
int num_fences = a->num_fences + b->num_fences;
struct sync_file *sync_file;
diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h
index 925fba5..ffc6df6 100644
--- a/drivers/staging/android/sync.h
+++ b/drivers/staging/android/sync.h
@@ -168,8 +168,6 @@ void sync_timeline_signal(struct sync_timeline *obj);
 struct fence *sync_pt_create(struct sync_timeline *parent, int size);

 struct sync_file *sync_file_create(const char *name, struct fence *fence);
-struct sync_file *sync_file_merge(const char *name,
-   struct sync_file *a, struct sync_file *b);
 struct sync_file *sync_file_fdget(int fd);

 #ifdef CONFIG_DEBUG_FS
-- 
2.5.5



[PATCH 03/12] staging/android: move sync_file functions comments to sync.c

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

To keep comments in line with drivers/dma-buf/ move all sync_file comments
to sync.c.

Signed-off-by: Gustavo Padovan 
---
 drivers/staging/android/sync.c | 26 +-
 drivers/staging/android/sync.h | 31 ---
 2 files changed, 25 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index b965e2a..a89ded0 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -173,7 +173,14 @@ static void fence_check_cb_func(struct fence *f, struct 
fence_cb *cb)
wake_up_all(_file->wq);
 }

-/* TODO: implement a create which takes more that one fence */
+/**
+ * sync_fence_create() - creates a sync fence
+ * @name:  name of fence to create
+ * @fence: fence to add to the sync_fence
+ *
+ * Creates a sync_file containg @fence. Once this is called, the sync_file
+ * takes ownership of @fence.
+ */
 struct sync_file *sync_file_create(const char *name, struct fence *fence)
 {
struct sync_file *sync_file;
@@ -198,6 +205,13 @@ struct sync_file *sync_file_create(const char *name, 
struct fence *fence)
 }
 EXPORT_SYMBOL(sync_file_create);

+/**
+ * sync_file_fdget() - get a sync_file from an fd
+ * @fd:fd referencing a fence
+ *
+ * Ensures @fd references a valid sync_file, increments the refcount of the
+ * backing file. Returns the sync_file or NULL in case of error.
+ */
 struct sync_file *sync_file_fdget(int fd)
 {
struct file *file = fget(fd);
@@ -229,6 +243,16 @@ static void sync_file_add_pt(struct sync_file *sync_file, 
int *i,
}
 }

+/**
+ * sync_file_merge() - merge two sync_files
+ * @name:  name of new fence
+ * @a: sync_file a
+ * @b: sync_file b
+ *
+ * Creates a new sync_file which contains copies of all the fences in both
+ * @a and @b.  @a and @b remain valid, independent sync_file. Returns the
+ * new merged sync_file or NULL in case of error.
+ */
 struct sync_file *sync_file_merge(const char *name,
  struct sync_file *a, struct sync_file *b)
 {
diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h
index c45cc7b..925fba5 100644
--- a/drivers/staging/android/sync.h
+++ b/drivers/staging/android/sync.h
@@ -167,40 +167,9 @@ void sync_timeline_signal(struct sync_timeline *obj);
  */
 struct fence *sync_pt_create(struct sync_timeline *parent, int size);

-/**
- * sync_fence_create() - creates a sync fence
- * @name:  name of fence to create
- * @fence: fence to add to the sync_fence
- *
- * Creates a sync_file containg @fence. Once this is called, the sync_file
- * takes ownership of @fence.
- */
 struct sync_file *sync_file_create(const char *name, struct fence *fence);
-
-/*
- * API for sync_file consumers
- */
-
-/**
- * sync_file_merge() - merge two sync_files
- * @name:  name of new fence
- * @a: sync_file a
- * @b: sync_file b
- *
- * Creates a new sync_file which contains copies of all the fences in both
- * @a and @b.  @a and @b remain valid, independent sync_file. Returns the
- * new merged sync_file or NULL in case of error.
- */
 struct sync_file *sync_file_merge(const char *name,
struct sync_file *a, struct sync_file *b);
-
-/**
- * sync_file_fdget() - get a sync_file from an fd
- * @fd:fd referencing a fence
- *
- * Ensures @fd references a valid sync_file, increments the refcount of the
- * backing file. Returns the sync_file or NULL in case of error.
- */
 struct sync_file *sync_file_fdget(int fd);

 #ifdef CONFIG_DEBUG_FS
-- 
2.5.5



[PATCH 02/12] staging/android: drop sync_file_install() and sync_file_put()

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

These two functions are just wrappers for one line functions, they
call fd_install() and fput() respectively, so just get rid of them
and use fd_install() and fput() directly for more simplicity.

Signed-off-by: Gustavo Padovan 
---
 drivers/staging/android/sync.c   | 20 
 drivers/staging/android/sync.h   | 19 ---
 drivers/staging/android/sync_debug.c |  4 ++--
 3 files changed, 6 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index f9c6094..b965e2a 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -216,18 +216,6 @@ err:
 }
 EXPORT_SYMBOL(sync_file_fdget);

-void sync_file_put(struct sync_file *sync_file)
-{
-   fput(sync_file->file);
-}
-EXPORT_SYMBOL(sync_file_put);
-
-void sync_file_install(struct sync_file *sync_file, int fd)
-{
-   fd_install(fd, sync_file->file);
-}
-EXPORT_SYMBOL(sync_file_install);
-
 static void sync_file_add_pt(struct sync_file *sync_file, int *i,
 struct fence *fence)
 {
@@ -469,15 +457,15 @@ static long sync_file_ioctl_merge(struct sync_file 
*sync_file,
goto err_put_fence3;
}

-   sync_file_install(fence3, fd);
-   sync_file_put(fence2);
+   fd_install(fd, fence3->file);
+   fput(fence2->file);
return 0;

 err_put_fence3:
-   sync_file_put(fence3);
+   fput(fence3->file);

 err_put_fence2:
-   sync_file_put(fence2);
+   fput(fence2->file);

 err_put_fd:
put_unused_fd(fd);
diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h
index d2a1734..c45cc7b 100644
--- a/drivers/staging/android/sync.h
+++ b/drivers/staging/android/sync.h
@@ -203,25 +203,6 @@ struct sync_file *sync_file_merge(const char *name,
  */
 struct sync_file *sync_file_fdget(int fd);

-/**
- * sync_file_put() - puts a reference of a sync_file
- * @sync_file: sync_file to put
- *
- * Puts a reference on @sync_fence.  If this is the last reference, the
- * sync_fil and all it's sync_pts will be freed
- */
-void sync_file_put(struct sync_file *sync_file);
-
-/**
- * sync_file_install() - installs a sync_file into a file descriptor
- * @sync_file: sync_file to install
- * @fd:file descriptor in which to install the fence
- *
- * Installs @sync_file into @fd.  @fd's should be acquired through
- * get_unused_fd_flags(O_CLOEXEC).
- */
-void sync_file_install(struct sync_file *sync_file, int fd);
-
 #ifdef CONFIG_DEBUG_FS

 void sync_timeline_debug_add(struct sync_timeline *obj);
diff --git a/drivers/staging/android/sync_debug.c 
b/drivers/staging/android/sync_debug.c
index 5a7ec58..e4b0e41 100644
--- a/drivers/staging/android/sync_debug.c
+++ b/drivers/staging/android/sync_debug.c
@@ -272,12 +272,12 @@ static long sw_sync_ioctl_create_fence(struct 
sw_sync_timeline *obj,

data.fence = fd;
if (copy_to_user((void __user *)arg, , sizeof(data))) {
-   sync_file_put(sync_file);
+   fput(sync_file->file);
err = -EFAULT;
goto err;
}

-   sync_file_install(sync_file, fd);
+   fd_install(fd, sync_file->file);

return 0;

-- 
2.5.5



[PATCH 01/12] staging/android: remove redundant comments on sync_merge_data

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

struct sync_merge_data already have documentation on top of the
struct definition. No need to duplicate it.

Signed-off-by: Gustavo Padovan 
Reviewed-by: Maarten Lankhorst 
---
 drivers/staging/android/uapi/sync.h | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/android/uapi/sync.h 
b/drivers/staging/android/uapi/sync.h
index 7de5d6a..413303d 100644
--- a/drivers/staging/android/uapi/sync.h
+++ b/drivers/staging/android/uapi/sync.h
@@ -23,9 +23,9 @@
  * @pad:   padding for 64-bit alignment, should always be zero
  */
 struct sync_merge_data {
-   charname[32]; /* name of new fence */
-   __s32   fd2; /* fd of second fence */
-   __s32   fence; /* fd on newly created fence */
+   charname[32];
+   __s32   fd2;
+   __s32   fence;
__u32   flags;
__u32   pad;
 };
@@ -33,8 +33,8 @@ struct sync_merge_data {
 /**
  * struct sync_fence_info - detailed fence information
  * @obj_name:  name of parent sync_timeline
- * @driver_name:   name of driver implementing the parent
- * @status:status of the fence 0:active 1:signaled <0:error
+* @driver_name:name of driver implementing the parent
+* @status: status of the fence 0:active 1:signaled <0:error
  * @flags: fence_info flags
  * @timestamp_ns:  timestamp of status change in nanoseconds
  */
-- 
2.5.5



[PATCH 00/12] De-stage Sync File Framework

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

Hi,

This patchset sits on top of Sync ABI Rework v13:

https://www.spinics.net/lists/dri-devel/msg105667.html

The first eight clean up and prepare sync_file for de-staging. The last four
patches do the de-staging, moving files to drivers/dma-buf/ and include/linux/
plus adding Documentation.

As the de-stage depends upon many changes on the staging tree it would
be good to get all the patches merged through the staging tree if Sumit
agrees with that.

The next step on the Sync de-stage is clean up the remaining bits 
of the Sync Framework, mainly SW_SYNC, which is only used for testing.

Thanks,

Gustavo

---
Gustavo Padovan (12):
  staging/android: remove redundant comments on sync_merge_data
  staging/android: drop sync_file_install() and sync_file_put()
  staging/android: move sync_file functions comments to sync.c
  staging/android: make sync_file_merge() static
  staging/android: make sync_file_fdget() static
  staging/android: prepare sync_file for de-staging
  staging/android: improve documentation for sync_file
  staging/android: style fix: alignment to match the open parenthesis
  dma-buf/sync_file: de-stage sync_file headers
  dma-buf/sync_file: de-stage sync_file
  Documentation: include sync_file into DocBook
  Documentation: add Sync File doc

 Documentation/DocBook/device-drivers.tmpl |   2 +
 Documentation/dma-buf-sync_file.txt   |  65 +
 drivers/Kconfig   |   2 +
 drivers/dma-buf/Kconfig   |  11 +
 drivers/dma-buf/Makefile  |   1 +
 drivers/dma-buf/sync_file.c   | 394 ++
 drivers/staging/android/Kconfig   |   1 +
 drivers/staging/android/sync.c| 362 ---
 drivers/staging/android/sync.h|  91 +--
 drivers/staging/android/sync_debug.c  |   5 +-
 drivers/staging/android/uapi/sync.h   | 100 
 include/linux/sync_file.h |  57 +
 include/uapi/linux/sync_file.h| 100 
 13 files changed, 638 insertions(+), 553 deletions(-)
 create mode 100644 Documentation/dma-buf-sync_file.txt
 create mode 100644 drivers/dma-buf/Kconfig
 create mode 100644 drivers/dma-buf/sync_file.c
 delete mode 100644 drivers/staging/android/uapi/sync.h
 create mode 100644 include/linux/sync_file.h
 create mode 100644 include/uapi/linux/sync_file.h

-- 
2.5.5



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

2016-04-27 Thread Daniel Vetter
On Wed, Apr 27, 2016 at 12:29:34PM +0200, Philipp Zabel wrote:
> Am Dienstag, den 26.04.2016, 19:29 +0200 schrieb 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 = _gem_cma_vm_ops,
> > .dumb_create= drm_gem_cma_dumb_create,
> > .dumb_map_offset= drm_gem_cma_dumb_map_offset,
> 
> Applied to imx-drm/fixes, thank you.

And that compiles for you? Might want to drop the patch again before
someone notices ;-)
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


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

2016-04-27 Thread Daniel Vetter
On Wed, Apr 27, 2016 at 11:31:00AM +0200, Lucas Stach wrote:
> Am Dienstag, den 26.04.2016, 19:29 +0200 schrieb 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 
> 
> Two mostly cosmetic comments below, otherwise looks good:
> 
> Reviewed-by: Lucas Stach 
> 
> > ---
> >  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(>struct_mutex));
> >  
> > -   if (dev->driver->gem_free_object != NULL)
> > +   if (dev->driver->gem_free_object_unlocked != NULL)
> 
> Why those explicit != NULL checks? The style mostly used in this file is
> to omit those, like "if (dev->driver->gem_free_object_unlocked)". Same
> comment applies to several hunks of this patch.

I move some of these functions around, the != NULL checks where there
already. I can easily change all the ones I touch.

> > +   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(>struct_mutex);
> > +
> > +   if (dev->driver->gem_free_object != NULL)
> > +   kref_put(>refcount, drm_gem_object_free);
> > +   else if (kref_put_mutex(>refcount, drm_gem_object_free,
> > +   >struct_mutex))
> > +   mutex_unlock(>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(>dev->struct_mutex));
> > +
> > +   kref_put(>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 part of the comment is really off. I see it's just copy from
> the comment above gem_free_object, but I think it should have been
> placed above gem_open_object and has 

[PATCH v4 00/13] Support non-lru page migration

2016-04-27 Thread Andrew Morton
On Wed, 27 Apr 2016 16:48:13 +0900 Minchan Kim  wrote:

> Recently, I got many reports about perfermance degradation in embedded
> system(Android mobile phone, webOS TV and so on) and easy fork fail.
> 
> The problem was fragmentation caused by zram and GPU driver mainly.
> With memory pressure, their pages were spread out all of pageblock and
> it cannot be migrated with current compaction algorithm which supports
> only LRU pages. In the end, compaction cannot work well so reclaimer
> shrinks all of working set pages. It made system very slow and even to
> fail to fork easily which requires order-[2 or 3] allocations.
> 
> Other pain point is that they cannot use CMA memory space so when OOM
> kill happens, I can see many free pages in CMA area, which is not
> memory efficient. In our product which has big CMA memory, it reclaims
> zones too exccessively to allocate GPU and zram page although there are
> lots of free space in CMA so system becomes very slow easily.
> 
> To solve these problem, this patch tries to add facility to migrate
> non-lru pages via introducing new functions and page flags to help
> migration.

I'm seeing some rejects here against Mel's changes and our patch
bandwidth is getting waaay way ahead of our review bandwidth.  So I
think I'll loadshed this patchset at this time, sorry.


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

2016-04-27 Thread Chris Wilson
On Wed, Apr 27, 2016 at 02:12:46PM +0200, Daniel Vetter wrote:
> On Wed, Apr 27, 2016 at 12:58:51PM +0100, Chris Wilson wrote:
> > On Wed, Apr 27, 2016 at 01:50:00PM +0200, Daniel Vetter wrote:
> > > 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.
> > > 
> > > v3: Review from Lucas:
> > > - drop != NULL in pointer checks.
> > > - fixup copypasted kerneldoc to actually match the functions.
> > > 
> > > Cc: Chris Wilson 
> > > Cc: Alex Deucher 
> > > Cc: Lucas Stach 
> > > Reviewed-by: Lucas Stach 
> > > Signed-off-by: Daniel Vetter 
> > > ---
> > >  drivers/gpu/drm/drm_gem.c | 64 
> > > ++-
> > >  include/drm/drmP.h| 15 ---
> > >  include/drm/drm_gem.h | 45 ++---
> > >  3 files changed, 66 insertions(+), 58 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> > > index 25dac31eef37..a4684a306c48 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(>struct_mutex));
> > >  
> > > - if (dev->driver->gem_free_object != NULL)
> > > + if (dev->driver->gem_free_object_unlocked)
> > > + dev->driver->gem_free_object_unlocked(obj);
> > > + else if (dev->driver->gem_free_object)
> > >   dev->driver->gem_free_object(obj);
> > >  }
> > > -EXPORT_SYMBOL(drm_gem_object_free);
> > 
> > With my plan, I want to keep drm_gem_object_free exported.
> > The plan being a __drm_gem_object_free_lockless fastpath.
> 
> Yeah, but I think we can reexport again in the patch that adds
> __drm_gem_object_free_lockless. Just not much personally a friend of
> sprawling EXPORT_SYMBOL when not needed. But I can drop that part too if
> you feel strongly.

The alternative is to add the function now and then I can just drop the
support into my tree and start testing :)
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


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

2016-04-27 Thread Daniel Vetter
On Wed, Apr 27, 2016 at 11:45:31AM +0200, Noralf Trønnes wrote:
> 
> Den 26.04.2016 19:19, skrev 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
> >;-)
> 
> Will do :-)
> Kernel development is just my hobby so I'm not well versed in all of this.

You're doing great tbh!

>    */
> 
>   /**
> @@ -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
> 

i915: screen flicker

2016-04-27 Thread Mihai Donțu
On Wed, 27 Apr 2016 10:09:32 +0300 Jani Nikula wrote:
> On Wed, 27 Apr 2016, Mihai Donțu wrote:
> > I noticed that since I started using 4.6.0-rcX, my screen flickers once
> > or twice after I stop using my laptop for ~1min or so. Given the
> > behavior, my prime suspect is the PSR feature that you have announced
> > for this release:
> >
> >   http://blog.ffwll.ch/2016/03/neat-drmi915-stuff-for-46.html
> >
> > Is 'enable_psr' the right knob to use to turn this feature off and see
> > if my suspicions are correct? Or is there a patch floating around that
> > I can test?  
> 
> i915.enable_psr=0 is the one to try, yes.

I can confirm that with PSR off, the flicker goes away.

> > I have an Intel i7-4600U CPU. I also attached to this email and archive
> > with the contents of /sys/kernel/debug/dri/0.

-- 
Mihai Donțu


[Intel-gfx] i951 ERRORs and WARN_ON()s (was: blank screen on boot with i915/DRM_FBDEV_EMULATION)

2016-04-27 Thread Marius Vlad
Florian, if you're using drm-intel-nigthly submit a bug at
https://bugs.freedesktop.org/enter_bug.cgi?product=DRI, with DRM/intel
as component. This way we can track some kind of progress/regress. The FIFO
underruns should've have been fixed, but maybe there's something related
to your platform.

On Tue, Apr 12, 2016 at 03:23:08AM +0200, Florian Zumbiehl wrote:
> Hi,
> 
> > > We've fixed piles of those in recent kernels, but didn't backport all the
> > > fixes (since usually it's a silent failure, but it can correlate with
> > > black screens).
> > 
> > Not quite completely, it seems ...
> > 
> > I have built drm-intel-nightly (f261f82359), and I'm getting this:
> [...]
> 
> ping?
> 
> Regards, Florian
> ___
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160427/33053c09/attachment.sig>


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

2016-04-27 Thread Chris Wilson
On Wed, Apr 27, 2016 at 01:50:00PM +0200, Daniel Vetter wrote:
> 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.
> 
> v3: Review from Lucas:
> - drop != NULL in pointer checks.
> - fixup copypasted kerneldoc to actually match the functions.
> 
> Cc: Chris Wilson 
> Cc: Alex Deucher 
> Cc: Lucas Stach 
> Reviewed-by: Lucas Stach 
> Signed-off-by: Daniel Vetter 
> ---
>  drivers/gpu/drm/drm_gem.c | 64 
> ++-
>  include/drm/drmP.h| 15 ---
>  include/drm/drm_gem.h | 45 ++---
>  3 files changed, 66 insertions(+), 58 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index 25dac31eef37..a4684a306c48 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(>struct_mutex));
>  
> - if (dev->driver->gem_free_object != NULL)
> + if (dev->driver->gem_free_object_unlocked)
> + dev->driver->gem_free_object_unlocked(obj);
> + else if (dev->driver->gem_free_object)
>   dev->driver->gem_free_object(obj);
>  }
> -EXPORT_SYMBOL(drm_gem_object_free);

With my plan, I want to keep drm_gem_object_free exported.
The plan being a __drm_gem_object_free_lockless fastpath.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


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

2016-04-27 Thread Daniel Vetter
On Wed, Apr 27, 2016 at 12:29:05PM +0200, Philipp Zabel wrote:
> Hi Daniel,
> 
> Am Dienstag, den 26.04.2016, 10:48 +0200 schrieb Daniel Vetter:
> [...]
> > > +static int mtk_drm_unload(struct drm_device *drm)
> > > +{
> > > + mtk_drm_kms_deinit(drm);
> > > + drm->dev_private = NULL;
> > > +
> > > + return 0;
> > > +}
> > 
> > Like load, the unload hook is deprecated. And in drm-next we now have some
> > nice helpers to make not using an unload hook easier. Please refactor per
> > existing examples and get rid of your unload hook.
> 
> Thanks, does this change look about right:

yup, lgtm, ack.
-Daniel

> 
> 8<
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -222,14 +222,6 @@ static void mtk_drm_kms_deinit(struct drm_device
> *drm)
>   drm_mode_config_cleanup(drm);
>  }
>  
> -static int mtk_drm_unload(struct drm_device *drm)
> -{
> - mtk_drm_kms_deinit(drm);
> - drm->dev_private = NULL;
> -
> - return 0;
> -}
> -
>  static const struct file_operations mtk_drm_fops = {
>   .owner = THIS_MODULE,
>   .open = drm_open,
> @@ -246,7 +238,6 @@ static const struct file_operations mtk_drm_fops = {
>  static struct drm_driver mtk_drm_driver = {
>   .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME |
>  DRIVER_ATOMIC,
> - .unload = mtk_drm_unload,
>  
>   .get_vblank_counter = drm_vblank_count,
>   .enable_vblank = mtk_drm_crtc_enable_vblank,
> @@ -455,8 +446,14 @@ err_node:
>  static int mtk_drm_remove(struct platform_device *pdev)
>  {
>   struct mtk_drm_private *private = platform_get_drvdata(pdev);
> + struct drm_device *drm = private->drm;
>   int i;
>  
> + drm_connector_unregister_all(drm);
> + drm_dev_unregister(drm);
> + mtk_drm_kms_deinit(drm);
> + drm_dev_unref(drm);
> +
>   component_master_del(>dev, _drm_ops);
>   pm_runtime_disable(>dev);
>   of_node_put(private->mutex_node);
> >8
> 
> > > +static const struct vm_operations_struct mtk_drm_gem_vm_ops = {
> > > + .open = drm_gem_vm_open,
> > > + .close = drm_gem_vm_close,
> > > +};
> > 
> > Drive-by review I just spotted: Please use drm_gem_cma_vm_ops instead of
> > rolling your own.
> 
> Good catch, will remove.
> 
> regards
> Philipp
> 

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


  1   2   >