Re: [PATCH v6 1/2] drm/tinydrm: Move tinydrm_of_find_backlight into drm_of.c

2017-09-30 Thread Meghana Madhyastha
On Sat, Sep 30, 2017 at 09:04:57PM +0200, Noralf Trønnes wrote:
> 
> Den 30.09.2017 19.12, skrev Meghana Madhyastha:
> >Rename tinydrm_of_find_backlight to drm_of_find_backlight
> >and move it into drm_of.c from tinydrm-helpers.c. This is
> >because other drivers in the drm subsystem might need to call
> >this function. In that case and otherwise, it is better from
> >an organizational point of view to move it into drm_of.c along
> >with the other _of.c functions.
> >
> >Signed-off-by: Meghana Madhyastha 
> >---
> >Changes in v6:
> >-Move function declarations to linux/backlight.h to resolve
> >  module dependency issues.
> >
> >  drivers/gpu/drm/drm_of.c   | 44 
> > ++
> >  drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c | 40 ---
> >  drivers/gpu/drm/tinydrm/mi0283qt.c |  2 +-
> >  include/drm/tinydrm/tinydrm-helpers.h  |  1 -
> >  include/linux/backlight.h  | 11 +++
> >  5 files changed, 56 insertions(+), 42 deletions(-)
> >
> >diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> >index 8dafbdf..d878d3a 100644
> >--- a/drivers/gpu/drm/drm_of.c
> >+++ b/drivers/gpu/drm/drm_of.c
> >@@ -1,6 +1,7 @@
> >  #include 
> >  #include 
> >  #include 
> >+#include 
> >  #include 
> >  #include 
> >  #include 
> >@@ -260,3 +261,46 @@ int drm_of_find_panel_or_bridge(const struct 
> >device_node *np,
> > return ret;
> >  }
> >  EXPORT_SYMBOL_GPL(drm_of_find_panel_or_bridge);
> >+
> >+/**
> >+ * drm_of_find_backlight - Find backlight device in device-tree
> >+ * @dev: Device
> >+ *
> >+ * This function looks for a DT node pointed to by a property named 
> >'backlight'
> >+ * and uses of_find_backlight_by_node() to get the backlight device.
> >+ * Additionally if the brightness property is zero, it is set to
> >+ * max_brightness.
> >+ *
> >+ * Note: It is the responsibility of the caller to call put_device() when
> >+ * releasing the resource.
> >+ *
> >+ * Returns:
> >+ * NULL if there's no backlight property.
> >+ * Error pointer -EPROBE_DEFER if the DT node is found, but no backlight 
> >device
> >+ * is found.
> >+ * If the backlight device is found, a pointer to the structure is returned.
> >+ */
> >+struct backlight_device *drm_of_find_backlight(struct device *dev)
> >+{
> >+struct backlight_device *backlight;
> >+struct device_node *np;
> >+
> >+np = of_parse_phandle(dev->of_node, "backlight", 0);
> >+if (!np)
> >+return NULL;
> >+
> >+backlight = of_find_backlight_by_node(np);
> >+of_node_put(np);
> >+
> >+if (!backlight)
> >+return ERR_PTR(-EPROBE_DEFER);
> >+
> >+if (!backlight->props.brightness) {
> >+backlight->props.brightness = backlight->props.max_brightness;
> >+DRM_DEBUG_KMS("Backlight brightness set to %d\n",
> >+  backlight->props.brightness);
> >+}
> >+
> >+return backlight;
> >+}
> >+EXPORT_SYMBOL(drm_of_find_backlight);
> >diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c 
> >b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
> >index bd6cce0..cd4c6a5 100644
> >--- a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
> >+++ b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
> >@@ -237,46 +237,6 @@ void tinydrm_xrgb_to_gray8(u8 *dst, void *vaddr, 
> >struct drm_framebuffer *fb,
> >  EXPORT_SYMBOL(tinydrm_xrgb_to_gray8);
> >  /**
> >- * tinydrm_of_find_backlight - Find backlight device in device-tree
> >- * @dev: Device
> >- *
> >- * This function looks for a DT node pointed to by a property named 
> >'backlight'
> >- * and uses of_find_backlight_by_node() to get the backlight device.
> >- * Additionally if the brightness property is zero, it is set to
> >- * max_brightness.
> >- *
> >- * Returns:
> >- * NULL if there's no backlight property.
> >- * Error pointer -EPROBE_DEFER if the DT node is found, but no backlight 
> >device
> >- * is found.
> >- * If the backlight device is found, a pointer to the structure is returned.
> >- */
> >-struct backlight_device *tinydrm_of_find_backlight(struct device *dev)
> >-{
> >-struct backlight_device *backlight;
> >-struct device_node *np;
> >-
> >-np = of_parse_phandle(dev->of_node, "backlight", 0);
> >-if (!np)
> >-return NULL;
> >-
> >-backlight = of_find_backlight_by_node(np);
> >-of_node_put(np);
> >-
> >-if (!backlight)
> >-return ERR_PTR(-EPROBE_DEFER);
> >-
> >-if (!backlight->props.brightness) {
> >-backlight->props.brightness = backlight->props.max_brightness;
> >-DRM_DEBUG_KMS("Backlight brightness set to %d\n",
> >-  backlight->props.brightness);
> >-}
> >-
> >-return backlight;
> >-}
> >-EXPORT_SYMBOL(tinydrm_of_find_backlight);
> >-
> >-/**
> >   * tinydrm_enable_backlight - Enable backlight helper
> >   * @backlight: Backlight device
> >   *
> >diff --git 

[radeon-alex:drm-next-4.15-wip 156/283] ci_smc.c:(.text+0xab0): multiple definition of `ci_send_msg_to_smc'

2017-09-30 Thread kbuild test robot
tree:   git://people.freedesktop.org/~agd5f/linux.git drm-next-4.15-wip
head:   92c7dfc70d8bd57e4ffae528418fb8a039ea26cb
commit: 9f4b35411cfed96d4f9f092b2fed14905af84d89 [156/283] drm/amd/powerplay: 
add CI asics support to smumgr (v3)
config: i386-randconfig-c0-10010618 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
git checkout 9f4b35411cfed96d4f9f092b2fed14905af84d89
# save the attached .config to linux build tree
make ARCH=i386 

Note: the radeon-alex/drm-next-4.15-wip HEAD 
92c7dfc70d8bd57e4ffae528418fb8a039ea26cb builds fine.
  It only hurts bisectibility.

All errors (new ones prefixed by >>):

   drivers/gpu/drm/amd/powerplay/smumgr/ci_smc.o: In function 
`ci_send_msg_to_smc':
>> ci_smc.c:(.text+0xab0): multiple definition of `ci_send_msg_to_smc'
   drivers/gpu/drm/radeon/ci_smc.o:ci_smc.c:(.text+0x300): first defined here

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[radeon-alex:drm-next-4.15-wip 169/283] arch/mn10300/include/asm/div64.h:52:12: error: incompatible types when assigning to type 'long long unsigned int' from type 'union '

2017-09-30 Thread kbuild test robot
tree:   git://people.freedesktop.org/~agd5f/linux.git drm-next-4.15-wip
head:   92c7dfc70d8bd57e4ffae528418fb8a039ea26cb
commit: 5d86b2c391965cbcb295e8fa795276977b2a416e [169/283] drm/amd: Closed hash 
table with low overhead (v2)
config: mn10300-allmodconfig (attached as .config)
compiler: am33_2.0-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 5d86b2c391965cbcb295e8fa795276977b2a416e
# save the attached .config to linux build tree
make.cross ARCH=mn10300 

Note: the radeon-alex/drm-next-4.15-wip HEAD 
92c7dfc70d8bd57e4ffae528418fb8a039ea26cb builds fine.
  It only hurts bisectibility.

All errors (new ones prefixed by >>):

   In file included from include/linux/kernel.h:151:0,
from include/asm-generic/bug.h:15,
from arch/mn10300/include/asm/bug.h:35,
from include/linux/bug.h:4,
from drivers/gpu/drm/amd/lib/chash.c:26:
   drivers/gpu/drm/amd/lib/chash.c: In function '__chash_table_dump_stats':
>> arch/mn10300/include/asm/div64.h:52:12: error: incompatible types when 
>> assigning to type 'long long unsigned int' from type 'union '
  __quot.l = n;  \
   ^
   drivers/gpu/drm/amd/lib/chash.c:84:12: note: in expansion of macro 'do_div'
  __rem  = do_div(__quot, __denom);   \
   ^~
   drivers/gpu/drm/amd/lib/chash.c:113:3: note: in expansion of macro 'DIV_FRAC'
  DIV_FRAC(table->hits_steps, table->hits, quot1, frac1, 1000);
  ^~~~
>> arch/mn10300/include/asm/div64.h:66:5: error: incompatible types when 
>> assigning to type 'union ' from type 'long long unsigned int'
  n = __quot.l;  \
^
   drivers/gpu/drm/amd/lib/chash.c:84:12: note: in expansion of macro 'do_div'
  __rem  = do_div(__quot, __denom);   \
   ^~
   drivers/gpu/drm/amd/lib/chash.c:113:3: note: in expansion of macro 'DIV_FRAC'
  DIV_FRAC(table->hits_steps, table->hits, quot1, frac1, 1000);
  ^~~~
>> arch/mn10300/include/asm/div64.h:52:12: error: incompatible types when 
>> assigning to type 'long long unsigned int' from type 'union '
  __quot.l = n;  \
   ^
   drivers/gpu/drm/amd/lib/chash.c:84:12: note: in expansion of macro 'do_div'
  __rem  = do_div(__quot, __denom);   \
   ^~
   drivers/gpu/drm/amd/lib/chash.c:114:3: note: in expansion of macro 'DIV_FRAC'
  DIV_FRAC(table->hits * 1000, table->hits_time_ns,
  ^~~~
>> arch/mn10300/include/asm/div64.h:66:5: error: incompatible types when 
>> assigning to type 'union ' from type 'long long unsigned int'
  n = __quot.l;  \
^
   drivers/gpu/drm/amd/lib/chash.c:84:12: note: in expansion of macro 'do_div'
  __rem  = do_div(__quot, __denom);   \
   ^~
   drivers/gpu/drm/amd/lib/chash.c:114:3: note: in expansion of macro 'DIV_FRAC'
  DIV_FRAC(table->hits * 1000, table->hits_time_ns,
  ^~~~
>> arch/mn10300/include/asm/div64.h:52:12: error: incompatible types when 
>> assigning to type 'long long unsigned int' from type 'union '
  __quot.l = n;  \
   ^
   drivers/gpu/drm/amd/lib/chash.c:84:12: note: in expansion of macro 'do_div'
  __rem  = do_div(__quot, __denom);   \
   ^~
   drivers/gpu/drm/amd/lib/chash.c:123:3: note: in expansion of macro 'DIV_FRAC'
  DIV_FRAC(table->miss_steps, table->miss, quot1, frac1, 1000);
  ^~~~
>> arch/mn10300/include/asm/div64.h:66:5: error: incompatible types when 
>> assigning to type 'union ' from type 'long long unsigned int'
  n = __quot.l;  \
^
   drivers/gpu/drm/amd/lib/chash.c:84:12: note: in expansion of macro 'do_div'
  __rem  = do_div(__quot, __denom);   \
   ^~
   drivers/gpu/drm/amd/lib/chash.c:123:3: note: in expansion of macro 'DIV_FRAC'
  DIV_FRAC(table->miss_steps, table->miss, quot1, frac1, 1000);
  ^~~~
>> arch/mn10300/include/asm/div64.h:52:12: error: incompatible types when 
>> assigning to type 'long long unsigned int' from type 'union '
  __quot.l = n;  \
   ^
   drivers/gpu/drm/amd/lib/chash.c:84:12: note: in expansion of macro 'do_div'
  __rem  = do_div(__quot, __denom);   \
   ^~
   drivers/gpu/drm/amd/lib/chash.c:124:3: note: in expansion of macro 'DIV_FRAC'
  DIV_FRAC(table->miss * 1000, table->miss_time_ns,
  ^~~~
>> arch/mn10300/include/asm/div64.h:66:5: error: incompatible types when 
>> assigning to type 'union ' from type 'long long unsigned int'
  n = __quot.l;  \
^
   drivers/gpu/drm/amd/lib/chash.c:84:12: note: in expansion of macro 'do_div'
  __rem  = do_div(__quot, __denom);   \
   ^~
   drivers/gpu/drm/amd/lib/chash.c:124:3: note: in expansion of macro 'DIV_FRAC'
  DIV_FRAC(table->miss * 1000, 

Re: [PATCH 2/3] drm/panel: Add DT bindings for Ilitek ILI9322

2017-09-30 Thread Linus Walleij
On Sun, Sep 24, 2017 at 10:36 PM, Rob Herring  wrote:
> On Wed, Sep 20, 2017 at 6:56 AM, Linus Walleij  
> wrote:
>> On Sat, Sep 2, 2017 at 11:17 PM, Linus Walleij  
>> wrote:

 Normally, we the physical panel is described which would imply all these
 settings. Are there lots of panels with this controller that would
 justify all these settings?
>>>
>>> The datasheet for the ili9322 just says it "drives panels" essentially.
>>> Googling around gives at hand that it is used pretty frequently in
>>> Shenzhen China for adapting different off-the-shelf panels to
>>> different inputs.
>>>
>>> I can't really answer how many of these products that run one or
>>> another OS using device tree to describe the configuration. It feels more
>>> like I'm paving the road for others to travel.
>
> Not really a road I want to pave and encourage others.

It's good when maintainers say "no"! :)

> +  - ilitek,entry-mode: the panel can be connected to various input 
> streams
> +and four of them can be selected by electronic straps on the display.
> +However it is possible to select another mode or override the
> +electronic default with this property. Valid values:
> +0: 8 bit serial RGB through
> +1: 8 bit serial RGB aligned
> +2: 8 bit serial RGB dummy 320x240
> +3: 8 bit serial RGB dummy 360x240
> +4: disabled
> +5: 24 bit parallel RGB through
> +6: 24 bit parallel RGB aligned
> +7: 24 bit YUV 640Y 320CbCr
> +8: 24 bit YUV 720Y 360CbCr
> +9: disabled
> +10: 8 bit ITU-R BT.656 720Y 360CbCr
> +11: 8 bit ITU-R BT.656 640Y 320CbCr

 To some extent, we have some standard bindings to describe this.
>>>
>>> I don't find any. Maybe I'm looking in the wrong places :(
>
> I guess bus-width is all we have. Normally, this is all implied by the
> compatible strings of either the controller, panel or both.
>
> Another way to look at it is, we already have support for lots of
> panels and controllers. If those haven't needed to specify this
> information, then why do you?

It's a question about devicetree vs driver configuration data altogether.
An intuitive thing, gray area. Your intuition is likely better.

I feel the same about the people who push too much pin control
data into the device tree instead of the driver so I understand the
issue. (If it is that.)

>>> Also the input modes of ili9322 is coupled with resolution so
>>> it would need two more cells or so for resolution so I feel
>>> it would over-complicate things for these 12 enumerators.
>>
>> Can we proceed with these patches?
>>
>> Any opinion from DT or panel maintainers?
>
> You have my opinion. I don't think Thierry's will be different.
>
> My suggestion is to move the settings you need into the panel driver
> and out of DT. We can always move things to DT later if it makes
> sense.

Sure thing. I will take the approach of compatible string like this:

compatible = "ilitek,ili9322", "dlink,dir685-panel";

And use the latter compatible to set up all the stuff in the panel
driver, what about that?

Yours,
Linus Walleij
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/3] drm/syncobj: extract two helpers from drm_syncobj_create

2017-09-30 Thread Zhou, David(ChunMing)
Could you test and review it? On hand, I have no env.

Regards,
David Zhou


发自坚果 Pro

Marek Ol?醟  于 2017年9月30日 下午11:56写道:

The idea sounds good.

Marek

On Sat, Sep 30, 2017 at 3:55 AM, Chunming Zhou  wrote:
> My mean is like the attached, I revert part of yours.
>
> Regards,
>
> David zhou
>
>
>
> On 2017年09月29日 22:15, Marek Olšák wrote:
>>
>> On Fri, Sep 29, 2017 at 4:13 PM, Marek Olšák  wrote:
>>>
>>> On Fri, Sep 29, 2017 at 4:44 AM, Chunming Zhou  wrote:


 On 2017年09月13日 04:42, Marek Olšák wrote:
>
> From: Marek Olšák 
>
> For amdgpu.
>
> drm_syncobj_create is renamed to drm_syncobj_create_as_handle, and new
> helpers drm_syncobj_create and drm_syncobj_get_handle are added.
>
> Signed-off-by: Marek Olšák 
> ---
>drivers/gpu/drm/drm_syncobj.c | 49
> +++
>include/drm/drm_syncobj.h |  4 
>2 files changed, 49 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_syncobj.c
> b/drivers/gpu/drm/drm_syncobj.c
> index 0422b8c..0bb1741 100644
> --- a/drivers/gpu/drm/drm_syncobj.c
> +++ b/drivers/gpu/drm/drm_syncobj.c
> @@ -262,8 +262,14 @@ void drm_syncobj_free(struct kref *kref)
>}
>EXPORT_SYMBOL(drm_syncobj_free);
>-static int drm_syncobj_create(struct drm_file *file_private,
> - u32 *handle, uint32_t flags)

 You can add a new parameter for passing dma fence, then in patch3, you
 can
 directly use it for AMDGPU_FENCE_TO HANDLE_GET_SYNCOBJ.

 otherwise the set looks good to me.
>>>
>>> Sorry I just pushed this.
>>
>> Actually, you commented on a deleted line. The function already has
>> dma_fence among the parameters.
>>
>> Marek
>
>
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/tve200: Check for IS_ERR instead of NULL in probe

2017-09-30 Thread Linus Walleij
On Mon, Sep 25, 2017 at 12:25 PM, Dan Carpenter
 wrote:

> devm_ioremap_resource() returns error pointer, it never returns NULL on
> error.
>
> Fixes: 179c02fe90a4 ("drm/tve200: Add new driver for TVE200")
> Signed-off-by: Dan Carpenter 

Patch applied.

Yours,
Linus Walleij
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm: of: always initialize panel in drm_of_find_panel_or_bridge()

2017-09-30 Thread Linus Walleij
On Mon, Sep 25, 2017 at 12:30 PM, Dan Carpenter
 wrote:

> The callers expect "panel" to be initialized, but that isn't true if we
> return -ENODEV.  It causes bugs like:
>
> drivers/gpu/drm/tve200/tve200_drv.c:83 tve200_modeset_init()
> error: uninitialized symbol 'panel'.
>
> Signed-off-by: Dan Carpenter 

Patch applied.

Yours,
Linus Walleij
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 103047] lighting render issue in i915

2017-09-30 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=103047

--- Comment #2 from Steven Noonan  ---
I've also uploaded apitrace-generated images from the two replays:

https://www.uplinklabs.net/files/mesa-pr103047/

The "good" folder is rendered with LIBGL_ALWAYS_SOFTWARE=1, and the "bad"
folder is rendered without. And of course the "diff" folder is from "apitrace
diff-images"

A few examples:

https://www.uplinklabs.net/files/mesa-pr103047/diff/0005113532.diff.png
https://www.uplinklabs.net/files/mesa-pr103047/diff/0005136883.diff.png
https://www.uplinklabs.net/files/mesa-pr103047/diff/0005159887.diff.png
https://www.uplinklabs.net/files/mesa-pr103047/diff/0005182641.diff.png
https://www.uplinklabs.net/files/mesa-pr103047/diff/0005205499.diff.png

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 103047] lighting render issue in i915

2017-09-30 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=103047

Steven Noonan  changed:

   What|Removed |Added

Version|unspecified |17.2

--- Comment #1 from Steven Noonan  ---
Whoops, fat-fingered submit button before I filled this in. Sorry.

Mesa version is 17.2.1

If I play this trace on an i915 Skylake system, the lighting on the landscape
is flickery and weird when the camera moves. If I export
LIBGL_ALWAYS_SOFTWARE=1 and play the trace, everything renders as it should.

Here's the apitrace output:

https://www.uplinklabs.net/files/darwinia-trace.log.gz

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 103047] lighting render issue in i915

2017-09-30 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=103047

Steven Noonan  changed:

   What|Removed |Added

 OS|All |Linux (All)
   Hardware|Other   |x86-64 (AMD64)

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v6 1/2] drm/tinydrm: Move tinydrm_of_find_backlight into drm_of.c

2017-09-30 Thread Noralf Trønnes


Den 30.09.2017 19.12, skrev Meghana Madhyastha:

Rename tinydrm_of_find_backlight to drm_of_find_backlight
and move it into drm_of.c from tinydrm-helpers.c. This is
because other drivers in the drm subsystem might need to call
this function. In that case and otherwise, it is better from
an organizational point of view to move it into drm_of.c along
with the other _of.c functions.

Signed-off-by: Meghana Madhyastha 
---
Changes in v6:
-Move function declarations to linux/backlight.h to resolve
  module dependency issues.

  drivers/gpu/drm/drm_of.c   | 44 ++
  drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c | 40 ---
  drivers/gpu/drm/tinydrm/mi0283qt.c |  2 +-
  include/drm/tinydrm/tinydrm-helpers.h  |  1 -
  include/linux/backlight.h  | 11 +++
  5 files changed, 56 insertions(+), 42 deletions(-)

diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index 8dafbdf..d878d3a 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -1,6 +1,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -260,3 +261,46 @@ int drm_of_find_panel_or_bridge(const struct device_node 
*np,
return ret;
  }
  EXPORT_SYMBOL_GPL(drm_of_find_panel_or_bridge);
+
+/**
+ * drm_of_find_backlight - Find backlight device in device-tree
+ * @dev: Device
+ *
+ * This function looks for a DT node pointed to by a property named 'backlight'
+ * and uses of_find_backlight_by_node() to get the backlight device.
+ * Additionally if the brightness property is zero, it is set to
+ * max_brightness.
+ *
+ * Note: It is the responsibility of the caller to call put_device() when
+ * releasing the resource.
+ *
+ * Returns:
+ * NULL if there's no backlight property.
+ * Error pointer -EPROBE_DEFER if the DT node is found, but no backlight device
+ * is found.
+ * If the backlight device is found, a pointer to the structure is returned.
+ */
+struct backlight_device *drm_of_find_backlight(struct device *dev)
+{
+   struct backlight_device *backlight;
+   struct device_node *np;
+
+   np = of_parse_phandle(dev->of_node, "backlight", 0);
+   if (!np)
+   return NULL;
+
+   backlight = of_find_backlight_by_node(np);
+   of_node_put(np);
+
+   if (!backlight)
+   return ERR_PTR(-EPROBE_DEFER);
+
+   if (!backlight->props.brightness) {
+   backlight->props.brightness = backlight->props.max_brightness;
+   DRM_DEBUG_KMS("Backlight brightness set to %d\n",
+ backlight->props.brightness);
+   }
+
+   return backlight;
+}
+EXPORT_SYMBOL(drm_of_find_backlight);
diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c 
b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
index bd6cce0..cd4c6a5 100644
--- a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
+++ b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
@@ -237,46 +237,6 @@ void tinydrm_xrgb_to_gray8(u8 *dst, void *vaddr, 
struct drm_framebuffer *fb,
  EXPORT_SYMBOL(tinydrm_xrgb_to_gray8);
  
  /**

- * tinydrm_of_find_backlight - Find backlight device in device-tree
- * @dev: Device
- *
- * This function looks for a DT node pointed to by a property named 'backlight'
- * and uses of_find_backlight_by_node() to get the backlight device.
- * Additionally if the brightness property is zero, it is set to
- * max_brightness.
- *
- * Returns:
- * NULL if there's no backlight property.
- * Error pointer -EPROBE_DEFER if the DT node is found, but no backlight device
- * is found.
- * If the backlight device is found, a pointer to the structure is returned.
- */
-struct backlight_device *tinydrm_of_find_backlight(struct device *dev)
-{
-   struct backlight_device *backlight;
-   struct device_node *np;
-
-   np = of_parse_phandle(dev->of_node, "backlight", 0);
-   if (!np)
-   return NULL;
-
-   backlight = of_find_backlight_by_node(np);
-   of_node_put(np);
-
-   if (!backlight)
-   return ERR_PTR(-EPROBE_DEFER);
-
-   if (!backlight->props.brightness) {
-   backlight->props.brightness = backlight->props.max_brightness;
-   DRM_DEBUG_KMS("Backlight brightness set to %d\n",
- backlight->props.brightness);
-   }
-
-   return backlight;
-}
-EXPORT_SYMBOL(tinydrm_of_find_backlight);
-
-/**
   * tinydrm_enable_backlight - Enable backlight helper
   * @backlight: Backlight device
   *
diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c 
b/drivers/gpu/drm/tinydrm/mi0283qt.c
index 7e5bb7d..682b4db 100644
--- a/drivers/gpu/drm/tinydrm/mi0283qt.c
+++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
@@ -189,7 +189,7 @@ static int mi0283qt_probe(struct spi_device *spi)
if (IS_ERR(mipi->regulator))
return PTR_ERR(mipi->regulator);
  
-	mipi->backlight = tinydrm_of_find_backlight(dev);

[PATCH v6 2/2] drm/tinydrm: Add devres versions of drm_of_find_backlight

2017-09-30 Thread Meghana Madhyastha
Add devm_drm_of_find_backlight and the corresponding release
function because some drivers such as tinydrm use devres versions
of functions for requiring device resources.

Signed-off-by: Meghana Madhyastha 
---
Changes in v6:
- Remove docstring for devm_drm_of_backlight_release because it is
 and internal function.

 drivers/gpu/drm/drm_of.c   | 40 ++
 drivers/gpu/drm/tinydrm/mi0283qt.c |  2 +-
 include/linux/backlight.h  |  7 +++
 3 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index d878d3a..6fb3fe5 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -304,3 +304,43 @@ struct backlight_device *drm_of_find_backlight(struct 
device *dev)
return backlight;
 }
 EXPORT_SYMBOL(drm_of_find_backlight);
+
+static void devm_drm_of_find_backlight_release(void *data)
+{
+   put_device(data);
+}
+
+/**
+ * devm_drm_of_find_backlight - Find backlight device in device-tree
+ * devres version of the function
+ * @dev: Device
+ *
+ * This is the devres version of the function drm_of_find_backlight.
+ * Some drivers use devres versions of functions for
+ * requiring device resources.
+ *
+ * Returns:
+ * NULL if there's no backlight property.
+ * Error pointer -EPROBE_DEFER if the DT node is found, but no backlight device
+ * is found.
+ * If the backlight device is found, a pointer to the structure is returned.
+ */
+struct backlight_device *devm_drm_of_find_backlight(struct device *dev)
+{
+   struct backlight_device *backlight;
+   int ret;
+
+   backlight = drm_of_find_backlight(dev);
+   if (IS_ERR_OR_NULL(backlight))
+   return backlight;
+
+   ret = devm_add_action(dev, devm_drm_of_find_backlight_release,
+ >dev);
+   if (ret) {
+   put_device(>dev);
+   return ERR_PTR(ret);
+   }
+
+   return backlight;
+}
+EXPORT_SYMBOL(devm_drm_of_find_backlight);
diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c 
b/drivers/gpu/drm/tinydrm/mi0283qt.c
index 682b4db..6724e5e 100644
--- a/drivers/gpu/drm/tinydrm/mi0283qt.c
+++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
@@ -189,7 +189,7 @@ static int mi0283qt_probe(struct spi_device *spi)
if (IS_ERR(mipi->regulator))
return PTR_ERR(mipi->regulator);
 
-   mipi->backlight = drm_of_find_backlight(dev);
+   mipi->backlight = devm_drm_of_find_backlight(dev);
if (IS_ERR(mipi->backlight))
return PTR_ERR(mipi->backlight);
 
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 47a095e..f601f15 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -175,12 +175,19 @@ of_find_backlight_by_node(struct device_node *node)
 #if defined(CONFIG_OF) && IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
 struct backlight_device *
 drm_of_find_backlight(struct device *dev);
+devm_drm_of_find_backlight(struct device *dev);
 #else
 static inline struct backlight_device *
 drm_of_find_backlight(struct device *dev)
 {
return NULL;
 }
+
+static inline struct backlight_device *
+devm_drm_of_find_backlight(struct device *dev)
+{
+   return NULL;
+}
 #endif
 
 #endif
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v6 1/2] drm/tinydrm: Move tinydrm_of_find_backlight into drm_of.c

2017-09-30 Thread Meghana Madhyastha
Rename tinydrm_of_find_backlight to drm_of_find_backlight
and move it into drm_of.c from tinydrm-helpers.c. This is
because other drivers in the drm subsystem might need to call
this function. In that case and otherwise, it is better from
an organizational point of view to move it into drm_of.c along
with the other _of.c functions.

Signed-off-by: Meghana Madhyastha 
---
Changes in v6:
-Move function declarations to linux/backlight.h to resolve
 module dependency issues.

 drivers/gpu/drm/drm_of.c   | 44 ++
 drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c | 40 ---
 drivers/gpu/drm/tinydrm/mi0283qt.c |  2 +-
 include/drm/tinydrm/tinydrm-helpers.h  |  1 -
 include/linux/backlight.h  | 11 +++
 5 files changed, 56 insertions(+), 42 deletions(-)

diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index 8dafbdf..d878d3a 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -1,6 +1,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -260,3 +261,46 @@ int drm_of_find_panel_or_bridge(const struct device_node 
*np,
return ret;
 }
 EXPORT_SYMBOL_GPL(drm_of_find_panel_or_bridge);
+
+/**
+ * drm_of_find_backlight - Find backlight device in device-tree
+ * @dev: Device
+ *
+ * This function looks for a DT node pointed to by a property named 'backlight'
+ * and uses of_find_backlight_by_node() to get the backlight device.
+ * Additionally if the brightness property is zero, it is set to
+ * max_brightness.
+ *
+ * Note: It is the responsibility of the caller to call put_device() when
+ * releasing the resource.
+ *
+ * Returns:
+ * NULL if there's no backlight property.
+ * Error pointer -EPROBE_DEFER if the DT node is found, but no backlight device
+ * is found.
+ * If the backlight device is found, a pointer to the structure is returned.
+ */
+struct backlight_device *drm_of_find_backlight(struct device *dev)
+{
+   struct backlight_device *backlight;
+   struct device_node *np;
+
+   np = of_parse_phandle(dev->of_node, "backlight", 0);
+   if (!np)
+   return NULL;
+
+   backlight = of_find_backlight_by_node(np);
+   of_node_put(np);
+
+   if (!backlight)
+   return ERR_PTR(-EPROBE_DEFER);
+
+   if (!backlight->props.brightness) {
+   backlight->props.brightness = backlight->props.max_brightness;
+   DRM_DEBUG_KMS("Backlight brightness set to %d\n",
+ backlight->props.brightness);
+   }
+
+   return backlight;
+}
+EXPORT_SYMBOL(drm_of_find_backlight);
diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c 
b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
index bd6cce0..cd4c6a5 100644
--- a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
+++ b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
@@ -237,46 +237,6 @@ void tinydrm_xrgb_to_gray8(u8 *dst, void *vaddr, 
struct drm_framebuffer *fb,
 EXPORT_SYMBOL(tinydrm_xrgb_to_gray8);
 
 /**
- * tinydrm_of_find_backlight - Find backlight device in device-tree
- * @dev: Device
- *
- * This function looks for a DT node pointed to by a property named 'backlight'
- * and uses of_find_backlight_by_node() to get the backlight device.
- * Additionally if the brightness property is zero, it is set to
- * max_brightness.
- *
- * Returns:
- * NULL if there's no backlight property.
- * Error pointer -EPROBE_DEFER if the DT node is found, but no backlight device
- * is found.
- * If the backlight device is found, a pointer to the structure is returned.
- */
-struct backlight_device *tinydrm_of_find_backlight(struct device *dev)
-{
-   struct backlight_device *backlight;
-   struct device_node *np;
-
-   np = of_parse_phandle(dev->of_node, "backlight", 0);
-   if (!np)
-   return NULL;
-
-   backlight = of_find_backlight_by_node(np);
-   of_node_put(np);
-
-   if (!backlight)
-   return ERR_PTR(-EPROBE_DEFER);
-
-   if (!backlight->props.brightness) {
-   backlight->props.brightness = backlight->props.max_brightness;
-   DRM_DEBUG_KMS("Backlight brightness set to %d\n",
- backlight->props.brightness);
-   }
-
-   return backlight;
-}
-EXPORT_SYMBOL(tinydrm_of_find_backlight);
-
-/**
  * tinydrm_enable_backlight - Enable backlight helper
  * @backlight: Backlight device
  *
diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c 
b/drivers/gpu/drm/tinydrm/mi0283qt.c
index 7e5bb7d..682b4db 100644
--- a/drivers/gpu/drm/tinydrm/mi0283qt.c
+++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
@@ -189,7 +189,7 @@ static int mi0283qt_probe(struct spi_device *spi)
if (IS_ERR(mipi->regulator))
return PTR_ERR(mipi->regulator);
 
-   mipi->backlight = tinydrm_of_find_backlight(dev);
+   mipi->backlight = drm_of_find_backlight(dev);
if 

[PATCH v6 0/2] drm/tinydrm: drm_of_find_backlight helper

2017-09-30 Thread Meghana Madhyastha
Move tinydrm_of_find_backlight to drm_of.c and rename it to
drm_of_find_backlight for better organizational structure. 

Changes in v6:
-Move function declarations to linux/backlight.h to prevent
 build errors for the dependencies issue.
-Remove docs for devm_drm_of_find_backlight_release as it is
 an internal function.

Meghana Madhyastha (2):
  drm/tinydrm: Move tinydrm_of_find_backlight into drm_of.c
  drm/tinydrm: Add devres versions of drm_of_find_backlight

 drivers/gpu/drm/drm_of.c   | 84 ++
 drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c | 40 
 drivers/gpu/drm/tinydrm/mi0283qt.c |  2 +-
 include/drm/tinydrm/tinydrm-helpers.h  |  1 -
 include/linux/backlight.h  | 18 ++
 5 files changed, 103 insertions(+), 42 deletions(-)

-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/3] drm/syncobj: extract two helpers from drm_syncobj_create

2017-09-30 Thread Marek Olšák
The idea sounds good.

Marek

On Sat, Sep 30, 2017 at 3:55 AM, Chunming Zhou  wrote:
> My mean is like the attached, I revert part of yours.
>
> Regards,
>
> David zhou
>
>
>
> On 2017年09月29日 22:15, Marek Olšák wrote:
>>
>> On Fri, Sep 29, 2017 at 4:13 PM, Marek Olšák  wrote:
>>>
>>> On Fri, Sep 29, 2017 at 4:44 AM, Chunming Zhou  wrote:


 On 2017年09月13日 04:42, Marek Olšák wrote:
>
> From: Marek Olšák 
>
> For amdgpu.
>
> drm_syncobj_create is renamed to drm_syncobj_create_as_handle, and new
> helpers drm_syncobj_create and drm_syncobj_get_handle are added.
>
> Signed-off-by: Marek Olšák 
> ---
>drivers/gpu/drm/drm_syncobj.c | 49
> +++
>include/drm/drm_syncobj.h |  4 
>2 files changed, 49 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_syncobj.c
> b/drivers/gpu/drm/drm_syncobj.c
> index 0422b8c..0bb1741 100644
> --- a/drivers/gpu/drm/drm_syncobj.c
> +++ b/drivers/gpu/drm/drm_syncobj.c
> @@ -262,8 +262,14 @@ void drm_syncobj_free(struct kref *kref)
>}
>EXPORT_SYMBOL(drm_syncobj_free);
>-static int drm_syncobj_create(struct drm_file *file_private,
> - u32 *handle, uint32_t flags)

 You can add a new parameter for passing dma fence, then in patch3, you
 can
 directly use it for AMDGPU_FENCE_TO HANDLE_GET_SYNCOBJ.

 otherwise the set looks good to me.
>>>
>>> Sorry I just pushed this.
>>
>> Actually, you commented on a deleted line. The function already has
>> dma_fence among the parameters.
>>
>> Marek
>
>
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 60879] [radeonsi] Tahiti LE: GFX block is not functional, CP is okay

2017-09-30 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=60879

--- Comment #170 from David Verelst  ---
Created attachment 134576
  --> https://bugs.freedesktop.org/attachment.cgi?id=134576=edit
journalctl -k amdgpu with linux-amd-staging-git

Also no luck with AMDGPU. Here's the kernel output for booting with
linux-amd-staging-git 4.12.0-2a69a4b35621, (on Arch Linux, see also
https://aur.archlinux.org/packages.php?ID=442065).

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [RESEND RFC PATCH 0/7] sun8i H3 HDMI glue driver for DW HDMI

2017-09-30 Thread Alexey Kardashevskiy
On 21/09/17 06:01, Jernej Skrabec wrote:
> [added media mailing list due to CEC question]
> 
> This patch series adds a HDMI glue driver for Allwinner H3 SoC. For now, only
> video and CEC functionality is supported. Audio needs more tweaks.
> 
> Series is based on the H3 DE2 patch series available on mailing list:
> http://lists.infradead.org/pipermail/linux-arm-kernel/2017-August/522697.html
> (ignore patches marked with [NOT FOR REVIEW NOW] tag)
> 
> Patch 1 adds support for polling plug detection since custom PHY used here
> doesn't support HPD interrupt.
> 
> Patch 2 enables overflow workaround for v1.32a. This HDMI controller exhibits
> same issues as HDMI controller used in iMX6 SoCs.
> 
> Patch 3 adds CLK_SET_RATE_PARENT to hdmi clock.
> 
> Patch 4 adds dt bindings documentation.
> 
> Patch 5 adds actual H3 HDMI glue driver.
> 
> Patch 6 and 7 add HDMI node to DT and enable it where needed.
> 
> Allwinner used DW HDMI controller in a non standard way:
> - register offsets obfuscation layer, which can fortunately be turned off
> - register read lock, which has to be disabled by magic number
> - custom PHY, which have to be initialized before DW HDMI controller
> - non standard clocks
> - no HPD interrupt
> 
> Because of that, I have two questions:
> - Since HPD have to be polled, is it enough just to enable poll mode? I'm
>   mainly concerned about invalidating CEC address here.
> - PHY has to be initialized before DW HDMI controller to disable offset
>   obfuscation and read lock among other things. This means that all clocks 
> have
>   to be enabled in glue driver. This poses a problem, since when using
>   component model, dw-hdmi bridge uses drvdata for it's own private data and
>   prevents glue layer to pass a pointer to unbind function, where clocks 
> should
>   be disabled. I noticed same issue in meson DW HDMI glue driver, where clocks
>   are also not disabled when unbind callback is called. I noticed that when H3
>   SoC is shutdown, HDMI output is still enabled and lastest image is shown on
>   monitor until it is unplugged from power supply. Is there any simple 
> solution
>   to this?
> 
> Chen-Yu,
> TL Lim was unable to obtain any answer from Allwinner about HDMI clocks. I 
> think
> it is safe to assume that divider in HDMI clock doesn't have any effect.
> 
> Branch based on linux-next from 1. September with integrated patches is
> available here:
> https://github.com/jernejsk/linux-1/tree/h3_hdmi_rfc


Out of curiosity I tried this one and got:



[0.071711] sun4i-usb-phy 1c19400.phy: Couldn't request ID GPIO
[0.074809] sun8i-h3-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[0.076167] sun8i-h3-r-pinctrl 1f02c00.pinctrl: initialized sunXi PIO driver
[0.148009] [ cut here ]
[0.148035] WARNING: CPU: 0 PID: 1 at
drivers/clk/sunxi-ng/ccu_common.c:41 ccu_nm_set_rate+0x1d0/0x274
[0.148046] CPU: 0 PID: 1 Comm: swapper/0 Not tainted
4.13.0-rc6-next-20170825-aik-aik #24
[0.148051] Hardware name: Allwinner sun8i Family
[0.148082] [] (unwind_backtrace) from []
(show_stack+0x10/0x14)
[0.148101] [] (show_stack) from []
(dump_stack+0x84/0x98)
[0.148117] [] (dump_stack) from [] (__warn+0xe0/0xfc)
[0.148132] [] (__warn) from []
(warn_slowpath_null+0x20/0x28)
[0.148145] [] (warn_slowpath_null) from []
(ccu_nm_set_rate+0x1d0/0x274)
[0.148161] [] (ccu_nm_set_rate) from []
(clk_change_rate+0x19c/0x250)
[0.148175] [] (clk_change_rate) from []
(clk_core_set_rate_nolock+0x68/0xb0)
[0.148187] [] (clk_core_set_rate_nolock) from []
(clk_set_rate+0x20/0x30)
[0.148202] [] (clk_set_rate) from []
(of_clk_set_defaults+0x200/0x364)
[0.148219] [] (of_clk_set_defaults) from []
(platform_drv_probe+0x18/0xb0)
[0.148233] [] (platform_drv_probe) from []
(driver_probe_device+0x234/0x2e8)
[0.148246] [] (driver_probe_device) from []
(__driver_attach+0xb8/0xbc)
[0.148258] [] (__driver_attach) from [

Re: [PATCH v5 4/4] drm/tinydrm: select BACKLIGHT_LCD_SUPPORT, BACKLIGHT_CLASS_DEVICE

2017-09-30 Thread Noralf Trønnes


Den 30.09.2017 11.10, skrev Meghana Madhyastha:

Add select BACKLIGHT_LCD_SUPPORT, BACKLIGHT_CLASS_DEVICE to
the Kconfig of drm. This is required for the successful build of
drm_of_find_backlight helpers.

Signed-off-by: Meghana Madhyastha 
---
Changes in v5:
-This commit was not present in v4. Selecting BACKLIGHT_LCD_SUPPORT,
BACKLIGHT_CLASS_DEVICE in the Kconfig file under the symbol DRM seems
to fix the Kbuild error drm_of.c:(.text+0x3bc): undefined reference to
`of_find_backlight_by_node'.

  drivers/gpu/drm/Kconfig | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 83cb2a8..3ba5632 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -7,6 +7,8 @@
  menuconfig DRM
tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI 
support)"
depends on (AGP || AGP=n) && !EMULATED_CMPXCHG && HAS_DMA
+   select BACKLIGHT_LCD_SUPPORT
+   select BACKLIGHT_CLASS_DEVICE
select HDMI
select FB_CMDLINE
select I2C


A night's sleep has made this more clear, we don't need 'depends on'
or select as you have tried here, it's enough that we make a change in
the backlight subsystem as I outlined earlier:

include/linux/backlight.h:

-#ifdef CONFIG_OF
+#if defined(CONFIG_OF) && IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
 struct backlight_device *of_find_backlight_by_node(struct device_node 
*node);

 #else
 static inline struct backlight_device *
 of_find_backlight_by_node(struct device_node *node)
 {
 return NULL;
 }
 #endif

Now we don't have to care about backlight being built-in, module or 
disabled.


This patch has to be the first in the patchset. No single patch can 
break anything

even if it's fixed later. This is so people can bisect.

Noralf.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v5 3/4] drm/tinydrm: Add the dummy versions of drm_of_find_backlight functions

2017-09-30 Thread Noralf Trønnes


Den 30.09.2017 11.07, skrev Meghana Madhyastha:

Add the dummy versions (function definition returning -EINVAL) of
drm_of_find_backlight and devm_drm_of_find_backlight in the #else
part of the conditional directive in drm_of.h. This is needed
for drivers where CONFIG_OF is optional.

Signed-off-by: Meghana Madhyastha 
---


You have to fold this into the previous patches, or else someone bisecting
might end up with a broken build.
And you need to return NULL. This shows that you haven't tried building
with CONFIG_OF=n ;-)

Noralf.


Changes in v5:
-Fix the kbuild errors and warnings such as return 0 instead of -EINVAL.

  include/drm/drm_of.h | 13 +
  1 file changed, 13 insertions(+)

diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h
index b2d6e0c..55c9304 100644
--- a/include/drm/drm_of.h
+++ b/include/drm/drm_of.h
@@ -60,6 +60,7 @@ static inline int drm_of_encoder_active_endpoint(struct 
device_node *node,
  {
return -EINVAL;
  }
+
  static inline int drm_of_find_panel_or_bridge(const struct device_node *np,
  int port, int endpoint,
  struct drm_panel **panel,
@@ -67,6 +68,18 @@ static inline int drm_of_find_panel_or_bridge(const struct 
device_node *np,
  {
return -EINVAL;
  }
+
+static inline struct backlight_device *drm_of_find_backlight(
+   struct device *dev)
+{
+   return 0;
+}
+
+static inline struct backlight_device *devm_drm_of_find_backlight(
+   struct device *dev)
+{
+   return 0;
+}
  #endif
  
  static inline int drm_of_encoder_active_endpoint_id(struct device_node *node,


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v5 2/4] drm/tinydrm: Add devres versions of drm_of_find_backlight

2017-09-30 Thread Noralf Trønnes


Den 30.09.2017 11.05, skrev Meghana Madhyastha:

Add devm_drm_of_find_backlight and the corresponding release
function because some drivers such as tinydrm use devres versions
of functions for requiring device resources.

Signed-off-by: Meghana Madhyastha 
---
Changes in v5:
-None

  drivers/gpu/drm/drm_of.c   | 47 ++
  drivers/gpu/drm/tinydrm/mi0283qt.c |  2 +-
  include/drm/drm_of.h   |  1 +
  3 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index d878d3a..cd80dfc 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -304,3 +304,50 @@ struct backlight_device *drm_of_find_backlight(struct 
device *dev)
return backlight;
  }
  EXPORT_SYMBOL(drm_of_find_backlight);
+
+/**
+ * devm_drm_of_find_backlight_release - Release backlight device
+ * @dev: Device
+ *
+ * This is the release function corresponding to the 
devm_drm_of_find_backlight.
+ * Each devres entry is associated with a release function.
+ */


No docs on internal functions.


+static void devm_drm_of_find_backlight_release(void *data)
+{
+   put_device(data);
+}
+
+/**
+ * devm_drm_of_find_backlight - Find backlight device in device-tree
+ * devres version of the function
+ * @dev: Device
+ *
+ * This is the devres version of the function drm_of_find_backlight.
+ * Some drivers use devres versions of functions for
+ * requiring device resources.
+ *
+ * Returns:
+ * NULL if there's no backlight property.
+ * Error pointer -EPROBE_DEFER if the DT node is found, but no backlight device
+ * is found.
+ * If the backlight device is found, a pointer to the structure is returned.
+ */
+struct backlight_device *devm_drm_of_find_backlight(struct device *dev)
+{
+   struct backlight_device *backlight;
+   int ret;
+
+   backlight = drm_of_find_backlight(dev);
+   if (IS_ERR_OR_NULL(backlight))
+   return backlight;
+
+   ret = devm_add_action(dev, devm_drm_of_find_backlight_release,
+ >dev);
+   if (ret) {
+   put_device(>dev);
+   return ERR_PTR(ret);
+   }
+
+   return backlight;
+}
+EXPORT_SYMBOL(devm_drm_of_find_backlight);
diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c 
b/drivers/gpu/drm/tinydrm/mi0283qt.c
index 5e3d635..d37f658 100644
--- a/drivers/gpu/drm/tinydrm/mi0283qt.c
+++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
@@ -190,7 +190,7 @@ static int mi0283qt_probe(struct spi_device *spi)
if (IS_ERR(mipi->regulator))
return PTR_ERR(mipi->regulator);
  
-	mipi->backlight = drm_of_find_backlight(dev);

+   mipi->backlight = devm_drm_of_find_backlight(dev);
if (IS_ERR(mipi->backlight))
return PTR_ERR(mipi->backlight);
  
diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h

index e8fba5b..b2d6e0c 100644
--- a/include/drm/drm_of.h
+++ b/include/drm/drm_of.h
@@ -30,6 +30,7 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,
struct drm_panel **panel,
struct drm_bridge **bridge);
  struct backlight_device *drm_of_find_backlight(struct device *dev);
+struct backlight_device *devm_drm_of_find_backlight(struct device *dev);
  #else
  static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
  struct device_node *port)


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 1/2] drm/tinydrm: Move tinydrm_of_find_backlight into drm_of.c

