[Bug 64471] Radeon HD6570 lockup in Brütal Legend with HyperZ

2014-12-29 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=64471

--- Comment #28 from Clément Guérin  ---
Here's an apitrace that makes my computer hang: http://ge.tt/7RmQXf72/v/0?c

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


[Bug 64471] Radeon HD6570 lockup in Brütal Legend with HyperZ

2014-12-29 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=64471

--- Comment #27 from Clément Guérin  ---
Latest Arch Linux with today's mesa-git and llvm-git, I'm getting a GPU lockup
after the intro, when beating up the three druids. HD 7950

I tried without HyperZ and with the lowest visual settings but it doesn't
change anything.

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


[Bug 87023] Dota 2 crashed and hang on ATi Mobility Radeon HD 5650 (Acer 4745G)

2014-12-29 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=87023

--- Comment #13 from Romy  ---
Clarify: I decided to reinstall Ubuntu 14.04 and using default mesa driver
(10.1.3), when playing dota2 it gives result seldom crashing but random. I
think it specific bug with dota2 (dont know on the game side or driver side), I
remember when using Ubuntu 12.04 and catalyst, it got crashed too, but when
update of dota2 someday, it gives no crash at all, it took for months. An
update available again, updating, and crash again.

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


[Bug 83510] Graphical glitches in Unreal Engine 4

2014-12-29 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=83510

--- Comment #12 from Clément Guérin  ---
I just upgraded mesa-git with the NaN fix.

Black pixel and motion blur glitches are gone. Nice work!

Low lighting glitch is still here. "can be seen in the Realistic Rendering demo
or the Shooter Game demo with the Sanctuary map"

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


[PATCH v8 0/2] ASoC: tda998x: add a codec to the HDMI transmitter

2014-12-29 Thread Jyri Sarha
On 12/29/2014 06:52 PM, Mark Brown wrote:
> On Thu, Oct 23, 2014 at 10:32:49AM +0200, Jean-Francois Moine wrote:
>> The NXP TDA998x HDMI transmitter may transmit audio to the HDMI link
>> from 2 different sources, I2S and S/PDIF.
>
> So, I'm not seeing *any* interest here from any other HDMI users.  This
> is a continuing theme with HDMI patches and is really very concerning,
> everyone appears to be working in their own bubbles coming up with their
> own things and ignoring everyone else's work - what little review I'm
> seeing seems to be happening only after I explicitly prompt it.  I'm
> following up to Jean-Francois' patches here but this isn't specific to
> them, it seems like a general thing with HDMI code.
>
> This in turn makes me think there's some abstraction problems with
> what's going on and we're going to have to go through yet more
> refactorings to fix things up as we do manage to come up with better
> abstractions.  What I'd really like to see as a bare minimum is some
> visible conversation about what we're doing and sign that people are
> at least keeping in mind generic solutions when working on HDMI code.
> Some commentary on the similarities and differences between hardware
> and which abstractions work with which devices would also be really
> helpful in working out if we're going in the right direction.
>
> Basically at the minute I'm worried that we may be making the problems
> we've got here worse not better, I've not personally had the time to sit
> down and study the hardware sufficiently to form a firm impression
> myself which isn't helping.
>

I have not seen any significant new development since v7 of these 
patches. My comments for v6 were mostly[1] addressed and I can live with 
these changes, even develop this approach further if it gets merged.

However, as a general note I see a need for a generic ASoC hdmi codec 
abstraction and I don't think this is generic enough. More of the audio 
specific implementation and HDMI standard specific things should be 
pushed away from the hdmi encoder driver (tda998x in this case) to the 
generic ASoC side hdmi codec driver (or library).

I am currently working on something that tries to be a generic solution 
that should be usable for different encoders and platforms, but 
unfortunately I have been busy with other things lately and have not 
been able to put anything working together yet. As soon as I have at 
least a bare bone API and and a proof of concept implementation working, 
I send RFC/POF patches out.

Best regards,
Jyri

[1] I personally do not like the hdmi_get_cdev() approach. I would 
rather go with only a library for registering from ASoC codec component 
under the HDMI encoder device or a completely separate device with only 
a reference to the HDMI encoder.



[PATCH RFC v6 16/21] drm: panel: Add support for Himax HX8369A MIPI DSI panel

2014-12-29 Thread Liu Ying
On 12/29/2014 05:09 PM, Andrzej Hajda wrote:
> On 12/29/2014 07:39 AM, Liu Ying wrote:
>> This patch adds support for Himax HX8369A MIPI DSI panel.
>>
>> Signed-off-by: Liu Ying 
>> ---
>> v5->v6:
>>   * Make the checkpatch.pl script be happier.
>>   * Do not set the dsi channel number to be zero in probe(), because the 
>> MIPI DSI
>> bus driver would set it.
>>
>> v4->v5:
>>   * Address Andrzej Hajda's comments.
>>   * Get the bs-gpios property instead of the bs[3:0]-gpios properties.
>>   * Implement error propagation for panel register configurations.
>>   * Other minor changes to improve the code quality.
>>
>> v3->v4:
>>   * Move the relevant dt-bindings to a separate patch to address Stefan
>> Wahren's comment.
>>
>> v2->v3:
>>   * Sort the included header files alphabetically.
>>
>> v1->v2:
>>   * Address almost all comments from Thierry Reding.
>>   * Remove several DT properties as they can be implied by the compatible 
>> string.
>>   * Add the HIMAX/himax prefixes to the driver's Kconfig name and driver 
>> name.
>>   * Move the driver's Makefile entry place to sort the entries 
>> alphabetically.
>>   * Reuse several standard DCS functions instead of inventing wheels.
>>   * Move the panel resetting and power logics to the driver probe/remove 
>> stages.
>> This may simplify panel prepare/unprepare hooks. The power consumption 
>> should
>> not change a lot at DPMS since the panel enters sleep mode at that time.
>>   * Add the module author.
>>   * Other minor changes, such as coding style issues.
>>
>>   drivers/gpu/drm/panel/Kconfig   |   5 +
>>   drivers/gpu/drm/panel/Makefile  |   1 +
>>   drivers/gpu/drm/panel/panel-himax-hx8369a.c | 614 
>> 
>>   3 files changed, 620 insertions(+)
>>   create mode 100644 drivers/gpu/drm/panel/panel-himax-hx8369a.c
>>
>> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
>> index 024e98e..81b0bf0 100644
>> --- a/drivers/gpu/drm/panel/Kconfig
>> +++ b/drivers/gpu/drm/panel/Kconfig
>> @@ -16,6 +16,11 @@ config DRM_PANEL_SIMPLE
>>that it can be automatically turned off when the panel goes into a
>>low power state.
>>
>> +config DRM_PANEL_HIMAX_HX8369A
>> +tristate "Himax HX8369A panel"
>> +depends on OF
>> +select DRM_MIPI_DSI
>> +
>>   config DRM_PANEL_LD9040
>>  tristate "LD9040 RGB/SPI panel"
>>  depends on OF && SPI
>> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
>> index 4b2a043..d5dbe06 100644
>> --- a/drivers/gpu/drm/panel/Makefile
>> +++ b/drivers/gpu/drm/panel/Makefile
>> @@ -1,4 +1,5 @@
>>   obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o
>> +obj-$(CONFIG_DRM_PANEL_HIMAX_HX8369A) += panel-himax-hx8369a.o
>>   obj-$(CONFIG_DRM_PANEL_LD9040) += panel-ld9040.o
>>   obj-$(CONFIG_DRM_PANEL_S6E8AA0) += panel-s6e8aa0.o
>>   obj-$(CONFIG_DRM_PANEL_SHARP_LQ101R1SX01) += panel-sharp-lq101r1sx01.o
>> diff --git a/drivers/gpu/drm/panel/panel-himax-hx8369a.c 
>> b/drivers/gpu/drm/panel/panel-himax-hx8369a.c
>> new file mode 100644
>> index 000..eee36a7
>> --- /dev/null
>> +++ b/drivers/gpu/drm/panel/panel-himax-hx8369a.c
>> @@ -0,0 +1,614 @@
>> +/*
>> + * Himax HX8369A panel driver.
>> + *
>> + * Copyright (C) 2011-2014 Freescale Semiconductor, 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 driver is based on Samsung s6e8aa0 panel driver.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#define WRDISBV 0x51
>> +#define WRCTRLD 0x53
>> +#define WRCABC  0x55
>> +#define SETPOWER0xb1
>> +#define SETDISP 0xb2
>> +#define SETCYC  0xb4
>> +#define SETVCOM 0xb6
>> +#define SETEXTC 0xb9
>> +#define SETMIPI 0xba
>> +#define SETPANEL0xcc
>> +#define SETGIP  0xd5
>> +#define SETGAMMA0xe0
>> +
>> +#define HX8369A_MIN_BRIGHTNESS  0x00
>> +#define HX8369A_MAX_BRIGHTNESS  0xff
>> +
>> +enum hx8369a_mpu_interface {
>> +HX8369A_DBI_TYPE_A_8BIT,
>> +HX8369A_DBI_TYPE_A_9BIT,
>> +HX8369A_DBI_TYPE_A_16BIT,
>> +HX8369A_DBI_TYPE_A_18BIT,
>> +HX8369A_DBI_TYPE_B_8BIT,
>> +HX8369A_DBI_TYPE_B_9BIT,
>> +HX8369A_DBI_TYPE_B_16BIT,
>> +HX8369A_DBI_TYPE_B_18BIT,
>> +HX8369A_DSI_CMD_MODE,
>> +HX8369A_DBI_TYPE_B_24BIT,
>> +HX8369A_DSI_VIDEO_MODE,
>> +HX8369A_MDDI,
>> +HX8369A_DPI_DBI_TYPE_C_OPT1,
>> +HX8369A_DPI_DBI_TYPE_C_OPT2,
>> +HX8369A_DPI_DBI_TYPE_C_OPT3
>> +};
>> +
>> +enum hx8369a_resolution {
>> +HX8369A_RES_480_864,
>> +HX8369A_RES_480_854,
>> +HX8369A_RES_480_800,
>> +HX8369A_RES_480_640,
>> +HX8369A_RES_360_640,
>> +

[PATCH 4/8] drm: fix error return code

2014-12-29 Thread Julia Lawall
Return a negative error code on failure.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// 
@@
identifier ret; expression e1,e2;
@@
(
if (\(ret < 0\|ret != 0\))
 { ... return ret; }
|
ret = 0
)
... when != ret = e1
when != 
*if(...)
{
  ... when != ret = e2
  when forall
 return ret;
}
// 

Signed-off-by: Julia Lawall 

---
 drivers/gpu/drm/gma500/psb_drv.c |8 ++--
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.c |1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 92e7e57..4eff0d6 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -326,12 +326,16 @@ static int psb_driver_load(struct drm_device *dev, 
unsigned long flags)
goto out_err;

dev_priv->mmu = psb_mmu_driver_init(dev, 1, 0, 0);
-   if (!dev_priv->mmu)
+   if (!dev_priv->mmu) {
+   ret = -ENOMEM;
goto out_err;
+   }

dev_priv->pf_pd = psb_mmu_alloc_pd(dev_priv->mmu, 1, 0);
-   if (!dev_priv->pf_pd)
+   if (!dev_priv->pf_pd) {
+   ret = -ENOMEM;
goto out_err;
+   }

ret = psb_do_init(dev);
if (ret)
diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c 
b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
index 56c6055..c0fb5fa 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
@@ -678,6 +678,7 @@ static int omap_dmm_probe(struct platform_device *dev)
_dmm->refill_pa, GFP_KERNEL);
if (!omap_dmm->refill_va) {
dev_err(>dev, "could not allocate refill memory\n");
+   ret = -ENOMEM;
goto fail;
}




[PATCH 0/8] fix error return code

2014-12-29 Thread Julia Lawall
The complate semantic patch that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// 
@ok exists@
identifier f,ret,i;
expression e;
constant c;
@@

// identify a function that returns a negative return value at least once.
f(...) {
... when any
(
return -c at i;
|
ret = -c at i;
... when != ret = e
return ret;
|
if (ret < 0) { ... return ret; }
)
... when any
}

@r exists@
identifier ret,ok.f,fn;
expression e1,e2,e3,e4,e5,e6,x;
statement S,S1;
position p1,p2,p3;
@@

// identify a case where the return variable is set to a non-negative value
// and then returned in error-handling code
f(...) {
... when any
(
if at p1 (\(ret < 0\|ret != 0\))
 { ... return ret; }
|
ret at p1 = 0
)
... when != \(ret = e1\|ret++\|ret--\|ret+=e1\|ret-=e1\)
when != 
when any
(
 if (<+... ret = e5 ...+>) S1
|
 if (<+...  ...+>) S1
|
if at p2(<+...x = fn(...)...+>)
 {
  ... when != ret = e6
  when forall
 return at p3 ret;
}
|
break;
|
x = fn(...)
... when != \(ret = e4\|ret++\|ret--\|ret+=e4\|ret-=e4\)
when != 
(
 if (<+... ret = e3 ...+>) S
|
 if (<+...  ...+>) S
|
if at p2(<+...\(x != 0\|x < 0\|x == NULL\|IS_ERR(x)\)...+>)
 {
  ... when != ret = e2
  when forall
 return at p3 ret;
}
)
)
... when any
}

@printer depends on r@
position p;
identifier ok.f,pr;
constant char [] c;
@@

f(...) { <...pr at p(...,c,...)...> }

@bad0 exists@
identifier r.ret,ok.f,g != {ERR_PTR,IS_ERR};
position p != printer.p;
@@

f(...) { ... when any
g at p(...,ret,...)
... when any
 }

@bad depends on !bad0 exists@
position r.p1,r.p2;
statement S1,S2;
identifier r.ret;
expression e1;
@@

// ignore the above if there is some path where the variable is set to
// something else
(
if at p1 (\(ret < 0\|ret != 0\)) S1
|
ret at p1 = 0
)
... when any
 \(ret = e1\|ret++\|ret--\|ret+=e1\|ret-=e1\|\)
... when any
if at p2(...) S2

@bad1 depends on !bad0 && !bad exists@
position r.p2;
statement S2;
identifier r.ret;
expression e1;
constant c;
@@

ret = -c
... when != \(ret = e1\|ret++\|ret--\|ret+=e1\|ret-=e1\)
when != 
when any
if at p2(...) S2

@bad2 depends on !bad0 && !bad && !bad1 exists@
position r.p1,r.p2;
identifier r.ret;
expression e1;
statement S2;
constant c;
@@

// likewise ignore it if there has been an intervening return
ret at p1 = 0
... when != if (...) { ... ret = e1 ... return ret; }
when != if (...) { ... return -c; }
when any
if at p2(...) S2


@script:python depends on !bad0 && !bad && !bad1 && !bad2@
p1 << r.p1;
p2 << r.p2;
p3 << r.p3;
@@

cocci.print_main("",p1)
cocci.print_secs("",p2)
cocci.print_secs("",p3)
// 



[PATCH v8 1/2] ASoC: hdmi: Add a transmitter interface to the HDMI CODEC

2014-12-29 Thread Mark Brown
On Thu, Oct 23, 2014 at 09:09:35AM +0200, Jean-Francois Moine wrote:

> +struct hdmi_data {
> + int (*get_audio)(struct device *dev,
> +  int *max_channels,
> +  int *rate_mask,
> +  int *fmt);
> + void (*audio_switch)(struct device *dev,
> +  int port_index,
> +  unsigned sample_rate,
> +  int sample_format);

I can't really tell from these function names what these functions are
supposed to do.  I think get_audio() should be get_audio_caps() or
similar since it reads the capabilities and audio_switch() is supposed
to be set_audio_params() or similar to set the settings for the running
stream.

> + snd_pcm_hw_constraint_list(runtime, 0,
> +SNDRV_PCM_HW_PARAM_RATE,
> +rate_constraints);
> +
> + formats = 0;
> + if (fmt & 1)
> + formats |= SNDRV_PCM_FMTBIT_S16_LE;
> + if (fmt & 2)
> + formats |= SNDRV_PCM_FMTBIT_S20_3LE;
> + if (fmt & 4)
> + formats |= SNDRV_PCM_FMTBIT_S24_LE |
> +SNDRV_PCM_FMTBIT_S24_3LE |
> +SNDRV_PCM_FMTBIT_S32_LE;

Magic numbers here - can't we have some constants defined?

> + priv->hdmi_data.audio_switch(dai->dev, dai->id,
> +  params_rate(params),
> +  params_format(params));

I'd be happier if this were able to return an error; even if the
constraints are satisfied perhaps something changed or some operation
fails for some reason.

> +static void hdmi_shutdown(struct snd_pcm_substream *substream,
> +   struct snd_soc_dai *dai)
> +{
> + struct device *cdev;
> + struct hdmi_priv *priv;
> +
> + cdev = hdmi_get_cdev(dai->dev);
> + if (!cdev)
> + return;
> + priv = dev_get_drvdata(cdev);
> +
> + priv->hdmi_data.audio_switch(dai->dev, -1, 0, 0);   /* stop */
> +}

So the set parameters operation has to support these magic values as
being "off" - why not have an explicit shutdown operation here?

> +static int hdmi_codec_probe(struct snd_soc_codec *codec)
> +{
> + struct hdmi_priv *priv;
> + struct device *dev = codec->dev;/* encoder device */
> + struct device *cdev;/* codec device */
> +
> + cdev = hdmi_get_cdev(dev);
> + if (!cdev)
> + return -ENODEV;

This is (I think) only called for cases where the driver is being used
from a parent device with ops but the name makes it sound like it should
be called all the time so errors like that shouldn't happen.  This
should be clearer, or perhaps we should just have a separate device
(perhaps rename the existing one to say that it's for a dumb device with
no control?).
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20141229/83121e5a/attachment-0001.sig>


[PATCH v8 0/2] ASoC: tda998x: add a codec to the HDMI transmitter

2014-12-29 Thread Mark Brown
On Thu, Oct 23, 2014 at 10:32:49AM +0200, Jean-Francois Moine wrote:
> The NXP TDA998x HDMI transmitter may transmit audio to the HDMI link
> from 2 different sources, I2S and S/PDIF.

So, I'm not seeing *any* interest here from any other HDMI users.  This
is a continuing theme with HDMI patches and is really very concerning,
everyone appears to be working in their own bubbles coming up with their
own things and ignoring everyone else's work - what little review I'm
seeing seems to be happening only after I explicitly prompt it.  I'm
following up to Jean-Francois' patches here but this isn't specific to
them, it seems like a general thing with HDMI code.

This in turn makes me think there's some abstraction problems with
what's going on and we're going to have to go through yet more
refactorings to fix things up as we do manage to come up with better
abstractions.  What I'd really like to see as a bare minimum is some
visible conversation about what we're doing and sign that people are
at least keeping in mind generic solutions when working on HDMI code.
Some commentary on the similarities and differences between hardware
and which abstractions work with which devices would also be really
helpful in working out if we're going in the right direction.

Basically at the minute I'm worried that we may be making the problems
we've got here worse not better, I've not personally had the time to sit
down and study the hardware sufficiently to form a firm impression
myself which isn't helping.
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20141229/eb326868/attachment-0001.sig>


[Bug 87796] radeonsi 120Hz graphic glitches

2014-12-29 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=87796

Vladimir Ysikov  changed:

   What|Removed |Added

 Attachment #111427|text/plain  |image/png
  mime type||

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


[PATCH 2/3] drm/amdkfd: reformat IOCTL definitions to drm-style

2014-12-29 Thread Oded Gabbay


On 12/29/2014 03:32 PM, Christian König wrote:
> Am 29.12.2014 um 14:17 schrieb Oded Gabbay:
>>
>>
>> On 12/29/2014 03:06 PM, Christian König wrote:
>>> Am 29.12.2014 um 13:42 schrieb Oded Gabbay:
 This patch reformats the ioctl definitions in kfd_ioctl.h to be similar to 
 the
 drm ioctls definition style.

 Signed-off-by: Oded Gabbay 
>>>
>>> You are aware that this is a kernel API breakage?
>> Yes, but as long as 3.19 isn't released yet, I'm allowed to do this, no ?
>
> Strictly speaking only if you fix a bug with it, but since we are still pretty
> early in the cycle it's ok with we (especially since it looks like a valid
> cleanup). I'm just not sure what Dave/Linus think of this.
>
> Christian.
Well, Dave said I should remove the error prints from the ioctl function and 
generally make it similar to drm ioctl handling. And as you said, this looks 
like a valid cleanup so I assume it would be ok from his POV to merge it for 
-rc2/3.

Oded