2017-09-30 Thread Meghana Madhyastha
On Fri, Sep 29, 2017 at 05:41:04PM +0200, Noralf Trønnes wrote:
> 
> Den 29.09.2017 16.13, skrev Meghana Madhyastha:
> >On Fri, Sep 29, 2017 at 02:33:12PM +0200, Noralf Trønnes wrote:
> >>Den 29.09.2017 14.20, skrev Meghana Madhyastha:
> >>>On Fri, Sep 29, 2017 at 02:10:31PM +0200, Noralf Trønnes wrote:
> Den 29.09.2017 05.22, skrev Meghana Madhyastha:
> >On Thu, Sep 28, 2017 at 06:02:27PM +0200, Noralf Trønnes wrote:
> >>Den 28.09.2017 16.08, skrev Daniel Vetter:
> >>>On Thu, Sep 28, 2017 at 02:44:34PM +0530, Meghana Madhyastha wrote:
> Rename tinydrm_of_find_backlight to drm_of_find_backlight
> and move it into drm_of.c from tinydrm-helpers.c. This is
> because other drivers in the drm subsystem might need to call
> this function. In that case and otherwise, it is better from
> an organizational point of view to move it into drm_of.c along
> with the other _of.c functions.
> 
> Signed-off-by: Meghana Madhyastha 
> ---
> Changes in v3:
> -Change it back to a single patch from two patches in v2
> 
>   drivers/gpu/drm/drm_of.c   | 44 
>  ++
>   drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c | 40 
>  ---
>   drivers/gpu/drm/tinydrm/mi0283qt.c |  3 +-
>   include/drm/drm_of.h   |  1 +
>   include/drm/tinydrm/tinydrm-helpers.h  |  1 -
>   5 files changed, 47 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index 8dafbdf..d878d3a 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -1,6 +1,7 @@
>   #include 
>   #include 
>   #include 
> +#include 
>   #include 
>   #include 
>   #include 
> @@ -260,3 +261,46 @@ int drm_of_find_panel_or_bridge(const struct 
> device_node *np,
>   return ret;
>   }
>   EXPORT_SYMBOL_GPL(drm_of_find_panel_or_bridge);
> +
> +/**
> + * drm_of_find_backlight - Find backlight device in device-tree
> + * @dev: Device
> + *
> + * This function looks for a DT node pointed to by a property named 
> 'backlight'
> + * and uses of_find_backlight_by_node() to get the backlight device.
> + * Additionally if the brightness property is zero, it is set to
> + * max_brightness.
> + *
> + * Note: It is the responsibility of the caller to call put_device() 
> when
> + * releasing the resource.
> + *
> + * Returns:
> + * NULL if there's no backlight property.
> + * Error pointer -EPROBE_DEFER if the DT node is found, but no 
> backlight device
> + * is found.
> + * If the backlight device is found, a pointer to the structure is 
> returned.
> + */
> +struct backlight_device *drm_of_find_backlight(struct device *dev)
> +{
> + struct backlight_device *backlight;
> + struct device_node *np;
> +
> + np = of_parse_phandle(dev->of_node, "backlight", 0);
> + if (!np)
> + return NULL;
> +
> + backlight = of_find_backlight_by_node(np);
> + of_node_put(np);
> +
> + if (!backlight)
> + return ERR_PTR(-EPROBE_DEFER);
> +
> + if (!backlight->props.brightness) {
> + backlight->props.brightness = 
> backlight->props.max_brightness;
> + DRM_DEBUG_KMS("Backlight brightness set to %d\n",
> +   backlight->props.brightness);
> + }
> +
> + return backlight;
> +}
> +EXPORT_SYMBOL(drm_of_find_backlight);
> 
> 
> 
> >>Another problem I discovered when trying to compile this, is that if
> >>DRM is builtin and LCD_CLASS_DEVICE is a module:
> >>
> >>drivers/gpu/drm/drm_of.c:292: undefined reference to
> >>`of_find_backlight_by_node'
> >>
> >>I see that I solved this in tinydrm by just selecting
> >>BACKLIGHT_LCD_SUPPORT and LCD_CLASS_DEVICE. I'm not aware of a way to
> >>force LCD_CLASS_DEVICE to be builtin if DRM is builtin.
> >>
> >>Arnd fixed a similar type of dependecy in the repaper driver by forcing
> >>repaper to be a module if necessary. To be honest, I don't know why his
> >>fix works:
> >>https://github.com/torvalds/linux/commit/8312a3fe84b96e30a010fa20f933606d976ac002
> >I didn't quite understand how we could use this fix for the current
> >case. Isn't this specific to the repaper driver dependency ?
> This is the solution Daniel 

[PATCH v5 4/4] drm/tinydrm: select BACKLIGHT_LCD_SUPPORT, BACKLIGHT_CLASS_DEVICE

2017-09-30 Thread Meghana Madhyastha
Add select BACKLIGHT_LCD_SUPPORT, BACKLIGHT_CLASS_DEVICE to
the Kconfig of drm. This is required for the successful build of
drm_of_find_backlight helpers.

Signed-off-by: Meghana Madhyastha 
---
Changes in v5:
-This commit was not present in v4. Selecting BACKLIGHT_LCD_SUPPORT,
BACKLIGHT_CLASS_DEVICE in the Kconfig file under the symbol DRM seems
to fix the Kbuild error drm_of.c:(.text+0x3bc): undefined reference to
`of_find_backlight_by_node'.

 drivers/gpu/drm/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 83cb2a8..3ba5632 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -7,6 +7,8 @@
 menuconfig DRM
tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI 
support)"
depends on (AGP || AGP=n) && !EMULATED_CMPXCHG && HAS_DMA
+   select BACKLIGHT_LCD_SUPPORT
+   select BACKLIGHT_CLASS_DEVICE
select HDMI
select FB_CMDLINE
select I2C
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v5 3/4] drm/tinydrm: Add the dummy versions of drm_of_find_backlight functions

2017-09-30 Thread Meghana Madhyastha
Add the dummy versions (function definition returning -EINVAL) of
drm_of_find_backlight and devm_drm_of_find_backlight in the #else
part of the conditional directive in drm_of.h. This is needed
for drivers where CONFIG_OF is optional.

Signed-off-by: Meghana Madhyastha 
---
Changes in v5:
-Fix the kbuild errors and warnings such as return 0 instead of -EINVAL.

 include/drm/drm_of.h | 13 +
 1 file changed, 13 insertions(+)

diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h
index b2d6e0c..55c9304 100644
--- a/include/drm/drm_of.h
+++ b/include/drm/drm_of.h
@@ -60,6 +60,7 @@ static inline int drm_of_encoder_active_endpoint(struct 
device_node *node,
 {
return -EINVAL;
 }
+
 static inline int drm_of_find_panel_or_bridge(const struct device_node *np,
  int port, int endpoint,
  struct drm_panel **panel,
@@ -67,6 +68,18 @@ static inline int drm_of_find_panel_or_bridge(const struct 
device_node *np,
 {
return -EINVAL;
 }
+
+static inline struct backlight_device *drm_of_find_backlight(
+   struct device *dev)
+{
+   return 0;
+}
+
+static inline struct backlight_device *devm_drm_of_find_backlight(
+   struct device *dev)
+{
+   return 0;
+}
 #endif
 
 static inline int drm_of_encoder_active_endpoint_id(struct device_node *node,
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v5 2/4] drm/tinydrm: Add devres versions of drm_of_find_backlight

2017-09-30 Thread Meghana Madhyastha
Add devm_drm_of_find_backlight and the corresponding release
function because some drivers such as tinydrm use devres versions
of functions for requiring device resources.

Signed-off-by: Meghana Madhyastha 
---
Changes in v5:
-None

 drivers/gpu/drm/drm_of.c   | 47 ++
 drivers/gpu/drm/tinydrm/mi0283qt.c |  2 +-
 include/drm/drm_of.h   |  1 +
 3 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index d878d3a..cd80dfc 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -304,3 +304,50 @@ struct backlight_device *drm_of_find_backlight(struct 
device *dev)
return backlight;
 }
 EXPORT_SYMBOL(drm_of_find_backlight);
+
+/**
+ * devm_drm_of_find_backlight_release - Release backlight device
+ * @dev: Device
+ *
+ * This is the release function corresponding to the 
devm_drm_of_find_backlight.
+ * Each devres entry is associated with a release function.
+ */
+static void devm_drm_of_find_backlight_release(void *data)
+{
+   put_device(data);
+}
+
+/**
+ * devm_drm_of_find_backlight - Find backlight device in device-tree
+ * devres version of the function
+ * @dev: Device
+ *
+ * This is the devres version of the function drm_of_find_backlight.
+ * Some drivers use devres versions of functions for
+ * requiring device resources.
+ *
+ * Returns:
+ * NULL if there's no backlight property.
+ * Error pointer -EPROBE_DEFER if the DT node is found, but no backlight device
+ * is found.
+ * If the backlight device is found, a pointer to the structure is returned.
+ */
+struct backlight_device *devm_drm_of_find_backlight(struct device *dev)
+{
+   struct backlight_device *backlight;
+   int ret;
+
+   backlight = drm_of_find_backlight(dev);
+   if (IS_ERR_OR_NULL(backlight))
+   return backlight;
+
+   ret = devm_add_action(dev, devm_drm_of_find_backlight_release,
+ >dev);
+   if (ret) {
+   put_device(>dev);
+   return ERR_PTR(ret);
+   }
+
+   return backlight;
+}
+EXPORT_SYMBOL(devm_drm_of_find_backlight);
diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c 
b/drivers/gpu/drm/tinydrm/mi0283qt.c
index 5e3d635..d37f658 100644
--- a/drivers/gpu/drm/tinydrm/mi0283qt.c
+++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
@@ -190,7 +190,7 @@ static int mi0283qt_probe(struct spi_device *spi)
if (IS_ERR(mipi->regulator))
return PTR_ERR(mipi->regulator);
 
-   mipi->backlight = drm_of_find_backlight(dev);
+   mipi->backlight = devm_drm_of_find_backlight(dev);
if (IS_ERR(mipi->backlight))
return PTR_ERR(mipi->backlight);
 
diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h
index e8fba5b..b2d6e0c 100644
--- a/include/drm/drm_of.h
+++ b/include/drm/drm_of.h
@@ -30,6 +30,7 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,
struct drm_panel **panel,
struct drm_bridge **bridge);
 struct backlight_device *drm_of_find_backlight(struct device *dev);
+struct backlight_device *devm_drm_of_find_backlight(struct device *dev);
 #else
 static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
  struct device_node *port)
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v5 1/4] drm/tinydrm: Move tinydrm_of_find_backlight into drm_of.c

2017-09-30 Thread Meghana Madhyastha
Rename tinydrm_of_find_backlight to drm_of_find_backlight
and move it into drm_of.c from tinydrm-helpers.c. This is
because other drivers in the drm subsystem might need to call
this function. In that case and otherwise, it is better from
an organizational point of view to move it into drm_of.c along
with the other _of.c functions.

Signed-off-by: Meghana Madhyastha 
---
Changes in v5:
-None

 drivers/gpu/drm/drm_of.c   | 44 ++
 drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c | 40 ---
 drivers/gpu/drm/tinydrm/mi0283qt.c |  3 +-
 include/drm/drm_of.h   |  1 +
 include/drm/tinydrm/tinydrm-helpers.h  |  1 -
 5 files changed, 47 insertions(+), 42 deletions(-)

diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index 8dafbdf..d878d3a 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -1,6 +1,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -260,3 +261,46 @@ int drm_of_find_panel_or_bridge(const struct device_node 
*np,
return ret;
 }
 EXPORT_SYMBOL_GPL(drm_of_find_panel_or_bridge);