>
>> and I want this patch-set to be inserted to 3.19 so there won't be API
>> breakage afterwards.
>>
>>>
 ---
   drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 15 +++--
   include/uapi/linux/kfd_ioctl.h   | 37
 +++-
   2 files changed, 30 insertions(+), 22 deletions(-)

 diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
 b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
 index 5460ad2..390385f 100644
 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
 +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
 @@ -524,35 +524,36 @@ static long kfd_ioctl(struct file *filep, unsigned 
 int
 cmd, unsigned long arg)
   switch (cmd) {
 -case KFD_IOC_GET_VERSION:
 +case AMDKFD_IOC_GET_VERSION:
   retcode = kfd_ioctl_get_version(filep, process, kdata);
   break;
 -case KFD_IOC_CREATE_QUEUE:
 +
 +case AMDKFD_IOC_CREATE_QUEUE:
   retcode = kfd_ioctl_create_queue(filep, process,
   kdata);
   break;
 -case KFD_IOC_DESTROY_QUEUE:
 +case AMDKFD_IOC_DESTROY_QUEUE:
   retcode = kfd_ioctl_destroy_queue(filep, process,
   kdata);
   break;
 -case KFD_IOC_SET_MEMORY_POLICY:
 +case AMDKFD_IOC_SET_MEMORY_POLICY:
   retcode = kfd_ioctl_set_memory_policy(filep, process,
   kdata);
   break;
 -case KFD_IOC_GET_CLOCK_COUNTERS:
 +case AMDKFD_IOC_GET_CLOCK_COUNTERS:
   retcode = kfd_ioctl_get_clock_counters(filep, process,
   kdata);
   break;
 -case KFD_IOC_GET_PROCESS_APERTURES:
 +case AMDKFD_IOC_GET_PROCESS_APERTURES:
   retcode = kfd_ioctl_get_process_apertures(filep, process,
   kdata);
   break;
 -case KFD_IOC_UPDATE_QUEUE:
 +case AMDKFD_IOC_UPDATE_QUEUE:
   retcode = kfd_ioctl_update_queue(filep, process,
   kdata);
   break;
 diff --git a/include/uapi/linux/kfd_ioctl.h 
 b/include/uapi/linux/kfd_ioctl.h
 index 7acef41..05b53f6 100644
 --- a/include/uapi/linux/kfd_ioctl.h
 +++ b/include/uapi/linux/kfd_ioctl.h
 @@ -128,27 +128,34 @@ struct kfd_ioctl_get_process_apertures_args {
   uint32_t pad;
   };
 -#define KFD_IOC_MAGIC 'K'
 +#define AMDKFD_IOCTL_BASE 'K'
 +#define AMDKFD_IO(nr)_IO(AMDKFD_IOCTL_BASE, nr)
 +#define AMDKFD_IOR(nr, type)_IOR(AMDKFD_IOCTL_BASE, nr, type)
 +#define AMDKFD_IOW(nr, type)_IOW(AMDKFD_IOCTL_BASE, nr, type)
 +#define AMDKFD_IOWR(nr, type)_IOWR(AMDKFD_IOCTL_BASE, nr, type)
 -#define KFD_IOC_GET_VERSION \
 -_IOR(KFD_IOC_MAGIC, 1, struct kfd_ioctl_get_version_args)
 +#define AMDKFD_IOC_GET_VERSION\
 +AMDKFD_IOR(0x01, struct kfd_ioctl_get_version_args)
 -#define KFD_IOC_CREATE_QUEUE \
 -_IOWR(KFD_IOC_MAGIC, 2, struct kfd_ioctl_create_queue_args)
 +#define AMDKFD_IOC_CREATE_QUEUE\
 +AMDKFD_IOWR(0x02, struct kfd_ioctl_create_queue_args)
 -#define KFD_IOC_DESTROY_QUEUE \
 -_IOWR(KFD_IOC_MAGIC, 3, struct kfd_ioctl_destroy_queue_args)
 +#define AMDKFD_IOC_DESTROY_QUEUE\
 +AMDKFD_IOWR(0x03, struct kfd_ioctl_destroy_queue_args)
 -#define KFD_IOC_SET_MEMORY_POLICY \
 -_IOW(KFD_IOC_MAGIC, 4, struct kfd_ioctl_set_memory_policy_args)
 +#define AMDKFD_IOC_SET_MEMORY_POLICY\
 +AMDKFD_IOW(0x04, struct kfd_ioctl_set_memory_policy_args)
 -#define KFD_IOC_GET_CLOCK_COUNTERS \
 -_IOWR(KFD_IOC_MAGIC, 5, struct kfd_ioctl_get_clock_counters_args)
 +#define AMDKFD_IOC_GET_CLOCK_COUNTERS\
 +AMDKFD_IOWR(0x05, struct 

[PATCH 1/3] drm/amdkfd: Do copy_to/from_user in general kfd_ioctl()

2014-12-29 Thread Oded Gabbay


On 12/29/2014 03:05 PM, Christian König wrote:
> Am 29.12.2014 um 13:42 schrieb Oded Gabbay:
>> This patch moves the copy_to_user() and copy_from_user() calls from the
>> different ioctl functions in amdkfd to the general kfd_ioctl() function, as
>> this is a common code for all ioctls.
>>
>> This was done according to example taken from drm_ioctl.c
>>
>> Signed-off-by: Oded Gabbay 
>
> In general sounds like a good idea to me and the patch is "Reviewed-by:
> Christian König " for now.
>
> What really questions me is why we need all this code duplication and can't
> reuse the DRM infrastructure for this. But that's more a problem in the long 
> term.
>
Do you mean registering as DRM IOCTL ?
Or do you mean something else ?

If it is the former, than I think the main problem is that we use different 
devices (/dev/kfd vs. /dev/dri/)

If it is the latter, could you give me more specifics ?

Oded

> Regards,
> Christian.
>
>> ---
>>   drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 234 
>> +++
>>   1 file changed, 117 insertions(+), 117 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>> b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>> index 7d4974b..5460ad2 100644
>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>> @@ -127,17 +127,14 @@ static int kfd_open(struct inode *inode, struct file
>> *filep)
>>   return 0;
>>   }
>> -static long kfd_ioctl_get_version(struct file *filep, struct kfd_process *p,
>> -void __user *arg)
>> +static int kfd_ioctl_get_version(struct file *filep, struct kfd_process *p,
>> +void *data)
>>   {
>> -struct kfd_ioctl_get_version_args args;
>> +struct kfd_ioctl_get_version_args *args = data;
>>   int err = 0;
>> -args.major_version = KFD_IOCTL_MAJOR_VERSION;
>> -args.minor_version = KFD_IOCTL_MINOR_VERSION;
>> -
>> -if (copy_to_user(arg, , sizeof(args)))
>> -err = -EFAULT;
>> +args->major_version = KFD_IOCTL_MAJOR_VERSION;
>> +args->minor_version = KFD_IOCTL_MINOR_VERSION;
>>   return err;
>>   }
>> @@ -221,10 +218,10 @@ static int set_queue_properties_from_user(struct
>> queue_properties *q_properties,
>>   return 0;
>>   }
>> -static long kfd_ioctl_create_queue(struct file *filep, struct kfd_process 
>> *p,
>> -void __user *arg)
>> +static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,
>> +void *data)
>>   {
>> -struct kfd_ioctl_create_queue_args args;
>> +struct kfd_ioctl_create_queue_args *args = data;
>>   struct kfd_dev *dev;
>>   int err = 0;
>>   unsigned int queue_id;
>> @@ -233,16 +230,13 @@ static long kfd_ioctl_create_queue(struct file *filep,
>> struct kfd_process *p,
>>   memset(_properties, 0, sizeof(struct queue_properties));
>> -if (copy_from_user(, arg, sizeof(args)))
>> -return -EFAULT;
>> -
>>   pr_debug("kfd: creating queue ioctl\n");
>> -err = set_queue_properties_from_user(_properties, );
>> +err = set_queue_properties_from_user(_properties, args);
>>   if (err)
>>   return err;
>> -dev = kfd_device_by_id(args.gpu_id);
>> +dev = kfd_device_by_id(args->gpu_id);
>>   if (dev == NULL)
>>   return -EINVAL;
>> @@ -250,7 +244,7 @@ static long kfd_ioctl_create_queue(struct file *filep,
>> struct kfd_process *p,
>>   pdd = kfd_bind_process_to_device(dev, p);
>>   if (IS_ERR(pdd)) {
>> -err = PTR_ERR(pdd);
>> +err = -ESRCH;
>>   goto err_bind_process;
>>   }
>> @@ -263,33 +257,26 @@ static long kfd_ioctl_create_queue(struct file *filep,
>> struct kfd_process *p,
>>   if (err != 0)
>>   goto err_create_queue;
>> -args.queue_id = queue_id;
>> +args->queue_id = queue_id;
>>   /* Return gpu_id as doorbell offset for mmap usage */
>> -args.doorbell_offset = args.gpu_id << PAGE_SHIFT;
>> -
>> -if (copy_to_user(arg, , sizeof(args))) {
>> -err = -EFAULT;
>> -goto err_copy_args_out;
>> -}
>> +args->doorbell_offset = args->gpu_id << PAGE_SHIFT;
>>   mutex_unlock(>mutex);
>> -pr_debug("kfd: queue id %d was created successfully\n", args.queue_id);
>> +pr_debug("kfd: queue id %d was created successfully\n", args->queue_id);
>>   pr_debug("ring buffer address == 0x%016llX\n",
>> -args.ring_base_address);
>> +args->ring_base_address);
>>   pr_debug("read ptr address== 0x%016llX\n",
>> -args.read_pointer_address);
>> +args->read_pointer_address);
>>   pr_debug("write ptr address   == 0x%016llX\n",
>> -args.write_pointer_address);
>> +args->write_pointer_address);
>>   return 0;
>> -err_copy_args_out:
>> -pqm_destroy_queue(>pqm, queue_id);
>>   err_create_queue:
>>   err_bind_process:
>>   mutex_unlock(>mutex);
>> @@ -297,99 +284,90 @@ 

[PATCH 2/3] drm/amdkfd: reformat IOCTL definitions to drm-style

2014-12-29 Thread Oded Gabbay


On 12/29/2014 03:06 PM, Christian König wrote:
> Am 29.12.2014 um 13:42 schrieb Oded Gabbay:
>> This patch reformats the ioctl definitions in kfd_ioctl.h to be similar to 
>> the
>> drm ioctls definition style.
>>
>> Signed-off-by: Oded Gabbay 
>
> You are aware that this is a kernel API breakage?
Yes, but as long as 3.19 isn't released yet, I'm allowed to do this, no ?
and I want this patch-set to be inserted to 3.19 so there won't be API breakage 
afterwards.

>
>> ---
>>   drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 15 +++--
>>   include/uapi/linux/kfd_ioctl.h   | 37 
>> +++-
>>   2 files changed, 30 insertions(+), 22 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>> b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>> index 5460ad2..390385f 100644
>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>> @@ -524,35 +524,36 @@ static long kfd_ioctl(struct file *filep, unsigned int
>> cmd, unsigned long arg)
>>   switch (cmd) {
>> -case KFD_IOC_GET_VERSION:
>> +case AMDKFD_IOC_GET_VERSION:
>>   retcode = kfd_ioctl_get_version(filep, process, kdata);
>>   break;
>> -case KFD_IOC_CREATE_QUEUE:
>> +
>> +case AMDKFD_IOC_CREATE_QUEUE:
>>   retcode = kfd_ioctl_create_queue(filep, process,
>>   kdata);
>>   break;
>> -case KFD_IOC_DESTROY_QUEUE:
>> +case AMDKFD_IOC_DESTROY_QUEUE:
>>   retcode = kfd_ioctl_destroy_queue(filep, process,
>>   kdata);
>>   break;
>> -case KFD_IOC_SET_MEMORY_POLICY:
>> +case AMDKFD_IOC_SET_MEMORY_POLICY:
>>   retcode = kfd_ioctl_set_memory_policy(filep, process,
>>   kdata);
>>   break;
>> -case KFD_IOC_GET_CLOCK_COUNTERS:
>> +case AMDKFD_IOC_GET_CLOCK_COUNTERS:
>>   retcode = kfd_ioctl_get_clock_counters(filep, process,
>>   kdata);
>>   break;
>> -case KFD_IOC_GET_PROCESS_APERTURES:
>> +case AMDKFD_IOC_GET_PROCESS_APERTURES:
>>   retcode = kfd_ioctl_get_process_apertures(filep, process,
>>   kdata);
>>   break;
>> -case KFD_IOC_UPDATE_QUEUE:
>> +case AMDKFD_IOC_UPDATE_QUEUE:
>>   retcode = kfd_ioctl_update_queue(filep, process,
>>   kdata);
>>   break;
>> diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h
>> index 7acef41..05b53f6 100644
>> --- a/include/uapi/linux/kfd_ioctl.h
>> +++ b/include/uapi/linux/kfd_ioctl.h
>> @@ -128,27 +128,34 @@ struct kfd_ioctl_get_process_apertures_args {
>>   uint32_t pad;
>>   };
>> -#define KFD_IOC_MAGIC 'K'
>> +#define AMDKFD_IOCTL_BASE 'K'
>> +#define AMDKFD_IO(nr)_IO(AMDKFD_IOCTL_BASE, nr)
>> +#define AMDKFD_IOR(nr, type)_IOR(AMDKFD_IOCTL_BASE, nr, type)
>> +#define AMDKFD_IOW(nr, type)_IOW(AMDKFD_IOCTL_BASE, nr, type)
>> +#define AMDKFD_IOWR(nr, type)_IOWR(AMDKFD_IOCTL_BASE, nr, type)
>> -#define KFD_IOC_GET_VERSION \
>> -_IOR(KFD_IOC_MAGIC, 1, struct kfd_ioctl_get_version_args)
>> +#define AMDKFD_IOC_GET_VERSION\
>> +AMDKFD_IOR(0x01, struct kfd_ioctl_get_version_args)
>> -#define KFD_IOC_CREATE_QUEUE \
>> -_IOWR(KFD_IOC_MAGIC, 2, struct kfd_ioctl_create_queue_args)
>> +#define AMDKFD_IOC_CREATE_QUEUE\
>> +AMDKFD_IOWR(0x02, struct kfd_ioctl_create_queue_args)
>> -#define KFD_IOC_DESTROY_QUEUE \
>> -_IOWR(KFD_IOC_MAGIC, 3, struct kfd_ioctl_destroy_queue_args)
>> +#define AMDKFD_IOC_DESTROY_QUEUE\
>> +AMDKFD_IOWR(0x03, struct kfd_ioctl_destroy_queue_args)
>> -#define KFD_IOC_SET_MEMORY_POLICY \
>> -_IOW(KFD_IOC_MAGIC, 4, struct kfd_ioctl_set_memory_policy_args)
>> +#define AMDKFD_IOC_SET_MEMORY_POLICY\
>> +AMDKFD_IOW(0x04, struct kfd_ioctl_set_memory_policy_args)
>> -#define KFD_IOC_GET_CLOCK_COUNTERS \
>> -_IOWR(KFD_IOC_MAGIC, 5, struct kfd_ioctl_get_clock_counters_args)
>> +#define AMDKFD_IOC_GET_CLOCK_COUNTERS\
>> +AMDKFD_IOWR(0x05, struct kfd_ioctl_get_clock_counters_args)
>> -#define KFD_IOC_GET_PROCESS_APERTURES \
>> -_IOR(KFD_IOC_MAGIC, 6, struct kfd_ioctl_get_process_apertures_args)
>> +#define AMDKFD_IOC_GET_PROCESS_APERTURES\
>> +AMDKFD_IOR(0x06, struct kfd_ioctl_get_process_apertures_args)
>> -#define KFD_IOC_UPDATE_QUEUE \
>> -_IOW(KFD_IOC_MAGIC, 7, struct kfd_ioctl_update_queue_args)
>> +#define AMDKFD_IOC_UPDATE_QUEUE\
>> +AMDKFD_IOW(0x07, struct kfd_ioctl_update_queue_args)
>> +
>> +#define KFD_COMMAND_START   0x01
>> +#define KFD_COMMAND_END0x08
>
> If you rename everything to AMDKFD_* you probably want to do so as well for
> KFD_COMMAND_(START|END).

Thanks, I'll do that.

Oded
>
> Regards,
> Christian.
>
>>   #endif
>


[PATCH v2] drm/radeon: Init amdkfd only if it was compiled

2014-12-29 Thread Oded Gabbay


On 12/29/2014 02:41 PM, Christian König wrote:
> Am 29.12.2014 um 09:59 schrieb Oded Gabbay:
>> This patch changes the radeon_kfd_init(), which is used to initialize the
>> interface between radeon and amdkfd, so the interface will be initialized 
>> only
>> if amdkfd was build, either as module or inside the kernel image.
>>
>> In the modules case, the symbol_request() will be used (same as old code). In
>> the in-image compilation case, a direct call to kgd2kfd_init() will be done.
>> For other cases, radeon_kfd_init() will just return false.
>>
>> This patch is necessary because in case of the following specific
>> configuration: kernel 32-bit, no modules support, random kernel base and no
>> hibernation, the symbol_request() doesn't work as expected - it doesn't 
>> return
>> NULL if the symbol doesn't exists - which makes the kernel panic.
>>
>> Signed-off-by: Oded Gabbay 
>
> Using symbol_request() in general doesn't seem to be such a good idea, because
> it breaks symbol versioning and as far as I can see is only very rarely used 
> in
> drivers (AFAIK only V4L drivers).
>
> But for the moment I don't have another idea either except for always loading
> the module which on most hardware is completely unnecessary. Maybe we should
> consider restructuring the module load dependencies in the next kernel 
> release.
>
> For now the patch is Reviewed-by: Christian König  amd.com>
>
Thanks Christian.
I agree that this is somewhat a mess, that was created unfortunately at the 
very 
beginning of kfd.

We will definitely fix this in 2015, as we also need to think how kfd will 
integrate with both radeon and amdgpu if they are present on the same system. 
The current method we use doesn't enable that situation.

Ideally, I would like to see total separation (between init of radeon and init 
of amdkfd) and use of exported symbols instead of symbol_request. Couple that 
with probe deferral and I think the end result will be much better than the 
current design.

Oded

>> ---
>>   drivers/gpu/drm/radeon/radeon_kfd.c | 12 
>>   1 file changed, 12 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/radeon/radeon_kfd.c
>> b/drivers/gpu/drm/radeon/radeon_kfd.c
>> index 242fd8b..d3e78b4 100644
>> --- a/drivers/gpu/drm/radeon/radeon_kfd.c
>> +++ b/drivers/gpu/drm/radeon/radeon_kfd.c
>> @@ -101,6 +101,7 @@ static const struct kgd2kfd_calls *kgd2kfd;
>>   bool radeon_kfd_init(void)
>>   {
>> +#if defined(CONFIG_HSA_AMD_MODULE)
>>   bool (*kgd2kfd_init_p)(unsigned, const struct kfd2kgd_calls*,
>>   const struct kgd2kfd_calls**);
>> @@ -117,6 +118,17 @@ bool radeon_kfd_init(void)
>>   }
>>   return true;
>> +#elif defined(CONFIG_HSA_AMD)
>> +if (!kgd2kfd_init(KFD_INTERFACE_VERSION, , )) {
>> +kgd2kfd = NULL;
>> +
>> +return false;
>> +}
>> +
>> +return true;
>> +#else
>> +return false;
>> +#endif
>>   }
>>   void radeon_kfd_fini(void)
>


[PATCH 1/3] drm/amdkfd: Do copy_to/from_user in general kfd_ioctl()

2014-12-29 Thread Christian König
Am 29.12.2014 um 14:22 schrieb Oded Gabbay:
>
>
> On 12/29/2014 03:05 PM, Christian König wrote:
>> Am 29.12.2014 um 13:42 schrieb Oded Gabbay:
>>> This patch moves the copy_to_user() and copy_from_user() calls from the
>>> different ioctl functions in amdkfd to the general kfd_ioctl() 
>>> function, as
>>> this is a common code for all ioctls.
>>>
>>> This was done according to example taken from drm_ioctl.c
>>>
>>> Signed-off-by: Oded Gabbay 
>>
>> In general sounds like a good idea to me and the patch is "Reviewed-by:
>> Christian König " for now.
>>
>> What really questions me is why we need all this code duplication and 
>> can't
>> reuse the DRM infrastructure for this. But that's more a problem in 
>> the long term.
>>
> Do you mean registering as DRM IOCTL ?
> Or do you mean something else ?
>
> If it is the former, than I think the main problem is that we use 
> different devices (/dev/kfd vs. /dev/dri/)

Ah, yes of course. I simply keep forgetting that we have two device 
nodes for the same physical hardware.

Christian.

>
> If it is the latter, could you give me more specifics ?
>
> Oded
>
>> Regards,
>> Christian.
>>
>>> ---
>>>   drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 234 
>>> +++
>>>   1 file changed, 117 insertions(+), 117 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>>> b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>>> index 7d4974b..5460ad2 100644
>>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>>> @@ -127,17 +127,14 @@ static int kfd_open(struct inode *inode, 
>>> struct file
>>> *filep)
>>>   return 0;
>>>   }
>>> -static long kfd_ioctl_get_version(struct file *filep, struct 
>>> kfd_process *p,
>>> -void __user *arg)
>>> +static int kfd_ioctl_get_version(struct file *filep, struct 
>>> kfd_process *p,
>>> +void *data)
>>>   {
>>> -struct kfd_ioctl_get_version_args args;
>>> +struct kfd_ioctl_get_version_args *args = data;
>>>   int err = 0;
>>> -args.major_version = KFD_IOCTL_MAJOR_VERSION;
>>> -args.minor_version = KFD_IOCTL_MINOR_VERSION;
>>> -
>>> -if (copy_to_user(arg, , sizeof(args)))
>>> -err = -EFAULT;
>>> +args->major_version = KFD_IOCTL_MAJOR_VERSION;
>>> +args->minor_version = KFD_IOCTL_MINOR_VERSION;
>>>   return err;
>>>   }
>>> @@ -221,10 +218,10 @@ static int set_queue_properties_from_user(struct
>>> queue_properties *q_properties,
>>>   return 0;
>>>   }
>>> -static long kfd_ioctl_create_queue(struct file *filep, struct 
>>> kfd_process *p,
>>> -void __user *arg)
>>> +static int kfd_ioctl_create_queue(struct file *filep, struct 
>>> kfd_process *p,
>>> +void *data)
>>>   {
>>> -struct kfd_ioctl_create_queue_args args;
>>> +struct kfd_ioctl_create_queue_args *args = data;
>>>   struct kfd_dev *dev;
>>>   int err = 0;
>>>   unsigned int queue_id;
>>> @@ -233,16 +230,13 @@ static long kfd_ioctl_create_queue(struct file 
>>> *filep,
>>> struct kfd_process *p,
>>>   memset(_properties, 0, sizeof(struct queue_properties));
>>> -if (copy_from_user(, arg, sizeof(args)))
>>> -return -EFAULT;
>>> -
>>>   pr_debug("kfd: creating queue ioctl\n");
>>> -err = set_queue_properties_from_user(_properties, );
>>> +err = set_queue_properties_from_user(_properties, args);
>>>   if (err)
>>>   return err;
>>> -dev = kfd_device_by_id(args.gpu_id);
>>> +dev = kfd_device_by_id(args->gpu_id);
>>>   if (dev == NULL)
>>>   return -EINVAL;
>>> @@ -250,7 +244,7 @@ static long kfd_ioctl_create_queue(struct file 
>>> *filep,
>>> struct kfd_process *p,
>>>   pdd = kfd_bind_process_to_device(dev, p);
>>>   if (IS_ERR(pdd)) {
>>> -err = PTR_ERR(pdd);
>>> +err = -ESRCH;
>>>   goto err_bind_process;
>>>   }
>>> @@ -263,33 +257,26 @@ static long kfd_ioctl_create_queue(struct file 
>>> *filep,
>>> struct kfd_process *p,
>>>   if (err != 0)
>>>   goto err_create_queue;
>>> -args.queue_id = queue_id;
>>> +args->queue_id = queue_id;
>>>   /* Return gpu_id as doorbell offset for mmap usage */
>>> -args.doorbell_offset = args.gpu_id << PAGE_SHIFT;
>>> -
>>> -if (copy_to_user(arg, , sizeof(args))) {
>>> -err = -EFAULT;
>>> -goto err_copy_args_out;
>>> -}
>>> +args->doorbell_offset = args->gpu_id << PAGE_SHIFT;
>>>   mutex_unlock(>mutex);
>>> -pr_debug("kfd: queue id %d was created successfully\n", 
>>> args.queue_id);
>>> +pr_debug("kfd: queue id %d was created successfully\n", 
>>> args->queue_id);
>>>   pr_debug("ring buffer address == 0x%016llX\n",
>>> -args.ring_base_address);
>>> +args->ring_base_address);
>>>   pr_debug("read ptr address== 0x%016llX\n",
>>> -args.read_pointer_address);
>>> +args->read_pointer_address);

[PATCH 1/4] amdkfd: fix error printing in kfd_ioctl()

2014-12-29 Thread Oded Gabbay


On 12/15/2014 10:32 AM, Dave Airlie wrote:
> On 15 December 2014 at 17:59, Daniel Vetter  wrote:
>> On Sun, Dec 14, 2014 at 03:10:17PM +0100, Christian König wrote:
>>> Am 14.12.2014 um 14:35 schrieb Oded Gabbay:
 When an ioctl function returns -EAGAIN, don't print error in kfd_ioctl()
>>>
>>> You most likely want to handle -ERESTARTSYS the same way.
>>
>> Please just reuse drmIoctl or at least copy it perfectly. We've had too
>> many tears about ioctl restarting going badly wrong. Also make sure you
>> never do a raw ioctl call anywhere for amdkfd. Adding Dave.
>
> Also please don't make a user triggerable printk.
>
> If the user can throw crap at the ioctl and get msgs in dmesg,
> then its annoying as hell.
>
> Copy the drm.debug stuff and code as well, and for userspace,
> yes do what Daniel says and use drmIoctl wrapper or something like
> that, though Daniel I believe one of the main consumers on i915
> insists on opencoding his ioctls.
>
> Dave.
>
Hi Dave, Daniel

I just sent a patch-set that copies the drm_ioctl() handling to kfd_ioctl(), as 
you requested.
All error prints have been converted to debug prints.
This is the first part and I'm now going to change the userspace as well.

Oded


[PATCH 3/3] drm/amdkfd: rewrite kfd_ioctl() according to drm_ioctl()

2014-12-29 Thread Oded Gabbay
This patch changes kfd_ioctl() to be very similar to drm_ioctl().

The patch defines an array of amdkfd_ioctls, which maps IOCTL definition to the
ioctl function.

The kfd_ioctl() uses that mapping to call the appropriate ioctl function,
through a function pointer.

This patch also declares a new typedef for the ioctl function pointer.

Signed-off-by: Oded Gabbay 
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 116 ++-
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h|  18 +
 2 files changed, 86 insertions(+), 48 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 390385f..06693fa 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -483,21 +483,79 @@ static int kfd_ioctl_get_process_apertures(struct file 
*filp,
return 0;
 }

+#define AMDKFD_IOCTL_DEF(ioctl, _func, _flags) \
+   [_IOC_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags, 
.cmd_drv = 0, .name = #ioctl}
+
+/** Ioctl table */
+static const struct amdkfd_ioctl_desc amdkfd_ioctls[] = {
+   AMDKFD_IOCTL_DEF(AMDKFD_IOC_GET_VERSION,
+   kfd_ioctl_get_version, 0),
+
+   AMDKFD_IOCTL_DEF(AMDKFD_IOC_CREATE_QUEUE,
+   kfd_ioctl_create_queue, 0),
+
+   AMDKFD_IOCTL_DEF(AMDKFD_IOC_DESTROY_QUEUE,
+   kfd_ioctl_destroy_queue, 0),
+
+   AMDKFD_IOCTL_DEF(AMDKFD_IOC_SET_MEMORY_POLICY,
+   kfd_ioctl_set_memory_policy, 0),
+
+   AMDKFD_IOCTL_DEF(AMDKFD_IOC_GET_CLOCK_COUNTERS,
+   kfd_ioctl_get_clock_counters, 0),
+
+   AMDKFD_IOCTL_DEF(AMDKFD_IOC_GET_PROCESS_APERTURES,
+   kfd_ioctl_get_process_apertures, 0),
+
+   AMDKFD_IOCTL_DEF(AMDKFD_IOC_UPDATE_QUEUE,
+   kfd_ioctl_update_queue, 0),
+};
+
+#define AMDKFD_CORE_IOCTL_COUNTARRAY_SIZE(amdkfd_ioctls)
+
 static long kfd_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
 {
struct kfd_process *process;
+   amdkfd_ioctl_t *func;
+   const struct amdkfd_ioctl_desc *ioctl = NULL;
+   unsigned int nr = _IOC_NR(cmd);
char stack_kdata[128];
char *kdata = NULL;
unsigned int usize, asize;
int retcode = -EINVAL;

-   dev_dbg(kfd_device,
-   "ioctl cmd 0x%x (#%d), arg 0x%lx\n",
-   cmd, _IOC_NR(cmd), arg);
+   if (nr >= AMDKFD_CORE_IOCTL_COUNT)
+   goto err_i1;
+
+   if ((nr >= KFD_COMMAND_START) && (nr < KFD_COMMAND_END)) {
+   u32 amdkfd_size;
+
+   ioctl = _ioctls[nr];
+
+   amdkfd_size = _IOC_SIZE(ioctl->cmd);
+   usize = asize = _IOC_SIZE(cmd);
+   if (amdkfd_size > asize)
+   asize = amdkfd_size;
+
+   cmd = ioctl->cmd;
+   } else
+   goto err_i1;
+
+   dev_dbg(kfd_device, "ioctl cmd 0x%x (#%d), arg 0x%lx\n", cmd, nr, arg);

process = kfd_get_process(current);
-   if (IS_ERR(process))
-   return PTR_ERR(process);
+   if (IS_ERR(process)) {
+   dev_dbg(kfd_device, "no process\n");
+   goto err_i1;
+   }
+
+   /* Do not trust userspace, use our own definition */
+   func = ioctl->func;
+
+   if (unlikely(!func)) {
+   dev_dbg(kfd_device, "no function\n");
+   retcode = -EINVAL;
+   goto err_i1;
+   }

if (cmd & (IOC_IN | IOC_OUT)) {
if (asize <= sizeof(stack_kdata)) {
@@ -522,55 +580,17 @@ static long kfd_ioctl(struct file *filep, unsigned int 
cmd, unsigned long arg)
memset(kdata, 0, usize);
}

-
-   switch (cmd) {
-   case AMDKFD_IOC_GET_VERSION:
-   retcode = kfd_ioctl_get_version(filep, process, kdata);
-   break;
-
-   case AMDKFD_IOC_CREATE_QUEUE:
-   retcode = kfd_ioctl_create_queue(filep, process,
-   kdata);
-   break;
-
-   case AMDKFD_IOC_DESTROY_QUEUE:
-   retcode = kfd_ioctl_destroy_queue(filep, process,
-   kdata);
-   break;
-
-   case AMDKFD_IOC_SET_MEMORY_POLICY:
-   retcode = kfd_ioctl_set_memory_policy(filep, process,
-   kdata);
-   break;
-
-   case AMDKFD_IOC_GET_CLOCK_COUNTERS:
-   retcode = kfd_ioctl_get_clock_counters(filep, process,
-   kdata);
-   break;
-
-   case AMDKFD_IOC_GET_PROCESS_APERTURES:
-   retcode = kfd_ioctl_get_process_apertures(filep, process,
-   kdata);
-   break;
-
-   case AMDKFD_IOC_UPDATE_QUEUE:
-   retcode = kfd_ioctl_update_queue(filep, process,
-  

[PATCH 2/3] drm/amdkfd: reformat IOCTL definitions to drm-style

2014-12-29 Thread Oded Gabbay
This patch reformats the ioctl definitions in kfd_ioctl.h to be similar to the
drm ioctls definition style.

Signed-off-by: Oded Gabbay 
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 15 +++--
 include/uapi/linux/kfd_ioctl.h   | 37 +++-
 2 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 5460ad2..390385f 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -524,35 +524,36 @@ static long kfd_ioctl(struct file *filep, unsigned int 
cmd, unsigned long arg)


switch (cmd) {
-   case KFD_IOC_GET_VERSION:
+   case AMDKFD_IOC_GET_VERSION:
retcode = kfd_ioctl_get_version(filep, process, kdata);
break;
-   case KFD_IOC_CREATE_QUEUE:
+
+   case AMDKFD_IOC_CREATE_QUEUE:
retcode = kfd_ioctl_create_queue(filep, process,
kdata);
break;

-   case KFD_IOC_DESTROY_QUEUE:
+   case AMDKFD_IOC_DESTROY_QUEUE:
retcode = kfd_ioctl_destroy_queue(filep, process,
kdata);
break;

-   case KFD_IOC_SET_MEMORY_POLICY:
+   case AMDKFD_IOC_SET_MEMORY_POLICY:
retcode = kfd_ioctl_set_memory_policy(filep, process,
kdata);
break;

-   case KFD_IOC_GET_CLOCK_COUNTERS:
+   case AMDKFD_IOC_GET_CLOCK_COUNTERS:
retcode = kfd_ioctl_get_clock_counters(filep, process,
kdata);
break;

-   case KFD_IOC_GET_PROCESS_APERTURES:
+   case AMDKFD_IOC_GET_PROCESS_APERTURES:
retcode = kfd_ioctl_get_process_apertures(filep, process,
kdata);
break;

-   case KFD_IOC_UPDATE_QUEUE:
+   case AMDKFD_IOC_UPDATE_QUEUE:
retcode = kfd_ioctl_update_queue(filep, process,
kdata);
break;
diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h
index 7acef41..05b53f6 100644
--- a/include/uapi/linux/kfd_ioctl.h
+++ b/include/uapi/linux/kfd_ioctl.h
@@ -128,27 +128,34 @@ struct kfd_ioctl_get_process_apertures_args {
uint32_t pad;
 };

-#define KFD_IOC_MAGIC 'K'
+#define AMDKFD_IOCTL_BASE 'K'
+#define AMDKFD_IO(nr)  _IO(AMDKFD_IOCTL_BASE, nr)
+#define AMDKFD_IOR(nr, type)   _IOR(AMDKFD_IOCTL_BASE, nr, type)
+#define AMDKFD_IOW(nr, type)   _IOW(AMDKFD_IOCTL_BASE, nr, type)
+#define AMDKFD_IOWR(nr, type)  _IOWR(AMDKFD_IOCTL_BASE, nr, type)

-#define KFD_IOC_GET_VERSION \
-   _IOR(KFD_IOC_MAGIC, 1, struct kfd_ioctl_get_version_args)
+#define AMDKFD_IOC_GET_VERSION \
+   AMDKFD_IOR(0x01, struct kfd_ioctl_get_version_args)

-#define KFD_IOC_CREATE_QUEUE \
-   _IOWR(KFD_IOC_MAGIC, 2, struct kfd_ioctl_create_queue_args)
+#define AMDKFD_IOC_CREATE_QUEUE\
+   AMDKFD_IOWR(0x02, struct kfd_ioctl_create_queue_args)

-#define KFD_IOC_DESTROY_QUEUE \
-   _IOWR(KFD_IOC_MAGIC, 3, struct kfd_ioctl_destroy_queue_args)
+#define AMDKFD_IOC_DESTROY_QUEUE   \
+   AMDKFD_IOWR(0x03, struct kfd_ioctl_destroy_queue_args)

-#define KFD_IOC_SET_MEMORY_POLICY \
-   _IOW(KFD_IOC_MAGIC, 4, struct kfd_ioctl_set_memory_policy_args)
+#define AMDKFD_IOC_SET_MEMORY_POLICY   \
+   AMDKFD_IOW(0x04, struct kfd_ioctl_set_memory_policy_args)

-#define KFD_IOC_GET_CLOCK_COUNTERS \
-   _IOWR(KFD_IOC_MAGIC, 5, struct kfd_ioctl_get_clock_counters_args)
+#define AMDKFD_IOC_GET_CLOCK_COUNTERS  \
+   AMDKFD_IOWR(0x05, struct kfd_ioctl_get_clock_counters_args)

-#define KFD_IOC_GET_PROCESS_APERTURES \
-   _IOR(KFD_IOC_MAGIC, 6, struct kfd_ioctl_get_process_apertures_args)
+#define AMDKFD_IOC_GET_PROCESS_APERTURES   \
+   AMDKFD_IOR(0x06, struct kfd_ioctl_get_process_apertures_args)

-#define KFD_IOC_UPDATE_QUEUE \
-   _IOW(KFD_IOC_MAGIC, 7, struct kfd_ioctl_update_queue_args)
+#define AMDKFD_IOC_UPDATE_QUEUE\
+   AMDKFD_IOW(0x07, struct kfd_ioctl_update_queue_args)
+
+#define KFD_COMMAND_START   0x01
+#define KFD_COMMAND_END0x08

 #endif
-- 
1.9.1



[PATCH 1/3] drm/amdkfd: Do copy_to/from_user in general kfd_ioctl()

2014-12-29 Thread Oded Gabbay
This patch moves the copy_to_user() and copy_from_user() calls from the
different ioctl functions in amdkfd to the general kfd_ioctl() function, as
this is a common code for all ioctls.

This was done according to example taken from drm_ioctl.c

Signed-off-by: Oded Gabbay 
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 234 +++
 1 file changed, 117 insertions(+), 117 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 7d4974b..5460ad2 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -127,17 +127,14 @@ static int kfd_open(struct inode *inode, struct file 
*filep)
return 0;
 }

-static long kfd_ioctl_get_version(struct file *filep, struct kfd_process *p,
-   void __user *arg)
+static int kfd_ioctl_get_version(struct file *filep, struct kfd_process *p,
+   void *data)
 {
-   struct kfd_ioctl_get_version_args args;
+   struct kfd_ioctl_get_version_args *args = data;
int err = 0;

-   args.major_version = KFD_IOCTL_MAJOR_VERSION;
-   args.minor_version = KFD_IOCTL_MINOR_VERSION;
-
-   if (copy_to_user(arg, , sizeof(args)))
-   err = -EFAULT;
+   args->major_version = KFD_IOCTL_MAJOR_VERSION;
+   args->minor_version = KFD_IOCTL_MINOR_VERSION;

return err;
 }
@@ -221,10 +218,10 @@ static int set_queue_properties_from_user(struct 
queue_properties *q_properties,
return 0;
 }

-static long kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,
-   void __user *arg)
+static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,
+   void *data)
 {
-   struct kfd_ioctl_create_queue_args args;
+   struct kfd_ioctl_create_queue_args *args = data;
struct kfd_dev *dev;
int err = 0;
unsigned int queue_id;
@@ -233,16 +230,13 @@ static long kfd_ioctl_create_queue(struct file *filep, 
struct kfd_process *p,

memset(_properties, 0, sizeof(struct queue_properties));

-   if (copy_from_user(, arg, sizeof(args)))
-   return -EFAULT;
-
pr_debug("kfd: creating queue ioctl\n");

-   err = set_queue_properties_from_user(_properties, );
+   err = set_queue_properties_from_user(_properties, args);
if (err)
return err;

-   dev = kfd_device_by_id(args.gpu_id);
+   dev = kfd_device_by_id(args->gpu_id);
if (dev == NULL)
return -EINVAL;

@@ -250,7 +244,7 @@ static long kfd_ioctl_create_queue(struct file *filep, 
struct kfd_process *p,

pdd = kfd_bind_process_to_device(dev, p);
if (IS_ERR(pdd)) {
-   err = PTR_ERR(pdd);
+   err = -ESRCH;
goto err_bind_process;
}

@@ -263,33 +257,26 @@ static long kfd_ioctl_create_queue(struct file *filep, 
struct kfd_process *p,
if (err != 0)
goto err_create_queue;

-   args.queue_id = queue_id;
+   args->queue_id = queue_id;

/* Return gpu_id as doorbell offset for mmap usage */
-   args.doorbell_offset = args.gpu_id << PAGE_SHIFT;
-
-   if (copy_to_user(arg, , sizeof(args))) {
-   err = -EFAULT;
-   goto err_copy_args_out;
-   }
+   args->doorbell_offset = args->gpu_id << PAGE_SHIFT;

mutex_unlock(>mutex);

-   pr_debug("kfd: queue id %d was created successfully\n", args.queue_id);
+   pr_debug("kfd: queue id %d was created successfully\n", args->queue_id);

pr_debug("ring buffer address == 0x%016llX\n",
-   args.ring_base_address);
+   args->ring_base_address);

pr_debug("read ptr address== 0x%016llX\n",
-   args.read_pointer_address);
+   args->read_pointer_address);

pr_debug("write ptr address   == 0x%016llX\n",
-   args.write_pointer_address);
+   args->write_pointer_address);

return 0;

-err_copy_args_out:
-   pqm_destroy_queue(>pqm, queue_id);
 err_create_queue:
 err_bind_process:
mutex_unlock(>mutex);
@@ -297,99 +284,90 @@ err_bind_process:
 }

 static int kfd_ioctl_destroy_queue(struct file *filp, struct kfd_process *p,
-   void __user *arg)
+   void *data)
 {
int retval;
-   struct kfd_ioctl_destroy_queue_args args;
-
-   if (copy_from_user(, arg, sizeof(args)))
-   return -EFAULT;
+   struct kfd_ioctl_destroy_queue_args *args = data;

pr_debug("kfd: destroying queue id %d for PASID %d\n",
-   args.queue_id,
+   args->queue_id,
p->pasid);

mutex_lock(>mutex);

[PATCH RFC v6 21/21] ARM: imx_v6_v7_defconfig: Add support for Himax HX8369A panel

2014-12-29 Thread Liu Ying
This patch adds support for Himax HX8369A panel.

The new imx_v6_v7_defconfig is generated in this way:
* make ARCH=arm imx_v6_v7_defconfig
* make ARCH=arm menuconfig and manually choose to build in
  the Himax HX8369A panel driver
* make ARCH=arm savedefconfig
* cp defconfig arch/arm/configs/imx_v6_v7_defconfig

Signed-off-by: Liu Ying 
---
v5->v6:
 * None.

v4->v5:
 * None.

v3->v4:
 * None.

v2->v3:
 * None.

v1->v2:
 * Add the HIMAX prefix in the Kconfig name.

 arch/arm/configs/imx_v6_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
b/arch/arm/configs/imx_v6_v7_defconfig
index 3e0e589..27db91b 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -192,6 +192,7 @@ CONFIG_SOC_CAMERA_OV2640=y
 CONFIG_IMX_IPUV3_CORE=y
 CONFIG_DRM=y
 CONFIG_DRM_PANEL_SIMPLE=y
+CONFIG_DRM_PANEL_HIMAX_HX8369A=y
 CONFIG_DRM_IMX=y
 CONFIG_DRM_IMX_FB_HELPER=y
 CONFIG_DRM_IMX_PARALLEL_DISPLAY=y
-- 
2.1.0



[PATCH RFC v6 20/21] ARM: imx_v6_v7_defconfig: Add support for MIPI DSI host controller

2014-12-29 Thread Liu Ying
This patch adds support for MIPI DSI host controller.

The new imx_v6_v7_defconfig is generated in this way:
* make ARCH=arm imx_v6_v7_defconfig
* make ARCH=arm menuconfig and manually choose to build in
  the MIPI DSI host controller driver
* make ARCH=arm savedefconfig
* cp defconfig arch/arm/configs/imx_v6_v7_defconfig

Signed-off-by: Liu Ying 
---
v5->v6:
 * None.

v4->v5:
 * None.

v3->v4:
 * None.

v2->v3:
 * None.

v1->v2:
 * None.

 arch/arm/configs/imx_v6_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
b/arch/arm/configs/imx_v6_v7_defconfig
index 0dbd0c3..3e0e589 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -199,6 +199,7 @@ CONFIG_DRM_IMX_TVE=y
 CONFIG_DRM_IMX_LDB=y
 CONFIG_DRM_IMX_IPUV3=y
 CONFIG_DRM_IMX_HDMI=y
+CONFIG_DRM_IMX_MIPI_DSI=y
 CONFIG_LCD_CLASS_DEVICE=y
 CONFIG_LCD_L4F00242T03=y
 CONFIG_LCD_PLATFORM=y
-- 
2.1.0



[PATCH RFC v6 19/21] ARM: imx_v6_v7_defconfig: Cleanup for imx drm being moved out of staging

2014-12-29 Thread Liu Ying
The new imx_v6_v7_defconfig is generated in this way:
* make ARCH=arm imx_v6_v7_defconfig
* make ARCH=arm savedefconfig
* cp defconfig arch/arm/configs/imx_v6_v7_defconfig

Signed-off-by: Liu Ying 
---
v5->v6:
 * None.

v4->v5:
 * None.

v3->v4:
 * None.

v2->v3:
 * None.

v1->v2:
 * None.

 arch/arm/configs/imx_v6_v7_defconfig | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
b/arch/arm/configs/imx_v6_v7_defconfig
index 6790f1b..0dbd0c3 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -192,7 +192,13 @@ CONFIG_SOC_CAMERA_OV2640=y
 CONFIG_IMX_IPUV3_CORE=y
 CONFIG_DRM=y
 CONFIG_DRM_PANEL_SIMPLE=y
-CONFIG_BACKLIGHT_LCD_SUPPORT=y
+CONFIG_DRM_IMX=y
+CONFIG_DRM_IMX_FB_HELPER=y
+CONFIG_DRM_IMX_PARALLEL_DISPLAY=y
+CONFIG_DRM_IMX_TVE=y
+CONFIG_DRM_IMX_LDB=y
+CONFIG_DRM_IMX_IPUV3=y
+CONFIG_DRM_IMX_HDMI=y
 CONFIG_LCD_CLASS_DEVICE=y
 CONFIG_LCD_L4F00242T03=y
 CONFIG_LCD_PLATFORM=y
@@ -249,13 +255,6 @@ CONFIG_IMX_SDMA=y
 CONFIG_MXS_DMA=y
 CONFIG_FSL_EDMA=y
 CONFIG_STAGING=y
-CONFIG_DRM_IMX=y
-CONFIG_DRM_IMX_FB_HELPER=y
-CONFIG_DRM_IMX_PARALLEL_DISPLAY=y
-CONFIG_DRM_IMX_TVE=y
-CONFIG_DRM_IMX_LDB=y
-CONFIG_DRM_IMX_IPUV3=y
-CONFIG_DRM_IMX_HDMI=y
 # CONFIG_IOMMU_SUPPORT is not set
 CONFIG_PWM=y
 CONFIG_PWM_IMX=y
-- 
2.1.0



[PATCH RFC v6 18/21] ARM: dts: imx6qdl-sabresd: Add support for TRULY TFT480800-16-E MIPI DSI panel

2014-12-29 Thread Liu Ying
The TRULY TFT480800-16-E panel is driven by the Himax HX8369A driver IC.
The driver IC supports several display/control interface modes, including
the MIPI DSI video mode and command mode.

Signed-off-by: Liu Ying 
---
v5->v6:
 * None.

v4->v5:
 * Replace the bs[3:0]-gpios properties with the bs-gpios property.
   This addresses Andrzej Hajda's comment.

v3->v4:
 * None.

v2->v3:
 * None.

v1->v2:
 * To address Thierry Reding's comments, remove several unnecessary
   properties as they can be implied by the compatible string.
 * Fix the compatible string.
 * Remove the display-timings node from the panel node as it can be
   implied by the compatible string as well.
 * Remove the status property as it is unneeded.

 arch/arm/boot/dts/imx6qdl-sabresd.dtsi | 20 
 1 file changed, 20 insertions(+)

diff --git a/arch/arm/boot/dts/imx6qdl-sabresd.dtsi 
b/arch/arm/boot/dts/imx6qdl-sabresd.dtsi
index baf2f00..4e3a666 100644
--- a/arch/arm/boot/dts/imx6qdl-sabresd.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-sabresd.dtsi
@@ -482,6 +482,13 @@
MX6QDL_PAD_SD4_DAT7__SD4_DATA7  0x17059
>;
};
+
+   pinctrl_mipi_panel: mipipanelgrp {
+   fsl,pins = <
+   MX6QDL_PAD_NANDF_CS0__GPIO6_IO11 0x1b0b0
+   MX6QDL_PAD_NANDF_CS1__GPIO6_IO14 0x1b0b0
+   >;
+   };
};

gpio_leds {
@@ -518,6 +525,19 @@
};
 };

+_dsi {
+   status = "okay";
+
+   panel {
+   compatible = "truly,tft480800-16-e-dsi";
+   reg = <0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_mipi_panel>;
+   reset-gpios = < 11 GPIO_ACTIVE_LOW>;
+   bs-gpios = <0>, <0>, < 14 GPIO_ACTIVE_HIGH>, <0>;
+   };
+};
+
  {
pinctrl-names = "default";
pinctrl-0 = <_pcie>;
-- 
2.1.0



[PATCH RFC v6 17/21] ARM: dtsi: imx6qdl: Add support for MIPI DSI host controller

2014-12-29 Thread Liu Ying
This patch adds support for MIPI DSI host controller.

Signed-off-by: Liu Ying 
---
v5->v6:
 * None.

v3->v4:
 * None.

v2->v3:
 * As suggested by Phillip Zabel, change the clocks and the clock-names
   properties to use the pllref and core_cfg clocks only.

v1->v2:
 * None.

 arch/arm/boot/dts/imx6qdl.dtsi | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi
index 96bf2a0..7b1c313 100644
--- a/arch/arm/boot/dts/imx6qdl.dtsi
+++ b/arch/arm/boot/dts/imx6qdl.dtsi
@@ -1006,7 +1006,13 @@
mipi_dsi: mipi at 021e {
#address-cells = <1>;
#size-cells = <0>;
+   compatible = "fsl,imx6q-mipi-dsi";
reg = <0x021e 0x4000>;
+   interrupts = <0 102 IRQ_TYPE_LEVEL_HIGH>;
+   gpr = <>;
+   clocks = < IMX6QDL_CLK_MIPI_CORE_CFG>,
+< IMX6QDL_CLK_MIPI_CORE_CFG>;
+   clock-names = "pllref", "core_cfg";
status = "disabled";

ports {
-- 
2.1.0



[PATCH RFC v6 16/21] drm: panel: Add support for Himax HX8369A MIPI DSI panel

2014-12-29 Thread Liu Ying
This patch adds support for Himax HX8369A MIPI DSI panel.

Signed-off-by: Liu Ying 
---
v5->v6:
 * Make the checkpatch.pl script be happier.
 * Do not set the dsi channel number to be zero in probe(), because the MIPI DSI
   bus driver would set it.

v4->v5:
 * Address Andrzej Hajda's comments.
 * Get the bs-gpios property instead of the bs[3:0]-gpios properties.
 * Implement error propagation for panel register configurations.
 * Other minor changes to improve the code quality.

v3->v4:
 * Move the relevant dt-bindings to a separate patch to address Stefan
   Wahren's comment.

v2->v3:
 * Sort the included header files alphabetically.

v1->v2:
 * Address almost all comments from Thierry Reding.
 * Remove several DT properties as they can be implied by the compatible string.
 * Add the HIMAX/himax prefixes to the driver's Kconfig name and driver name.
 * Move the driver's Makefile entry place to sort the entries alphabetically.
 * Reuse several standard DCS functions instead of inventing wheels.
 * Move the panel resetting and power logics to the driver probe/remove stages.
   This may simplify panel prepare/unprepare hooks. The power consumption should
   not change a lot at DPMS since the panel enters sleep mode at that time.
 * Add the module author.
 * Other minor changes, such as coding style issues.

 drivers/gpu/drm/panel/Kconfig   |   5 +
 drivers/gpu/drm/panel/Makefile  |   1 +
 drivers/gpu/drm/panel/panel-himax-hx8369a.c | 614 
 3 files changed, 620 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-himax-hx8369a.c

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index 024e98e..81b0bf0 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -16,6 +16,11 @@ config DRM_PANEL_SIMPLE
  that it can be automatically turned off when the panel goes into a
  low power state.

+config DRM_PANEL_HIMAX_HX8369A
+   tristate "Himax HX8369A panel"
+   depends on OF
+   select DRM_MIPI_DSI
+
 config DRM_PANEL_LD9040
tristate "LD9040 RGB/SPI panel"
depends on OF && SPI
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index 4b2a043..d5dbe06 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o
+obj-$(CONFIG_DRM_PANEL_HIMAX_HX8369A) += panel-himax-hx8369a.o
 obj-$(CONFIG_DRM_PANEL_LD9040) += panel-ld9040.o
 obj-$(CONFIG_DRM_PANEL_S6E8AA0) += panel-s6e8aa0.o
 obj-$(CONFIG_DRM_PANEL_SHARP_LQ101R1SX01) += panel-sharp-lq101r1sx01.o
diff --git a/drivers/gpu/drm/panel/panel-himax-hx8369a.c 
b/drivers/gpu/drm/panel/panel-himax-hx8369a.c
new file mode 100644
index 000..eee36a7
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-himax-hx8369a.c
@@ -0,0 +1,614 @@
+/*
+ * Himax HX8369A panel driver.
+ *
+ * Copyright (C) 2011-2014 Freescale Semiconductor, 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 driver is based on Samsung s6e8aa0 panel driver.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#define WRDISBV0x51
+#define WRCTRLD0x53
+#define WRCABC 0x55
+#define SETPOWER   0xb1
+#define SETDISP0xb2
+#define SETCYC 0xb4
+#define SETVCOM0xb6
+#define SETEXTC0xb9
+#define SETMIPI0xba
+#define SETPANEL   0xcc
+#define SETGIP 0xd5
+#define SETGAMMA   0xe0
+
+#define HX8369A_MIN_BRIGHTNESS 0x00
+#define HX8369A_MAX_BRIGHTNESS 0xff
+
+enum hx8369a_mpu_interface {
+   HX8369A_DBI_TYPE_A_8BIT,
+   HX8369A_DBI_TYPE_A_9BIT,
+   HX8369A_DBI_TYPE_A_16BIT,
+   HX8369A_DBI_TYPE_A_18BIT,
+   HX8369A_DBI_TYPE_B_8BIT,
+   HX8369A_DBI_TYPE_B_9BIT,
+   HX8369A_DBI_TYPE_B_16BIT,
+   HX8369A_DBI_TYPE_B_18BIT,
+   HX8369A_DSI_CMD_MODE,
+   HX8369A_DBI_TYPE_B_24BIT,
+   HX8369A_DSI_VIDEO_MODE,
+   HX8369A_MDDI,
+   HX8369A_DPI_DBI_TYPE_C_OPT1,
+   HX8369A_DPI_DBI_TYPE_C_OPT2,
+   HX8369A_DPI_DBI_TYPE_C_OPT3
+};
+
+enum hx8369a_resolution {
+   HX8369A_RES_480_864,
+   HX8369A_RES_480_854,
+   HX8369A_RES_480_800,
+   HX8369A_RES_480_640,
+   HX8369A_RES_360_640,
+   HX8369A_RES_480_720,
+};
+
+struct hx8369a_panel_desc {
+   const struct drm_display_mode *mode;
+
+   /* ms */
+   unsigned int power_on_delay;
+   unsigned int reset_delay;
+
+   unsigned int dsi_lanes;
+};
+
+struct hx8369a {
+   struct device *dev;
+   struct drm_panel panel;
+
+   const struct hx8369a_panel_desc *pd;
+
+   struct regulator_bulk_data supplies[5];
+   struct gpio_desc *reset_gpio;
+   struct gpio_desc 

[PATCH RFC v6 15/21] Documentation: dt-bindings: Add bindings for Himax HX8369A DRM panel driver

2014-12-29 Thread Liu Ying
This patch adds device tree bindings for Himax HX8369A DRM panel driver.

Signed-off-by: Liu Ying 
---
v5->v6:
 * None.

v4->v5:
 * Merge the bs[3:0]-gpios properties into one property - bs-gpios.
   This addresses Andrzej Hajda's comment.

v3->v4:
 * Newly introduced in v4.  This is separated from the relevant driver patch
   in v3 to address Stefan Wahren's comment.

 .../devicetree/bindings/panel/himax,hx8369a.txt| 39 ++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/panel/himax,hx8369a.txt

diff --git a/Documentation/devicetree/bindings/panel/himax,hx8369a.txt 
b/Documentation/devicetree/bindings/panel/himax,hx8369a.txt
new file mode 100644
index 000..3a44b70
--- /dev/null
+++ b/Documentation/devicetree/bindings/panel/himax,hx8369a.txt
@@ -0,0 +1,39 @@
+Himax HX8369A WVGA 16.7M color TFT single chip driver with internal GRAM
+
+Himax HX8369A is a WVGA resolution driving controller.
+It is designed to provide a single chip solution that combines a source
+driver and power supply circuits to drive a TFT dot matrix LCD with
+480RGBx864 dots at the maximum.
+
+The HX8369A supports several interface modes, including MPU MIPI DBI Type
+A/B mode, MIPI DPI/DBI Type C mode, MIPI DSI video mode, MIPI DSI command
+mode and MDDI mode. The interface mode is selected by the external hardware
+pins BS[3:0].
+
+Currently, only the MIPI DSI video mode is supported.
+
+Required properties:
+  - compatible: should be a panel's compatible string
+  - reg: the virtual channel number of a DSI peripheral, as described in [1]
+  - reset-gpios: a GPIO spec for the reset pin, as described in [2]
+
+Optional properties:
+  - vdd1-supply: I/O and interface power supply
+  - vdd2-supply: analog power supply
+  - vdd3-supply: logic power supply
+  - dsi-vcc-supply: DSI and MDDI power supply
+  - vpp-supply: OTP programming voltage
+  - bs-gpios: a GPIO spec for the pins BS[3:0], as described in [2]
+
+[1] Documentation/devicetree/bindings/mipi/dsi/mipi-dsi-bus.txt
+[2] Documentation/devicetree/bindings/gpio/gpio.txt
+
+Example:
+   panel {
+   compatible = "truly,tft480800-16-e-dsi";
+   reg = <0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_mipi_panel>;
+   reset-gpios = < 11 GPIO_ACTIVE_LOW>;
+   bs-gpios = <0>, <0>, < 14 GPIO_ACTIVE_HIGH>, <0>;
+   };
-- 
2.1.0



[PATCH RFC v6 14/21] drm: imx: Support Synopsys DesignWare MIPI DSI host controller

2014-12-29 Thread Liu Ying
This patch adds support for Synopsys DesignWare MIPI DSI host controller
which is embedded in the i.MX6q/sdl SoCs.

Signed-off-by: Liu Ying 
---
v5->v6:
 * Make the checkpatch.pl script be happier.

v4->v5:
 * None.

v3->v4:
 * Move the relevant dt-bindings to a separate patch to address Stefan
   Wahren's comment.

v2->v3:
 * To address Andy Yan's comments, move the common Synopsys DesignWare MIPI DSI
   host controller logic into it's drm/bridge driver and leave the i.MX specific
   logic only.

v1->v2:
 * Address almost all comments from Thierry Reding and Russell.
 * Update the DT documentation to remove the display-timings node in the panel 
node.
 * Update the DT documentation to state that the nodes which represent the 
possible
   DRM CRTCs the controller may connect with should be placed in the node 
"ports".
 * Remove the flag 'enabled' from the struct imx_mipi_dsi.
 * Move the format_to_bpp() function in v1 to the common DRM MIPI DSI driver.
 * Improve the way we wait for check status for DPHY and command packet 
transfer.
 * Improve the DPMS support for the encoder.
 * Split the functions of ->host_attach() and ->mode_valid() clearly as 
suggested by
   Thierry Reding.
 * Improve the logics in imx_mipi_dsi_dcs_long_write().
 * Enable/disable the pllref_clk and pllref_gate_clk at the component 
binding/unbinding
   stages to help remove the flag 'enabled'.
 * Update the module license to be "GPL".
 * Other minor changes, such as coding style issues and macro naming issues.

 drivers/gpu/drm/imx/Kconfig   |   7 ++
 drivers/gpu/drm/imx/Makefile  |   1 +
 drivers/gpu/drm/imx/dw_mipi_dsi-imx.c | 230 ++
 3 files changed, 238 insertions(+)
 create mode 100644 drivers/gpu/drm/imx/dw_mipi_dsi-imx.c

diff --git a/drivers/gpu/drm/imx/Kconfig b/drivers/gpu/drm/imx/Kconfig
index 82fb758..c576f6b 100644
--- a/drivers/gpu/drm/imx/Kconfig
+++ b/drivers/gpu/drm/imx/Kconfig
@@ -51,3 +51,10 @@ config DRM_IMX_HDMI
depends on DRM_IMX
help
  Choose this if you want to use HDMI on i.MX6.
+
+config DRM_IMX_MIPI_DSI
+   tristate "Freescale i.MX DRM MIPI DSI"
+   select DRM_DW_MIPI_DSI
+   depends on DRM_IMX
+   help
+ Choose this if you want to use MIPI DSI on i.MX6.
diff --git a/drivers/gpu/drm/imx/Makefile b/drivers/gpu/drm/imx/Makefile
index 582c438..f0dc278 100644
--- a/drivers/gpu/drm/imx/Makefile
+++ b/drivers/gpu/drm/imx/Makefile
@@ -10,3 +10,4 @@ obj-$(CONFIG_DRM_IMX_LDB) += imx-ldb.o
 imx-ipuv3-crtc-objs  := ipuv3-crtc.o ipuv3-plane.o
 obj-$(CONFIG_DRM_IMX_IPUV3)+= imx-ipuv3-crtc.o
 obj-$(CONFIG_DRM_IMX_HDMI) += imx-hdmi.o
+obj-$(CONFIG_DRM_IMX_MIPI_DSI) += dw_mipi_dsi-imx.o
diff --git a/drivers/gpu/drm/imx/dw_mipi_dsi-imx.c 
b/drivers/gpu/drm/imx/dw_mipi_dsi-imx.c
new file mode 100644
index 000..b2c96e2
--- /dev/null
+++ b/drivers/gpu/drm/imx/dw_mipi_dsi-imx.c
@@ -0,0 +1,230 @@
+/*
+ * i.MX drm driver - MIPI DSI Host Controller
+ *
+ * Copyright (C) 2011-2014 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "imx-drm.h"
+
+#define DRIVER_NAME"imx-mipi-dsi"
+
+struct imx_mipi_dsi {
+   struct drm_encoder encoder;
+   struct device *dev;
+   struct regmap *regmap;
+};
+
+static inline struct imx_mipi_dsi *enc_to_dsi(struct drm_encoder *enc)
+{
+   return container_of(enc, struct imx_mipi_dsi, encoder);
+}
+
+static void imx_mipi_dsi_set_ipu_di_mux(struct imx_mipi_dsi *dsi, int ipu_di)
+{
+   regmap_update_bits(dsi->regmap, IOMUXC_GPR3,
+  IMX6Q_GPR3_MIPI_MUX_CTL_MASK,
+  ipu_di << IMX6Q_GPR3_MIPI_MUX_CTL_SHIFT);
+}
+
+static struct drm_encoder_funcs imx_mipi_dsi_encoder_funcs = {
+   .destroy = imx_drm_encoder_destroy,
+};
+
+static bool imx_mipi_dsi_encoder_mode_fixup(struct drm_encoder *encoder,
+   const struct drm_display_mode *mode,
+   struct drm_display_mode *adjusted_mode)
+{
+   return true;
+}
+
+static void imx_mipi_dsi_encoder_prepare(struct drm_encoder *encoder)
+{
+   u32 encoder_pix_fmt, interface_pix_fmt;
+
+   encoder_pix_fmt = dw_mipi_dsi_get_encoder_pixel_format(encoder);
+
+   switch (encoder_pix_fmt) {
+   case MIPI_DSI_FMT_RGB888:
+   interface_pix_fmt = V4L2_PIX_FMT_RGB24;
+   break;
+  

[PATCH RFC v6 13/21] Documentation: dt-bindings: Add bindings for i.MX specific Synopsys DW MIPI DSI driver

2014-12-29 Thread Liu Ying
This patch adds device tree bindings for i.MX specific Synopsys DW MIPI DSI 
driver.

Signed-off-by: Liu Ying 
---
v5->v6:
 * Add the #address-cells and #size-cells properties in the example 'ports'
   node.
 * Remove the useless pllref_gate clock from the required clocks, clock-names
   property.

v4->v5:
 * None.

v3->v4:
 * Newly introduced in v4.  This is separated from the relevant driver patch
   in v3 to address Stefan Wahren's comment.

 .../devicetree/bindings/drm/imx/mipi_dsi.txt   | 78 ++
 1 file changed, 78 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/drm/imx/mipi_dsi.txt

diff --git a/Documentation/devicetree/bindings/drm/imx/mipi_dsi.txt 
b/Documentation/devicetree/bindings/drm/imx/mipi_dsi.txt
new file mode 100644
index 000..75a7766
--- /dev/null
+++ b/Documentation/devicetree/bindings/drm/imx/mipi_dsi.txt
@@ -0,0 +1,78 @@
+i.MX specific Device-Tree bindings for Synopsys DesignWare MIPI DSI host 
controller
+
+MIPI DSI host controller
+
+
+The MIPI DSI host controller is a Synopsys DesignWare IP.
+The common device tree documentation for this controller can be found
+at [1].
+
+Required properties:
+ - #address-cells: Should be <1>.
+ - #size-cells: Should be <0>.
+ - compatible: The compatible string should be "fsl,imx6q-mipi-dsi"
+   for i.MX6q/sdl SoCs.
+ - reg: Physical base address of the controller and length of memory
+   mapped region.
+ - interrupts: The controller's interrupt number to the CPU(s).
+ - gpr: Should be <>.
+   The phandle points to the iomuxc-gpr region containing the
+   multiplexer control register for the controller.
+ - clocks, clock-names: Phandles to the controller pllref and core_cfg clocks,
+   as described in [2] and [3].
+
+Required sub-nodes:
+ - ports: This node may contain up to four port nodes with endpoint
+   definitions as defined in [4], corresponding to the four inputs to
+   the controller multiplexer.
+ - A node to represent a DSI peripheral as described in [5].
+
+[1] Documentation/devicetree/bindings/drm/bridge/dw_mipi_dsi.txt.
+[2] Documentation/devicetree/bindings/clock/clock-bindings.txt
+[3] Documentation/devicetree/bindings/clock/imx6q-clock.txt
+[4] Documentation/devicetree/bindings/media/video-interfaces.txt
+[5] Documentation/devicetree/bindings/mipi/dsi/mipi-dsi-bus.txt
+
+example:
+   gpr: iomuxc-gpr at 020e {
+   /* ... */
+   };
+
+   mipi_dsi: mipi at 021e {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   compatible = "fsl,imx6q-mipi-dsi";
+   reg = <0x021e 0x4000>;
+   interrupts = <0 102 IRQ_TYPE_LEVEL_HIGH>;
+   gpr = <>;
+   clocks = < IMX6QDL_CLK_MIPI_CORE_CFG>,
+< IMX6QDL_CLK_MIPI_CORE_CFG>;
+   clock-names = "pllref", "core_cfg";
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port at 0 {
+   reg = <0>;
+
+   mipi_mux_0: endpoint {
+   remote-endpoint = <_di0_mipi>;
+   };
+   };
+
+   port at 1 {
+   reg = <1>;
+
+   mipi_mux_1: endpoint {
+   remote-endpoint = <_di1_mipi>;
+   };
+   };
+   };
+
+   panel {
+   compatible = "truly,tft480800-16-e-dsi";
+   reg = <0>;
+   /* ... */
+   };
+   };
-- 
2.1.0



[PATCH RFC v6 12/21] drm/bridge: Add Synopsys DesignWare MIPI DSI host controller driver

2014-12-29 Thread Liu Ying
This patch adds Synopsys DesignWare MIPI DSI host controller driver support.
Currently, the driver supports the burst with sync pulses mode only.

Signed-off-by: Liu Ying 
---
v5->v6:
 * Make the checkpatch.pl script be happier.

v4->v5:
 * Remove 'dsi->panel = NULL;' in dw_mipi_dsi_host_detach() to address
   Andrzej Hajda's comment.

v3->v4:
 * Move the relevant dt-bindings to a separate patch to address Stefan
   Wahren's comment.

v2->v3:
 * Newly introduced in v3 to address Andy Yan's comment.  This is based on
   the i.MX MIPI DSI driver in v2.  To make the Synopsys DesignWare MIPI DSI
   host controller driver less platform-dependant, this patch places it at
   the drm/bridge directory as a DRM bridge driver.

 drivers/gpu/drm/bridge/Kconfig   |   5 +
 drivers/gpu/drm/bridge/Makefile  |   1 +
 drivers/gpu/drm/bridge/dw_mipi_dsi.c | 996 +++
 include/drm/bridge/dw_mipi_dsi.h |  27 +
 4 files changed, 1029 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/dw_mipi_dsi.c
 create mode 100644 include/drm/bridge/dw_mipi_dsi.h

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index 884923f..8180477 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -1,3 +1,8 @@
+config DRM_DW_MIPI_DSI
+   bool "Synopsys DesignWare MIPI DSI host controller bridge"
+   depends on DRM
+   select DRM_KMS_HELPER
+
 config DRM_PTN3460
tristate "PTN3460 DP/LVDS bridge"
depends on DRM
diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index b4733e1..b326ad5 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -1,3 +1,4 @@
 ccflags-y := -Iinclude/drm

+obj-$(CONFIG_DRM_DW_MIPI_DSI) += dw_mipi_dsi.o
 obj-$(CONFIG_DRM_PTN3460) += ptn3460.o
diff --git a/drivers/gpu/drm/bridge/dw_mipi_dsi.c 
b/drivers/gpu/drm/bridge/dw_mipi_dsi.c
new file mode 100644
index 000..2b54d44
--- /dev/null
+++ b/drivers/gpu/drm/bridge/dw_mipi_dsi.c
@@ -0,0 +1,996 @@
+/*
+ * Synopsys DesignWare(DW) MIPI DSI Host Controller
+ *
+ * Copyright (C) 2011-2014 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DSI_VERSION0x00
+
+#define DSI_PWR_UP 0x04
+#define RESET  0
+#define POWERUPBIT(0)
+
+#define DSI_CLKMGR_CFG 0x08
+#define TO_CLK_DIVIDSION(div)  (((div) & 0xff) << 8)
+#define TX_ESC_CLK_DIVIDSION(div)  (((div) & 0xff) << 0)
+
+#define DSI_DPI_CFG0x0c
+#define EN18_LOOSELY   BIT(10)
+#define COLORM_ACTIVE_LOW  BIT(9)
+#define SHUTD_ACTIVE_LOW   BIT(8)
+#define HSYNC_ACTIVE_LOW   BIT(7)
+#define VSYNC_ACTIVE_LOW   BIT(6)
+#define DATAEN_ACTIVE_LOW  BIT(5)
+#define DPI_COLOR_CODING_16BIT_1   (0x0 << 2)
+#define DPI_COLOR_CODING_16BIT_2   (0x1 << 2)
+#define DPI_COLOR_CODING_16BIT_3   (0x2 << 2)
+#define DPI_COLOR_CODING_18BIT_1   (0x3 << 2)
+#define DPI_COLOR_CODING_18BIT_2   (0x4 << 2)
+#define DPI_COLOR_CODING_24BIT (0x5 << 2)
+#define DPI_VID(vid)   (((vid) & 0x3) << 0)
+
+#define DSI_DBI_CFG0x10
+#define DSI_DBIS_CMDSIZE   0x14
+
+#define DSI_PCKHDL_CFG 0x18
+#define GEN_VID_RX(vid)(((vid) & 0x3) << 5)
+#define EN_CRC_RX  BIT(4)
+#define EN_ECC_RX  BIT(3)
+#define EN_BTA BIT(2)
+#define EN_EOTN_RX BIT(1)
+#define EN_EOTP_TX BIT(0)
+
+#define DSI_VID_MODE_CFG   0x1c
+#define FRAME_BTA_ACK  BIT(11)
+#define EN_NULL_PKTBIT(10)
+#define EN_NULL_PKT_MASK   BIT(10)
+#define EN_MULTI_PKT   BIT(9)
+#define ENABLE_LOW_POWER   (0x3f << 3)
+#define ENABLE_LOW_POWER_MASK  (0x3f << 3)
+#define VID_MODE_TYPE_NONBURST_SYNC_PULSES (0x0 << 1)
+#define VID_MODE_TYPE_NONBURST_SYNC_EVENTS (0x1 << 1)
+#define VID_MODE_TYPE_BURST_SYNC_PULSES(0x3 << 1)
+#define VID_MODE_TYPE_MASK (0x3 << 1)
+#define ENABLE_VIDEO_MODE  BIT(0)
+#define DISABLE_VIDEO_MODE 0
+#define 

[PATCH RFC v6 11/21] Documentation: dt-bindings: Add bindings for Synopsys DW MIPI DSI DRM bridge driver

2014-12-29 Thread Liu Ying
This patch adds device tree bindings for Synopsys DesignWare MIPI DSI
host controller DRM bridge driver.

Signed-off-by: Liu Ying 
---
v5->v6:
 * Add the #address-cells and #size-cells properties in the example 'ports'
   node.
 * Remove the useless input-port properties from the example port at 0 and port 
at 1
   nodes.

v4->v5:
 * None.

v3->v4:
 * Newly introduced in v4.  This is separated from the relevant driver patch
   in v3 to address Stefan Wahren's comment.

 .../devicetree/bindings/drm/bridge/dw_mipi_dsi.txt | 73 ++
 1 file changed, 73 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/drm/bridge/dw_mipi_dsi.txt

diff --git a/Documentation/devicetree/bindings/drm/bridge/dw_mipi_dsi.txt 
b/Documentation/devicetree/bindings/drm/bridge/dw_mipi_dsi.txt
new file mode 100644
index 000..f88a8d6
--- /dev/null
+++ b/Documentation/devicetree/bindings/drm/bridge/dw_mipi_dsi.txt
@@ -0,0 +1,73 @@
+Device-Tree bindings for Synopsys DesignWare MIPI DSI host controller
+
+The controller is a digital core that implements all protocol functions
+defined in the MIPI DSI specification, providing an interface between
+the system and the MIPI DPHY, and allowing communication with a MIPI DSI
+compliant display.
+
+Required properties:
+ - #address-cells: Should be <1>.
+ - #size-cells: Should be <0>.
+ - compatible: The compatible string should be "fsl,imx6q-mipi-dsi" for
+   i.MX6q/sdl SoCs.  For other SoCs, please refer to their specific
+   device tree binding documentations.
+ - reg: Represent the physical address range of the controller.
+ - interrupts: Represent the controller's interrupt to the CPU(s).
+ - clocks, clock-names: Phandles to the controller pll reference and
+   core configuration clocks, as described in [1].
+
+For more required properties, please refer to relevant device tree binding
+documentations which describe the controller embedded in specific SoCs.
+
+Required sub-nodes:
+ - A node to represent a DSI peripheral as described in [2].
+
+For more required sub-nodes, please refer to relevant device tree binding
+documentations which describe the controller embedded in specific SoCs.
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+[2] Documentation/devicetree/bindings/mipi/dsi/mipi-dsi-bus.txt
+
+example:
+   gpr: iomuxc-gpr at 020e {
+   /* ... */
+   };
+
+   mipi_dsi: mipi at 021e {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   compatible = "fsl,imx6q-mipi-dsi";
+   reg = <0x021e 0x4000>;
+   interrupts = <0 102 IRQ_TYPE_LEVEL_HIGH>;
+   gpr = <>;
+   clocks = < IMX6QDL_CLK_MIPI_CORE_CFG>,
+< IMX6QDL_CLK_MIPI_CORE_CFG>;
+   clock-names = "pllref", "core_cfg";
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port at 0 {
+   reg = <0>;
+
+   mipi_mux_0: endpoint {
+   remote-endpoint = <_di0_mipi>;
+   };
+   };
+
+   port at 1 {
+   reg = <1>;
+
+   mipi_mux_1: endpoint {
+   remote-endpoint = <_di1_mipi>;
+   };
+   };
+   };
+
+   panel {
+   compatible = "truly,tft480800-16-e-dsi";
+   reg = <0>;
+   /* ... */
+   };
+   };
-- 
2.1.0



[PATCH RFC v6 10/21] drm/dsi: Add a helper to get bits per pixel of MIPI DSI pixel format

2014-12-29 Thread Liu Ying
Signed-off-by: Liu Ying 
---
v5->v6:
 * Address the over 80 characters in one line warning reported by the
   checkpatch.pl script.

v4->v5:
 * None.

v3->v4:
 * None.

v2->v3:
 * None.

v1->v2:
 * Thierry Reding suggested that the mipi_dsi_pixel_format_to_bpp() function
   could be placed at the common DRM MIPI DSI driver.
   This patch is newly added.

 include/drm/drm_mipi_dsi.h | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
index f1d8d0d..3662021 100644
--- a/include/drm/drm_mipi_dsi.h
+++ b/include/drm/drm_mipi_dsi.h
@@ -163,6 +163,20 @@ static inline struct mipi_dsi_device 
*to_mipi_dsi_device(struct device *dev)
return container_of(dev, struct mipi_dsi_device, dev);
 }

+static inline int mipi_dsi_pixel_format_to_bpp(enum mipi_dsi_pixel_format fmt)
+{
+   switch (fmt) {
+   case MIPI_DSI_FMT_RGB888:
+   case MIPI_DSI_FMT_RGB666:
+   return 24;
+   case MIPI_DSI_FMT_RGB666_PACKED:
+   return 18;
+   case MIPI_DSI_FMT_RGB565:
+   return 16;
+   }
+   return -EINVAL;
+}
+
 struct mipi_dsi_device *of_find_mipi_dsi_device_by_node(struct device_node 
*np);
 int mipi_dsi_attach(struct mipi_dsi_device *dsi);
 int mipi_dsi_detach(struct mipi_dsi_device *dsi);
-- 
2.1.0



[PATCH RFC v6 09/21] ARM: dts: imx6qdl: Move existing MIPI DSI ports into a new 'ports' node

2014-12-29 Thread Liu Ying
The MIPI DSI node contains some ports which represent possible DRM CRTCs
it can connect with.  Each port has a 'reg' property embedded.  This
property will be wrongly interpretted by the MIPI DSI bus driver, because
the driver will take each subnode which contains a 'reg' property as a
DSI peripheral device.  This patch moves the existing MIPI DSI ports into
a new 'ports' node so that the MIPI DSI bus driver may distinguish its
DSI peripheral device(s) from the existing ports.