+
+/**
+ * drm_of_find_backlight - Find backlight device in device-tree
+ * @dev: Device
+ *
+ * This function looks for a DT node pointed to by a property named 'backlight'
+ * and uses of_find_backlight_by_node() to get the backlight device.
+ * Additionally if the brightness property is zero, it is set to
+ * max_brightness.
+ *
+ * Note: It is the responsibility of the caller to call put_device() when
+ * releasing the resource.
+ *
+ * Returns:
+ * NULL if there's no backlight property.
+ * Error pointer -EPROBE_DEFER if the DT node is found, but no backlight device
+ * is found.
+ * If the backlight device is found, a pointer to the structure is returned.
+ */
+struct backlight_device *drm_of_find_backlight(struct device *dev)
+{
+   struct backlight_device *backlight;
+   struct device_node *np;
+
+   np = of_parse_phandle(dev->of_node, "backlight", 0);
+   if (!np)
+   return NULL;
+
+   backlight = of_find_backlight_by_node(np);
+   of_node_put(np);
+
+   if (!backlight)
+   return ERR_PTR(-EPROBE_DEFER);
+
+   if (!backlight->props.brightness) {
+   backlight->props.brightness = backlight->props.max_brightness;
+   DRM_DEBUG_KMS("Backlight brightness set to %d\n",
+ backlight->props.brightness);
+   }
+
+   return backlight;
+}
+EXPORT_SYMBOL(drm_of_find_backlight);
diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c 
b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
index bd6cce0..cd4c6a5 100644
--- a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
+++ b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
@@ -237,46 +237,6 @@ void tinydrm_xrgb_to_gray8(u8 *dst, void *vaddr, 
struct drm_framebuffer *fb,
 EXPORT_SYMBOL(tinydrm_xrgb_to_gray8);
 
 /**
- * tinydrm_of_find_backlight - Find backlight device in device-tree
- * @dev: Device
- *
- * This function looks for a DT node pointed to by a property named 'backlight'
- * and uses of_find_backlight_by_node() to get the backlight device.
- * Additionally if the brightness property is zero, it is set to
- * max_brightness.
- *
- * Returns:
- * NULL if there's no backlight property.
- * Error pointer -EPROBE_DEFER if the DT node is found, but no backlight device
- * is found.
- * If the backlight device is found, a pointer to the structure is returned.
- */
-struct backlight_device *tinydrm_of_find_backlight(struct device *dev)
-{
-   struct backlight_device *backlight;
-   struct device_node *np;
-
-   np = of_parse_phandle(dev->of_node, "backlight", 0);
-   if (!np)
-   return NULL;
-
-   backlight = of_find_backlight_by_node(np);
-   of_node_put(np);
-
-   if (!backlight)
-   return ERR_PTR(-EPROBE_DEFER);
-
-   if (!backlight->props.brightness) {
-   backlight->props.brightness = backlight->props.max_brightness;
-   DRM_DEBUG_KMS("Backlight brightness set to %d\n",
- backlight->props.brightness);
-   }
-
-   return backlight;
-}
-EXPORT_SYMBOL(tinydrm_of_find_backlight);
-
-/**
  * tinydrm_enable_backlight - Enable backlight helper
  * @backlight: Backlight device
  *
diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c 
b/drivers/gpu/drm/tinydrm/mi0283qt.c
index 7e5bb7d..5e3d635 100644
--- a/drivers/gpu/drm/tinydrm/mi0283qt.c
+++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -189,7 +190,7 @@ static int mi0283qt_probe(struct spi_device *spi)
if (IS_ERR(mipi->regulator))
return PTR_ERR(mipi->regulator);
 
-   mipi->backlight = tinydrm_of_find_backlight(dev);
+   mipi->backlight = drm_of_find_backlight(dev);
  

[PATCH v5 0/4] drm/tinydrm: drm_of_find_backlight helper

2017-09-30 Thread Meghana Madhyastha
This patchset introduces some changes such as move
tinydrm_of_find_backlight to drm_of.c and rename it to
drm_of_find_backlight for better organizational structure.

Changes in v5:
-Fix kbuild errors and warnings

Meghana Madhyastha (4):
  drm/tinydrm: Move tinydrm_of_find_backlight into drm_of.c
  drm/tinydrm: Add devres versions of drm_of_find_backlight
  drm/tinydrm: Add the dummy versions of drm_of_find_backlight functions
  drm/tinydrm: select BACKLIGHT_LCD_SUPPORT, BACKLIGHT_CLASS_DEVICE

 drivers/gpu/drm/Kconfig|  2 +
 drivers/gpu/drm/drm_of.c   | 91 ++
 drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c | 40 ---
 drivers/gpu/drm/tinydrm/mi0283qt.c |  3 +-
 include/drm/drm_of.h   | 15 +
 include/drm/tinydrm/tinydrm-helpers.h  |  1 -
 6 files changed, 110 insertions(+), 42 deletions(-)

-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/2] drm/amdgpu: potential uninitialized variable in amdgpu_vce_ring_parse_cs()

2017-09-30 Thread Christian König

Am 30.09.2017 um 10:13 schrieb Dan Carpenter:

We shifted some code around in commit 9cca0b8e5df0 ("drm/amdgpu: move
amdgpu_cs_sysvm_access_required into find_mapping") and now my static
checker complains that "r" might not be initialized at the end of the
function.  I've reviewed the code, and that seems possible, but it's
also possible I may have missed something.

Signed-off-by: Dan Carpenter 


Good catches, Reviewed-by: Christian König  
for both patches.




diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
index b46280c1279f..2918de2f39ec 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
@@ -648,7 +648,7 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, 
uint32_t ib_idx)
uint32_t allocated = 0;
uint32_t tmp, handle = 0;
uint32_t *size = 
-   int i, r, idx = 0;
+   int i, r = 0, idx = 0;
  
  	p->job->vm = NULL;

ib->gpu_addr = amdgpu_sa_bo_gpu_addr(ib->sa_bo);



___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[RFC 08/11] hack: drm/mediatek: roll back drm_of_find_panel_or_bridge() use

2017-09-30 Thread Ulrich Hecht
Haven't looked into how to do this properly.

Fixes display initialization on the Acer Chromebook R13.

Reverts mediatek part of ebc9446135671b89c2397f438af45d9cef0d1368
("drm: convert drivers to use drm_of_find_panel_or_bridge")

Signed-off-by: Ulrich Hecht 
---
 drivers/gpu/drm/mediatek/mtk_dsi.c | 21 +
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c 
b/drivers/gpu/drm/mediatek/mtk_dsi.c
index 7e5e24c..fd10cc4 100644
--- a/drivers/gpu/drm/mediatek/mtk_dsi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
@@ -1093,6 +1093,7 @@ static int mtk_dsi_probe(struct platform_device *pdev)
 {
struct mtk_dsi *dsi;
struct device *dev = >dev;
+   struct device_node *remote_node, *endpoint;
struct resource *regs;
int irq_num;
int comp_id;
@@ -1105,10 +1106,22 @@ static int mtk_dsi_probe(struct platform_device *pdev)
dsi->host.ops = _dsi_ops;
dsi->host.dev = dev;
 
-   ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0,
- >panel, >bridge);
-   if (ret)
-   return ret;
+   endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
+   if (endpoint) {
+   remote_node = of_graph_get_remote_port_parent(endpoint);
+   if (!remote_node) {
+   dev_err(dev, "No panel connected\n");
+   return -ENODEV;
+   }
+
+   dsi->bridge = of_drm_find_bridge(remote_node);
+   dsi->panel = of_drm_find_panel(remote_node);
+   of_node_put(remote_node);
+   if (!dsi->bridge && !dsi->panel) {
+   dev_info(dev, "Waiting for bridge or panel driver\n");
+   return -EPROBE_DEFER;
+   }
+   }
 
dsi->engine_clk = devm_clk_get(dev, "engine");
if (IS_ERR(dsi->engine_clk)) {
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 0/3] Add support rockchip RGB output interface

2017-09-30 Thread Sandy Huang

Do you  have any suggests for this series of patches?
Or apply to drm-misc-next?

在 2017/9/22 11:00, Sandy Huang 写道:

This patches add support rockchip RGB output, Some Rockchip CRTCs, like rv1108,
can directly output parallel and serial RGB data to panel or to conversion chip.
So we add this driver to probe encoder and connector to support this case.

Sandy Huang (3):
   dt-bindings: Add document for rockchip RGB output interface
   drm/rockchip: Add support for Rockchip Soc RGB output interface
   drm/rockchip: vop: Add more RGB output interface type

  .../bindings/display/rockchip/rockchip-rgb.txt |  78 +
  drivers/gpu/drm/rockchip/Kconfig   |   9 +
  drivers/gpu/drm/rockchip/Makefile  |   1 +
  drivers/gpu/drm/rockchip/rockchip_drm_drv.c|   2 +
  drivers/gpu/drm/rockchip/rockchip_drm_drv.h|   1 +
  drivers/gpu/drm/rockchip/rockchip_drm_vop.h|   2 +
  drivers/gpu/drm/rockchip/rockchip_rgb.c| 343 +
  7 files changed, 436 insertions(+)
  create mode 100644 
Documentation/devicetree/bindings/display/rockchip/rockchip-rgb.txt
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_rgb.c



___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[RFC 10/11] hack: mtk-sd: use old driver from vendor kernel

2017-09-30 Thread Ulrich Hecht
Mainline driver doesn't work on R13, haven't looked into this yet.

Signed-off-by: Ulrich Hecht 
---
 drivers/mmc/host/mtk-sd.c | 465 +++---
 1 file changed, 230 insertions(+), 235 deletions(-)

diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
index 267f7ab..1286256 100644
--- a/drivers/mmc/host/mtk-sd.c
+++ b/drivers/mmc/host/mtk-sd.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -28,7 +29,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
@@ -76,7 +76,6 @@
 #define MSDC_PATCH_BIT1  0xb4
 #define MSDC_PAD_TUNE0xec
 #define PAD_DS_TUNE  0x188
-#define PAD_CMD_TUNE 0x18c
 #define EMMC50_CFG0  0x208
 
 /*--*/
@@ -119,6 +118,7 @@
 #define MSDC_PS_CDSTS   (0x1 << 1) /* R  */
 #define MSDC_PS_CDDEBOUNCE  (0xf << 12)/* RW */
 #define MSDC_PS_DAT (0xff << 16)   /* R  */
+#define MSDC_PS_DATA1   (0x1 << 17)/* R  */
 #define MSDC_PS_CMD (0x1 << 24)/* R  */
 #define MSDC_PS_WP  (0x1 << 31)/* R  */
 
@@ -212,17 +212,13 @@
 #define MSDC_PATCH_BIT_SPCPUSH(0x1 << 29)  /* RW */
 #define MSDC_PATCH_BIT_DECRCTMO   (0x1 << 30)  /* RW */
 
-#define MSDC_PAD_TUNE_DATWRDLY   (0x1f <<  0)  /* RW */
-#define MSDC_PAD_TUNE_DATRRDLY   (0x1f <<  8)  /* RW */
-#define MSDC_PAD_TUNE_CMDRDLY(0x1f << 16)  /* RW */
-#define MSDC_PAD_TUNE_CMDRRDLY   (0x1f << 22)  /* RW */
-#define MSDC_PAD_TUNE_CLKTDLY(0x1f << 27)  /* RW */
-
-#define PAD_DS_TUNE_DLY1 (0x1f << 2)   /* RW */
-#define PAD_DS_TUNE_DLY2 (0x1f << 7)   /* RW */
-#define PAD_DS_TUNE_DLY3 (0x1f << 12)  /* RW */
+#define MSDC_PAD_TUNE_DATRRDLY(0x1f <<  8) /* RW */
+#define MSDC_PAD_TUNE_CMDRDLY (0x1f << 16)  /* RW */
+#define MSDC_PAD_TUNE_CLKTDLY (0x1f << 27)  /* RW */
 
-#define PAD_CMD_TUNE_RX_DLY3 (0x1f << 1)  /* RW */
+#define PAD_DS_TUNE_DLY1  (0x1f << 2)   /* RW */
+#define PAD_DS_TUNE_DLY2  (0x1f << 7)   /* RW */
+#define PAD_DS_TUNE_DLY3  (0x1f << 12)  /* RW */
 
 #define EMMC50_CFG_PADCMD_LATCHCK (0x1 << 0)   /* RW */
 #define EMMC50_CFG_CRCSTS_EDGE(0x1 << 3)   /* RW */
@@ -291,14 +287,12 @@ struct msdc_save_para {
u32 patch_bit0;
u32 patch_bit1;
u32 pad_ds_tune;
-   u32 pad_cmd_tune;
u32 emmc50_cfg0;
 };
 
 struct msdc_tune_para {
u32 iocon;
u32 pad_tune;
-   u32 pad_cmd_tune;
 };
 
 struct msdc_delay_phase {
@@ -313,6 +307,7 @@ struct msdc_host {
int cmd_rsp;
 
spinlock_t lock;
+   spinlock_t irqlock;
struct mmc_request *mrq;
struct mmc_command *cmd;
struct mmc_data *data;
@@ -331,19 +326,18 @@ struct msdc_host {
struct pinctrl_state *pins_uhs;
struct delayed_work req_timeout;
int irq;/* host interrupt */
+   bool irq_thread_alive;
 
struct clk *src_clk;/* msdc source clock */
struct clk *h_clk;  /* msdc h_clk */
u32 mclk;   /* mmc subsystem clock frequency */
u32 src_clk_freq;   /* source clock frequency */
u32 sclk;   /* SD/MS bus clock frequency */
+   bool clock_on;
unsigned char timing;
bool vqmmc_enabled;
u32 hs400_ds_delay;
-   u32 hs200_cmd_int_delay; /* cmd internal delay for HS200/SDR104 */
-   u32 hs400_cmd_int_delay; /* cmd internal delay for HS400 */
-   bool hs400_cmd_resp_sel_rising;
-/* cmd response sample selection for HS400 */
+   u32 sdr104_clk_delay;
bool hs400_mode;/* current eMMC will run at hs400 mode */
struct msdc_save_para save_para; /* used when gate HCLK */
struct msdc_tune_para def_tune_para; /* default tune setting */
@@ -400,6 +394,7 @@ static void msdc_reset_hw(struct msdc_host *host)
 
 static void msdc_cmd_next(struct msdc_host *host,
struct mmc_request *mrq, struct mmc_command *cmd);
+static void msdc_recheck_sdio_irq(struct msdc_host *host);
 
 static const u32 cmd_ints_mask = MSDC_INTEN_CMDRDY | MSDC_INTEN_RSPCRCERR |
MSDC_INTEN_CMDTMO | MSDC_INTEN_ACMDRDY |
@@ -474,9 +469,11 @@ static void msdc_prepare_data(struct msdc_host *host, 
struct mmc_request *mrq)
struct mmc_data *data = mrq->data;
 
if (!(data->host_cookie & MSDC_PREPARE_FLAG)) {
+   bool read = (data->flags & MMC_DATA_READ) != 0;
+
data->host_cookie |= MSDC_PREPARE_FLAG;
data->sg_count = dma_map_sg(host->dev, data->sg, data->sg_len,
-   mmc_get_dma_dir(data));
+  read ? DMA_FROM_DEVICE : 
DMA_TO_DEVICE);
}
 }
 
@@ -488,8 +485,10 @@ static void 

Re: [PATCH v3 1/6] gpu: host1x: Enable Tegra186 syncpoint protection

2017-09-30 Thread Mikko Perttunen

On 09/30/2017 05:41 AM, Dmitry Osipenko wrote:

On 28.09.2017 15:50, Mikko Perttunen wrote:

..
diff --git a/drivers/gpu/host1x/hw/channel_hw.c 
b/drivers/gpu/host1x/hw/channel_hw.c
index 8447a56c41ca..b929d7f1e291 100644
--- a/drivers/gpu/host1x/hw/channel_hw.c
+++ b/drivers/gpu/host1x/hw/channel_hw.c
@@ -147,6 +147,9 @@ static int channel_submit(struct host1x_job *job)
  
  	syncval = host1x_syncpt_incr_max(sp, user_syncpt_incrs);
  
+	/* assign syncpoint to channel */

+   host1x_hw_syncpt_assign_to_channel(host, sp, ch);
+


Since you've preserved the comment, what about to extend it with a brief
explanation of what actually the 'assignment' does? Like that CDMA will stop
execution on touching any syncpoint other then the assigned one.


Whoops, I actually forgot to remove that :) I think the best would be to 
remove the comment here and have a more proper description of the 
feature somewhere else.


Mikko
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [linux-sunxi] Re: [PATCH v3 04/14] drm/sun4i: tcon: Add support for demuxing TCON output on A31

2017-09-30 Thread Julian Calaby
Hi Chen-Yu,

On Fri, Sep 29, 2017 at 8:22 PM, Chen-Yu Tsai  wrote:
> On Fri, Sep 29, 2017 at 6:20 PM, Maxime Ripard
>  wrote:
>> On Fri, Sep 29, 2017 at 08:22:56AM +, Chen-Yu Tsai wrote:
>>> On systems with 2 TCONs such as the A31, it is possible to demux the
>>> output of the TCONs to one encoder.
>>>
>>> Add support for this for the A31.
>>>
>>> Signed-off-by: Chen-Yu Tsai 
>>> ---
>>>  drivers/gpu/drm/sun4i/sun4i_tcon.c | 38 
>>> ++
>>>  1 file changed, 38 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c 
>>> b/drivers/gpu/drm/sun4i/sun4i_tcon.c
>>> index 7bf51abaee97..c949309d4285 100644
>>> --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
>>> +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
>>> @@ -112,6 +112,21 @@ void sun4i_tcon_enable_vblank(struct sun4i_tcon *tcon, 
>>> bool enable)
>>>  }
>>>  EXPORT_SYMBOL(sun4i_tcon_enable_vblank);
>>>
>>> +static struct sun4i_tcon *sun4i_get_first_tcon(struct drm_device *drm)
>>
>> Would that make sense to make it a bit more generic, and pass the id
>> to look for as an argument?
>
> The reason to look for TCON0 explicitly is to access the muxing registers, 
> which
> are only available in TCON0. Other than that, there's nothing else
> shared between
> the two TCONs. So there's no particular reason to look for TCON1 explicitly.

In that case: in the bizarre case where we're trying to use this mux
type and there is no TCON0, shouldn't we fail?