Acked-by: Philipp Zabel 
Signed-off-by: Liu Ying 
---
v5->v6:
 * None.

v4->v5:
 * None.

v3->v4:
 * None.

v2->v3:
 * Add Philipp's Ack.

v1->v2:
 * Newly added, as suggested by Thierry Reding.

 arch/arm/boot/dts/imx6q.dtsi   | 20 +++-
 arch/arm/boot/dts/imx6qdl.dtsi | 23 ++-
 2 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index e9f3646..9c0990b 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -292,19 +292,21 @@
 };

 _dsi {
-   port at 2 {
-   reg = <2>;
+   ports {
+   port at 2 {
+   reg = <2>;

-   mipi_mux_2: endpoint {
-   remote-endpoint = <_di0_mipi>;
+   mipi_mux_2: endpoint {
+   remote-endpoint = <_di0_mipi>;
+   };
};
-   };

-   port at 3 {
-   reg = <3>;
+   port at 3 {
+   reg = <3>;

-   mipi_mux_3: endpoint {
-   remote-endpoint = <_di1_mipi>;
+   mipi_mux_3: endpoint {
+   remote-endpoint = <_di1_mipi>;
+   };
};
};
 };
diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi
index 9596ed5..96bf2a0 100644
--- a/arch/arm/boot/dts/imx6qdl.dtsi
+++ b/arch/arm/boot/dts/imx6qdl.dtsi
@@ -1009,19 +1009,24 @@
reg = <0x021e 0x4000>;
status = "disabled";

-   port at 0 {
-   reg = <0>;
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port at 0 {
+   reg = <0>;

-   mipi_mux_0: endpoint {
-   remote-endpoint = 
<_di0_mipi>;
+   mipi_mux_0: endpoint {
+   remote-endpoint = 
<_di0_mipi>;
+   };
};
-   };

-   port at 1 {
-   reg = <1>;
+   port at 1 {
+   reg = <1>;

-   mipi_mux_1: endpoint {
-   remote-endpoint = 
<_di1_mipi>;
+   mipi_mux_1: endpoint {
+   remote-endpoint = 
<_di1_mipi>;
+   };
};
};
};
-- 
2.1.0



[PATCH RFC v6 08/21] ARM: imx6q: clk: Add support for mipi_core_cfg clock as a shared clock gate

2014-12-29 Thread Liu Ying
The CG8 field of the CCM CCGR3 register is named as 'mipi_core_cfg' clock,
according to the i.MX6q/sdl reference manuals.  This clock is actually the
gate for several clocks, including the hsi_tx_sel clock's output and the
video_27m clock's output.  The MIPI DSI host controller embedded in the
i.MX6q/sdl SoCs uses the video_27m clock to generate PLL reference clock and
MIPI core configuration clock.  In order to gate/ungate the two MIPI DSI
host controller relevant clocks, this patch adds the mipi_core_cfg clock as
a shared clock gate.

Suggested-by: Philipp Zabel 
Signed-off-by: Liu Ying 
---
v5->v6:
 * Add two spaces in the clock driver to eliminate two errors reported by
   the checkpatch.pl script.

v4->v5:
 * None.

v3->v4:
 * None.

v2->v3:
 * Newly introduced in v3.

 arch/arm/mach-imx/clk-imx6q.c | 1 +
 include/dt-bindings/clock/imx6qdl-clock.h | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index 080d5b7..0f4d07c 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -418,6 +418,7 @@ static void __init imx6q_clocks_init(struct device_node 
*ccm_node)
clk[IMX6QDL_CLK_LDB_DI1]  = imx_clk_gate2("ldb_di1",   
"ldb_di1_podf",  base + 0x74, 14);
clk[IMX6QDL_CLK_IPU2_DI1] = imx_clk_gate2("ipu2_di1",  
"ipu2_di1_sel",  base + 0x74, 10);
clk[IMX6QDL_CLK_HSI_TX]   = imx_clk_gate2_shared("hsi_tx", 
"hsi_tx_podf",   base + 0x74, 16, _count_mipi_core_cfg);
+   clk[IMX6QDL_CLK_MIPI_CORE_CFG] = imx_clk_gate2_shared("mipi_core_cfg", 
"video_27m", base + 0x74, 16, _count_mipi_core_cfg);
if (cpu_is_imx6dl())
/*
 * The multiplexer and divider of the imx6q clock gpu2d get
diff --git a/include/dt-bindings/clock/imx6qdl-clock.h 
b/include/dt-bindings/clock/imx6qdl-clock.h
index 25625bf..dbc828c 100644
--- a/include/dt-bindings/clock/imx6qdl-clock.h
+++ b/include/dt-bindings/clock/imx6qdl-clock.h
@@ -249,6 +249,7 @@
 #define IMX6QDL_PLL7_BYPASS236
 #define IMX6QDL_CLK_GPT_3M 237
 #define IMX6QDL_CLK_VIDEO_27M  238
-#define IMX6QDL_CLK_END239
+#define IMX6QDL_CLK_MIPI_CORE_CFG  239
+#define IMX6QDL_CLK_END240

 #endif /* __DT_BINDINGS_CLOCK_IMX6QDL_H */
-- 
2.1.0



[PATCH RFC v6 07/21] ARM: imx6q: clk: Change hsi_tx clock to be a shared clock gate

2014-12-29 Thread Liu Ying
The CG8 field of the CCM CCGR3 register is named as 'mipi_core_cfg'
clock, according to the i.MX6q/sdl reference manuals.  This clock is
actually the gate for several clocks, including the hsi_tx_sel clock's
output and the video_27m clock's output.  So, this patch changes the
hsi_tx clock to be a shared clock gate.

Suggested-by: Philipp Zabel 
Signed-off-by: Liu Ying 
---
v5->v6:
 * None.

v4->v5:
 * None.

v3->v4:
 * None.

v2->v3:
 * Newly introduced in v3.

 arch/arm/mach-imx/clk-imx6q.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index f19472a..080d5b7 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -119,6 +119,7 @@ static unsigned int share_count_asrc;
 static unsigned int share_count_ssi1;
 static unsigned int share_count_ssi2;
 static unsigned int share_count_ssi3;
+static unsigned int share_count_mipi_core_cfg;

 static void __init imx6q_clocks_init(struct device_node *ccm_node)
 {
@@ -416,7 +417,7 @@ static void __init imx6q_clocks_init(struct device_node 
*ccm_node)
clk[IMX6QDL_CLK_LDB_DI0]  = imx_clk_gate2("ldb_di0",   
"ldb_di0_podf",  base + 0x74, 12);
clk[IMX6QDL_CLK_LDB_DI1]  = imx_clk_gate2("ldb_di1",   
"ldb_di1_podf",  base + 0x74, 14);
clk[IMX6QDL_CLK_IPU2_DI1] = imx_clk_gate2("ipu2_di1",  
"ipu2_di1_sel",  base + 0x74, 10);
-   clk[IMX6QDL_CLK_HSI_TX]   = imx_clk_gate2("hsi_tx",
"hsi_tx_podf",   base + 0x74, 16);
+   clk[IMX6QDL_CLK_HSI_TX]   = imx_clk_gate2_shared("hsi_tx", 
"hsi_tx_podf",   base + 0x74, 16, _count_mipi_core_cfg);
if (cpu_is_imx6dl())
/*
 * The multiplexer and divider of the imx6q clock gpu2d get
-- 
2.1.0



[PATCH RFC v6 06/21] ARM: imx6q: clk: Change hdmi_isfr clock's parent to be video_27m clock

2014-12-29 Thread Liu Ying
According to the table 33-1 in the i.MX6Q reference manual, the hdmi_isfr
clock's parent should be the video_27m clock.  The i.MX6DL reference manual
has the same statement.  This patch changes the hdmi_isfr clock's parent
from the pll3_pfd1_540m clock to the video_27m clock.

Suggested-by: Philipp Zabel 
Signed-off-by: Liu Ying 
---
v5->v6:
 * None.

v4->v5:
 * None.

v3->v4:
 * None.

v2->v3:
 * Newly introduced in v3.

 arch/arm/mach-imx/clk-imx6q.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index 9470df3..f19472a 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -401,7 +401,7 @@ static void __init imx6q_clocks_init(struct device_node 
*ccm_node)
clk[IMX6QDL_CLK_GPU2D_CORE] = imx_clk_gate2("gpu2d_core", 
"gpu2d_core_podf", base + 0x6c, 24);
clk[IMX6QDL_CLK_GPU3D_CORE]   = imx_clk_gate2("gpu3d_core",
"gpu3d_core_podf",   base + 0x6c, 26);
clk[IMX6QDL_CLK_HDMI_IAHB]= imx_clk_gate2("hdmi_iahb", "ahb",   
base + 0x70, 0);
-   clk[IMX6QDL_CLK_HDMI_ISFR]= imx_clk_gate2("hdmi_isfr", 
"pll3_pfd1_540m",base + 0x70, 4);
+   clk[IMX6QDL_CLK_HDMI_ISFR]= imx_clk_gate2("hdmi_isfr", 
"video_27m", base + 0x70, 4);
clk[IMX6QDL_CLK_I2C1] = imx_clk_gate2("i2c1",  
"ipg_per",   base + 0x70, 6);
clk[IMX6QDL_CLK_I2C2] = imx_clk_gate2("i2c2",  
"ipg_per",   base + 0x70, 8);
clk[IMX6QDL_CLK_I2C3] = imx_clk_gate2("i2c3",  
"ipg_per",   base + 0x70, 10);
-- 
2.1.0



[PATCH RFC v6 05/21] ARM: imx6q: clk: Add the video_27m clock

2014-12-29 Thread Liu Ying
This patch supports the video_27m clock which is a fixed factor
clock of the pll3_pfd1_540m clock.

Signed-off-by: Liu Ying 
---
v5->v6:
 * None.

v4->v5:
 * None.

v3->v4:
 * None.

v2->v3:
 * None.

v1->v2:
 * None.

 arch/arm/mach-imx/clk-imx6q.c | 1 +
 include/dt-bindings/clock/imx6qdl-clock.h | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index 4e79da7..9470df3 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -246,6 +246,7 @@ static void __init imx6q_clocks_init(struct device_node 
*ccm_node)
clk[IMX6QDL_CLK_PLL3_60M]  = imx_clk_fixed_factor("pll3_60m",  
"pll3_usb_otg",   1, 8);
clk[IMX6QDL_CLK_TWD]   = imx_clk_fixed_factor("twd",   "arm",   
 1, 2);
clk[IMX6QDL_CLK_GPT_3M]= imx_clk_fixed_factor("gpt_3m","osc",   
 1, 8);
+   clk[IMX6QDL_CLK_VIDEO_27M] = imx_clk_fixed_factor("video_27m", 
"pll3_pfd1_540m", 1, 20);
if (cpu_is_imx6dl()) {
clk[IMX6QDL_CLK_GPU2D_AXI] = imx_clk_fixed_factor("gpu2d_axi", 
"mmdc_ch0_axi_podf", 1, 1);
clk[IMX6QDL_CLK_GPU3D_AXI] = imx_clk_fixed_factor("gpu3d_axi", 
"mmdc_ch0_axi_podf", 1, 1);
diff --git a/include/dt-bindings/clock/imx6qdl-clock.h 
b/include/dt-bindings/clock/imx6qdl-clock.h
index b690cdb..25625bf 100644
--- a/include/dt-bindings/clock/imx6qdl-clock.h
+++ b/include/dt-bindings/clock/imx6qdl-clock.h
@@ -248,6 +248,7 @@
 #define IMX6QDL_PLL6_BYPASS235
 #define IMX6QDL_PLL7_BYPASS236
 #define IMX6QDL_CLK_GPT_3M 237
-#define IMX6QDL_CLK_END238
+#define IMX6QDL_CLK_VIDEO_27M  238
+#define IMX6QDL_CLK_END239

 #endif /* __DT_BINDINGS_CLOCK_IMX6QDL_H */
-- 
2.1.0



[PATCH RFC v6 04/21] ARM: imx6q: Add GPR3 MIPI muxing control register field shift bits definition

2014-12-29 Thread Liu Ying
This patch adds a macro to define the GPR3 MIPI muxing control register field
shift bits.

Signed-off-by: Liu Ying 
---
v5->v6:
 * None.

v4->v5:
 * None.

v3->v4:
 * None.

v2->v3:
 * None.

v1->v2:
 * None.

 include/linux/mfd/syscon/imx6q-iomuxc-gpr.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h 
b/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h
index ff44374..3b0bed4 100644
--- a/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h
+++ b/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h
@@ -207,6 +207,7 @@
 #define IMX6Q_GPR3_LVDS0_MUX_CTL_IPU1_DI1  (0x1 << 6)
 #define IMX6Q_GPR3_LVDS0_MUX_CTL_IPU2_DI0  (0x2 << 6)
 #define IMX6Q_GPR3_LVDS0_MUX_CTL_IPU2_DI1  (0x3 << 6)
+#define IMX6Q_GPR3_MIPI_MUX_CTL_SHIFT  4
 #define IMX6Q_GPR3_MIPI_MUX_CTL_MASK   (0x3 << 4)
 #define IMX6Q_GPR3_MIPI_MUX_CTL_IPU1_DI0   (0x0 << 4)
 #define IMX6Q_GPR3_MIPI_MUX_CTL_IPU1_DI1   (0x1 << 4)
-- 
2.1.0



[PATCH RFC v6 03/21] of: Add vendor prefix for Truly Semiconductors Limited

2014-12-29 Thread Liu Ying
Signed-off-by: Liu Ying 
---
v5->v6:
 * None.

v4->v5:
 * None.

v3->v4:
 * None.

v2->v3:
 * None.

v1->v2:
 * None.

 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index f46adb2..0e67bad 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -158,6 +158,7 @@ tlm Trusted Logic Mobility
 toradexToradex AG
 toshibaToshiba Corporation
 toumaz Toumaz
+truly  Truly Semiconductors Limited
 usiUniversal Scientific Industrial Co., Ltd.
 v3 V3 Semiconductor
 variscite  Variscite Ltd.
-- 
2.1.0



[PATCH RFC v6 02/21] of: Add vendor prefix for Himax Technologies Inc.

2014-12-29 Thread Liu Ying
Signed-off-by: Liu Ying 
---
v5->v6:
 * None.

v4->v5:
 * None.

v3->v4:
 * Fix an ordering issue to address Stefan Wahren's comment.

v2->v3:
 * None.

v1->v2:
 * None.

 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 78efebb..f46adb2 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -67,6 +67,7 @@ gumstix   Gumstix, Inc.
 gw Gateworks Corporation
 hannstar   HannStar Display Corporation
 haoyu  Haoyu Microelectronic Co. Ltd.
+himax  Himax Technologies, Inc.
 hisilicon  Hisilicon Limited.
 hitHitachi Ltd.
 honeywell  Honeywell
-- 
2.1.0



[PATCH RFC v6 01/21] clk: divider: Correct parent clk round rate if no bestdiv is normally found

2014-12-29 Thread Liu Ying
If no best divider is normally found, we will try to use the maximum divider.
We should not set the parent clock rate to be 1Hz by force for being rounded.
Instead, we should take the maximum divider as a base and calculate a correct
parent clock rate for being rounded.

Signed-off-by: Liu Ying 
---
v5->v6:
 * None.

v4->v5:
 * None.

v3->v4:
 * None.

v2->v3:
 * None.

v1->v2:
 * None.

 drivers/clk/clk-divider.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index c0a842b..f641d4b 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -311,7 +311,8 @@ static int clk_divider_bestdiv(struct clk_hw *hw, unsigned 
long rate,

if (!bestdiv) {
bestdiv = _get_maxdiv(divider);
-   *best_parent_rate = __clk_round_rate(__clk_get_parent(hw->clk), 
1);
+   *best_parent_rate = __clk_round_rate(__clk_get_parent(hw->clk),
+   MULT_ROUND_UP(rate, bestdiv));
}

return bestdiv;
-- 
2.1.0



[PATCH RFC v6 00/21] Add support for i.MX MIPI DSI DRM driver

2014-12-29 Thread Liu Ying
Hi,

This version does some minor changes to improve the code quality.
The checkpatch.pl script is happier now on this version.
For detail change log, please find them in each standalone patch.

The i.MX MIPI DSI is a Synopsys DesignWare MIPI DSI host controller IP.
This series adds support for a Synopsys DesignWare MIPI DSI host controller
DRM bridge driver and a i.MX MIPI DSI specific DRM driver.
Currently, the MIPI DSI drivers only support the burst with sync pulse mode.

This series also includes a DRM panel driver for the Truly TFT480800-16-E panel
which is driven by the Himax HX8369A driver IC.  The driver IC data sheet could
be found at [1].  As mentioned by the data sheet, the driver IC supports several
interface modes.  Currently, the DRM panel driver only supports the MIPI DSI 
video
mode.  New interface modes could be added later(perhaps, just like the way the 
DRM
simple panel driver supports both MIPI DSI interface panels and simple(parallel)
interface panels).

The MIPI DSI feature is tested on i.MX6Q SabreSD board and i.MX6DL SabreSD 
board.
The MIPI DSI display could be enabled directly on i.MX6Q SabreSD board after
applying this series, because the 26.4MHz pixel clock the panel requires could 
be
derived from the IPU HSP clock(264MHz) with an integer divider.
On i.MX6DL SabreSD board, we need to manually disable the LVDS and HDMI 
displays in
the device tree blob, since the i.MX6DL IPU HSP clock is 198MHz at present, 
which
makes the pixel clock share the PLL5 video clock source with the LVDS and HDMI,
thus, the panel cannot get the pixel clock rate it wants.

Patch 01/21 is needed to get a precise pixel clock rate(26.4MHz) from the PLL5 
video
clock.  If we don't have this patch, the pixel clock rate is about 20MHz, which
causes a horitonal shift on the display image.

This series can be applied on the drm-next branch.

[1] http://www.allshore.com/pdf/Himax_HX8369-A.pdf

Liu Ying (21):
  clk: divider: Correct parent clk round rate if no bestdiv is normally
found
  of: Add vendor prefix for Himax Technologies Inc.
  of: Add vendor prefix for Truly Semiconductors Limited
  ARM: imx6q: Add GPR3 MIPI muxing control register field shift bits
definition
  ARM: imx6q: clk: Add the video_27m clock
  ARM: imx6q: clk: Change hdmi_isfr clock's parent to be video_27m clock
  ARM: imx6q: clk: Change hsi_tx clock to be a shared clock gate
  ARM: imx6q: clk: Add support for mipi_core_cfg clock as a shared clock
gate
  ARM: dts: imx6qdl: Move existing MIPI DSI ports into a new 'ports'
node
  drm/dsi: Add a helper to get bits per pixel of MIPI DSI pixel format
  Documentation: dt-bindings: Add bindings for Synopsys DW MIPI DSI DRM
bridge driver
  drm/bridge: Add Synopsys DesignWare MIPI DSI host controller driver
  Documentation: dt-bindings: Add bindings for i.MX specific Synopsys DW
MIPI DSI driver
  drm: imx: Support Synopsys DesignWare MIPI DSI host controller
  Documentation: dt-bindings: Add bindings for Himax HX8369A DRM panel
driver
  drm: panel: Add support for Himax HX8369A MIPI DSI panel
  ARM: dtsi: imx6qdl: Add support for MIPI DSI host controller
  ARM: dts: imx6qdl-sabresd: Add support for TRULY TFT480800-16-E MIPI
DSI panel
  ARM: imx_v6_v7_defconfig: Cleanup for imx drm being moved out of
staging
  ARM: imx_v6_v7_defconfig: Add support for MIPI DSI host controller
  ARM: imx_v6_v7_defconfig: Add support for Himax HX8369A panel

 .../devicetree/bindings/drm/bridge/dw_mipi_dsi.txt |  73 ++
 .../devicetree/bindings/drm/imx/mipi_dsi.txt   |  78 ++
 .../devicetree/bindings/panel/himax,hx8369a.txt|  39 +
 .../devicetree/bindings/vendor-prefixes.txt|   2 +
 arch/arm/boot/dts/imx6q.dtsi   |  20 +-
 arch/arm/boot/dts/imx6qdl-sabresd.dtsi |  20 +
 arch/arm/boot/dts/imx6qdl.dtsi |  29 +-
 arch/arm/configs/imx_v6_v7_defconfig   |  17 +-
 arch/arm/mach-imx/clk-imx6q.c  |   7 +-
 drivers/clk/clk-divider.c  |   3 +-
 drivers/gpu/drm/bridge/Kconfig |   5 +
 drivers/gpu/drm/bridge/Makefile|   1 +
 drivers/gpu/drm/bridge/dw_mipi_dsi.c   | 996 +
 drivers/gpu/drm/imx/Kconfig|   7 +
 drivers/gpu/drm/imx/Makefile   |   1 +
 drivers/gpu/drm/imx/dw_mipi_dsi-imx.c  | 230 +
 drivers/gpu/drm/panel/Kconfig  |   5 +
 drivers/gpu/drm/panel/Makefile |   1 +
 drivers/gpu/drm/panel/panel-himax-hx8369a.c| 614 +
 include/drm/bridge/dw_mipi_dsi.h   |  27 +
 include/drm/drm_mipi_dsi.h |  14 +
 include/dt-bindings/clock/imx6qdl-clock.h  |   4 +-
 include/linux/mfd/syscon/imx6q-iomuxc-gpr.h|   1 +
 23 files changed, 2164 insertions(+), 30 deletions(-)
 create mode 100644 

[PATCH 2/3] drm/amdkfd: reformat IOCTL definitions to drm-style

2014-12-29 Thread Christian König
Am 29.12.2014 um 14:17 schrieb Oded Gabbay:
>
>
> On 12/29/2014 03:06 PM, Christian König wrote:
>> Am 29.12.2014 um 13:42 schrieb Oded Gabbay:
>>> This patch reformats the ioctl definitions in kfd_ioctl.h to be 
>>> similar to the
>>> drm ioctls definition style.
>>>
>>> Signed-off-by: Oded Gabbay 
>>
>> You are aware that this is a kernel API breakage?
> Yes, but as long as 3.19 isn't released yet, I'm allowed to do this, no ?

Strictly speaking only if you fix a bug with it, but since we are still 
pretty early in the cycle it's ok with we (especially since it looks 
like a valid cleanup). I'm just not sure what Dave/Linus think of this.

Christian.

> and I want this patch-set to be inserted to 3.19 so there won't be API 
> breakage afterwards.
>
>>
>>> ---
>>>   drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 15 +++--
>>>   include/uapi/linux/kfd_ioctl.h   | 37 
>>> +++-
>>>   2 files changed, 30 insertions(+), 22 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>>> b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>>> index 5460ad2..390385f 100644
>>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>>> @@ -524,35 +524,36 @@ static long kfd_ioctl(struct file *filep, 
>>> unsigned int
>>> cmd, unsigned long arg)
>>>   switch (cmd) {
>>> -case KFD_IOC_GET_VERSION:
>>> +case AMDKFD_IOC_GET_VERSION:
>>>   retcode = kfd_ioctl_get_version(filep, process, kdata);
>>>   break;
>>> -case KFD_IOC_CREATE_QUEUE:
>>> +
>>> +case AMDKFD_IOC_CREATE_QUEUE:
>>>   retcode = kfd_ioctl_create_queue(filep, process,
>>>   kdata);
>>>   break;
>>> -case KFD_IOC_DESTROY_QUEUE:
>>> +case AMDKFD_IOC_DESTROY_QUEUE:
>>>   retcode = kfd_ioctl_destroy_queue(filep, process,
>>>   kdata);
>>>   break;
>>> -case KFD_IOC_SET_MEMORY_POLICY:
>>> +case AMDKFD_IOC_SET_MEMORY_POLICY:
>>>   retcode = kfd_ioctl_set_memory_policy(filep, process,
>>>   kdata);
>>>   break;
>>> -case KFD_IOC_GET_CLOCK_COUNTERS:
>>> +case AMDKFD_IOC_GET_CLOCK_COUNTERS:
>>>   retcode = kfd_ioctl_get_clock_counters(filep, process,
>>>   kdata);
>>>   break;
>>> -case KFD_IOC_GET_PROCESS_APERTURES:
>>> +case AMDKFD_IOC_GET_PROCESS_APERTURES:
>>>   retcode = kfd_ioctl_get_process_apertures(filep, process,
>>>   kdata);
>>>   break;
>>> -case KFD_IOC_UPDATE_QUEUE:
>>> +case AMDKFD_IOC_UPDATE_QUEUE:
>>>   retcode = kfd_ioctl_update_queue(filep, process,
>>>   kdata);
>>>   break;
>>> diff --git a/include/uapi/linux/kfd_ioctl.h 
>>> b/include/uapi/linux/kfd_ioctl.h
>>> index 7acef41..05b53f6 100644
>>> --- a/include/uapi/linux/kfd_ioctl.h
>>> +++ b/include/uapi/linux/kfd_ioctl.h
>>> @@ -128,27 +128,34 @@ struct kfd_ioctl_get_process_apertures_args {
>>>   uint32_t pad;
>>>   };
>>> -#define KFD_IOC_MAGIC 'K'
>>> +#define AMDKFD_IOCTL_BASE 'K'
>>> +#define AMDKFD_IO(nr)_IO(AMDKFD_IOCTL_BASE, nr)
>>> +#define AMDKFD_IOR(nr, type)_IOR(AMDKFD_IOCTL_BASE, nr, type)
>>> +#define AMDKFD_IOW(nr, type)_IOW(AMDKFD_IOCTL_BASE, nr, type)
>>> +#define AMDKFD_IOWR(nr, type)_IOWR(AMDKFD_IOCTL_BASE, nr, 
>>> type)
>>> -#define KFD_IOC_GET_VERSION \
>>> -_IOR(KFD_IOC_MAGIC, 1, struct kfd_ioctl_get_version_args)
>>> +#define AMDKFD_IOC_GET_VERSION\
>>> +AMDKFD_IOR(0x01, struct kfd_ioctl_get_version_args)
>>> -#define KFD_IOC_CREATE_QUEUE \
>>> -_IOWR(KFD_IOC_MAGIC, 2, struct kfd_ioctl_create_queue_args)
>>> +#define AMDKFD_IOC_CREATE_QUEUE\
>>> +AMDKFD_IOWR(0x02, struct kfd_ioctl_create_queue_args)
>>> -#define KFD_IOC_DESTROY_QUEUE \
>>> -_IOWR(KFD_IOC_MAGIC, 3, struct kfd_ioctl_destroy_queue_args)
>>> +#define AMDKFD_IOC_DESTROY_QUEUE\
>>> +AMDKFD_IOWR(0x03, struct kfd_ioctl_destroy_queue_args)
>>> -#define KFD_IOC_SET_MEMORY_POLICY \
>>> -_IOW(KFD_IOC_MAGIC, 4, struct kfd_ioctl_set_memory_policy_args)
>>> +#define AMDKFD_IOC_SET_MEMORY_POLICY\
>>> +AMDKFD_IOW(0x04, struct kfd_ioctl_set_memory_policy_args)
>>> -#define KFD_IOC_GET_CLOCK_COUNTERS \
>>> -_IOWR(KFD_IOC_MAGIC, 5, struct kfd_ioctl_get_clock_counters_args)
>>> +#define AMDKFD_IOC_GET_CLOCK_COUNTERS\
>>> +AMDKFD_IOWR(0x05, struct kfd_ioctl_get_clock_counters_args)
>>> -#define KFD_IOC_GET_PROCESS_APERTURES \
>>> -_IOR(KFD_IOC_MAGIC, 6, struct 
>>> kfd_ioctl_get_process_apertures_args)
>>> +#define AMDKFD_IOC_GET_PROCESS_APERTURES\
>>> +AMDKFD_IOR(0x06, struct kfd_ioctl_get_process_apertures_args)
>>> -#define KFD_IOC_UPDATE_QUEUE \
>>> -_IOW(KFD_IOC_MAGIC, 7, struct kfd_ioctl_update_queue_args)
>>> +#define AMDKFD_IOC_UPDATE_QUEUE 

[PATCH 2/3] drm/amdkfd: reformat IOCTL definitions to drm-style

2014-12-29 Thread Christian König
Am 29.12.2014 um 13:42 schrieb Oded Gabbay:
> This patch reformats the ioctl definitions in kfd_ioctl.h to be similar to the
> drm ioctls definition style.
>
> Signed-off-by: Oded Gabbay 

You are aware that this is a kernel API breakage?

> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 15 +++--
>   include/uapi/linux/kfd_ioctl.h   | 37 
> +++-
>   2 files changed, 30 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c 
> b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> index 5460ad2..390385f 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> @@ -524,35 +524,36 @@ static long kfd_ioctl(struct file *filep, unsigned int 
> cmd, unsigned long arg)
>   
>   
>   switch (cmd) {
> - case KFD_IOC_GET_VERSION:
> + case AMDKFD_IOC_GET_VERSION:
>   retcode = kfd_ioctl_get_version(filep, process, kdata);
>   break;
> - case KFD_IOC_CREATE_QUEUE:
> +
> + case AMDKFD_IOC_CREATE_QUEUE:
>   retcode = kfd_ioctl_create_queue(filep, process,
>   kdata);
>   break;
>   
> - case KFD_IOC_DESTROY_QUEUE:
> + case AMDKFD_IOC_DESTROY_QUEUE:
>   retcode = kfd_ioctl_destroy_queue(filep, process,
>   kdata);
>   break;
>   
> - case KFD_IOC_SET_MEMORY_POLICY:
> + case AMDKFD_IOC_SET_MEMORY_POLICY:
>   retcode = kfd_ioctl_set_memory_policy(filep, process,
>   kdata);
>   break;
>   
> - case KFD_IOC_GET_CLOCK_COUNTERS:
> + case AMDKFD_IOC_GET_CLOCK_COUNTERS:
>   retcode = kfd_ioctl_get_clock_counters(filep, process,
>   kdata);
>   break;
>   
> - case KFD_IOC_GET_PROCESS_APERTURES:
> + case AMDKFD_IOC_GET_PROCESS_APERTURES:
>   retcode = kfd_ioctl_get_process_apertures(filep, process,
>   kdata);
>   break;
>   
> - case KFD_IOC_UPDATE_QUEUE:
> + case AMDKFD_IOC_UPDATE_QUEUE:
>   retcode = kfd_ioctl_update_queue(filep, process,
>   kdata);
>   break;
> diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h
> index 7acef41..05b53f6 100644
> --- a/include/uapi/linux/kfd_ioctl.h
> +++ b/include/uapi/linux/kfd_ioctl.h
> @@ -128,27 +128,34 @@ struct kfd_ioctl_get_process_apertures_args {
>   uint32_t pad;
>   };
>   
> -#define KFD_IOC_MAGIC 'K'
> +#define AMDKFD_IOCTL_BASE 'K'
> +#define AMDKFD_IO(nr)_IO(AMDKFD_IOCTL_BASE, nr)
> +#define AMDKFD_IOR(nr, type) _IOR(AMDKFD_IOCTL_BASE, nr, type)
> +#define AMDKFD_IOW(nr, type) _IOW(AMDKFD_IOCTL_BASE, nr, type)
> +#define AMDKFD_IOWR(nr, type)_IOWR(AMDKFD_IOCTL_BASE, nr, 
> type)
>   
> -#define KFD_IOC_GET_VERSION \
> - _IOR(KFD_IOC_MAGIC, 1, struct kfd_ioctl_get_version_args)
> +#define AMDKFD_IOC_GET_VERSION   \
> + AMDKFD_IOR(0x01, struct kfd_ioctl_get_version_args)
>   
> -#define KFD_IOC_CREATE_QUEUE \
> - _IOWR(KFD_IOC_MAGIC, 2, struct kfd_ioctl_create_queue_args)
> +#define AMDKFD_IOC_CREATE_QUEUE  \
> + AMDKFD_IOWR(0x02, struct kfd_ioctl_create_queue_args)
>   
> -#define KFD_IOC_DESTROY_QUEUE \
> - _IOWR(KFD_IOC_MAGIC, 3, struct kfd_ioctl_destroy_queue_args)
> +#define AMDKFD_IOC_DESTROY_QUEUE \
> + AMDKFD_IOWR(0x03, struct kfd_ioctl_destroy_queue_args)
>   
> -#define KFD_IOC_SET_MEMORY_POLICY \
> - _IOW(KFD_IOC_MAGIC, 4, struct kfd_ioctl_set_memory_policy_args)
> +#define AMDKFD_IOC_SET_MEMORY_POLICY \
> + AMDKFD_IOW(0x04, struct kfd_ioctl_set_memory_policy_args)
>   
> -#define KFD_IOC_GET_CLOCK_COUNTERS \
> - _IOWR(KFD_IOC_MAGIC, 5, struct kfd_ioctl_get_clock_counters_args)
> +#define AMDKFD_IOC_GET_CLOCK_COUNTERS\
> + AMDKFD_IOWR(0x05, struct kfd_ioctl_get_clock_counters_args)
>   
> -#define KFD_IOC_GET_PROCESS_APERTURES \
> - _IOR(KFD_IOC_MAGIC, 6, struct kfd_ioctl_get_process_apertures_args)
> +#define AMDKFD_IOC_GET_PROCESS_APERTURES \
> + AMDKFD_IOR(0x06, struct kfd_ioctl_get_process_apertures_args)
>   
> -#define KFD_IOC_UPDATE_QUEUE \
> - _IOW(KFD_IOC_MAGIC, 7, struct kfd_ioctl_update_queue_args)
> +#define AMDKFD_IOC_UPDATE_QUEUE  \
> + AMDKFD_IOW(0x07, struct kfd_ioctl_update_queue_args)
> +
> +#define KFD_COMMAND_START   0x01
> +#define KFD_COMMAND_END  0x08

If you rename everything to AMDKFD_* you probably want to do so as well 
for KFD_COMMAND_(START|END).

Regards,
Christian.

>   
>   #endif



[PATCH 1/3] drm/amdkfd: Do copy_to/from_user in general kfd_ioctl()

2014-12-29 Thread Christian König
Am 29.12.2014 um 13:42 schrieb Oded Gabbay:
> This patch moves the copy_to_user() and copy_from_user() calls from the
> different ioctl functions in amdkfd to the general kfd_ioctl() function, as
> this is a common code for all ioctls.
>
> This was done according to example taken from drm_ioctl.c
>
> Signed-off-by: Oded Gabbay 

In general sounds like a good idea to me and the patch is "Reviewed-by: 
Christian König " for now.

What really questions me is why we need all this code duplication and 
can't reuse the DRM infrastructure for this. But that's more a problem 
in the long term.

Regards,
Christian.

> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 234 
> +++
>   1 file changed, 117 insertions(+), 117 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c 
> b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> index 7d4974b..5460ad2 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> @@ -127,17 +127,14 @@ static int kfd_open(struct inode *inode, struct file 
> *filep)
>   return 0;
>   }
>   
> -static long kfd_ioctl_get_version(struct file *filep, struct kfd_process *p,
> - void __user *arg)
> +static int kfd_ioctl_get_version(struct file *filep, struct kfd_process *p,
> + void *data)
>   {
> - struct kfd_ioctl_get_version_args args;
> + struct kfd_ioctl_get_version_args *args = data;
>   int err = 0;
>   
> - args.major_version = KFD_IOCTL_MAJOR_VERSION;
> - args.minor_version = KFD_IOCTL_MINOR_VERSION;
> -
> - if (copy_to_user(arg, , sizeof(args)))
> - err = -EFAULT;
> + args->major_version = KFD_IOCTL_MAJOR_VERSION;
> + args->minor_version = KFD_IOCTL_MINOR_VERSION;
>   
>   return err;
>   }
> @@ -221,10 +218,10 @@ static int set_queue_properties_from_user(struct 
> queue_properties *q_properties,
>   return 0;
>   }
>   
> -static long kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,
> - void __user *arg)
> +static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,
> + void *data)
>   {
> - struct kfd_ioctl_create_queue_args args;
> + struct kfd_ioctl_create_queue_args *args = data;
>   struct kfd_dev *dev;
>   int err = 0;
>   unsigned int queue_id;
> @@ -233,16 +230,13 @@ static long kfd_ioctl_create_queue(struct file *filep, 
> struct kfd_process *p,
>   
>   memset(_properties, 0, sizeof(struct queue_properties));
>   
> - if (copy_from_user(, arg, sizeof(args)))
> - return -EFAULT;
> -
>   pr_debug("kfd: creating queue ioctl\n");
>   
> - err = set_queue_properties_from_user(_properties, );
> + err = set_queue_properties_from_user(_properties, args);
>   if (err)
>   return err;
>   
> - dev = kfd_device_by_id(args.gpu_id);
> + dev = kfd_device_by_id(args->gpu_id);
>   if (dev == NULL)
>   return -EINVAL;
>   
> @@ -250,7 +244,7 @@ static long kfd_ioctl_create_queue(struct file *filep, 
> struct kfd_process *p,
>   
>   pdd = kfd_bind_process_to_device(dev, p);
>   if (IS_ERR(pdd)) {
> - err = PTR_ERR(pdd);
> + err = -ESRCH;
>   goto err_bind_process;
>   }
>   
> @@ -263,33 +257,26 @@ static long kfd_ioctl_create_queue(struct file *filep, 
> struct kfd_process *p,
>   if (err != 0)
>   goto err_create_queue;
>   
> - args.queue_id = queue_id;
> + args->queue_id = queue_id;
>   
>   /* Return gpu_id as doorbell offset for mmap usage */
> - args.doorbell_offset = args.gpu_id << PAGE_SHIFT;
> -
> - if (copy_to_user(arg, , sizeof(args))) {
> - err = -EFAULT;
> - goto err_copy_args_out;
> - }
> + args->doorbell_offset = args->gpu_id << PAGE_SHIFT;
>   
>   mutex_unlock(>mutex);
>   
> - pr_debug("kfd: queue id %d was created successfully\n", args.queue_id);
> + pr_debug("kfd: queue id %d was created successfully\n", args->queue_id);
>   
>   pr_debug("ring buffer address == 0x%016llX\n",
> - args.ring_base_address);
> + args->ring_base_address);
>   
>   pr_debug("read ptr address== 0x%016llX\n",
> - args.read_pointer_address);
> + args->read_pointer_address);
>   
>   pr_debug("write ptr address   == 0x%016llX\n",
> - args.write_pointer_address);
> + args->write_pointer_address);
>   
>   return 0;
>   
> -err_copy_args_out:
> - pqm_destroy_queue(>pqm, queue_id);
>   err_create_queue:
>   err_bind_process:
>   mutex_unlock(>mutex);
> @@ -297,99 +284,90 @@ err_bind_process:
>   }
>   
>   static int kfd_ioctl_destroy_queue(struct file *filp, struct kfd_process *p,
> - 

[PATCH v2] drm/radeon: Init amdkfd only if it was compiled

2014-12-29 Thread Christian König
Am 29.12.2014 um 09:59 schrieb Oded Gabbay:
> This patch changes the radeon_kfd_init(), which is used to initialize the
> interface between radeon and amdkfd, so the interface will be initialized only
> if amdkfd was build, either as module or inside the kernel image.
>
> In the modules case, the symbol_request() will be used (same as old code). In
> the in-image compilation case, a direct call to kgd2kfd_init() will be done.
> For other cases, radeon_kfd_init() will just return false.
>
> This patch is necessary because in case of the following specific
> configuration: kernel 32-bit, no modules support, random kernel base and no
> hibernation, the symbol_request() doesn't work as expected - it doesn't return
> NULL if the symbol doesn't exists - which makes the kernel panic.
>
> Signed-off-by: Oded Gabbay 

Using symbol_request() in general doesn't seem to be such a good idea, 
because it breaks symbol versioning and as far as I can see is only very 
rarely used in drivers (AFAIK only V4L drivers).

But for the moment I don't have another idea either except for always 
loading the module which on most hardware is completely unnecessary. 
Maybe we should consider restructuring the module load dependencies in 
the next kernel release.

For now the patch is Reviewed-by: Christian König 

> ---
>   drivers/gpu/drm/radeon/radeon_kfd.c | 12 
>   1 file changed, 12 insertions(+)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_kfd.c 
> b/drivers/gpu/drm/radeon/radeon_kfd.c
> index 242fd8b..d3e78b4 100644
> --- a/drivers/gpu/drm/radeon/radeon_kfd.c
> +++ b/drivers/gpu/drm/radeon/radeon_kfd.c
> @@ -101,6 +101,7 @@ static const struct kgd2kfd_calls *kgd2kfd;
>   
>   bool radeon_kfd_init(void)
>   {
> +#if defined(CONFIG_HSA_AMD_MODULE)
>   bool (*kgd2kfd_init_p)(unsigned, const struct kfd2kgd_calls*,
>   const struct kgd2kfd_calls**);
>   
> @@ -117,6 +118,17 @@ bool radeon_kfd_init(void)
>   }
>   
>   return true;
> +#elif defined(CONFIG_HSA_AMD)
> + if (!kgd2kfd_init(KFD_INTERFACE_VERSION, , )) {
> + kgd2kfd = NULL;
> +
> + return false;
> + }
> +
> + return true;
> +#else
> + return false;
> +#endif
>   }
>   
>   void radeon_kfd_fini(void)



[Bug 90451] New: Dedicated gpu on HP 355 G2 not working correctly (slower than integrated+corrupt display in es2gears)

2014-12-29 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=90451

Bug ID: 90451
   Summary: Dedicated gpu on HP 355 G2 not working correctly
(slower than integrated+corrupt display in es2gears)
   Product: Drivers
   Version: 2.5
Kernel Version: 3.16
  Hardware: All
OS: Linux
  Tree: Mainline
Status: NEW
  Severity: high
  Priority: P1
 Component: Video(DRI - non Intel)
  Assignee: drivers_video-dri at kernel-bugs.osdl.org
  Reporter: l55 at anonymousspeech.com
Regression: No

The HP 355 G2 has an integrated R5 Mullins and a dedicated Hainan GPU(R5 M240).
Only the integrated one seems to work correctly.

When running "DRI_PRIME=1 es2gears"(dedicated) i get corrupt image and lower
fps than with "es2gears"(integrated), while i think the dedicated should be way
better. These are the results on Ubuntu 14.10(kernel 3.16).

I also tried the Gears on Gallium livedvd (2014.12.25) with kernel 3.19-rc1 and
devel mesa/xorg/radeon drivers ( http://www.gearsongallium.com/?p=1668 ).
With Gears on Gallium the switchable graphics don't seem to work at all, it
seems to use the integrated gpu always, even with DRI_PRIME=1.

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


[PATCH RFC v6 16/21] drm: panel: Add support for Himax HX8369A MIPI DSI panel

2014-12-29 Thread Andrzej Hajda
On 12/29/2014 11:07 AM, Liu Ying wrote:
> On 12/29/2014 05:09 PM, Andrzej Hajda wrote:
>> On 12/29/2014 07:39 AM, Liu Ying wrote:
>>> This patch adds support for Himax HX8369A MIPI DSI panel.
>>>
>>> Signed-off-by: Liu Ying 
>>> ---
>>> v5->v6:
>>>   * Make the checkpatch.pl script be happier.
>>>   * Do not set the dsi channel number to be zero in probe(), because the 
>>> MIPI DSI
>>> bus driver would set it.
>>>
>>> v4->v5:
>>>   * Address Andrzej Hajda's comments.
>>>   * Get the bs-gpios property instead of the bs[3:0]-gpios properties.
>>>   * Implement error propagation for panel register configurations.
>>>   * Other minor changes to improve the code quality.
>>>
>>> v3->v4:
>>>   * Move the relevant dt-bindings to a separate patch to address Stefan
>>> Wahren's comment.
>>>
>>> v2->v3:
>>>   * Sort the included header files alphabetically.
>>>
>>> v1->v2:
>>>   * Address almost all comments from Thierry Reding.
>>>   * Remove several DT properties as they can be implied by the compatible 
>>> string.
>>>   * Add the HIMAX/himax prefixes to the driver's Kconfig name and driver 
>>> name.
>>>   * Move the driver's Makefile entry place to sort the entries 
>>> alphabetically.
>>>   * Reuse several standard DCS functions instead of inventing wheels.
>>>   * Move the panel resetting and power logics to the driver probe/remove 
>>> stages.
>>> This may simplify panel prepare/unprepare hooks. The power consumption 
>>> should
>>> not change a lot at DPMS since the panel enters sleep mode at that time.
>>>   * Add the module author.
>>>   * Other minor changes, such as coding style issues.
>>>
>>>   drivers/gpu/drm/panel/Kconfig   |   5 +
>>>   drivers/gpu/drm/panel/Makefile  |   1 +
>>>   drivers/gpu/drm/panel/panel-himax-hx8369a.c | 614 
>>> 
>>>   3 files changed, 620 insertions(+)
>>>   create mode 100644 drivers/gpu/drm/panel/panel-himax-hx8369a.c
>>>
>>> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
>>> index 024e98e..81b0bf0 100644
>>> --- a/drivers/gpu/drm/panel/Kconfig
>>> +++ b/drivers/gpu/drm/panel/Kconfig
>>> @@ -16,6 +16,11 @@ config DRM_PANEL_SIMPLE
>>>   that it can be automatically turned off when the panel goes into a
>>>   low power state.
>>>
>>> +config DRM_PANEL_HIMAX_HX8369A
>>> +   tristate "Himax HX8369A panel"
>>> +   depends on OF
>>> +   select DRM_MIPI_DSI
>>> +
>>>   config DRM_PANEL_LD9040
>>> tristate "LD9040 RGB/SPI panel"
>>> depends on OF && SPI
>>> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
>>> index 4b2a043..d5dbe06 100644
>>> --- a/drivers/gpu/drm/panel/Makefile
>>> +++ b/drivers/gpu/drm/panel/Makefile
>>> @@ -1,4 +1,5 @@
>>>   obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o
>>> +obj-$(CONFIG_DRM_PANEL_HIMAX_HX8369A) += panel-himax-hx8369a.o
>>>   obj-$(CONFIG_DRM_PANEL_LD9040) += panel-ld9040.o
>>>   obj-$(CONFIG_DRM_PANEL_S6E8AA0) += panel-s6e8aa0.o
>>>   obj-$(CONFIG_DRM_PANEL_SHARP_LQ101R1SX01) += panel-sharp-lq101r1sx01.o
>>> diff --git a/drivers/gpu/drm/panel/panel-himax-hx8369a.c 
>>> b/drivers/gpu/drm/panel/panel-himax-hx8369a.c
>>> new file mode 100644
>>> index 000..eee36a7
>>> --- /dev/null
>>> +++ b/drivers/gpu/drm/panel/panel-himax-hx8369a.c
>>> @@ -0,0 +1,614 @@
>>> +/*
>>> + * Himax HX8369A panel driver.
>>> + *
>>> + * Copyright (C) 2011-2014 Freescale Semiconductor, 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 driver is based on Samsung s6e8aa0 panel driver.
>>> + */
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +#define WRDISBV0x51
>>> +#define WRCTRLD0x53
>>> +#define WRCABC 0x55
>>> +#define SETPOWER   0xb1
>>> +#define SETDISP0xb2
>>> +#define SETCYC 0xb4
>>> +#define SETVCOM0xb6
>>> +#define SETEXTC0xb9
>>> +#define SETMIPI0xba
>>> +#define SETPANEL   0xcc
>>> +#define SETGIP 0xd5
>>> +#define SETGAMMA   0xe0
>>> +
>>> +#define HX8369A_MIN_BRIGHTNESS 0x00
>>> +#define HX8369A_MAX_BRIGHTNESS 0xff
>>> +
>>> +enum hx8369a_mpu_interface {
>>> +   HX8369A_DBI_TYPE_A_8BIT,
>>> +   HX8369A_DBI_TYPE_A_9BIT,
>>> +   HX8369A_DBI_TYPE_A_16BIT,
>>> +   HX8369A_DBI_TYPE_A_18BIT,
>>> +   HX8369A_DBI_TYPE_B_8BIT,
>>> +   HX8369A_DBI_TYPE_B_9BIT,
>>> +   HX8369A_DBI_TYPE_B_16BIT,
>>> +   HX8369A_DBI_TYPE_B_18BIT,
>>> +   HX8369A_DSI_CMD_MODE,
>>> +   HX8369A_DBI_TYPE_B_24BIT,
>>> +   HX8369A_DSI_VIDEO_MODE,
>>> +   HX8369A_MDDI,
>>> +   HX8369A_DPI_DBI_TYPE_C_OPT1,
>>> +   HX8369A_DPI_DBI_TYPE_C_OPT2,
>>> +   HX8369A_DPI_DBI_TYPE_C_OPT3
>>> +};
>>> +
>>> +enum hx8369a_resolution {
>>> +   

i915: regression: after DP connected monitor is turned off, when turned on, it does not work anymore

2014-12-29 Thread Jani Nikula
On Sat, 27 Dec 2014, Jiri Pirko  wrote:
> Please let me know if you need me to provide any other info. I'm eager to
> test patches.

Please file a bug at [1] to ensure this doesn't get lost. Holiday season
and all. Please reference this thread, and attach dmesg with
drm.debug=14 module parameter set, reproducing the issue.

Please also give drm-intel-nightly branch of [2] a try, although I don't
immediately recall any specific fixes that might address your issue.

Thanks,
Jani.

[1] https://bugs.freedesktop.org/enter_bug.cgi?product=DRI=DRM/Intel
[2] http://cgit.freedesktop.org/drm-intel


-- 
Jani Nikula, Intel Open Source Technology Center


[PATCH v2] drm/radeon: Init amdkfd only if it was compiled

2014-12-29 Thread Oded Gabbay
This patch changes the radeon_kfd_init(), which is used to initialize the
interface between radeon and amdkfd, so the interface will be initialized only
if amdkfd was build, either as module or inside the kernel image.

In the modules case, the symbol_request() will be used (same as old code). In
the in-image compilation case, a direct call to kgd2kfd_init() will be done.
For other cases, radeon_kfd_init() will just return false.

This patch is necessary because in case of the following specific
configuration: kernel 32-bit, no modules support, random kernel base and no
hibernation, the symbol_request() doesn't work as expected - it doesn't return
NULL if the symbol doesn't exists - which makes the kernel panic.

Signed-off-by: Oded Gabbay 
---
 drivers/gpu/drm/radeon/radeon_kfd.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/radeon/radeon_kfd.c 
b/drivers/gpu/drm/radeon/radeon_kfd.c
index 242fd8b..d3e78b4 100644
--- a/drivers/gpu/drm/radeon/radeon_kfd.c
+++ b/drivers/gpu/drm/radeon/radeon_kfd.c
@@ -101,6 +101,7 @@ static const struct kgd2kfd_calls *kgd2kfd;

 bool radeon_kfd_init(void)
 {
+#if defined(CONFIG_HSA_AMD_MODULE)
bool (*kgd2kfd_init_p)(unsigned, const struct kfd2kgd_calls*,
const struct kgd2kfd_calls**);

@@ -117,6 +118,17 @@ bool radeon_kfd_init(void)
}

return true;
+#elif defined(CONFIG_HSA_AMD)
+   if (!kgd2kfd_init(KFD_INTERFACE_VERSION, , )) {
+   kgd2kfd = NULL;
+
+   return false;
+   }
+
+   return true;
+#else
+   return false;
+#endif
 }

 void radeon_kfd_fini(void)
-- 
1.9.1



[PATCH] amdkfd: actually allocate longs for the pasid bitmask

2014-12-29 Thread Oded Gabbay


On 12/28/2014 06:44 PM, Sasha Levin wrote:
> Commit "amdkfd: use sizeof(long) granularity for the pasid bitmask" calculated
> the number of longs it will need, but ended up allocating that number of
> bytes rather than longs.
>
> Fix that silly error and allocate the amount of data really required.
>
> Signed-off-by: Sasha Levin 
> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_pasid.c |2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_pasid.c 
> b/drivers/gpu/drm/amd/amdkfd/kfd_pasid.c
> index 71699ad..4c25ef5 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_pasid.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_pasid.c
> @@ -32,7 +32,7 @@ int kfd_pasid_init(void)
>   {
>   pasid_limit = max_num_of_processes;
>
> - pasid_bitmap = kzalloc(BITS_TO_LONGS(pasid_limit), GFP_KERNEL);
> + pasid_bitmap = kcalloc(BITS_TO_LONGS(pasid_limit), sizeof(long), 
> GFP_KERNEL);
>   if (!pasid_bitmap)
>   return -ENOMEM;
>
>
Thanks!
Applied to my amdkfd-fixes tree.

Oded


[patch] drm/radeon: integer underflow in radeon_cp_dispatch_texture()

2014-12-29 Thread Christian König
Am 23.12.2014 um 10:56 schrieb Dan Carpenter:
> The test:
>
>   if (size > RADEON_MAX_TEXTURE_SIZE) {
>
> "size" is an integer and it's controled by the user so it can be
> negative and the test can underflow.  Later we use "size" in:
>
>   dwords = size / 4;
>   ...
>   RADEON_COPY_MT(buffer, data, (int)(dwords * sizeof(u32)));
>
> It causes memory corruption to copy a negative size buffer.
>
> Signed-off-by: Dan Carpenter 

This specific line of code is completely deprecated and the patch is 
just another coffin nail to finally remove it.

But since we can't be sure that it doesn't break any userspace still in 
use I'm generally ok to apply the patch and it is Reviewed-by: Christian 
König 

Regards,
Christian.

> ---
> Static checkers complain about the integer overflows here, and there are
> many real overflows but they appear harmless.
>
> diff --git a/drivers/gpu/drm/radeon/radeon_state.c 
> b/drivers/gpu/drm/radeon/radeon_state.c
> index 535403e..15aee72 100644
> --- a/drivers/gpu/drm/radeon/radeon_state.c
> +++ b/drivers/gpu/drm/radeon/radeon_state.c
> @@ -1703,7 +1703,7 @@ static int radeon_cp_dispatch_texture(struct drm_device 
> * dev,
>   u32 format;
>   u32 *buffer;
>   const u8 __user *data;
> - int size, dwords, tex_width, blit_width, spitch;
> + unsigned int size, dwords, tex_width, blit_width, spitch;
>   u32 height;
>   int i;
>   u32 texpitch, microtile;



[PATCH 0/2] Change order of linkage in kernel makefiles for amdkfd

2014-12-29 Thread Christian König
Am 29.12.2014 um 09:16 schrieb Laurent Pinchart:
> Hi Oded,
>
> On Sunday 28 December 2014 13:36:50 Oded Gabbay wrote:
>> On 12/26/2014 11:19 AM, Laurent Pinchart wrote:
>>> On Thursday 25 December 2014 14:20:59 Thierry Reding wrote:
 On Mon, Dec 22, 2014 at 01:07:13PM +0200, Oded Gabbay wrote:
> This small patch-set, was created to solve the bug described at
> https://bugzilla.kernel.org/show_bug.cgi?id=89661 (Kernel panic when
> trying use amdkfd driver on Kaveri). It replaces the previous patch-set
> called [PATCH 0/3] Use workqueue for device init in amdkfd
> (http://lists.freedesktop.org/archives/dri-devel/2014-December/074401.ht
> ml)
>
> That bug appears only when radeon, amdkfd and amd_iommu_v2 are compiled
> inside the kernel (not as modules). In that case, the correct loading
> order, as determined by the exported symbol used by each driver, is
> not enforced anymore and the kernel loads them based on who was linked
> first. That makes radeon load first, amdkfd second and amd_iommu_v2
> third.
>
> Because the initialization of a device in amdkfd is initiated by radeon,
> and can only be completed if amdkfd and amd_iommu_v2 were loaded and
> initialized, then in the case mentioned above, this initalization fails
> and there is a kernel panic as some pointers are not initialized but
> used nontheless.
>
> To solve this bug, this patch-set moves iommu/ before gpu/ in
> drivers/Makefile and also moves amdkfd/ before radeon/ in
> drivers/gpu/drm/Makefile.
>
> The rationale is that in general, AMD GPU devices are dependent on AMD
> IOMMU controller functionality to allow the GPU to access a process's
> virtual memory address space, without the need for pinning the memory.
> That's why it makes sense to initialize the iommu/ subsystem ahead of
> the gpu/ subsystem.
 I strongly object to this patch set. This makes assumptions about how
 the build system influences probe order. That's bad because seemingly
 unrelated changes could easily break this in the future.

 We already have ways to solve this kind of dependency (driver probe
 deferral), and I think you should be using it to solve this particular
 problem rather than some linking order hack.
>>> While I agree with you that probe deferral is the way to go, I believe
>>> linkage ordering can still be used as an optimization to avoid deferring
>>> probe in the most common cases. I'm thus not opposed to moving iommu/
>>> earlier in link order (provided we can properly test for side effects, as
>>> the jump is pretty large), but not as a replacement for probe deferral.
>> My thoughts exactly. If this was some extreme use case, than it would be
>> justified to solve it with probe deferral. But I think that for most common
>> cases, GPU are dependent on IOMMU and *not* vice-versa.

Fixing this through deferred probing sounds like the correct long term 
solution to me as well.

But what Thierry is referring to here is probably the approach of 
returning -EAGAIN from the probe method (at least that was the last 
status when I looked into this).

The problem with this approach is the interface design between radeon 
and amdkfd. amdkfd simply doesn't have a probe method which gets called 
when the hardware is detected and can return -EAGAIN. Instead amdkfd is 
called by radeon after hardware initialization when it is way to late 
for such a thing.

>>
>> BTW, my first try at solving this was to use probe deferral (using
>> workqueue), but the feedback I got from Christian and Dave was that moving
>> iommu/ linkage before gpu/ was a much more simpler solution.
> To clarify my position, I believe changing the link order can be a worthwhile
> optimization, but I'm uncertain about the long term viability of that change
> as a fix. Probe deferral has been introduced because not all probe ordering
> issues can be fixed through link ordering, so we should fix the problem
> properly.
>
> This being said, if modifying the link order can help for now without
> introducing negative side effects, it would only postpone the real fix, so I'm
> not opposed to it.

Yeah, that sounds like the right approach to me as well. In general I 
would prefer that modules compiled into the kernel load by the order of 
their symbol dependency just like standalone modules do.

That's what Rusty proposed more than 10 years ago when he reworked the 
module system and I'm actually not sure why it was never done this way. 
I can only find the initial patch to do so in the mail history, but not 
why it was rejected.

Regards,
Christian.

>
>> In addition, Linus said he doesn't object to this "band-aid". See:
>> https://lkml.org/lkml/2014/12/25/152
>>
>>  Oded
>>
 Coincidentally there's a separate thread currently going on that deals
 with IOMMUs and probe order. The solution being worked on is currently
 somewhat ARM-specific, so 

[PATCH 0/2] Change order of linkage in kernel makefiles for amdkfd

2014-12-29 Thread Laurent Pinchart
Hi Oded,

On Sunday 28 December 2014 13:36:50 Oded Gabbay wrote:
> On 12/26/2014 11:19 AM, Laurent Pinchart wrote:
> > On Thursday 25 December 2014 14:20:59 Thierry Reding wrote:
> >> On Mon, Dec 22, 2014 at 01:07:13PM +0200, Oded Gabbay wrote:
> >>> This small patch-set, was created to solve the bug described at
> >>> https://bugzilla.kernel.org/show_bug.cgi?id=89661 (Kernel panic when
> >>> trying use amdkfd driver on Kaveri). It replaces the previous patch-set
> >>> called [PATCH 0/3] Use workqueue for device init in amdkfd
> >>> (http://lists.freedesktop.org/archives/dri-devel/2014-December/074401.ht
> >>> ml)
> >>> 
> >>> That bug appears only when radeon, amdkfd and amd_iommu_v2 are compiled
> >>> inside the kernel (not as modules). In that case, the correct loading
> >>> order, as determined by the exported symbol used by each driver, is
> >>> not enforced anymore and the kernel loads them based on who was linked
> >>> first. That makes radeon load first, amdkfd second and amd_iommu_v2
> >>> third.
> >>> 
> >>> Because the initialization of a device in amdkfd is initiated by radeon,
> >>> and can only be completed if amdkfd and amd_iommu_v2 were loaded and
> >>> initialized, then in the case mentioned above, this initalization fails
> >>> and there is a kernel panic as some pointers are not initialized but
> >>> used nontheless.
> >>> 
> >>> To solve this bug, this patch-set moves iommu/ before gpu/ in
> >>> drivers/Makefile and also moves amdkfd/ before radeon/ in
> >>> drivers/gpu/drm/Makefile.
> >>> 
> >>> The rationale is that in general, AMD GPU devices are dependent on AMD
> >>> IOMMU controller functionality to allow the GPU to access a process's
> >>> virtual memory address space, without the need for pinning the memory.
> >>> That's why it makes sense to initialize the iommu/ subsystem ahead of
> >>> the gpu/ subsystem.
> >> 
> >> I strongly object to this patch set. This makes assumptions about how
> >> the build system influences probe order. That's bad because seemingly
> >> unrelated changes could easily break this in the future.
> >> 
> >> We already have ways to solve this kind of dependency (driver probe
> >> deferral), and I think you should be using it to solve this particular
> >> problem rather than some linking order hack.
> > 
> > While I agree with you that probe deferral is the way to go, I believe
> > linkage ordering can still be used as an optimization to avoid deferring
> > probe in the most common cases. I'm thus not opposed to moving iommu/
> > earlier in link order (provided we can properly test for side effects, as
> > the jump is pretty large), but not as a replacement for probe deferral.
> 
> My thoughts exactly. If this was some extreme use case, than it would be
> justified to solve it with probe deferral. But I think that for most common
> cases, GPU are dependent on IOMMU and *not* vice-versa.
> 
> BTW, my first try at solving this was to use probe deferral (using
> workqueue), but the feedback I got from Christian and Dave was that moving
> iommu/ linkage before gpu/ was a much more simpler solution.

To clarify my position, I believe changing the link order can be a worthwhile 
optimization, but I'm uncertain about the long term viability of that change 
as a fix. Probe deferral has been introduced because not all probe ordering 
issues can be fixed through link ordering, so we should fix the problem 
properly.

This being said, if modifying the link order can help for now without 
introducing negative side effects, it would only postpone the real fix, so I'm 
not opposed to it.

> In addition, Linus said he doesn't object to this "band-aid". See:
> https://lkml.org/lkml/2014/12/25/152
> 
>   Oded
> 
> >> Coincidentally there's a separate thread currently going on that deals
> >> with IOMMUs and probe order. The solution being worked on is currently
> >> somewhat ARM-specific, so adding a couple of folks for visibility. It
> >> looks like we're going to need something more generic since this is a
> >> problem that even the "big" architectures need to solve.

-- 
Regards,

Laurent Pinchart



[PATCH RFC v6 16/21] drm: panel: Add support for Himax HX8369A MIPI DSI panel

2014-12-29 Thread Andrzej Hajda
On 12/29/2014 07:39 AM, Liu Ying wrote:
> This patch adds support for Himax HX8369A MIPI DSI panel.
>
> Signed-off-by: Liu Ying 
> ---
> v5->v6:
>  * Make the checkpatch.pl script be happier.
>  * Do not set the dsi channel number to be zero in probe(), because the MIPI 
> DSI
>bus driver would set it.
>
> v4->v5:
>  * Address Andrzej Hajda's comments.
>  * Get the bs-gpios property instead of the bs[3:0]-gpios properties.
>  * Implement error propagation for panel register configurations.
>  * Other minor changes to improve the code quality.
>
> v3->v4:
>  * Move the relevant dt-bindings to a separate patch to address Stefan
>Wahren's comment.
>
> v2->v3:
>  * Sort the included header files alphabetically.
>
> v1->v2:
>  * Address almost all comments from Thierry Reding.
>  * Remove several DT properties as they can be implied by the compatible 
> string.
>  * Add the HIMAX/himax prefixes to the driver's Kconfig name and driver name.
>  * Move the driver's Makefile entry place to sort the entries alphabetically.
>  * Reuse several standard DCS functions instead of inventing wheels.
>  * Move the panel resetting and power logics to the driver probe/remove 
> stages.
>This may simplify panel prepare/unprepare hooks. The power consumption 
> should
>not change a lot at DPMS since the panel enters sleep mode at that time.
>  * Add the module author.
>  * Other minor changes, such as coding style issues.
>
>  drivers/gpu/drm/panel/Kconfig   |   5 +
>  drivers/gpu/drm/panel/Makefile  |   1 +
>  drivers/gpu/drm/panel/panel-himax-hx8369a.c | 614 
> 
>  3 files changed, 620 insertions(+)
>  create mode 100644 drivers/gpu/drm/panel/panel-himax-hx8369a.c
>
> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
> index 024e98e..81b0bf0 100644
> --- a/drivers/gpu/drm/panel/Kconfig
> +++ b/drivers/gpu/drm/panel/Kconfig
> @@ -16,6 +16,11 @@ config DRM_PANEL_SIMPLE
> that it can be automatically turned off when the panel goes into a
> low power state.
>  
> +config DRM_PANEL_HIMAX_HX8369A
> + tristate "Himax HX8369A panel"
> + depends on OF
> + select DRM_MIPI_DSI
> +
>  config DRM_PANEL_LD9040
>   tristate "LD9040 RGB/SPI panel"
>   depends on OF && SPI
> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
> index 4b2a043..d5dbe06 100644
> --- a/drivers/gpu/drm/panel/Makefile
> +++ b/drivers/gpu/drm/panel/Makefile
> @@ -1,4 +1,5 @@
>  obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o
> +obj-$(CONFIG_DRM_PANEL_HIMAX_HX8369A) += panel-himax-hx8369a.o
>  obj-$(CONFIG_DRM_PANEL_LD9040) += panel-ld9040.o
>  obj-$(CONFIG_DRM_PANEL_S6E8AA0) += panel-s6e8aa0.o
>  obj-$(CONFIG_DRM_PANEL_SHARP_LQ101R1SX01) += panel-sharp-lq101r1sx01.o
> diff --git a/drivers/gpu/drm/panel/panel-himax-hx8369a.c 
> b/drivers/gpu/drm/panel/panel-himax-hx8369a.c
> new file mode 100644
> index 000..eee36a7
> --- /dev/null
> +++ b/drivers/gpu/drm/panel/panel-himax-hx8369a.c
> @@ -0,0 +1,614 @@
> +/*
> + * Himax HX8369A panel driver.
> + *
> + * Copyright (C) 2011-2014 Freescale Semiconductor, 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 driver is based on Samsung s6e8aa0 panel driver.
> + */
> +
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +
> +#define WRDISBV  0x51
> +#define WRCTRLD  0x53
> +#define WRCABC   0x55
> +#define SETPOWER 0xb1
> +#define SETDISP  0xb2
> +#define SETCYC   0xb4
> +#define SETVCOM  0xb6
> +#define SETEXTC  0xb9
> +#define SETMIPI  0xba
> +#define SETPANEL 0xcc
> +#define SETGIP   0xd5
> +#define SETGAMMA 0xe0
> +
> +#define HX8369A_MIN_BRIGHTNESS   0x00
> +#define HX8369A_MAX_BRIGHTNESS   0xff
> +
> +enum hx8369a_mpu_interface {
> + HX8369A_DBI_TYPE_A_8BIT,
> + HX8369A_DBI_TYPE_A_9BIT,
> + HX8369A_DBI_TYPE_A_16BIT,
> + HX8369A_DBI_TYPE_A_18BIT,
> + HX8369A_DBI_TYPE_B_8BIT,
> + HX8369A_DBI_TYPE_B_9BIT,
> + HX8369A_DBI_TYPE_B_16BIT,
> + HX8369A_DBI_TYPE_B_18BIT,
> + HX8369A_DSI_CMD_MODE,
> + HX8369A_DBI_TYPE_B_24BIT,
> + HX8369A_DSI_VIDEO_MODE,
> + HX8369A_MDDI,
> + HX8369A_DPI_DBI_TYPE_C_OPT1,
> + HX8369A_DPI_DBI_TYPE_C_OPT2,
> + HX8369A_DPI_DBI_TYPE_C_OPT3
> +};
> +
> +enum hx8369a_resolution {
> + HX8369A_RES_480_864,
> + HX8369A_RES_480_854,
> + HX8369A_RES_480_800,
> + HX8369A_RES_480_640,
> + HX8369A_RES_360_640,
> + HX8369A_RES_480_720,
> +};
> +
> +struct hx8369a_panel_desc {
> + const struct drm_display_mode *mode;
> +
> + /* ms */
> + unsigned int power_on_delay;
> + unsigned int