(Also, the code doesn't make sense if we have some TCON1 and TCON2 in
that order as it'll return TCON2)

Thanks,

-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[RFC 06/11] arm64: dts: mediatek: Add Elm Rev. 3 device tree

2017-09-30 Thread Ulrich Hecht
Signed-off-by: Ulrich Hecht 
---
 arch/arm64/boot/dts/mediatek/Makefile|1 +
 arch/arm64/boot/dts/mediatek/mt8173-elm-rev3.dts |   21 +
 arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi |  210 +
 arch/arm64/boot/dts/mediatek/mt8173-oak.dtsi | 1014 ++
 4 files changed, 1246 insertions(+)
 create mode 100644 arch/arm64/boot/dts/mediatek/mt8173-elm-rev3.dts
 create mode 100644 arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi
 create mode 100644 arch/arm64/boot/dts/mediatek/mt8173-oak.dtsi

diff --git a/arch/arm64/boot/dts/mediatek/Makefile 
b/arch/arm64/boot/dts/mediatek/Makefile
index 151723b..0521e29 100644
--- a/arch/arm64/boot/dts/mediatek/Makefile
+++ b/arch/arm64/boot/dts/mediatek/Makefile
@@ -4,6 +4,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += mt6795-evb.dtb
 dtb-$(CONFIG_ARCH_MEDIATEK) += mt6797-evb.dtb
 dtb-$(CONFIG_ARCH_MEDIATEK) += mt7622-rfb1.dtb
 dtb-$(CONFIG_ARCH_MEDIATEK) += mt8173-evb.dtb
+dtb-$(CONFIG_ARCH_MEDIATEK) += mt8173-elm-rev3.dtb
 
 always := $(dtb-y)
 subdir-y   := $(dts-dirs)
diff --git a/arch/arm64/boot/dts/mediatek/mt8173-elm-rev3.dts 
b/arch/arm64/boot/dts/mediatek/mt8173-elm-rev3.dts
new file mode 100644
index 000..68d4095
--- /dev/null
+++ b/arch/arm64/boot/dts/mediatek/mt8173-elm-rev3.dts
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2016 MediaTek Inc.
+ * Author: Eddie Huang 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+/dts-v1/;
+#include "mt8173-elm.dtsi"
+
+/ {
+   model = "Mediatek Elm rev3 board";
+   compatible = "google,elm-rev3", "google,elm", "mediatek,mt8173";
+};
diff --git a/arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi
new file mode 100644
index 000..850037f
--- /dev/null
+++ b/arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi
@@ -0,0 +1,210 @@
+/*
+ * Copyright 2016 MediaTek Inc.
+ * Author: Eddie Huang 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include "mt8173-oak.dtsi"
+
+/ {
+   hdmicon: connector {
+   compatible = "hdmi-connector";
+   label = "hdmi";
+   type = "a";
+
+   port {
+   hdmi_connector_in: endpoint {
+   remote-endpoint = <_mux_out_hdmi>;
+   };
+   };
+   };
+
+   hdmi_mux: hdmi_mux {
+   compatible = "gpio-display-mux";
+   status = "okay";
+   detect-gpios = < 36 GPIO_ACTIVE_HIGH>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_mux_pins>;
+   ddc-i2c-bus = <>;
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 { /* input */
+   reg = <0>;
+
+   hdmi_mux_in: endpoint {
+   remote-endpoint = <_out>;
+   };
+   };
+
+   port@1 { /* output */
+   reg = <1>;
+
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   hdmi_mux_out_anx: endpoint@0 {
+   reg = <0>;
+   remote-endpoint = <_in>;
+   };
+
+   hdmi_mux_out_hdmi: endpoint@1 {
+   reg = <1>;
+   remote-endpoint = <_connector_in>;
+   };
+   };
+   };
+   };
+
+   sound: sound {
+   compatible = "mediatek,mt8173-rt5650";
+   mediatek,audio-codec = < >;
+   mediatek,mclk = <1>;
+   mediatek,platform = <>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_i2s2>;
+   codec-capture {
+   sound-dai = < 1>;
+   };
+   };
+};
+
+_i2s2 {
+   pins1 {
+  

[RFC 01/11] soc: mediatek: MediaTek Command Queue (CMDQ) driver

2017-09-30 Thread Ulrich Hecht
Ported from chromeos-3.18 kernel.

Signed-off-by: Ulrich Hecht 
---
 drivers/soc/mediatek/Kconfig|   10 +
 drivers/soc/mediatek/Makefile   |1 +
 drivers/soc/mediatek/mtk-cmdq.c | 2814 +++
 include/soc/mediatek/cmdq.h |  211 +++
 4 files changed, 3036 insertions(+)
 create mode 100644 drivers/soc/mediatek/mtk-cmdq.c
 create mode 100644 include/soc/mediatek/cmdq.h

diff --git a/drivers/soc/mediatek/Kconfig b/drivers/soc/mediatek/Kconfig
index 609bb34..ef271e0 100644
--- a/drivers/soc/mediatek/Kconfig
+++ b/drivers/soc/mediatek/Kconfig
@@ -1,6 +1,16 @@
 #
 # MediaTek SoC drivers
 #
+config MTK_CMDQ
+   bool "MediaTek CMDQ Support"
+   depends on ARCH_MEDIATEK || COMPILE_TEST
+   select MTK_INFRACFG
+   help
+ Say yes here to add support for the MediaTek Command Queue (CMDQ)
+ driver. The CMDQ is used to help read/write registers with critical
+ time limitation, such as updating display configuration during the
+ vblank.
+
 config MTK_INFRACFG
bool "MediaTek INFRACFG Support"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/soc/mediatek/Makefile b/drivers/soc/mediatek/Makefile
index 12998b0..f7397ef 100644
--- a/drivers/soc/mediatek/Makefile
+++ b/drivers/soc/mediatek/Makefile
@@ -1,3 +1,4 @@
+obj-$(CONFIG_MTK_CMDQ) += mtk-cmdq.o
 obj-$(CONFIG_MTK_INFRACFG) += mtk-infracfg.o
 obj-$(CONFIG_MTK_PMIC_WRAP) += mtk-pmic-wrap.o
 obj-$(CONFIG_MTK_SCPSYS) += mtk-scpsys.o
diff --git a/drivers/soc/mediatek/mtk-cmdq.c b/drivers/soc/mediatek/mtk-cmdq.c
new file mode 100644
index 000..a8bfb5c
--- /dev/null
+++ b/drivers/soc/mediatek/mtk-cmdq.c
@@ -0,0 +1,2814 @@
+/*
+ * Copyright (c) 2015 MediaTek Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * Please calculate this value for each platform.
+ * task number = vblank time / ((task cmds * cmd ticks) / GCE freq)
+ */
+#define CMDQ_MAX_TASK_IN_THREAD70
+
+#define CMDQ_INITIAL_CMD_BLOCK_SIZEPAGE_SIZE
+#define CMDQ_CMD_BUF_POOL_BUF_SIZE PAGE_SIZE
+#define CMDQ_CMD_BUF_POOL_BUF_NUM  140 /* 2 * 70 = 140 */
+#define CMDQ_INST_SIZE 8 /* instruction is 64-bit */
+
+/*
+ * cmdq_thread cookie value is from 0 to CMDQ_MAX_COOKIE_VALUE.
+ * And, this value also be used as MASK.
+ */
+#define CMDQ_MAX_COOKIE_VALUE  0x
+#define CMDQ_COOKIE_MASK   CMDQ_MAX_COOKIE_VALUE
+
+#define CMDQ_DEFAULT_TIMEOUT_MS1000
+#define CMDQ_ACQUIRE_THREAD_TIMEOUT_MS 5000
+#define CMDQ_PREALARM_TIMEOUT_NS   2
+
+#define CMDQ_INVALID_THREAD-1
+
+#define CMDQ_DRIVER_DEVICE_NAME"mtk_cmdq"
+
+#define CMDQ_CLK_NAME  "gce"
+
+#define CMDQ_CURR_IRQ_STATUS_OFFSET0x010
+#define CMDQ_CURR_LOADED_THR_OFFSET0x018
+#define CMDQ_THR_SLOT_CYCLES_OFFSET0x030
+#define CMDQ_THR_EXEC_CYCLES_OFFSET0x034
+#define CMDQ_THR_TIMEOUT_TIMER_OFFSET  0x038
+#define CMDQ_BUS_CONTROL_TYPE_OFFSET   0x040
+
+#define CMDQ_SYNC_TOKEN_ID_OFFSET  0x060
+#define CMDQ_SYNC_TOKEN_VAL_OFFSET 0x064
+#define CMDQ_SYNC_TOKEN_UPD_OFFSET 0x068
+
+#define CMDQ_GPR_SHIFT 0x004
+#define CMDQ_GPR_OFFSET0x080
+
+#define CMDQ_THR_SHIFT 0x080
+#define CMDQ_THR_WARM_RESET_OFFSET 0x100
+#define CMDQ_THR_ENABLE_TASK_OFFSET0x104
+#define CMDQ_THR_SUSPEND_TASK_OFFSET   0x108
+#define CMDQ_THR_CURR_STATUS_OFFSET0x10c
+#define CMDQ_THR_IRQ_STATUS_OFFSET 0x110
+#define CMDQ_THR_IRQ_ENABLE_OFFSET 0x114
+#define CMDQ_THR_CURR_ADDR_OFFSET  0x120
+#define CMDQ_THR_END_ADDR_OFFSET   0x124
+#define CMDQ_THR_EXEC_CNT_OFFSET   0x128
+#define CMDQ_THR_WAIT_TOKEN_OFFSET 0x130
+#define CMDQ_THR_CFG_OFFSET0x140
+#define CMDQ_THR_INST_CYCLES_OFFSET0x150
+#define CMDQ_THR_INST_THRESX_OFFSET0x154
+#define CMDQ_THR_STATUS_OFFSET 0x18c
+
+#define CMDQ_SYNC_TOKEN_SETBIT(16)
+#define CMDQ_IRQ_MASK  0x
+
+#define CMDQ_THR_ENABLED   0x1
+#define CMDQ_THR_DISABLED  0x0
+#define CMDQ_THR_SUSPEND   0x1
+#define CMDQ_THR_RESUME0x0
+#define CMDQ_THR_STATUS_SUSPENDED  BIT(1)
+#define CMDQ_THR_WARM_RESETBIT(0)
+#define CMDQ_THR_SLOT_CYCLES   

Re: [PATCH v3 6/6] drm/tegra: Use u64_to_user_ptr helper

2017-09-30 Thread Dmitry Osipenko
On 28.09.2017 15:50, Mikko Perttunen wrote:
> Use the u64_to_user_ptr helper macro to cast IOCTL argument u64 values
> to user pointers instead of writing out the cast manually. Also do
> some other cleanup with user pointers to make them stand out more
> and look cleaner.
> 
> Signed-off-by: Mikko Perttunen 
> ---

Reviewed-by: Dmitry Osipenko 
Tested-by: Dmitry Osipenko 

>  drivers/gpu/drm/tegra/drm.c | 29 +++--
>  1 file changed, 15 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
> index 130d193192ee..943bdf88c4a2 100644
> --- a/drivers/gpu/drm/tegra/drm.c
> +++ b/drivers/gpu/drm/tegra/drm.c
> @@ -386,12 +386,10 @@ int tegra_drm_submit(struct tegra_drm_context *context,
>   unsigned int num_cmdbufs = args->num_cmdbufs;
>   unsigned int num_relocs = args->num_relocs;
>   unsigned int num_waitchks = args->num_waitchks;
> - struct drm_tegra_cmdbuf __user *cmdbufs =
> - (void __user *)(uintptr_t)args->cmdbufs;
> - struct drm_tegra_reloc __user *relocs =
> - (void __user *)(uintptr_t)args->relocs;
> - struct drm_tegra_waitchk __user *waitchks =
> - (void __user *)(uintptr_t)args->waitchks;
> + struct drm_tegra_cmdbuf __user *user_cmdbufs;
> + struct drm_tegra_reloc __user *user_relocs;
> + struct drm_tegra_waitchk __user *user_waitchks;
> + struct drm_tegra_syncpt __user *user_syncpt;
>   struct drm_tegra_syncpt syncpt;
>   struct host1x *host1x = dev_get_drvdata(drm->dev->parent);
>   struct drm_gem_object **refs;
> @@ -400,6 +398,11 @@ int tegra_drm_submit(struct tegra_drm_context *context,
>   unsigned int num_refs;
>   int err;
>  
> + user_cmdbufs = u64_to_user_ptr(args->cmdbufs);
> + user_relocs = u64_to_user_ptr(args->relocs);
> + user_waitchks = u64_to_user_ptr(args->waitchks);
> + user_syncpt = u64_to_user_ptr(args->syncpts);
> +
>   /* We don't yet support other than one syncpt_incr struct per submit */
>   if (args->num_syncpts != 1)
>   return -EINVAL;
> @@ -440,7 +443,7 @@ int tegra_drm_submit(struct tegra_drm_context *context,
>   struct tegra_bo *obj;
>   u64 offset;
>  
> - if (copy_from_user(, cmdbufs, sizeof(cmdbuf))) {
> + if (copy_from_user(, user_cmdbufs, sizeof(cmdbuf))) {
>   err = -EFAULT;
>   goto fail;
>   }
> @@ -476,7 +479,7 @@ int tegra_drm_submit(struct tegra_drm_context *context,
>  
>   host1x_job_add_gather(job, bo, cmdbuf.words, cmdbuf.offset);
>   num_cmdbufs--;
> - cmdbufs++;
> + user_cmdbufs++;
>   }
>  
>   /* copy and resolve relocations from submit */
> @@ -485,7 +488,7 @@ int tegra_drm_submit(struct tegra_drm_context *context,
>   struct tegra_bo *obj;
>  
>   err = host1x_reloc_copy_from_user(>relocarray[num_relocs],
> -   [num_relocs], drm,
> +   _relocs[num_relocs], drm,
> file);
>   if (err < 0)
>   goto fail;
> @@ -519,9 +522,8 @@ int tegra_drm_submit(struct tegra_drm_context *context,
>   struct host1x_waitchk *wait = >waitchk[num_waitchks];
>   struct tegra_bo *obj;
>  
> - err = host1x_waitchk_copy_from_user(wait,
> - [num_waitchks],
> - file);
> + err = host1x_waitchk_copy_from_user(
> + wait, _waitchks[num_waitchks], file);
>   if (err < 0)
>   goto fail;
>  
> @@ -539,8 +541,7 @@ int tegra_drm_submit(struct tegra_drm_context *context,
>   }
>   }
>  
> - if (copy_from_user(, (void __user *)(uintptr_t)args->syncpts,
> -sizeof(syncpt))) {
> + if (copy_from_user(, user_syncpt, sizeof(syncpt))) {
>   err = -EFAULT;
>   goto fail;
>   }
> 

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 5/7] drm/rockchip: dw_hdmi: add hclk_vio

2017-09-30 Thread Algea Cao
Add clk hclk_vio and enable it when hdmi bind.

Signed-off-by: Algea Cao 
---
 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c 
b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
index 7658b2f..e1a9941 100644
--- a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
@@ -61,6 +61,7 @@ struct rockchip_hdmi {
enum dw_hdmi_devtype dev_type;
struct clk *vpll_clk;
struct clk *grf_clk;
+   struct clk *hclk_vio;
struct phy *phy;
 };
 
@@ -277,12 +278,27 @@ static int rockchip_hdmi_parse_dt(struct rockchip_hdmi 
*hdmi)
return PTR_ERR(hdmi->grf_clk);
}
 
+   hdmi->hclk_vio = devm_clk_get(hdmi->dev, "hclk_vio");
+   if (PTR_ERR(hdmi->hclk_vio) == -ENOENT) {
+   hdmi->hclk_vio = NULL;
+   } else if (PTR_ERR(hdmi->hclk_vio) == -EPROBE_DEFER) {
+   return -EPROBE_DEFER;
+   } else if (IS_ERR(hdmi->hclk_vio)) {
+   dev_dbg(hdmi->dev, "failed to get hclk_vio clock\n");
+   return PTR_ERR(hdmi->hclk_vio);
+   }
ret = clk_prepare_enable(hdmi->vpll_clk);
if (ret) {
dev_err(hdmi->dev, "Failed to enable HDMI vpll: %d\n", ret);
return ret;
}
 
+   ret = clk_prepare_enable(hdmi->hclk_vio);
+   if (ret) {
+   dev_dbg(hdmi->dev, "Failed to eanble HDMI hclk_vio: %d\n",
+   ret);
+   return ret;
+   }
return 0;
 }
 
@@ -506,6 +522,11 @@ static int dw_hdmi_rockchip_bind(struct device *dev, 
struct device *master,
 static void dw_hdmi_rockchip_unbind(struct device *dev, struct device *master,
void *data)
 {
+   struct rockchip_hdmi *hdmi = container_of(, struct rockchip_hdmi,
+ dev);
+
+   clk_disable_unprepare(hdmi->hclk_vio);
+
return dw_hdmi_unbind(dev);
 }
 
-- 
2.7.4


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 0/7] Add support RK3328 drm hdmi

2017-09-30 Thread Algea Cao
These patches add support drm hdmi in RK3328 and has been tested in RK 
development
board. We add dev_type to distinguish different rockchip chips. Hdmi phy or 
some regs
configuration can't be switched according to dev_type, that hdmi driver's 
compatibility
will be better.

Algea Cao (7):
  drm/rockchip: dw_hdmi: update dw_hdmi_rockchip_dt_ids
  drm/rockchip: dw_hdmi: add device type
  drm: bridge: dw-hdmi: change hdmi phy hpd read function to export
  drm/rockchip: dw_hdmi: add inno hdmi phy ops
  drm/rockchip: dw_hdmi: add hclk_vio
  drm/rockchip: dw_hdmi: update dw-hdmi encoder enable
  drm: bridge: dw-hdmi: get phy ops by device type

 .../bindings/display/rockchip/dw_hdmi-rockchip.txt |   1 +
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c  |  11 +-
 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c| 161 -
 include/drm/bridge/dw_hdmi.h   |  13 +-
 4 files changed, 178 insertions(+), 8 deletions(-)

-- 
2.7.4


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[RFC 09/11] drm/mediatek: add fbdev support

2017-09-30 Thread Ulrich Hecht
Forward-ported from chromeos-3.18 vendor kernel.

Signed-off-by: Ulrich Hecht 
---
 drivers/gpu/drm/mediatek/Makefile|   2 +
 drivers/gpu/drm/mediatek/mtk_drm_drv.c   |   9 ++
 drivers/gpu/drm/mediatek/mtk_drm_drv.h   |   4 +-
 drivers/gpu/drm/mediatek/mtk_drm_fb.c|  13 +++
 drivers/gpu/drm/mediatek/mtk_drm_fb.h|   3 +
 drivers/gpu/drm/mediatek/mtk_drm_fbdev.c | 184 +++
 drivers/gpu/drm/mediatek/mtk_drm_fbdev.h |  32 ++
 7 files changed, 246 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_fbdev.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_fbdev.h

diff --git a/drivers/gpu/drm/mediatek/Makefile 
b/drivers/gpu/drm/mediatek/Makefile
index e37b55a..8306fb5 100644
--- a/drivers/gpu/drm/mediatek/Makefile
+++ b/drivers/gpu/drm/mediatek/Makefile
@@ -12,6 +12,8 @@ mediatek-drm-y := mtk_disp_color.o \
  mtk_mipi_tx.o \
  mtk_dpi.o
 
+mediatek-drm-$(CONFIG_DRM_FBDEV_EMULATION) += mtk_drm_fbdev.o
+
 obj-$(CONFIG_DRM_MEDIATEK) += mediatek-drm.o
 
 mediatek-drm-hdmi-objs := mtk_cec.o \
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c 
b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index 8c92630..a69aa2f 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -30,6 +30,7 @@
 #include "mtk_drm_ddp_comp.h"
 #include "mtk_drm_drv.h"
 #include "mtk_drm_fb.h"
+#include "mtk_drm_fbdev.h"
 #include "mtk_drm_gem.h"
 
 #define DRIVER_NAME "mediatek"
@@ -257,8 +258,15 @@ static int mtk_drm_kms_init(struct drm_device *drm)
drm_kms_helper_poll_init(drm);
drm_mode_config_reset(drm);
 
+   ret = mtk_fbdev_init(drm);
+   if (ret)
+   goto err_kms_helper_poll_fini;
+
return 0;
 
+err_kms_helper_poll_fini:
+   drm_kms_helper_poll_fini(drm);
+// drm_vblank_cleanup(drm);
 err_component_unbind:
component_unbind_all(drm->dev, drm);
 err_config_cleanup:
@@ -269,6 +277,7 @@ static int mtk_drm_kms_init(struct drm_device *drm)
 
 static void mtk_drm_kms_deinit(struct drm_device *drm)
 {
+   mtk_fbdev_fini(drm);
drm_kms_helper_poll_fini(drm);
 
component_unbind_all(drm->dev, drm);
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.h 
b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
index c3378c4..4edc002 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.h
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
@@ -14,6 +14,7 @@
 #ifndef MTK_DRM_DRV_H
 #define MTK_DRM_DRV_H
 
+#include 
 #include 
 #include "mtk_drm_ddp_comp.h"
 
@@ -24,7 +25,6 @@ struct device;
 struct device_node;
 struct drm_crtc;
 struct drm_device;
-struct drm_fb_helper;
 struct drm_property;
 struct regmap;
 
@@ -56,6 +56,8 @@ struct mtk_drm_private {
} commit;
 
struct drm_atomic_state *suspend_state;
+   struct drm_fb_helper fb_helper;
+   struct drm_gem_object *fbdev_bo;
 };
 
 extern struct platform_driver mtk_ddp_driver;
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.c 
b/drivers/gpu/drm/mediatek/mtk_drm_fb.c
index 0d8d506..ac8561d 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_fb.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.c
@@ -96,6 +96,19 @@ static struct mtk_drm_fb *mtk_drm_framebuffer_init(struct 
drm_device *dev,
return mtk_fb;
 }
 
+struct drm_framebuffer *mtk_drm_framebuffer_create(struct drm_device *dev,
+   const struct drm_mode_fb_cmd2 *mode,
+   struct drm_gem_object *obj)
+{
+   struct mtk_drm_fb *mtk_fb;
+
+   mtk_fb = mtk_drm_framebuffer_init(dev, mode, obj);
+   if (IS_ERR(mtk_fb))
+   return ERR_CAST(mtk_fb);
+
+   return _fb->base;
+}
+
 /*
  * Wait for any exclusive fence in fb's gem object's reservation object.
  *
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.h 
b/drivers/gpu/drm/mediatek/mtk_drm_fb.h
index 9b2ae34..9ee1ac2 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_fb.h
+++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.h
@@ -19,5 +19,8 @@ int mtk_fb_wait(struct drm_framebuffer *fb);
 struct drm_framebuffer *mtk_drm_mode_fb_create(struct drm_device *dev,
   struct drm_file *file,
   const struct drm_mode_fb_cmd2 
*cmd);
+struct drm_framebuffer *mtk_drm_framebuffer_create(struct drm_device *dev,
+   const struct drm_mode_fb_cmd2 *mode,
+   struct drm_gem_object *obj);
 
 #endif /* MTK_DRM_FB_H */
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fbdev.c 
b/drivers/gpu/drm/mediatek/mtk_drm_fbdev.c
new file mode 100644
index 000..1e46216
--- /dev/null
+++ b/drivers/gpu/drm/mediatek/mtk_drm_fbdev.c
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2016 MediaTek Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be 

[PATCH v2 1/7] drm/rockchip: dw_hdmi: update dw_hdmi_rockchip_dt_ids

2017-09-30 Thread Algea Cao
Add rk3328-dw-hdmi to support rk3328.

Signed-off-by: Algea Cao 
---
 .../devicetree/bindings/display/rockchip/dw_hdmi-rockchip.txt   | 1 +
 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 6 ++
 2 files changed, 7 insertions(+)

diff --git 
a/Documentation/devicetree/bindings/display/rockchip/dw_hdmi-rockchip.txt 
b/Documentation/devicetree/bindings/display/rockchip/dw_hdmi-rockchip.txt
index adc94fc..8b9649c 100644
--- a/Documentation/devicetree/bindings/display/rockchip/dw_hdmi-rockchip.txt
+++ b/Documentation/devicetree/bindings/display/rockchip/dw_hdmi-rockchip.txt
@@ -14,6 +14,7 @@ Required properties:
 - compatible: should be one of the following:
"rockchip,rk3288-dw-hdmi"
"rockchip,rk3399-dw-hdmi"
+   "rockchip,rk3328-dw-hdmi"
 - reg: See dw_hdmi.txt.
 - reg-io-width: See dw_hdmi.txt. Shall be 4.
 - interrupts: HDMI interrupt number
diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c 
b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
index ccd5d59..719452d 100644
--- a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
@@ -313,6 +313,9 @@ static struct rockchip_hdmi_chip_data rk3399_chip_data = {
.lcdsel_lit = HIWORD_UPDATE(RK3399_HDMI_LCDC_SEL, RK3399_HDMI_LCDC_SEL),
 };
 
+static const struct dw_hdmi_plat_data rk3328_hdmi_drv_data = {
+   .mode_valid = dw_hdmi_rockchip_mode_valid,
+};
 static const struct dw_hdmi_plat_data rk3399_hdmi_drv_data = {
.mode_valid = dw_hdmi_rockchip_mode_valid,
.mpll_cfg   = rockchip_mpll_cfg,
@@ -328,6 +331,9 @@ static const struct of_device_id dw_hdmi_rockchip_dt_ids[] 
= {
{ .compatible = "rockchip,rk3399-dw-hdmi",
  .data = _hdmi_drv_data
},
+   { .compatible = "rockchip,rk3328-dw-hdmi",
+ .data = _hdmi_drv_data
+   },
{},
 };
 MODULE_DEVICE_TABLE(of, dw_hdmi_rockchip_dt_ids);
-- 
2.7.4


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[RFC 04/11] drm/bridge: Parade PS8640 MIPI DSI -> eDP converter driver

2017-09-30 Thread Ulrich Hecht
Ported from chromeos-3.18 kernel.

Signed-off-by: Ulrich Hecht 
---
 drivers/gpu/drm/bridge/Kconfig |   12 +
 drivers/gpu/drm/bridge/Makefile|3 +
 drivers/gpu/drm/bridge/parade-ps8640.c | 1104 
 3 files changed, 1119 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/parade-ps8640.c

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index 966f4eb..a1c0d95 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -26,6 +26,18 @@ config DRM_GENERIC_GPIO_MUX
  is active, reports it as a GPIO, and the driver redirects calls to the
  appropriate downstream bridge (if any).
 
+config DRM_PARADE_PS8640
+   tristate "Parade PS8640 MIPI DSI to eDP Converter"
+   depends on DRM
+   depends on OF
+   select DRM_KMS_HELPER
+   select DRM_MIPI_DSI
+   select DRM_PANEL
+   ---help---
+ Choose this option if you have PS8640 for display
+ The PS8640 is a high-performance and low-power
+ MIPI DSI to eDP converter
+
 config DRM_ANALOGIX_ANX78XX
tristate "Analogix ANX78XX bridge"
select DRM_KMS_HELPER
diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index 2d5652e..6be8a9d 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -1,3 +1,6 @@
+ccflags-y := -Iinclude/drm
+
+obj-$(CONFIG_DRM_PARADE_PS8640) += parade-ps8640.o
 obj-$(CONFIG_DRM_ANALOGIX_ANX78XX) += analogix-anx78xx.o
 obj-$(CONFIG_DRM_GENERIC_GPIO_MUX) += generic-gpio-mux.o
 obj-$(CONFIG_DRM_DUMB_VGA_DAC) += dumb-vga-dac.o
diff --git a/drivers/gpu/drm/bridge/parade-ps8640.c 
b/drivers/gpu/drm/bridge/parade-ps8640.c
new file mode 100644
index 000..8489f6c
--- /dev/null
+++ b/drivers/gpu/drm/bridge/parade-ps8640.c
@@ -0,0 +1,1104 @@
+/*
+ * Copyright (c) 2016 MediaTek Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define PAGE1_VSTART   0x6b
+#define PAGE2_SPI_CFG3 0x82
+#define I2C_TO_SPI_RESET   0x20
+#define PAGE2_ROMADD_BYTE1 0x8e
+#define PAGE2_ROMADD_BYTE2 0x8f
+#define PAGE2_SWSPI_WDATA  0x90
+#define PAGE2_SWSPI_RDATA  0x91
+#define PAGE2_SWSPI_LEN0x92
+#define PAGE2_SWSPI_CTL0x93
+#define TRIGGER_NO_READBACK0x05
+#define TRIGGER_READBACK   0x01
+#define PAGE2_SPI_STATUS   0x9e
+#define SPI_READY  0x0c
+#define PAGE2_GPIO_L   0xa6
+#define PAGE2_GPIO_H   0xa7
+#define PS_GPIO9   BIT(1)
+#define PAGE2_IROM_CTRL0xb0
+#define IROM_ENABLE0xc0
+#define IROM_DISABLE   0x80
+#define PAGE2_SW_RESET 0xbc
+#define SPI_SW_RESET   BIT(7)
+#define MPU_SW_RESET   BIT(6)
+#define PAGE2_ENCTLSPI_WR  0xda
+#define PAGE2_I2C_BYPASS   0xea
+#define I2C_BYPASS_EN  0xd0
+#define PAGE2_MCS_EN   0xf3
+#define MCS_EN BIT(0)
+#define PAGE3_SET_ADD  0xfe
+#define PAGE3_SET_VAL  0xff
+#define VDO_CTL_ADD0x13
+#define VDO_DIS0x18
+#define VDO_EN 0x1c
+#define PAGE4_REV_L0xf0
+#define PAGE4_REV_H0xf1
+#define PAGE4_CHIP_L   0xf2
+#define PAGE4_CHIP_H   0xf3
+
+/* Firmware */
+#define SPI_MAX_RETRY_CNT  8
+#define PS_FW_NAME "ps864x_fw.bin"
+
+#define FW_CHIP_ID_OFFSET  0
+#define FW_VERSION_OFFSET  2
+#define EDID_I2C_ADDR  0x50
+
+#define WRITE_STATUS_REG_CMD   0x01
+#define READ_STATUS_REG_CMD0x05
+#define BUSY   BIT(0)
+#define CLEAR_ALL_PROTECT  0x00
+#define BLK_PROTECT_BITS   0x0c
+#define STATUS_REG_PROTECT BIT(7)
+#define WRITE_ENABLE_CMD   0x06
+#define CHIP_ERASE_CMD 0xc7
+#define MAX_DEVS   0x8
+struct ps8640_info {
+   u8 family_id;
+   u8 variant_id;
+   u16 version;
+};
+
+struct ps8640 {
+   struct drm_connector connector;
+   struct drm_bridge bridge;
+   struct edid *edid;
+   struct mipi_dsi_device dsi;
+   struct i2c_client *page[MAX_DEVS];
+   struct i2c_client *ddc_i2c;
+   struct regulator *v33;
+   struct regulator *v12;
+   struct drm_panel *panel;
+   struct gpio_desc *gpio_rst_n;
+   struct 

[PATCH v2 6/7] drm/rockchip: dw_hdmi: update dw-hdmi encoder enable

2017-09-30 Thread Algea Cao
Writing grf register according to device type.

Signed-off-by: Algea Cao 
---
 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c 
b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
index e1a9941..b9087af 100644
--- a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
@@ -349,9 +349,26 @@ static void dw_hdmi_rockchip_encoder_mode_set(struct 
drm_encoder *encoder,
 static void dw_hdmi_rockchip_encoder_enable(struct drm_encoder *encoder)
 {
struct rockchip_hdmi *hdmi = to_rockchip_hdmi(encoder);
-   u32 val;
+   struct drm_crtc *crtc = encoder->crtc;
+   u32 val, lcdsel_grf_reg, lcdsel_mask;
int ret;
 
+   if (WARN_ON(!crtc || !crtc->state))
+   return;
+
+   switch (hdmi->dev_type) {
+   case RK3288_HDMI:
+   lcdsel_grf_reg = RK3288_GRF_SOC_CON6;
+   lcdsel_mask = RK3288_HDMI_LCDC_SEL;
+   break;
+   case RK3399_HDMI:
+   lcdsel_grf_reg = RK3399_GRF_SOC_CON20;
+   lcdsel_mask = RK3399_HDMI_LCDC_SEL;
+   break;
+   default:
+   return;
+   }
+
ret = drm_of_encoder_active_endpoint_id(hdmi->dev->of_node, encoder);
if (ret)
val = hdmi->chip_data->lcdsel_lit;
-- 
2.7.4


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 3/7] drm: bridge: dw-hdmi: change hdmi phy hpd read function to export

2017-09-30 Thread Algea Cao
Change dw_hdmi_phy_read_hpd from static to export.
inno hdmi phy ops will call this interface to get
hpd status.

Signed-off-by: Algea Cao 
---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 5 +++--
 include/drm/bridge/dw_hdmi.h  | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c 
b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
index bf14214..34eeaf6 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
@@ -1250,12 +1250,13 @@ static void dw_hdmi_phy_disable(struct dw_hdmi *hdmi, 
void *data)
dw_hdmi_phy_power_off(hdmi);
 }
 
-static enum drm_connector_status dw_hdmi_phy_read_hpd(struct dw_hdmi *hdmi,
- void *data)
+enum drm_connector_status dw_hdmi_phy_read_hpd(struct dw_hdmi *hdmi,
+  void *data)
 {
return hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_HPD ?
connector_status_connected : connector_status_disconnected;
 }
+EXPORT_SYMBOL_GPL(dw_hdmi_phy_read_hpd);
 
 static void dw_hdmi_phy_update_hpd(struct dw_hdmi *hdmi, void *data,
   bool force, bool disabled, bool rxsense)
diff --git a/include/drm/bridge/dw_hdmi.h b/include/drm/bridge/dw_hdmi.h
index fdb1f0a..01e4979 100644
--- a/include/drm/bridge/dw_hdmi.h
+++ b/include/drm/bridge/dw_hdmi.h
@@ -161,7 +161,8 @@ int dw_hdmi_bind(struct platform_device *pdev, struct 
drm_encoder *encoder,
 const struct dw_hdmi_plat_data *plat_data);
 
 void dw_hdmi_setup_rx_sense(struct device *dev, bool hpd, bool rx_sense);
-
+enum drm_connector_status dw_hdmi_phy_read_hpd(struct dw_hdmi *hdmi,
+  void *data);
 void dw_hdmi_set_sample_rate(struct dw_hdmi *hdmi, unsigned int rate);
 void dw_hdmi_audio_enable(struct dw_hdmi *hdmi);
 void dw_hdmi_audio_disable(struct dw_hdmi *hdmi);
-- 
2.7.4


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[RFC 11/11] hack: Revert "iommu/io-pgtable: Sanitise map/unmap addresses"

2017-09-30 Thread Ulrich Hecht
This check breaks DRM initialization on Acer Chromebook R13, paddr is above
4GB. Haven't looked into this yet.

This reverts commit 76557391433c77d330cede1a531b358d2f90df66.

Signed-off-by: Ulrich Hecht 
---
 drivers/iommu/io-pgtable-arm-v7s.c | 6 --
 drivers/iommu/io-pgtable-arm.c | 7 ---
 2 files changed, 13 deletions(-)

diff --git a/drivers/iommu/io-pgtable-arm-v7s.c 
b/drivers/iommu/io-pgtable-arm-v7s.c
index d665d0d..af330f5 100644
--- a/drivers/iommu/io-pgtable-arm-v7s.c
+++ b/drivers/iommu/io-pgtable-arm-v7s.c
@@ -479,9 +479,6 @@ static int arm_v7s_map(struct io_pgtable_ops *ops, unsigned 
long iova,
if (!(prot & (IOMMU_READ | IOMMU_WRITE)))
return 0;
 
-   if (WARN_ON(upper_32_bits(iova) || upper_32_bits(paddr)))
-   return -ERANGE;
-
ret = __arm_v7s_map(data, iova, paddr, size, prot, 1, data->pgd);
/*
 * Synchronise all PTE updates for the new mapping before there's
@@ -662,9 +659,6 @@ static int arm_v7s_unmap(struct io_pgtable_ops *ops, 
unsigned long iova,
struct arm_v7s_io_pgtable *data = io_pgtable_ops_to_data(ops);
size_t unmapped;
 
-   if (WARN_ON(upper_32_bits(iova)))
-   return 0;
-
unmapped = __arm_v7s_unmap(data, iova, size, 1, data->pgd);
if (unmapped)
io_pgtable_tlb_sync(>iop);
diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
index e8018a3..b182039 100644
--- a/drivers/iommu/io-pgtable-arm.c
+++ b/drivers/iommu/io-pgtable-arm.c
@@ -452,10 +452,6 @@ static int arm_lpae_map(struct io_pgtable_ops *ops, 
unsigned long iova,
if (!(iommu_prot & (IOMMU_READ | IOMMU_WRITE)))
return 0;
 
-   if (WARN_ON(iova >= (1ULL << data->iop.cfg.ias) ||
-   paddr >= (1ULL << data->iop.cfg.oas)))
-   return -ERANGE;
-
prot = arm_lpae_prot_to_pte(data, iommu_prot);
ret = __arm_lpae_map(data, iova, paddr, size, prot, lvl, ptep);
/*
@@ -614,9 +610,6 @@ static int arm_lpae_unmap(struct io_pgtable_ops *ops, 
unsigned long iova,
arm_lpae_iopte *ptep = data->pgd;
int lvl = ARM_LPAE_START_LVL(data);
 
-   if (WARN_ON(iova >= (1ULL << data->iop.cfg.ias)))
-   return 0;
-
unmapped = __arm_lpae_unmap(data, iova, size, lvl, ptep);
if (unmapped)
io_pgtable_tlb_sync(>iop);
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 4/7] drm/rockchip: dw_hdmi: add inno hdmi phy ops

2017-09-30 Thread Algea Cao
Because some RK chips use inno hdmi phy, such as RK3328, we add
inno hdmi phy ops.

Signed-off-by: Algea Cao 
---
 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 110 +++-
 1 file changed, 107 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c 
b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
index 09c77f9..7658b2f 100644
--- a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
@@ -12,7 +12,7 @@
 #include 
 #include 
 #include 
-
+#include 
 #include 
 #include 
 #include 
@@ -26,6 +26,18 @@
 #define RK3288_HDMI_LCDC_SEL   BIT(4)
 #define RK3399_GRF_SOC_CON20   0x6250
 #define RK3399_HDMI_LCDC_SEL   BIT(6)
+#define RK3328_GRF_SOC_CON20x0408
+#define RK3328_DDC_MASK_EN ((3 << 10) | (3 << (10 + 16)))
+#define RK3328_GRF_SOC_CON30x040c
+#define RK3328_IO_CTRL_BY_HDMI (0xf000 | BIT(13) | BIT(12))
+#define RK3328_GRF_SOC_CON40x0410
+#define RK3328_IO_3V_DOMAIN(7 << (9 + 16))
+#define RK3328_IO_5V_DOMAIN((7 << 9) | (3 << (9 + 16)))
+#define RK3328_HPD_3V  (BIT(8 + 16) | BIT(13 + 16))
+#define RK3228_GRF_SOC_CON20x0408
+#define RK3228_DDC_MASK_EN ((3 << 13) | (3 << (13 + 16)))
+#define RK3228_GRF_SOC_CON60x0418
+#define RK3228_IO_3V_DOMAIN((7 << 4) | (7 << (4 + 16)))
 
 #define HIWORD_UPDATE(val, mask)   (val | (mask) << 16)
 
@@ -49,10 +61,82 @@ struct rockchip_hdmi {
enum dw_hdmi_devtype dev_type;
struct clk *vpll_clk;
struct clk *grf_clk;
+   struct phy *phy;
 };
 
 #define to_rockchip_hdmi(x)container_of(x, struct rockchip_hdmi, x)
 
+static int
+inno_dw_hdmi_phy_init(struct dw_hdmi *dw_hdmi, void *data,
+ struct drm_display_mode *mode)
+{
+   struct rockchip_hdmi *hdmi = (struct rockchip_hdmi *)data;
+
+   return phy_power_on(hdmi->phy);
+}
+
+static void inno_dw_hdmi_phy_disable(struct dw_hdmi *dw_hdmi, void *data)
+{
+   struct rockchip_hdmi *hdmi = (struct rockchip_hdmi *)data;
+
+   phy_power_off(hdmi->phy);
+}
+
+static enum drm_connector_status
+inno_dw_hdmi_phy_read_hpd(struct dw_hdmi *dw_hdmi, void *data)
+{
+   struct rockchip_hdmi *hdmi = (struct rockchip_hdmi *)data;
+   enum drm_connector_status status;
+
+   status = dw_hdmi_phy_read_hpd(dw_hdmi, data);
+
+   if (hdmi->dev_type == RK3228_HDMI)
+   return status;
+
+   if (status == connector_status_connected)
+   regmap_write(hdmi->regmap,
+RK3328_GRF_SOC_CON4,
+RK3328_IO_5V_DOMAIN);
+   else
+   regmap_write(hdmi->regmap,
+RK3328_GRF_SOC_CON4,
+RK3328_IO_3V_DOMAIN);
+   return status;
+}
+
+static int inno_dw_hdmi_init(struct rockchip_hdmi *hdmi)
+{
+   int ret;
+
+   ret = clk_prepare_enable(hdmi->grf_clk);
+   if (ret < 0) {
+   dev_err(hdmi->dev, "failed to enable grfclk %d\n", ret);
+   return -EPROBE_DEFER;
+   }
+   if (hdmi->dev_type == RK3328_HDMI) {
+   /* Map HPD pin to 3V io */
+   regmap_write(hdmi->regmap,
+RK3328_GRF_SOC_CON4,
+RK3328_IO_3V_DOMAIN |
+RK3328_HPD_3V);
+   /* Map ddc pin to 5V io */
+   regmap_write(hdmi->regmap,
+RK3328_GRF_SOC_CON3,
+RK3328_IO_CTRL_BY_HDMI);
+   regmap_write(hdmi->regmap,
+RK3328_GRF_SOC_CON2,
+RK3328_DDC_MASK_EN |
+BIT(18));
+   } else {
+   regmap_write(hdmi->regmap, RK3228_GRF_SOC_CON2,
+RK3228_DDC_MASK_EN);
+   regmap_write(hdmi->regmap, RK3228_GRF_SOC_CON6,
+RK3228_IO_3V_DOMAIN);
+   }
+   clk_disable_unprepare(hdmi->grf_clk);
+   return 0;
+}
+
 static const struct dw_hdmi_mpll_config rockchip_mpll_cfg[] = {
{
2700, {
@@ -294,6 +378,12 @@ static const struct drm_encoder_helper_funcs 
dw_hdmi_rockchip_encoder_helper_fun
.atomic_check = dw_hdmi_rockchip_encoder_atomic_check,
 };
 
+static const struct dw_hdmi_phy_ops inno_dw_hdmi_phy_ops = {
+   .init   = inno_dw_hdmi_phy_init,
+   .disable= inno_dw_hdmi_phy_disable,
+   .read_hpd   = inno_dw_hdmi_phy_read_hpd,
+};
+
 static struct rockchip_hdmi_chip_data rk3288_chip_data = {
.lcdsel_grf_reg = RK3288_GRF_SOC_CON6,
.lcdsel_big = HIWORD_UPDATE(0, RK3288_HDMI_LCDC_SEL),
@@ -317,6 +407,8 @@ static struct rockchip_hdmi_chip_data rk3399_chip_data = {
 
 static const struct dw_hdmi_plat_data rk3328_hdmi_drv_data = {
  

Re: [PATCH v3 4/6] gpu: host1x: Disassemble more instructions

2017-09-30 Thread Dmitry Osipenko
On 28.09.2017 15:50, Mikko Perttunen wrote:
> The disassembler for debug dumps was missing some newer host1x opcodes.
> Add disassembly support for these.
> 
> Signed-off-by: Mikko Perttunen 
> ---

Reviewed-by: Dmitry Osipenko 

And for older Tegra's:

Tested-by: Dmitry Osipenko 


>  drivers/gpu/host1x/hw/debug_hw.c  | 59 
> ---
>  drivers/gpu/host1x/hw/debug_hw_1x01.c |  2 +-
>  drivers/gpu/host1x/hw/debug_hw_1x06.c |  3 +-
>  3 files changed, 58 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/host1x/hw/debug_hw.c 
> b/drivers/gpu/host1x/hw/debug_hw.c
> index 1e67667e308c..989476801f9d 100644
> --- a/drivers/gpu/host1x/hw/debug_hw.c
> +++ b/drivers/gpu/host1x/hw/debug_hw.c
> @@ -30,6 +30,13 @@ enum {
>   HOST1X_OPCODE_IMM   = 0x04,
>   HOST1X_OPCODE_RESTART   = 0x05,
>   HOST1X_OPCODE_GATHER= 0x06,
> + HOST1X_OPCODE_SETSTRMID = 0x07,
> + HOST1X_OPCODE_SETAPPID  = 0x08,
> + HOST1X_OPCODE_SETPYLD   = 0x09,
> + HOST1X_OPCODE_INCR_W= 0x0a,
> + HOST1X_OPCODE_NONINCR_W = 0x0b,
> + HOST1X_OPCODE_GATHER_W  = 0x0c,
> + HOST1X_OPCODE_RESTART_W = 0x0d,
>   HOST1X_OPCODE_EXTEND= 0x0e,
>  };
>  
> @@ -38,11 +45,16 @@ enum {
>   HOST1X_OPCODE_EXTEND_RELEASE_MLOCK  = 0x01,
>  };
>  
> -static unsigned int show_channel_command(struct output *o, u32 val)
> +#define INVALID_PAYLOAD  0x
> +
> +static unsigned int show_channel_command(struct output *o, u32 val,
> +  u32 *payload)
>  {
> - unsigned int mask, subop, num;
> + unsigned int mask, subop, num, opcode;
> +
> + opcode = val >> 28;
>  
> - switch (val >> 28) {
> + switch (opcode) {
>   case HOST1X_OPCODE_SETCLASS:
>   mask = val & 0x3f;
>   if (mask) {
> @@ -97,6 +109,44 @@ static unsigned int show_channel_command(struct output 
> *o, u32 val)
>   val >> 14 & 0x1, val & 0x3fff);
>   return 1;
>  
> +#if HOST1X_HW >= 6
> + case HOST1X_OPCODE_SETSTRMID:
> + host1x_debug_cont(o, "SETSTRMID(offset=%06x)\n",
> +   val & 0x3f);
> + return 0;
> +
> + case HOST1X_OPCODE_SETAPPID:
> + host1x_debug_cont(o, "SETAPPID(appid=%02x)\n", val & 0xff);
> + return 0;
> +
> + case HOST1X_OPCODE_SETPYLD:
> + *payload = val & 0x;
> + host1x_debug_cont(o, "SETPYLD(data=%04x)\n", *payload);
> + return 0;
> +
> + case HOST1X_OPCODE_INCR_W:
> + case HOST1X_OPCODE_NONINCR_W:
> + host1x_debug_cont(o, "%s(offset=%06x, ",
> +   opcode == HOST1X_OPCODE_INCR_W ?
> + "INCR_W" : "NONINCR_W",
> +   val & 0x3f);
> + if (*payload == 0) {
> + host1x_debug_cont(o, "[])\n");
> + return 0;
> + } else if (*payload == INVALID_PAYLOAD) {
> + host1x_debug_cont(o, "unknown)\n");
> + return 0;
> + } else {
> + host1x_debug_cont(o, "[");
> + return *payload;
> + }
> +
> + case HOST1X_OPCODE_GATHER_W:
> + host1x_debug_cont(o, "GATHER_W(count=%04x, addr=[",
> +   val & 0x3fff);
> + return 2;
> +#endif
> +
>   case HOST1X_OPCODE_EXTEND:
>   subop = val >> 24 & 0xf;
>   if (subop == HOST1X_OPCODE_EXTEND_ACQUIRE_MLOCK)
> @@ -122,6 +172,7 @@ static void show_gather(struct output *o, phys_addr_t 
> phys_addr,
>   /* Map dmaget cursor to corresponding mem handle */
>   u32 offset = phys_addr - pin_addr;
>   unsigned int data_count = 0, i;
> + u32 payload = INVALID_PAYLOAD;
>  
>   /*
>* Sometimes we're given different hardware address to the same
> @@ -139,7 +190,7 @@ static void show_gather(struct output *o, phys_addr_t 
> phys_addr,
>  
>   if (!data_count) {
>   host1x_debug_output(o, "%08x: %08x: ", addr, val);
> - data_count = show_channel_command(o, val);
> + data_count = show_channel_command(o, val, );
>   } else {
>   host1x_debug_cont(o, "%08x%s", val,
>   data_count > 1 ? ", " : "])\n");
> diff --git a/drivers/gpu/host1x/hw/debug_hw_1x01.c 
> b/drivers/gpu/host1x/hw/debug_hw_1x01.c
> index 09e1aa7bb5dd..8790d5fd5f20 100644
> --- a/drivers/gpu/host1x/hw/debug_hw_1x01.c
> +++ b/drivers/gpu/host1x/hw/debug_hw_1x01.c
> @@ -112,7 +112,7 @@ static void host1x_debug_show_channel_fifo(struct host1x 
> *host,
>  
>   if (!data_count) {
>   host1x_debug_output(o, "%08x: ", val);
> -

Re: [PATCH v3 1/6] gpu: host1x: Enable Tegra186 syncpoint protection

2017-09-30 Thread Dmitry Osipenko
On 28.09.2017 15:50, Mikko Perttunen wrote:
> Since Tegra186 the Host1x hardware allows syncpoints to be assigned to
> specific channels, preventing any other channels from incrementing
> them.
> 
> Enable this feature where available and assign syncpoints to channels
> when submitting a job. Syncpoints are currently never unassigned from
> channels since that would require extra work and is unnecessary with
> the current channel allocation model.
> 
> Signed-off-by: Mikko Perttunen 
> ---
Reviewed-by: Dmitry Osipenko 

Only one minor comment below.

>  drivers/gpu/host1x/dev.h   | 15 +
>  drivers/gpu/host1x/hw/channel_hw.c |  3 +++
>  drivers/gpu/host1x/hw/syncpt_hw.c  | 46 
> ++
>  drivers/gpu/host1x/syncpt.c|  8 +++
>  4 files changed, 72 insertions(+)
> 
> diff --git a/drivers/gpu/host1x/dev.h b/drivers/gpu/host1x/dev.h
> index def802c0a6bf..502769726480 100644
> --- a/drivers/gpu/host1x/dev.h
> +++ b/drivers/gpu/host1x/dev.h
> @@ -79,6 +79,9 @@ struct host1x_syncpt_ops {
>   u32 (*load)(struct host1x_syncpt *syncpt);
>   int (*cpu_incr)(struct host1x_syncpt *syncpt);
>   int (*patch_wait)(struct host1x_syncpt *syncpt, void *patch_addr);
> + void (*assign_to_channel)(struct host1x_syncpt *syncpt,
> +   struct host1x_channel *channel);
> + void (*enable_protection)(struct host1x *host);
>  };
>  
>  struct host1x_intr_ops {
> @@ -186,6 +189,18 @@ static inline int host1x_hw_syncpt_patch_wait(struct 
> host1x *host,
>   return host->syncpt_op->patch_wait(sp, patch_addr);
>  }
>  
> +static inline void host1x_hw_syncpt_assign_to_channel(
> + struct host1x *host, struct host1x_syncpt *sp,
> + struct host1x_channel *ch)
> +{
> + return host->syncpt_op->assign_to_channel(sp, ch);
> +}
> +
> +static inline void host1x_hw_syncpt_enable_protection(struct host1x *host)
> +{
> + return host->syncpt_op->enable_protection(host);
> +}
> +
>  static inline int host1x_hw_intr_init_host_sync(struct host1x *host, u32 cpm,
>   void (*syncpt_thresh_work)(struct work_struct *))
>  {
> diff --git a/drivers/gpu/host1x/hw/channel_hw.c 
> b/drivers/gpu/host1x/hw/channel_hw.c
> index 8447a56c41ca..b929d7f1e291 100644
> --- a/drivers/gpu/host1x/hw/channel_hw.c
> +++ b/drivers/gpu/host1x/hw/channel_hw.c
> @@ -147,6 +147,9 @@ static int channel_submit(struct host1x_job *job)
>  
>   syncval = host1x_syncpt_incr_max(sp, user_syncpt_incrs);
>  
> + /* assign syncpoint to channel */
> + host1x_hw_syncpt_assign_to_channel(host, sp, ch);
> +

Since you've preserved the comment, what about to extend it with a brief
explanation of what actually the 'assignment' does? Like that CDMA will stop
execution on touching any syncpoint other then the assigned one.

>   job->syncpt_end = syncval;
>  
>   /* add a setclass for modules that require it */
> diff --git a/drivers/gpu/host1x/hw/syncpt_hw.c 
> b/drivers/gpu/host1x/hw/syncpt_hw.c
> index 7b0270d60742..7dfd47d74f89 100644
> --- a/drivers/gpu/host1x/hw/syncpt_hw.c
> +++ b/drivers/gpu/host1x/hw/syncpt_hw.c
> @@ -106,6 +106,50 @@ static int syncpt_patch_wait(struct host1x_syncpt *sp, 
> void *patch_addr)
>   return 0;
>  }
>  
> +/**
> + * syncpt_assign_to_channel() - Assign syncpoint to channel
> + * @sp: syncpoint
> + * @ch: channel
> + *
> + * On chips with the syncpoint protection feature (Tegra186+), assign @sp to
> + * @ch, preventing other channels from incrementing the syncpoints. If @ch is
> + * NULL, unassigns the syncpoint.
> + *
> + * On older chips, do nothing.
> + */
> +static void syncpt_assign_to_channel(struct host1x_syncpt *sp,
> +   struct host1x_channel *ch)
> +{
> +#if HOST1X_HW >= 6
> + struct host1x *host = sp->host;
> +
> + if (!host->hv_regs)
> + return;
> +
> + host1x_sync_writel(host,
> +HOST1X_SYNC_SYNCPT_CH_APP_CH(ch ? ch->id : 0xff),
> +HOST1X_SYNC_SYNCPT_CH_APP(sp->id));
> +#endif
> +}
> +
> +/**
> + * syncpt_enable_protection() - Enable syncpoint protection
> + * @host: host1x instance
> + *
> + * On chips with the syncpoint protection feature (Tegra186+), enable this
> + * feature. On older chips, do nothing.
> + */
> +static void syncpt_enable_protection(struct host1x *host)
> +{
> +#if HOST1X_HW >= 6
> + if (!host->hv_regs)
> + return;
> +
> + host1x_hypervisor_writel(host, HOST1X_HV_SYNCPT_PROT_EN_CH_EN,
> +  HOST1X_HV_SYNCPT_PROT_EN);
> +#endif
> +}
> +
>  static const struct host1x_syncpt_ops host1x_syncpt_ops = {
>   .restore = syncpt_restore,
>   .restore_wait_base = syncpt_restore_wait_base,
> @@ -113,4 +157,6 @@ static const struct host1x_syncpt_ops host1x_syncpt_ops = 
> {
>   .load = syncpt_load,
>   .cpu_incr = syncpt_cpu_incr,
>   .patch_wait = syncpt_patch_wait,
> 

[PATCH] drm/virtio: Replace instances of reference/unreference with get/put

2017-09-30 Thread Srishti Sharma
Replace reference/unreference with get/put as it is consistent
with the kernel coding style. Done using the following semantic
patch by coccinelle.

@r@
expression e;
@@

-drm_gem_object_unreference_unlocked(e);
+drm_gem_object_put_unlocked(e);

Signed-off-by: Srishti Sharma 
---
 drivers/gpu/drm/virtio/virtgpu_display.c |  4 ++--
 drivers/gpu/drm/virtio/virtgpu_gem.c |  4 ++--
 drivers/gpu/drm/virtio/virtgpu_ioctl.c   | 12 ++--
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c 
b/drivers/gpu/drm/virtio/virtgpu_display.c
index b6d5205..41b0930 100644
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -53,7 +53,7 @@ static void virtio_gpu_user_framebuffer_destroy(struct 
drm_framebuffer *fb)
struct virtio_gpu_framebuffer *virtio_gpu_fb
= to_virtio_gpu_framebuffer(fb);
 
-   drm_gem_object_unreference_unlocked(virtio_gpu_fb->obj);
+   drm_gem_object_put_unlocked(virtio_gpu_fb->obj);
drm_framebuffer_cleanup(fb);
kfree(virtio_gpu_fb);
 }
@@ -327,7 +327,7 @@ virtio_gpu_user_framebuffer_create(struct drm_device *dev,
ret = virtio_gpu_framebuffer_init(dev, virtio_gpu_fb, mode_cmd, obj);
if (ret) {
kfree(virtio_gpu_fb);
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
return NULL;
}
 
diff --git a/drivers/gpu/drm/virtio/virtgpu_gem.c 
b/drivers/gpu/drm/virtio/virtgpu_gem.c
index 72ad7b1..92fb277 100644
--- a/drivers/gpu/drm/virtio/virtgpu_gem.c
+++ b/drivers/gpu/drm/virtio/virtgpu_gem.c
@@ -72,7 +72,7 @@ int virtio_gpu_gem_create(struct drm_file *file,
*obj_p = >gem_base;
 
/* drop reference from allocate - handle holds it now */
-   drm_gem_object_unreference_unlocked(>gem_base);
+   drm_gem_object_put_unlocked(>gem_base);
 
*handle_p = handle;
return 0;
@@ -130,7 +130,7 @@ int virtio_gpu_mode_dumb_mmap(struct drm_file *file_priv,
return -ENOENT;
obj = gem_to_virtio_gpu_obj(gobj);
*offset_p = virtio_gpu_object_mmap_offset(obj);
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return 0;
 }
 
diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c 
b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
index b94bd54..0528edb 100644
--- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
+++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
@@ -86,7 +86,7 @@ static void virtio_gpu_unref_list(struct list_head *head)
bo = buf->bo;
qobj = container_of(bo, struct virtio_gpu_object, tbo);
 
-   drm_gem_object_unreference_unlocked(>gem_base);
+   drm_gem_object_put_unlocked(>gem_base);
}
 }
 
@@ -304,7 +304,7 @@ static int virtio_gpu_resource_create_ioctl(struct 
drm_device *dev, void *data,
}
return ret;
}
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
 
rc->res_handle = res_id; /* similiar to a VM address */
rc->bo_handle = handle;
@@ -341,7 +341,7 @@ static int virtio_gpu_resource_info_ioctl(struct drm_device 
*dev, void *data,
 
ri->size = qobj->gem_base.size;
ri->res_handle = qobj->hw_res_handle;
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return 0;
 }
 
@@ -389,7 +389,7 @@ static int virtio_gpu_transfer_from_host_ioctl(struct 
drm_device *dev,
 out_unres:
virtio_gpu_object_unreserve(qobj);
 out:
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return ret;
 }
 
@@ -439,7 +439,7 @@ static int virtio_gpu_transfer_to_host_ioctl(struct 
drm_device *dev, void *data,
 out_unres:
virtio_gpu_object_unreserve(qobj);
 out:
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return ret;
 }
 
@@ -462,7 +462,7 @@ static int virtio_gpu_wait_ioctl(struct drm_device *dev, 
void *data,
nowait = true;
ret = virtio_gpu_object_wait(qobj, nowait);
 
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return ret;
 }
 
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [linux-sunxi] Re: [PATCH v3 04/14] drm/sun4i: tcon: Add support for demuxing TCON output on A31

2017-09-30 Thread Julian Calaby
Hi Chen-Yu,

On Sat, Sep 30, 2017 at 3:58 PM, Chen-Yu Tsai  wrote:
> On Sat, Sep 30, 2017 at 1:35 PM, Julian Calaby  
> wrote:
>> Hi Chen-Yu,
>>
>> On Fri, Sep 29, 2017 at 8:22 PM, Chen-Yu Tsai  wrote:
>>> On Fri, Sep 29, 2017 at 6:20 PM, Maxime Ripard
>>>  wrote:
 On Fri, Sep 29, 2017 at 08:22:56AM +, Chen-Yu Tsai wrote:
> On systems with 2 TCONs such as the A31, it is possible to demux the
> output of the TCONs to one encoder.
>
> Add support for this for the A31.
>
> Signed-off-by: Chen-Yu Tsai 
> ---
>  drivers/gpu/drm/sun4i/sun4i_tcon.c | 38 
> ++
>  1 file changed, 38 insertions(+)
>
> diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c 
> b/drivers/gpu/drm/sun4i/sun4i_tcon.c
> index 7bf51abaee97..c949309d4285 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
> @@ -112,6 +112,21 @@ void sun4i_tcon_enable_vblank(struct sun4i_tcon 
> *tcon, bool enable)
>  }
>  EXPORT_SYMBOL(sun4i_tcon_enable_vblank);
>
> +static struct sun4i_tcon *sun4i_get_first_tcon(struct drm_device *drm)

 Would that make sense to make it a bit more generic, and pass the id
 to look for as an argument?
>>>
>>> The reason to look for TCON0 explicitly is to access the muxing registers, 
>>> which
>>> are only available in TCON0. Other than that, there's nothing else
>>> shared between
>>> the two TCONs. So there's no particular reason to look for TCON1 explicitly.
>>
>> In that case: in the bizarre case where we're trying to use this mux
>> type and there is no TCON0, shouldn't we fail?
>
> It gives out a big warning, indicating something is wrong. If TCON0 is not 
> found
> it is most likely your device tree is broken. There's nothing more the
> driver can do.
> Are you suggesting to return NULL in this case, and also do error
> handling in the
> callers?

You're already returning -EINVAL for other failure cases, so a lack of
TCON0 might as well do the same.

>> (Also, the code doesn't make sense if we have some TCON1 and TCON2 in
>> that order as it'll return TCON2)
>
> I'm guessing you want it to return NULL.

I'm just pointing out the mismatch between getting the "first" TCON
and the actual behaviour.

Thanks,

-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[RFC 05/11] drm/bridge: Analogix ANX7688 HDMI -> DP bridge driver

2017-09-30 Thread Ulrich Hecht
Ported from chromeos-3.18.

Signed-off-by: Ulrich Hecht 
---
 drivers/gpu/drm/bridge/Kconfig|   9 ++
 drivers/gpu/drm/bridge/Makefile   |   1 +
 drivers/gpu/drm/bridge/analogix-anx7688.c | 233 ++
 3 files changed, 243 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/analogix-anx7688.c

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index a1c0d95..712ac0a 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -38,6 +38,15 @@ config DRM_PARADE_PS8640
  The PS8640 is a high-performance and low-power
  MIPI DSI to eDP converter
 
+config DRM_ANALOGIX_ANX7688
+   tristate "Analogix ANX7688 bridge"
+   depends on DRM
+   select DRM_KMS_HELPER
+   ---help---
+ ANX7688 is a transmitter to support DisplayPort over USB-C for
+ smartphone and tablets.
+ This driver only supports the HDMI to DP component of the chip.
+
 config DRM_ANALOGIX_ANX78XX
tristate "Analogix ANX78XX bridge"
select DRM_KMS_HELPER
diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index 6be8a9d..9cbf788 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -1,6 +1,7 @@
 ccflags-y := -Iinclude/drm
 
 obj-$(CONFIG_DRM_PARADE_PS8640) += parade-ps8640.o
+obj-$(CONFIG_DRM_ANALOGIX_ANX7688) += analogix-anx7688.o
 obj-$(CONFIG_DRM_ANALOGIX_ANX78XX) += analogix-anx78xx.o
 obj-$(CONFIG_DRM_GENERIC_GPIO_MUX) += generic-gpio-mux.o
 obj-$(CONFIG_DRM_DUMB_VGA_DAC) += dumb-vga-dac.o
diff --git a/drivers/gpu/drm/bridge/analogix-anx7688.c 
b/drivers/gpu/drm/bridge/analogix-anx7688.c
new file mode 100644
index 000..cc995c8
--- /dev/null
+++ b/drivers/gpu/drm/bridge/analogix-anx7688.c
@@ -0,0 +1,233 @@
+/*
+ * ANX7688 HDMI->DP bridge driver
+ *
+ * Copyright (C) 2016 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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 
+
+/* Register addresses */
+#define VENDOR_ID_REG 0x00
+#define DEVICE_ID_REG 0x02
+
+#define FW_VERSION_REG 0x80
+
+#define DP_BANDWIDTH_REG 0x85
+#define DP_LANE_COUNT_REG 0x86
+
+#define VENDOR_ID 0x1f29
+#define DEVICE_ID 0x7688
+
+/* First supported firmware version (0.85) */
+#define MINIMUM_FW_VERSION 0x0085
+
+struct anx7688 {
+   struct drm_bridge bridge;
+   struct i2c_client *client;
+
+   bool filter;
+};
+
+static int anx7688_read(struct i2c_client *client, u8 reg, u8 *data,
+   u16 data_len)
+{
+   int ret;
+   struct i2c_msg msgs[] = {
+   {
+.addr = client->addr,
+.flags = 0,
+.len = 1,
+.buf = ,
+},
+   {
+.addr = client->addr,
+.flags = I2C_M_RD,
+.len = data_len,
+.buf = data,
+}
+   };
+
+   ret = i2c_transfer(client->adapter, msgs, 2);
+
+   if (ret == 2)
+   return 0;
+   if (ret < 0)
+   return ret;
+   else
+   return -EIO;
+}
+
+static inline struct anx7688 *bridge_to_anx7688(struct drm_bridge *bridge)
+{
+   return container_of(bridge, struct anx7688, bridge);
+}
+
+static bool anx7688_bridge_mode_fixup(struct drm_bridge *bridge,
+ const struct drm_display_mode *mode,
+ struct drm_display_mode *adjusted_mode)
+{
+   struct anx7688 *anx7688 = bridge_to_anx7688(bridge);
+   u8 regs[2];
+   u8 dpbw, lanecount;
+   int totalbw, requiredbw;
+   int ret;
+
+   if (!anx7688->filter)
+   return true;
+
+   /* Read both regs 0x85 (bandwidth) and 0x86 (lane count). */
+   ret = anx7688_read(anx7688->client, DP_BANDWIDTH_REG, regs, 2);
+   if (ret < 0) {
+   dev_err(>client->dev,
+   "Failed to read bandwidth/lane count\n");
+   return false;
+   }
+   dpbw = regs[0];
+   lanecount = regs[1];
+
+   /* Maximum 0x19 bandwidth (6.75 Gbps Turbo mode), 2 lanes */
+   if (dpbw > 0x19 || lanecount > 2) {
+   dev_err(>client->dev,
+   "Invalid bandwidth/lane count (%02x/%d)\n",
+   dpbw, lanecount);
+   return false;
+   }
+
+   /* Compute available bandwidth (kHz) */
+   totalbw = dpbw * lanecount * 27 * 8 / 10;
+
+   /* Required bandwidth (8 bpc, kHz) */
+  

[RFC 07/11] hack: mediatek: get mmsys to register as both DRM and clock device

2017-09-30 Thread Ulrich Hecht
"mediatek,mt8173-mmsys" is the compatible string for both a clock controller
and a DRM device. The assumption seems to be that all compatible strings
trigger, and that mmsys will be registered as two devices.
This does work in the 3.18 vendor kernel, but it is not what happens in
mainline: only the clock portion is probed.

This hack probes the clocks from mtk_drm_probe(), and has all drivers
that need these clocks defer instead of fail. Fixes DRM initialization
on Acer Chromebook R13.

Signed-off-by: Ulrich Hecht 
---
 drivers/clk/mediatek/clk-mt8173.c  | 4 ++--
 drivers/gpu/drm/mediatek/mtk_dpi.c | 5 +++--
 drivers/gpu/drm/mediatek/mtk_drm_ddp.c | 5 +++--
 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 7 +++
 drivers/gpu/drm/mediatek/mtk_hdmi.c| 5 +++--
 5 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt8173.c 
b/drivers/clk/mediatek/clk-mt8173.c
index 96c292c..9339d2c 100644
--- a/drivers/clk/mediatek/clk-mt8173.c
+++ b/drivers/clk/mediatek/clk-mt8173.c
@@ -1152,7 +1152,7 @@ static void __init mtk_imgsys_init(struct device_node 
*node)
 }
 CLK_OF_DECLARE(mtk_imgsys, "mediatek,mt8173-imgsys", mtk_imgsys_init);
 
-static void __init mtk_mmsys_init(struct device_node *node)
+/*static*/ void /*__init*/ mtk_mmsys_init(struct device_node *node)
 {
struct clk_onecell_data *clk_data;
int r;
@@ -1167,7 +1167,7 @@ static void __init mtk_mmsys_init(struct device_node 
*node)
pr_err("%s(): could not register clock provider: %d\n",
__func__, r);
 }
-CLK_OF_DECLARE(mtk_mmsys, "mediatek,mt8173-mmsys", mtk_mmsys_init);
+//CLK_OF_DECLARE(mtk_mmsys, "mediatek,mt8173-mmsys", mtk_mmsys_init);
 
 static void __init mtk_vdecsys_init(struct device_node *node)
 {
diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c 
b/drivers/gpu/drm/mediatek/mtk_dpi.c
index e80a603..ed999891 100644
--- a/drivers/gpu/drm/mediatek/mtk_dpi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
@@ -682,8 +682,9 @@ static int mtk_dpi_probe(struct platform_device *pdev)
dpi->engine_clk = devm_clk_get(dev, "engine");
if (IS_ERR(dpi->engine_clk)) {
ret = PTR_ERR(dpi->engine_clk);
-   dev_err(dev, "Failed to get engine clock: %d\n", ret);
-   return ret;
+   dev_err(dev, "Failed to get engine clock: %d, deferring\n", 
ret);
+   return -EPROBE_DEFER;
+   //return ret;
}
 
dpi->pixel_clk = devm_clk_get(dev, "pixel");
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c 
b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
index 8130f3d..465ee60 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
@@ -382,8 +382,9 @@ static int mtk_ddp_probe(struct platform_device *pdev)
 
ddp->clk = devm_clk_get(dev, NULL);
if (IS_ERR(ddp->clk)) {
-   dev_err(dev, "Failed to get clock\n");
-   return PTR_ERR(ddp->clk);
+   dev_err(dev, "Failed to get clock, deferring\n");
+   return -EPROBE_DEFER;
+   //return PTR_ERR(ddp->clk);
}
 
regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c 
b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index a2ca90f..8c92630 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -381,6 +381,8 @@ static const struct of_device_id mtk_ddp_comp_dt_ids[] = {
{ }
 };
 
+static int foo = 0;
+void mtk_mmsys_init(struct device_node *node);
 static int mtk_drm_probe(struct platform_device *pdev)
 {
struct device *dev = >dev;
@@ -391,6 +393,11 @@ static int mtk_drm_probe(struct platform_device *pdev)
int ret;
int i;
 
+   if (!foo) {
+   mtk_mmsys_init(dev->of_node);
+   foo = 1;
+   }
+
private = devm_kzalloc(dev, sizeof(*private), GFP_KERNEL);
if (!private)
return -ENOMEM;
diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c 
b/drivers/gpu/drm/mediatek/mtk_hdmi.c
index 690c675..715c0e0 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
@@ -1441,8 +1441,9 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
 
ret = mtk_hdmi_get_all_clk(hdmi, np);
if (ret) {
-   dev_err(dev, "Failed to get clocks: %d\n", ret);
-   return ret;
+   dev_err(dev, "Failed to get clocks: %d, deferring\n", ret);
+   return -EPROBE_DEFER;
+   //return ret;
}
 
/* The CEC module handles HDMI hotplug detection */
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[RFC 03/11] platform/chrome: ChromeOS firmware interface driver

2017-09-30 Thread Ulrich Hecht
Ported from chromeos-3.18 kernel.

Signed-off-by: Ulrich Hecht 
---
 drivers/platform/chrome/Kconfig|  18 +++
 drivers/platform/chrome/Makefile   |   2 +
 drivers/platform/chrome/chromeos.c | 120 +++
 drivers/platform/chrome/chromeos.h |  61 
 drivers/platform/chrome/chromeos_arm.c | 264 +
 drivers/platform/chrome/elog.h | 186 +++
 include/linux/chromeos_platform.h  |  27 
 7 files changed, 678 insertions(+)
 create mode 100644 drivers/platform/chrome/chromeos.c
 create mode 100644 drivers/platform/chrome/chromeos.h
 create mode 100644 drivers/platform/chrome/chromeos_arm.c
 create mode 100644 drivers/platform/chrome/elog.h
 create mode 100644 include/linux/chromeos_platform.h

diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig
index 0ad6e29..f8b1876 100644
--- a/drivers/platform/chrome/Kconfig
+++ b/drivers/platform/chrome/Kconfig
@@ -14,6 +14,24 @@ menuconfig CHROME_PLATFORMS
 
 if CHROME_PLATFORMS
 
+config CHROMEOS
+   bool
+   depends on CHROMEOS_OF_FIRMWARE || (NVRAM && ACPI_CHROMEOS)
+
+   ---help---
+ Provides abstracted interfaces to the firmware features provided on
+ ChromeOS devices. It depends on a lowlevel driver to implement the
+ firmware interface on the platform.
+
+config CHROMEOS_OF_FIRMWARE
+   bool "ChromeOS firmware interface driver"
+   depends on OF
+   select CHROMEOS
+   ---help---
+ This driver provides an interface to ChromeOS firmware.
+
+ Say Y here if you are building for a ChromeOS device.
+
 config CHROMEOS_LAPTOP
tristate "Chrome OS Laptop"
depends on I2C && DMI && X86
diff --git a/drivers/platform/chrome/Makefile b/drivers/platform/chrome/Makefile
index 66c345c..f10a7b6 100644
--- a/drivers/platform/chrome/Makefile
+++ b/drivers/platform/chrome/Makefile
@@ -1,4 +1,6 @@
 
+obj-$(CONFIG_CHROMEOS) += chromeos.o
+obj-$(CONFIG_CHROMEOS_OF_FIRMWARE) += chromeos_arm.o
 obj-$(CONFIG_CHROMEOS_LAPTOP)  += chromeos_laptop.o
 obj-$(CONFIG_CHROMEOS_PSTORE)  += chromeos_pstore.o
 cros_ec_devs-objs  := cros_ec_dev.o cros_ec_sysfs.o \
diff --git a/drivers/platform/chrome/chromeos.c 
b/drivers/platform/chrome/chromeos.c
new file mode 100644
index 000..8b01630
--- /dev/null
+++ b/drivers/platform/chrome/chromeos.c
@@ -0,0 +1,120 @@
+/*
+ *  ChromeOS platform support code. Glue layer between higher level functions
+ *  and per-platform firmware interfaces.
+ *
+ *  Copyright (C) 2010 The Chromium OS Authors
+ *
+ *  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.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include 
+#include 
+#include 
+#include "chromeos.h"
+
+static struct chromeos_vbc *chromeos_vbc_ptr;
+
+static int vbc_read(u8 *buf, int buf_size);
+static int vbc_write_byte(unsigned offset, u8 value);
+
+/* the following defines are copied from
+ * vboot_reference:firmware/lib/vboot_nvstorage.c.
+ */
+#define RECOVERY_OFFSET  2
+#define VBNV_RECOVERY_RW_INVALID_OS  0x43
+
+int chromeos_set_need_recovery(void)
+{
+   if (!chromeos_legacy_set_need_recovery())
+   return 0;
+
+   return vbc_write_byte(RECOVERY_OFFSET, VBNV_RECOVERY_RW_INVALID_OS);
+}
+EXPORT_SYMBOL(chromeos_set_need_recovery);
+
+/*
+ * Lifted from vboot_reference:firmware/lib/vboot_nvstorage.c and formatted.
+ *
+ * Return CRC-8 of the data, using x^8 + x^2 + x + 1 polynomial. A table-based
+ * algorithm would be faster, but for only 15 bytes isn't worth the code size.
+ */
+static u8 crc8(const u8 *data, int len)
+{
+   unsigned crc = 0;
+   int i, j;
+
+   for (j = len; j; j--, data++) {
+   crc ^= (*data << 8);
+   for (i = 8; i; i--) {
+   if (crc & 0x8000)
+   crc ^= (0x1070 << 3);
+   crc <<= 1;
+   }
+   }
+   return (u8)(crc >> 8);
+}
+
+static int vbc_write_byte(unsigned offset, u8 value)
+{
+   u8 buf[MAX_VBOOT_CONTEXT_BUFFER_SIZE];
+   ssize_t size;
+
+   if (!chromeos_vbc_ptr)
+   return -ENOSYS;
+
+   size = vbc_read(buf, sizeof(buf));
+   if (size <= 0)
+   return -EINVAL;
+
+  

[PATCH v2] drm/tinydrm: Replace dev_error with DRM_DEV_ERROR

2017-09-30 Thread Harsha Sharma
Convert instances of dev_error to DRM_DEV_ERROR as we have
DRM_DEV_ERROR variants of drm print macros.

Signed-off-by: Harsha Sharma 
---
Changes in v2:
 -Fix alignment issues

 drivers/gpu/drm/tinydrm/mi0283qt.c |  8 
 drivers/gpu/drm/tinydrm/repaper.c  | 26 +-
 drivers/gpu/drm/tinydrm/st7586.c   |  6 +++---
 3 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c 
b/drivers/gpu/drm/tinydrm/mi0283qt.c
index 7e5bb7d..7dded50 100644
--- a/drivers/gpu/drm/tinydrm/mi0283qt.c
+++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
@@ -31,7 +31,7 @@ static int mi0283qt_init(struct mipi_dbi *mipi)
 
ret = regulator_enable(mipi->regulator);
if (ret) {
-   dev_err(dev, "Failed to enable regulator %d\n", ret);
+   DRM_DEV_ERROR(dev, "Failed to enable regulator %d\n", ret);
return ret;
}
 
@@ -42,7 +42,7 @@ static int mi0283qt_init(struct mipi_dbi *mipi)
mipi_dbi_hw_reset(mipi);
ret = mipi_dbi_command(mipi, MIPI_DCS_SOFT_RESET);
if (ret) {
-   dev_err(dev, "Error sending command %d\n", ret);
+   DRM_DEV_ERROR(dev, "Error sending command %d\n", ret);
regulator_disable(mipi->regulator);
return ret;
}
@@ -175,13 +175,13 @@ static int mi0283qt_probe(struct spi_device *spi)
 
mipi->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(mipi->reset)) {
-   dev_err(dev, "Failed to get gpio 'reset'\n");
+   DRM_DEV_ERROR(dev, "Failed to get gpio 'reset'\n");
return PTR_ERR(mipi->reset);
}
 
dc = devm_gpiod_get_optional(dev, "dc", GPIOD_OUT_LOW);
if (IS_ERR(dc)) {
-   dev_err(dev, "Failed to get gpio 'dc'\n");
+   DRM_DEV_ERROR(dev, "Failed to get gpio 'dc'\n");
return PTR_ERR(dc);
}
 
diff --git a/drivers/gpu/drm/tinydrm/repaper.c 
b/drivers/gpu/drm/tinydrm/repaper.c
index 30dc97b..bd152bb 100644
--- a/drivers/gpu/drm/tinydrm/repaper.c
+++ b/drivers/gpu/drm/tinydrm/repaper.c
@@ -473,7 +473,7 @@ static void repaper_get_temperature(struct repaper_epd *epd)
 
ret = thermal_zone_get_temp(epd->thermal, );
if (ret) {
-   dev_err(>spi->dev, "Failed to get temperature (%d)\n",
+   DRM_DEV_ERROR(>spi->dev, "Failed to get temperature 
(%d)\n", ret);
return;
}
@@ -629,7 +629,7 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb,
mutex_unlock(>dirty_lock);
 
if (ret)
-   dev_err(fb->dev->dev, "Failed to update display (%d)\n", ret);
+   DRM_DEV_ERROR(fb->dev->dev, "Failed to update display (%d)\n", 
ret);
kfree(buf);
 
return ret;
@@ -703,7 +703,7 @@ static void repaper_pipe_enable(struct 
drm_simple_display_pipe *pipe,
}
 
if (!i) {
-   dev_err(dev, "timeout waiting for panel to become ready.\n");
+   DRM_DEV_ERROR(dev, "timeout waiting for panel to become 
ready.\n");
power_off(epd);
return;
}
@@ -725,9 +725,9 @@ static void repaper_pipe_enable(struct 
drm_simple_display_pipe *pipe,
ret = repaper_read_val(spi, 0x0f);
if (ret < 0 || !(ret & 0x80)) {
if (ret < 0)
-   dev_err(dev, "failed to read chip (%d)\n", ret);
+   DRM_DEV_ERROR(dev, "failed to read chip (%d)\n", ret);
else
-   dev_err(dev, "panel is reported broken\n");
+   DRM_DEV_ERROR(dev, "panel is reported broken\n");
power_off(epd);
return;
}
@@ -767,7 +767,7 @@ static void repaper_pipe_enable(struct 
drm_simple_display_pipe *pipe,
/* check DC/DC */
ret = repaper_read_val(spi, 0x0f);
if (ret < 0) {
-   dev_err(dev, "failed to read chip (%d)\n", ret);
+   DRM_DEV_ERROR(dev, "failed to read chip (%d)\n", ret);
power_off(epd);
return;
}
@@ -779,7 +779,7 @@ static void repaper_pipe_enable(struct 
drm_simple_display_pipe *pipe,
}
 
if (!dc_ok) {
-   dev_err(dev, "dc/dc failed\n");
+   DRM_DEV_ERROR(dev, "dc/dc failed\n");
power_off(epd);
return;
}
@@ -959,7 +959,7 @@ static int repaper_probe(struct spi_device *spi)
if (IS_ERR(epd->panel_on)) {
ret = PTR_ERR(epd->panel_on);
if (ret != -EPROBE_DEFER)
-   dev_err(dev, "Failed to get gpio 'panel-on'\n");
+   DRM_DEV_ERROR(dev, "Failed to get gpio 'panel-on'\n");
return ret;
}
 
@@ -967,7 +967,7 @@ static int repaper_probe(struct spi_device *spi)
if 

Re: [PATCHv1 00/14] omapdrm: DSI command mode panel support

2017-09-30 Thread Sebastian Reichel
Hi Tomi & Laurent,

ping?

-- Sebastian

On Mon, Jul 24, 2017 at 07:32:57PM +0200, Sebastian Reichel wrote:
> Hi,
> 
> This adds support for command mode DSI panels to
> omapdrm. I tested the patches on Nokia N950 (omap3)
> and Motorola Droid 4 (omap4). This is basically
> PATCHv3 of my series adding N950 display support,
> but I started from scratch without reverting the
> removal of manual display update support.
> 
> Tested:
>  * Framebuffer Console
>  * Display blanking
>  * kmstest
>  * Xorg with omap and modesetting driver
>  * No updates send when nothing needs to be sent
> 
> Known issues:
>  * Proper display rotation support
>  * N950 (and N9) has first and last few lines
>covered by plastic, so we should expose a
>smaller screen
> 
> I plan to look into these issues once basic support
> has been merged.
> 
> -- Sebastian
> 
> Sebastian Reichel (13):
>   drm/omap: remove unused function defines
>   drm/omap: drop incorrect comment
>   drm/omap: plane: update fifo size on ovl setup
>   drm/omap: add framedone interrupt support
>   drm/omap: add manual update detection helper
>   drm/omap: add support for manually updated displays
>   drm/omap: add support for physical size hints from display drivers
>   drm/omap: panel-dsi-cm: add regulator support
>   drm/omap: panel-dsi-cm: add physical size support
>   drm/omap: panel-dsi-cm: add external backlight support
>   drm/omap: panel-dsi-cm: switch to gpiod
>   ARM: dts: omap4-droid4: improve LCD description
>   ARM: dts: n950: add display support
> 
> Tony Lindgren (1):
>   drm/omap: panel-dsi-cm: fix driver
> 
>  arch/arm/boot/dts/omap3-n950.dts|  88 
>  arch/arm/boot/dts/omap4-droid4-xt894.dts|   6 +-
>  drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 289 
> +---
>  drivers/gpu/drm/omapdrm/dss/dispc.c |  16 ++
>  drivers/gpu/drm/omapdrm/dss/omapdss.h   |   5 +-
>  drivers/gpu/drm/omapdrm/omap_connector.c|  14 ++
>  drivers/gpu/drm/omapdrm/omap_crtc.c | 158 -
>  drivers/gpu/drm/omapdrm/omap_drv.h  |   4 +
>  drivers/gpu/drm/omapdrm/omap_fb.c   |  20 ++
>  drivers/gpu/drm/omapdrm/omap_fbdev.c|   3 -
>  drivers/gpu/drm/omapdrm/omap_irq.c  |  24 ++
>  11 files changed, 529 insertions(+), 98 deletions(-)
> 
> -- 
> 2.13.2
> 


signature.asc
Description: PGP signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[RFC 02/11] drm/bridge: GPIO-controlled display multiplexer driver

2017-09-30 Thread Ulrich Hecht
Ported from chromeos-3.18 kernel.

Signed-off-by: Ulrich Hecht 
---
 drivers/gpu/drm/bridge/Kconfig|  11 ++
 drivers/gpu/drm/bridge/Makefile   |   1 +
 drivers/gpu/drm/bridge/generic-gpio-mux.c | 316 ++
 3 files changed, 328 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/generic-gpio-mux.c

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index adf9ae0..966f4eb 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -15,6 +15,17 @@ config DRM_PANEL_BRIDGE
 menu "Display Interface Bridges"
depends on DRM && DRM_BRIDGE
 
+config DRM_GENERIC_GPIO_MUX
+   tristate "Generic GPIO-controlled mux"
+   depends on DRM
+   depends on OF
+   select DRM_KMS_HELPER
+   ---help---
+ This bridge driver models a GPIO-controlled display mux with one
+ input, 2 outputs (e.g. an HDMI mux). The hardware decides which output
+ is active, reports it as a GPIO, and the driver redirects calls to the
+ appropriate downstream bridge (if any).
+
 config DRM_ANALOGIX_ANX78XX
tristate "Analogix ANX78XX bridge"
select DRM_KMS_HELPER
diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index defcf1e..2d5652e 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_DRM_ANALOGIX_ANX78XX) += analogix-anx78xx.o
+obj-$(CONFIG_DRM_GENERIC_GPIO_MUX) += generic-gpio-mux.o
 obj-$(CONFIG_DRM_DUMB_VGA_DAC) += dumb-vga-dac.o
 obj-$(CONFIG_DRM_LVDS_ENCODER) += lvds-encoder.o
 obj-$(CONFIG_DRM_MEGACHIPS_STDP_GE_B850V3_FW) += 
megachips-stdp-ge-b850v3-fw.o
diff --git a/drivers/gpu/drm/bridge/generic-gpio-mux.c 
b/drivers/gpu/drm/bridge/generic-gpio-mux.c
new file mode 100644
index 000..744804b
--- /dev/null
+++ b/drivers/gpu/drm/bridge/generic-gpio-mux.c
@@ -0,0 +1,316 @@
+/*
+ * ANX7688 HDMI->DP bridge driver
+ *
+ * Copyright (C) 2016 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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 
+
+struct gpio_display_mux {
+   struct device *dev;
+
+   struct gpio_desc *gpiod_detect;
+   int detect_irq;
+
+   struct drm_bridge bridge;
+
+   struct drm_bridge *next[2];
+};
+
+static inline struct gpio_display_mux *bridge_to_gpio_display_mux(
+   struct drm_bridge *bridge)
+{
+   return container_of(bridge, struct gpio_display_mux, bridge);
+}
+
+static irqreturn_t gpio_display_mux_det_threaded_handler(int unused, void 
*data)
+{
+   struct gpio_display_mux *gpio_display_mux = data;
+   int active = gpiod_get_value(gpio_display_mux->gpiod_detect);
+
+   dev_dbg(gpio_display_mux->dev, "Interrupt %d!\n", active);
+
+   if (gpio_display_mux->bridge.dev)
+   drm_kms_helper_hotplug_event(gpio_display_mux->bridge.dev);
+
+   return IRQ_HANDLED;
+}
+
+static int gpio_display_mux_attach(struct drm_bridge *bridge)
+{
+   struct gpio_display_mux *gpio_display_mux =
+   bridge_to_gpio_display_mux(bridge);
+   struct drm_bridge *next;
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(gpio_display_mux->next); i++) {
+   next = gpio_display_mux->next[i];
+   if (next)
+   next->encoder = bridge->encoder;
+   }
+
+   return 0;
+}
+
+static bool gpio_display_mux_mode_fixup(struct drm_bridge *bridge,
+   const struct drm_display_mode *mode,
+   struct drm_display_mode *adjusted_mode)
+{
+   struct gpio_display_mux *gpio_display_mux =
+   bridge_to_gpio_display_mux(bridge);
+   int active;
+   struct drm_bridge *next;
+
+   active = gpiod_get_value(gpio_display_mux->gpiod_detect);
+   next = gpio_display_mux->next[active];
+
+   if (next && next->funcs->mode_fixup)
+   return next->funcs->mode_fixup(next, mode, adjusted_mode);
+   else
+   return true;
+}
+
+static void gpio_display_mux_mode_set(struct drm_bridge *bridge,
+   struct drm_display_mode *mode,
+   struct drm_display_mode *adjusted_mode)
+{
+   struct gpio_display_mux *gpio_display_mux =
+   bridge_to_gpio_display_mux(bridge);
+   int active;
+   struct drm_bridge *next;
+
+   active = gpiod_get_value(gpio_display_mux->gpiod_detect);
+ 

[PATCH] drm/arm: Replace instances of drm_dev_unref with drm_dev_put.

2017-09-30 Thread Srishti Sharma
Replace drm_dev_unref with drm_dev_put as it is more consistent
with kernel coding style. Done using the following semantic
patch by coccinelle.

@r@
expression e;
@@

-drm_dev_unref();
+drm_dev_put();

Signed-off-by: Srishti Sharma 
---
 drivers/gpu/drm/arm/hdlcd_drv.c  | 4 ++--
 drivers/gpu/drm/arm/malidp_drv.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index f9bda7b..1a96462 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -353,7 +353,7 @@ static int hdlcd_drm_bind(struct device *dev)
 err_free:
drm_mode_config_cleanup(drm);
dev_set_drvdata(dev, NULL);
-   drm_dev_unref(drm);
+   drm_dev_put(drm);
 
return ret;
 }
@@ -378,7 +378,7 @@ static void hdlcd_drm_unbind(struct device *dev)
pm_runtime_disable(drm->dev);
of_reserved_mem_device_release(drm->dev);
drm_mode_config_cleanup(drm);
-   drm_dev_unref(drm);
+   drm_dev_put(drm);
drm->dev_private = NULL;
dev_set_drvdata(dev, NULL);
 }
diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index 7ae94a1..1b92f41 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -665,7 +665,7 @@ static int malidp_bind(struct device *dev)
malidp_runtime_pm_suspend(dev);
drm->dev_private = NULL;
dev_set_drvdata(dev, NULL);
-   drm_dev_unref(drm);
+   drm_dev_put(drm);
 alloc_fail:
of_reserved_mem_device_release(dev);
 
@@ -698,7 +698,7 @@ static void malidp_unbind(struct device *dev)
malidp_runtime_pm_suspend(dev);
drm->dev_private = NULL;
dev_set_drvdata(dev, NULL);
-   drm_dev_unref(drm);
+   drm_dev_put(drm);
of_reserved_mem_device_release(dev);
 }
 
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 2/2] drm/amdgpu: Potential uninitialized variable in amdgpu_vm_update_directories()

2017-09-30 Thread Dan Carpenter
After commit ea09729c9302 ("drm/amdgpu: rework page directory filling
v2") then it becomes a lot harder to verify that "r" is initialized.  My
static checker complains and so I've reviewed the code.  It does look
like it might be buggy... Anyway, it doesn't hurt to set "r" to zero
at the start.

Signed-off-by: Dan Carpenter 

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index bbcc67038203..fb3afab55907 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1243,7 +1243,7 @@ static void amdgpu_vm_invalidate_level(struct amdgpu_vm 
*vm,
 int amdgpu_vm_update_directories(struct amdgpu_device *adev,
 struct amdgpu_vm *vm)
 {
-   int r;
+   int r = 0;
 
spin_lock(>status_lock);
while (!list_empty(>relocated)) {
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/2] drm/amdgpu: potential uninitialized variable in amdgpu_vce_ring_parse_cs()

2017-09-30 Thread Dan Carpenter
We shifted some code around in commit 9cca0b8e5df0 ("drm/amdgpu: move
amdgpu_cs_sysvm_access_required into find_mapping") and now my static
checker complains that "r" might not be initialized at the end of the
function.  I've reviewed the code, and that seems possible, but it's
also possible I may have missed something.

Signed-off-by: Dan Carpenter 

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
index b46280c1279f..2918de2f39ec 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
@@ -648,7 +648,7 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, 
uint32_t ib_idx)
uint32_t allocated = 0;
uint32_t tmp, handle = 0;
uint32_t *size = 
-   int i, r, idx = 0;
+   int i, r = 0, idx = 0;
 
p->job->vm = NULL;
ib->gpu_addr = amdgpu_sa_bo_gpu_addr(ib->sa_bo);
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 6/8] drm/etnaviv: mmu: stop using iommu map/unmap functions

2017-09-30 Thread kbuild test robot
Hi Lucas,

[auto build test ERROR on drm/drm-next]
[also build test ERROR on v4.14-rc2 next-20170929]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Lucas-Stach/drm-etnaviv-remove-iommu-fault-handler/20170930-080416
base:   git://people.freedesktop.org/~airlied/linux.git drm-next
config: arm-allyesconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

Note: the 
linux-review/Lucas-Stach/drm-etnaviv-remove-iommu-fault-handler/20170930-080416 
HEAD bd98331a05ea789da46e9c1428ebffe31ca58b67 builds fine.
  It only hurts bisectibility.

All errors (new ones prefixed by >>):

>> drivers/gpu/drm/etnaviv/etnaviv_mmu.c:117:6: error: conflicting types for 
>> 'etnaviv_iommu_unmap'
void etnaviv_iommu_unmap(struct etnaviv_iommu *iommu, u32 iova,
 ^~~
   In file included from drivers/gpu/drm/etnaviv/etnaviv_mmu.c:23:0:
   drivers/gpu/drm/etnaviv/etnaviv_mmu.h:56:5: note: previous declaration of 
'etnaviv_iommu_unmap' was here
int etnaviv_iommu_unmap(struct etnaviv_iommu *iommu, u32 iova,
^~~

vim +/etnaviv_iommu_unmap +117 drivers/gpu/drm/etnaviv/etnaviv_mmu.c

   116  
 > 117  void etnaviv_iommu_unmap(struct etnaviv_iommu *iommu, u32 iova,
   118   struct sg_table *sgt, unsigned len)
   119  {
   120  struct iommu_domain *domain = iommu->domain;
   121  struct scatterlist *sg;
   122  unsigned int da = iova;
   123  int i;
   124  
   125  for_each_sg(sgt->sgl, sg, sgt->nents, i) {
   126  size_t bytes = sg_dma_len(sg) + sg->offset;
   127  
   128  etnaviv_domain_unmap(domain, da, bytes);
   129  
   130  VERB("unmap[%d]: %08x(%zx)", i, iova, bytes);
   131  
   132  BUG_ON(!PAGE_ALIGNED(bytes));
   133  
   134  da += bytes;
   135  }
   136  }
   137  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel