Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-25 Thread Daniel Vetter
On Thu, Sep 25, 2014 at 2:54 AM, Mark yao  wrote:
> Hi, Daniel
> this version is old, newest is v5. and I remove uapi at v5.
> you can see v5 patch at:
> https://lkml.org/lkml/2014/9/23/1061
> thanks
>
> This version doesn't seem to be cc'ed to dri-devel, at least it didn't
> yet show up. Can you please double-check?
>
> actually I cc the v5 version to dri-de...@lists.freedesktop.org.
> and we can found the patch at https://patchwork.kernel.org/patch/4967501/(
> Project: dri-devel)

Yeah it eventually showed up here too. Looks sane from a really high
level up I think, so Ack: me.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-25 Thread Daniel Vetter
On Thu, Sep 25, 2014 at 2:54 AM, Mark yao mark@rock-chips.com wrote:
 Hi, Daniel
 this version is old, newest is v5. and I remove uapi at v5.
 you can see v5 patch at:
 https://lkml.org/lkml/2014/9/23/1061
 thanks

 This version doesn't seem to be cc'ed to dri-devel, at least it didn't
 yet show up. Can you please double-check?

 actually I cc the v5 version to dri-de...@lists.freedesktop.org.
 and we can found the patch at https://patchwork.kernel.org/patch/4967501/(
 Project: dri-devel)

Yeah it eventually showed up here too. Looks sane from a really high
level up I think, so Ack: me.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-24 Thread Daniel Vetter
On Wed, Sep 24, 2014 at 11:31 AM, Mark yao  wrote:
> On 2014年09月24日 16:20, Daniel Vetter wrote:
>>
>> On Mon, Sep 22, 2014 at 06:48:54PM +0800, Mark yao wrote:
>>>
>>> This patch adds the basic structure of a DRM Driver for Rockchip Socs.
>>>
>>> Signed-off-by: Mark yao 
>>> ---
>>> Changes in v2:
>>> - use the component framework to defer main drm driver probe
>>>until all VOP devices have been probed.
>>> - use dma-mapping API with ARM_DMA_USE_IOMMU, create dma mapping by
>>>master device and each vop device can shared the drm dma mapping.
>>> - use drm_crtc_init_with_planes and drm_universal_plane_init.
>>> - remove unnecessary middle layers.
>>> - add cursor set, move funcs to rockchip drm crtc.
>>> - use vop reset at first init
>>> - reference framebuffer when used and unreference when swap out vop
>>>
>>> Changes in v3:
>>> - change "crtc->fb" to "crtc->primary-fb"
>>> Adviced by Daniel Vetter
>>> - init cursor plane with universal api, remove unnecessary cursor
>>> set,move
>>>
>>> Changes in v4:
>>> Adviced by David Herrmann
>>> - remove drm_platform_*() usage, use register drm device directly.
>>> Adviced by Rob Clark
>>> - remove special mmap ioctl, do userspace mmap with normal mmap() or mmap
>>> offset
>>>
>>>   drivers/gpu/drm/Kconfig   |2 +
>>>   drivers/gpu/drm/Makefile  |1 +
>>>   drivers/gpu/drm/rockchip/Kconfig  |   19 +
>>>   drivers/gpu/drm/rockchip/Makefile |   10 +
>>>   drivers/gpu/drm/rockchip/rockchip_drm_drv.c   |  524 ++
>>>   drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |  120 +++
>>>   drivers/gpu/drm/rockchip/rockchip_drm_fb.c|  201 
>>>   drivers/gpu/drm/rockchip/rockchip_drm_fb.h|   28 +
>>>   drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  231 +
>>>   drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h |   20 +
>>>   drivers/gpu/drm/rockchip/rockchip_drm_gem.c   |  404 
>>>   drivers/gpu/drm/rockchip/rockchip_drm_gem.h   |   72 ++
>>>   drivers/gpu/drm/rockchip/rockchip_drm_vop.c   | 1372
>>> +
>>>   drivers/gpu/drm/rockchip/rockchip_drm_vop.h   |  187 
>>>   include/uapi/drm/rockchip_drm.h   |   75 ++
>>
>> uapi is still here ... Was this an oversight?
>> -Daniel
>>
> Hi, Daniel
> this version is old, newest is v5. and I remove uapi at v5.
> you can see v5 patch at:
> https://lkml.org/lkml/2014/9/23/1061
> thanks

This version doesn't seem to be cc'ed to dri-devel, at least it didn't
yet show up. Can you please double-check?

Thanks, Daniel
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-24 Thread Mark yao

On 2014年09月24日 16:20, Daniel Vetter wrote:

On Mon, Sep 22, 2014 at 06:48:54PM +0800, Mark yao wrote:

This patch adds the basic structure of a DRM Driver for Rockchip Socs.

Signed-off-by: Mark yao 
---
Changes in v2:
- use the component framework to defer main drm driver probe
   until all VOP devices have been probed.
- use dma-mapping API with ARM_DMA_USE_IOMMU, create dma mapping by
   master device and each vop device can shared the drm dma mapping.
- use drm_crtc_init_with_planes and drm_universal_plane_init.
- remove unnecessary middle layers.
- add cursor set, move funcs to rockchip drm crtc.
- use vop reset at first init
- reference framebuffer when used and unreference when swap out vop

Changes in v3:
- change "crtc->fb" to "crtc->primary-fb"
Adviced by Daniel Vetter
- init cursor plane with universal api, remove unnecessary cursor set,move

Changes in v4:
Adviced by David Herrmann
- remove drm_platform_*() usage, use register drm device directly.
Adviced by Rob Clark
- remove special mmap ioctl, do userspace mmap with normal mmap() or mmap offset

  drivers/gpu/drm/Kconfig   |2 +
  drivers/gpu/drm/Makefile  |1 +
  drivers/gpu/drm/rockchip/Kconfig  |   19 +
  drivers/gpu/drm/rockchip/Makefile |   10 +
  drivers/gpu/drm/rockchip/rockchip_drm_drv.c   |  524 ++
  drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |  120 +++
  drivers/gpu/drm/rockchip/rockchip_drm_fb.c|  201 
  drivers/gpu/drm/rockchip/rockchip_drm_fb.h|   28 +
  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  231 +
  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h |   20 +
  drivers/gpu/drm/rockchip/rockchip_drm_gem.c   |  404 
  drivers/gpu/drm/rockchip/rockchip_drm_gem.h   |   72 ++
  drivers/gpu/drm/rockchip/rockchip_drm_vop.c   | 1372 +
  drivers/gpu/drm/rockchip/rockchip_drm_vop.h   |  187 
  include/uapi/drm/rockchip_drm.h   |   75 ++

uapi is still here ... Was this an oversight?
-Daniel


Hi, Daniel
this version is old, newest is v5. and I remove uapi at v5.
you can see v5 patch at:
https://lkml.org/lkml/2014/9/23/1061
thanks
-Mark

  15 files changed, 3266 insertions(+)
  create mode 100644 drivers/gpu/drm/rockchip/Kconfig
  create mode 100644 drivers/gpu/drm/rockchip/Makefile
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.h
  create mode 100644 include/uapi/drm/rockchip_drm.h

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index b066bb3..7c4c3c6 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -171,6 +171,8 @@ config DRM_SAVAGE
  
  source "drivers/gpu/drm/exynos/Kconfig"
  
+source "drivers/gpu/drm/rockchip/Kconfig"

+
  source "drivers/gpu/drm/vmwgfx/Kconfig"
  
  source "drivers/gpu/drm/gma500/Kconfig"

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 4a55d59..d03387a 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
  obj-$(CONFIG_DRM_VIA) +=via/
  obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/
  obj-$(CONFIG_DRM_EXYNOS) +=exynos/
+obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/
  obj-$(CONFIG_DRM_GMA500) += gma500/
  obj-$(CONFIG_DRM_UDL) += udl/
  obj-$(CONFIG_DRM_AST) += ast/
diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
new file mode 100644
index 000..7146c80
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -0,0 +1,19 @@
+config DRM_ROCKCHIP
+   tristate "DRM Support for Rockchip"
+   depends on DRM && ROCKCHIP_IOMMU
+   select ARM_DMA_USE_IOMMU
+   select IOMMU_API
+   select DRM_KMS_HELPER
+   select DRM_KMS_FB_HELPER
+   select DRM_PANEL
+   select FB_CFB_FILLRECT
+   select FB_CFB_COPYAREA
+   select FB_CFB_IMAGEBLIT
+   select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
+   select VIDEOMODE_HELPERS
+   help
+ Choose this option if you have a Rockchip soc chipset.
+ This driver provides kernel mode setting and buffer
+ management to userspace. This driver does not provides
+ 2D or 3D acceleration; acceleration is performed by other
+ IP found on the SoC.
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
new file mode 100644
index 000..6e6d468
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/Makefile

Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-24 Thread Daniel Vetter
On Mon, Sep 22, 2014 at 06:48:54PM +0800, Mark yao wrote:
> This patch adds the basic structure of a DRM Driver for Rockchip Socs.
> 
> Signed-off-by: Mark yao 
> ---
> Changes in v2:
> - use the component framework to defer main drm driver probe
>   until all VOP devices have been probed.
> - use dma-mapping API with ARM_DMA_USE_IOMMU, create dma mapping by
>   master device and each vop device can shared the drm dma mapping.
> - use drm_crtc_init_with_planes and drm_universal_plane_init.
> - remove unnecessary middle layers.
> - add cursor set, move funcs to rockchip drm crtc.
> - use vop reset at first init
> - reference framebuffer when used and unreference when swap out vop
> 
> Changes in v3:
> - change "crtc->fb" to "crtc->primary-fb"
> Adviced by Daniel Vetter
> - init cursor plane with universal api, remove unnecessary cursor set,move 
> 
> Changes in v4:
> Adviced by David Herrmann
> - remove drm_platform_*() usage, use register drm device directly.
> Adviced by Rob Clark
> - remove special mmap ioctl, do userspace mmap with normal mmap() or mmap 
> offset
> 
>  drivers/gpu/drm/Kconfig   |2 +
>  drivers/gpu/drm/Makefile  |1 +
>  drivers/gpu/drm/rockchip/Kconfig  |   19 +
>  drivers/gpu/drm/rockchip/Makefile |   10 +
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c   |  524 ++
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |  120 +++
>  drivers/gpu/drm/rockchip/rockchip_drm_fb.c|  201 
>  drivers/gpu/drm/rockchip/rockchip_drm_fb.h|   28 +
>  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  231 +
>  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h |   20 +
>  drivers/gpu/drm/rockchip/rockchip_drm_gem.c   |  404 
>  drivers/gpu/drm/rockchip/rockchip_drm_gem.h   |   72 ++
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c   | 1372 
> +
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.h   |  187 
>  include/uapi/drm/rockchip_drm.h   |   75 ++

uapi is still here ... Was this an oversight?
-Daniel

>  15 files changed, 3266 insertions(+)
>  create mode 100644 drivers/gpu/drm/rockchip/Kconfig
>  create mode 100644 drivers/gpu/drm/rockchip/Makefile
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.c
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.h
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.c
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.h
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.h
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.c
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.h
>  create mode 100644 include/uapi/drm/rockchip_drm.h
> 
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index b066bb3..7c4c3c6 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -171,6 +171,8 @@ config DRM_SAVAGE
>  
>  source "drivers/gpu/drm/exynos/Kconfig"
>  
> +source "drivers/gpu/drm/rockchip/Kconfig"
> +
>  source "drivers/gpu/drm/vmwgfx/Kconfig"
>  
>  source "drivers/gpu/drm/gma500/Kconfig"
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index 4a55d59..d03387a 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -52,6 +52,7 @@ obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
>  obj-$(CONFIG_DRM_VIA)+=via/
>  obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/
>  obj-$(CONFIG_DRM_EXYNOS) +=exynos/
> +obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/
>  obj-$(CONFIG_DRM_GMA500) += gma500/
>  obj-$(CONFIG_DRM_UDL) += udl/
>  obj-$(CONFIG_DRM_AST) += ast/
> diff --git a/drivers/gpu/drm/rockchip/Kconfig 
> b/drivers/gpu/drm/rockchip/Kconfig
> new file mode 100644
> index 000..7146c80
> --- /dev/null
> +++ b/drivers/gpu/drm/rockchip/Kconfig
> @@ -0,0 +1,19 @@
> +config DRM_ROCKCHIP
> + tristate "DRM Support for Rockchip"
> + depends on DRM && ROCKCHIP_IOMMU
> + select ARM_DMA_USE_IOMMU
> + select IOMMU_API
> + select DRM_KMS_HELPER
> + select DRM_KMS_FB_HELPER
> + select DRM_PANEL
> + select FB_CFB_FILLRECT
> + select FB_CFB_COPYAREA
> + select FB_CFB_IMAGEBLIT
> + select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
> + select VIDEOMODE_HELPERS
> + help
> +   Choose this option if you have a Rockchip soc chipset.
> +   This driver provides kernel mode setting and buffer
> +   management to userspace. This driver does not provides
> +   2D or 3D acceleration; acceleration is performed by other
> +   IP found on the SoC.
> diff --git a/drivers/gpu/drm/rockchip/Makefile 
> b/drivers/gpu/drm/rockchip/Makefile
> new file mode 100644
> index 000..6e6d468
> --- /dev/null
> +++ b/drivers/gpu/drm/rockchip/Makefile
> @@ -0,0 +1,10 @@
> +#
> +# 

Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-24 Thread Daniel Vetter
On Mon, Sep 22, 2014 at 06:48:54PM +0800, Mark yao wrote:
 This patch adds the basic structure of a DRM Driver for Rockchip Socs.
 
 Signed-off-by: Mark yao mark@rock-chips.com
 ---
 Changes in v2:
 - use the component framework to defer main drm driver probe
   until all VOP devices have been probed.
 - use dma-mapping API with ARM_DMA_USE_IOMMU, create dma mapping by
   master device and each vop device can shared the drm dma mapping.
 - use drm_crtc_init_with_planes and drm_universal_plane_init.
 - remove unnecessary middle layers.
 - add cursor set, move funcs to rockchip drm crtc.
 - use vop reset at first init
 - reference framebuffer when used and unreference when swap out vop
 
 Changes in v3:
 - change crtc-fb to crtc-primary-fb
 Adviced by Daniel Vetter
 - init cursor plane with universal api, remove unnecessary cursor set,move 
 
 Changes in v4:
 Adviced by David Herrmann
 - remove drm_platform_*() usage, use register drm device directly.
 Adviced by Rob Clark
 - remove special mmap ioctl, do userspace mmap with normal mmap() or mmap 
 offset
 
  drivers/gpu/drm/Kconfig   |2 +
  drivers/gpu/drm/Makefile  |1 +
  drivers/gpu/drm/rockchip/Kconfig  |   19 +
  drivers/gpu/drm/rockchip/Makefile |   10 +
  drivers/gpu/drm/rockchip/rockchip_drm_drv.c   |  524 ++
  drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |  120 +++
  drivers/gpu/drm/rockchip/rockchip_drm_fb.c|  201 
  drivers/gpu/drm/rockchip/rockchip_drm_fb.h|   28 +
  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  231 +
  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h |   20 +
  drivers/gpu/drm/rockchip/rockchip_drm_gem.c   |  404 
  drivers/gpu/drm/rockchip/rockchip_drm_gem.h   |   72 ++
  drivers/gpu/drm/rockchip/rockchip_drm_vop.c   | 1372 
 +
  drivers/gpu/drm/rockchip/rockchip_drm_vop.h   |  187 
  include/uapi/drm/rockchip_drm.h   |   75 ++

uapi is still here ... Was this an oversight?
-Daniel

  15 files changed, 3266 insertions(+)
  create mode 100644 drivers/gpu/drm/rockchip/Kconfig
  create mode 100644 drivers/gpu/drm/rockchip/Makefile
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.h
  create mode 100644 include/uapi/drm/rockchip_drm.h
 
 diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
 index b066bb3..7c4c3c6 100644
 --- a/drivers/gpu/drm/Kconfig
 +++ b/drivers/gpu/drm/Kconfig
 @@ -171,6 +171,8 @@ config DRM_SAVAGE
  
  source drivers/gpu/drm/exynos/Kconfig
  
 +source drivers/gpu/drm/rockchip/Kconfig
 +
  source drivers/gpu/drm/vmwgfx/Kconfig
  
  source drivers/gpu/drm/gma500/Kconfig
 diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
 index 4a55d59..d03387a 100644
 --- a/drivers/gpu/drm/Makefile
 +++ b/drivers/gpu/drm/Makefile
 @@ -52,6 +52,7 @@ obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
  obj-$(CONFIG_DRM_VIA)+=via/
  obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/
  obj-$(CONFIG_DRM_EXYNOS) +=exynos/
 +obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/
  obj-$(CONFIG_DRM_GMA500) += gma500/
  obj-$(CONFIG_DRM_UDL) += udl/
  obj-$(CONFIG_DRM_AST) += ast/
 diff --git a/drivers/gpu/drm/rockchip/Kconfig 
 b/drivers/gpu/drm/rockchip/Kconfig
 new file mode 100644
 index 000..7146c80
 --- /dev/null
 +++ b/drivers/gpu/drm/rockchip/Kconfig
 @@ -0,0 +1,19 @@
 +config DRM_ROCKCHIP
 + tristate DRM Support for Rockchip
 + depends on DRM  ROCKCHIP_IOMMU
 + select ARM_DMA_USE_IOMMU
 + select IOMMU_API
 + select DRM_KMS_HELPER
 + select DRM_KMS_FB_HELPER
 + select DRM_PANEL
 + select FB_CFB_FILLRECT
 + select FB_CFB_COPYAREA
 + select FB_CFB_IMAGEBLIT
 + select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
 + select VIDEOMODE_HELPERS
 + help
 +   Choose this option if you have a Rockchip soc chipset.
 +   This driver provides kernel mode setting and buffer
 +   management to userspace. This driver does not provides
 +   2D or 3D acceleration; acceleration is performed by other
 +   IP found on the SoC.
 diff --git a/drivers/gpu/drm/rockchip/Makefile 
 b/drivers/gpu/drm/rockchip/Makefile
 new file mode 100644
 index 000..6e6d468
 --- /dev/null
 +++ b/drivers/gpu/drm/rockchip/Makefile
 @@ -0,0 +1,10 @@
 +#
 +# Makefile for the drm device driver.  This driver provides support for the
 +# Direct Rendering Infrastructure (DRI) in 

Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-24 Thread Mark yao

On 2014年09月24日 16:20, Daniel Vetter wrote:

On Mon, Sep 22, 2014 at 06:48:54PM +0800, Mark yao wrote:

This patch adds the basic structure of a DRM Driver for Rockchip Socs.

Signed-off-by: Mark yao mark@rock-chips.com
---
Changes in v2:
- use the component framework to defer main drm driver probe
   until all VOP devices have been probed.
- use dma-mapping API with ARM_DMA_USE_IOMMU, create dma mapping by
   master device and each vop device can shared the drm dma mapping.
- use drm_crtc_init_with_planes and drm_universal_plane_init.
- remove unnecessary middle layers.
- add cursor set, move funcs to rockchip drm crtc.
- use vop reset at first init
- reference framebuffer when used and unreference when swap out vop

Changes in v3:
- change crtc-fb to crtc-primary-fb
Adviced by Daniel Vetter
- init cursor plane with universal api, remove unnecessary cursor set,move

Changes in v4:
Adviced by David Herrmann
- remove drm_platform_*() usage, use register drm device directly.
Adviced by Rob Clark
- remove special mmap ioctl, do userspace mmap with normal mmap() or mmap offset

  drivers/gpu/drm/Kconfig   |2 +
  drivers/gpu/drm/Makefile  |1 +
  drivers/gpu/drm/rockchip/Kconfig  |   19 +
  drivers/gpu/drm/rockchip/Makefile |   10 +
  drivers/gpu/drm/rockchip/rockchip_drm_drv.c   |  524 ++
  drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |  120 +++
  drivers/gpu/drm/rockchip/rockchip_drm_fb.c|  201 
  drivers/gpu/drm/rockchip/rockchip_drm_fb.h|   28 +
  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  231 +
  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h |   20 +
  drivers/gpu/drm/rockchip/rockchip_drm_gem.c   |  404 
  drivers/gpu/drm/rockchip/rockchip_drm_gem.h   |   72 ++
  drivers/gpu/drm/rockchip/rockchip_drm_vop.c   | 1372 +
  drivers/gpu/drm/rockchip/rockchip_drm_vop.h   |  187 
  include/uapi/drm/rockchip_drm.h   |   75 ++

uapi is still here ... Was this an oversight?
-Daniel


Hi, Daniel
this version is old, newest is v5. and I remove uapi at v5.
you can see v5 patch at:
https://lkml.org/lkml/2014/9/23/1061
thanks
-Mark

  15 files changed, 3266 insertions(+)
  create mode 100644 drivers/gpu/drm/rockchip/Kconfig
  create mode 100644 drivers/gpu/drm/rockchip/Makefile
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.h
  create mode 100644 include/uapi/drm/rockchip_drm.h

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index b066bb3..7c4c3c6 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -171,6 +171,8 @@ config DRM_SAVAGE
  
  source drivers/gpu/drm/exynos/Kconfig
  
+source drivers/gpu/drm/rockchip/Kconfig

+
  source drivers/gpu/drm/vmwgfx/Kconfig
  
  source drivers/gpu/drm/gma500/Kconfig

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 4a55d59..d03387a 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
  obj-$(CONFIG_DRM_VIA) +=via/
  obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/
  obj-$(CONFIG_DRM_EXYNOS) +=exynos/
+obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/
  obj-$(CONFIG_DRM_GMA500) += gma500/
  obj-$(CONFIG_DRM_UDL) += udl/
  obj-$(CONFIG_DRM_AST) += ast/
diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
new file mode 100644
index 000..7146c80
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -0,0 +1,19 @@
+config DRM_ROCKCHIP
+   tristate DRM Support for Rockchip
+   depends on DRM  ROCKCHIP_IOMMU
+   select ARM_DMA_USE_IOMMU
+   select IOMMU_API
+   select DRM_KMS_HELPER
+   select DRM_KMS_FB_HELPER
+   select DRM_PANEL
+   select FB_CFB_FILLRECT
+   select FB_CFB_COPYAREA
+   select FB_CFB_IMAGEBLIT
+   select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
+   select VIDEOMODE_HELPERS
+   help
+ Choose this option if you have a Rockchip soc chipset.
+ This driver provides kernel mode setting and buffer
+ management to userspace. This driver does not provides
+ 2D or 3D acceleration; acceleration is performed by other
+ IP found on the SoC.
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
new file mode 100644
index 000..6e6d468
--- /dev/null
+++ 

Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-24 Thread Daniel Vetter
On Wed, Sep 24, 2014 at 11:31 AM, Mark yao mark@rock-chips.com wrote:
 On 2014年09月24日 16:20, Daniel Vetter wrote:

 On Mon, Sep 22, 2014 at 06:48:54PM +0800, Mark yao wrote:

 This patch adds the basic structure of a DRM Driver for Rockchip Socs.

 Signed-off-by: Mark yao mark@rock-chips.com
 ---
 Changes in v2:
 - use the component framework to defer main drm driver probe
until all VOP devices have been probed.
 - use dma-mapping API with ARM_DMA_USE_IOMMU, create dma mapping by
master device and each vop device can shared the drm dma mapping.
 - use drm_crtc_init_with_planes and drm_universal_plane_init.
 - remove unnecessary middle layers.
 - add cursor set, move funcs to rockchip drm crtc.
 - use vop reset at first init
 - reference framebuffer when used and unreference when swap out vop

 Changes in v3:
 - change crtc-fb to crtc-primary-fb
 Adviced by Daniel Vetter
 - init cursor plane with universal api, remove unnecessary cursor
 set,move

 Changes in v4:
 Adviced by David Herrmann
 - remove drm_platform_*() usage, use register drm device directly.
 Adviced by Rob Clark
 - remove special mmap ioctl, do userspace mmap with normal mmap() or mmap
 offset

   drivers/gpu/drm/Kconfig   |2 +
   drivers/gpu/drm/Makefile  |1 +
   drivers/gpu/drm/rockchip/Kconfig  |   19 +
   drivers/gpu/drm/rockchip/Makefile |   10 +
   drivers/gpu/drm/rockchip/rockchip_drm_drv.c   |  524 ++
   drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |  120 +++
   drivers/gpu/drm/rockchip/rockchip_drm_fb.c|  201 
   drivers/gpu/drm/rockchip/rockchip_drm_fb.h|   28 +
   drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  231 +
   drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h |   20 +
   drivers/gpu/drm/rockchip/rockchip_drm_gem.c   |  404 
   drivers/gpu/drm/rockchip/rockchip_drm_gem.h   |   72 ++
   drivers/gpu/drm/rockchip/rockchip_drm_vop.c   | 1372
 +
   drivers/gpu/drm/rockchip/rockchip_drm_vop.h   |  187 
   include/uapi/drm/rockchip_drm.h   |   75 ++

 uapi is still here ... Was this an oversight?
 -Daniel

 Hi, Daniel
 this version is old, newest is v5. and I remove uapi at v5.
 you can see v5 patch at:
 https://lkml.org/lkml/2014/9/23/1061
 thanks

This version doesn't seem to be cc'ed to dri-devel, at least it didn't
yet show up. Can you please double-check?

Thanks, Daniel
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-23 Thread Arnd Bergmann
On Tuesday 23 September 2014 15:09:37 Mark yao wrote:
> On 2014年09月22日 23:54, Arnd Bergmann wrote:
> > On Monday 22 September 2014 17:15:06 Boris BREZILLON wrote:
>  +
>  +   /* TODO(djkurtz): fetch the mapping start/size from somewhere */
>  +   mapping = arm_iommu_create_mapping(_bus_type, 0x1000,
>  +  SZ_1G);
>  +   if (IS_ERR(mapping)) {
>  +   ret = PTR_ERR(mapping);
>  +   goto err_config_cleanup;
>  +   }
>  +
>  +   dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
> >>> This is the default coherent mask. If you call this function, you
> >>> should normally check the return value, or call dma_set_mask first,
> >>> which you apparently don't do here, and in another place in this
> >>> patch.
> >> By "This is the default mask" do you mean it shouldn't be called at
> >> all ? Cause I ran into some trouble when not calling this in my
> >> atmel-hlcdc driver.
> > We used to get this wrong in the of_platform code, but it should
> > work now.
> >
> >> Actually, in my case the platform device is created by the MFD core
> >> which seems to let the coherent_dma_mask uninitialized.
> > That may well be different, but it seems like a good idea to allow
> > the MFD core to set this up as well.
> >
> > In general, we expect that devices that are capable of doing DMA
> > start with a 32-bit mask for both dma_mask and dma_coherent_mask,
> > and a driver that requires a smaller masks or wants a larger mask
> > has to call the appropriate interface to set these, and check the
> > return value.
> so I think we can use dma_set_mask_and_coherent(...) to set dma_mask and 
> dma_coherent_mark
> at the same time, and check the return value.

Yes, that would be good.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-23 Thread Mark yao

On 2014年09月22日 23:54, Arnd Bergmann wrote:

On Monday 22 September 2014 17:15:06 Boris BREZILLON wrote:

+
+   /* TODO(djkurtz): fetch the mapping start/size from somewhere */
+   mapping = arm_iommu_create_mapping(_bus_type, 0x1000,
+  SZ_1G);
+   if (IS_ERR(mapping)) {
+   ret = PTR_ERR(mapping);
+   goto err_config_cleanup;
+   }
+
+   dma_set_coherent_mask(dev, DMA_BIT_MASK(32));

This is the default coherent mask. If you call this function, you
should normally check the return value, or call dma_set_mask first,
which you apparently don't do here, and in another place in this
patch.

By "This is the default mask" do you mean it shouldn't be called at
all ? Cause I ran into some trouble when not calling this in my
atmel-hlcdc driver.

We used to get this wrong in the of_platform code, but it should
work now.


Actually, in my case the platform device is created by the MFD core
which seems to let the coherent_dma_mask uninitialized.

That may well be different, but it seems like a good idea to allow
the MFD core to set this up as well.

In general, we expect that devices that are capable of doing DMA
start with a 32-bit mask for both dma_mask and dma_coherent_mask,
and a driver that requires a smaller masks or wants a larger mask
has to call the appropriate interface to set these, and check the
return value.
so I think we can use dma_set_mask_and_coherent(...) to set dma_mask and 
dma_coherent_mark

at the same time, and check the return value.

Arnd






--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-23 Thread Mark yao

On 2014年09月22日 22:43, Arnd Bergmann wrote:

On Monday 22 September 2014 18:48:54 Mark yao wrote:

diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
new file mode 100644
index 000..7146c80
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -0,0 +1,19 @@
+config DRM_ROCKCHIP
+   tristate "DRM Support for Rockchip"
+   depends on DRM && ROCKCHIP_IOMMU
+   select ARM_DMA_USE_IOMMU
+   select IOMMU_API
+   select DRM_KMS_HELPER
+   select DRM_KMS_FB_HELPER
+   select DRM_PANEL
+   select FB_CFB_FILLRECT
+   select FB_CFB_COPYAREA
+   select FB_CFB_IMAGEBLIT
+   select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
+   select VIDEOMODE_HELPERS

Be careful with 'select', at least some of these should be 'depends on'.
In particular IOMMU_API and ARM_DMA_USE_IOMMU, but possibly others
as well. Just check how the symbols are used normally, if you get this
wrong, we can end up with incorrect dependencies or loops.


I see, I will change it.

diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
new file mode 100644
index 000..6e6d468
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -0,0 +1,10 @@
+#
+# Makefile for the drm device driver.  This driver provides support for the
+# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
+
+ccflags-y := -Iinclude/drm -Idrivers/gpu/drm/rockchip

The second one should not be required.

Sure, I will change it.

+static int rockchip_drm_load(struct drm_device *drm_dev, unsigned long flags)
+{
+   struct rockchip_drm_private *private;
+   struct dma_iommu_mapping *mapping;
+   struct device *dev = drm_dev->dev;
+   int ret;
+
+   private = devm_kzalloc(drm_dev->dev, sizeof(*private), GFP_KERNEL);
+   if (!private)
+   return -ENOMEM;
+
+   dev_set_drvdata(drm_dev->dev, dev);
+   drm_dev->dev_private = private;
+
+   drm_mode_config_init(drm_dev);
+
+   rockchip_drm_mode_config_init(drm_dev);
+
+   dev->dma_parms = devm_kzalloc(dev, sizeof(*dev->dma_parms),
+ GFP_KERNEL);
+   if (!dev->dma_parms) {
+   ret = -ENOMEM;
+   goto err_config_cleanup;
+   }
+
+   /* TODO(djkurtz): fetch the mapping start/size from somewhere */
+   mapping = arm_iommu_create_mapping(_bus_type, 0x1000,
+  SZ_1G);
+   if (IS_ERR(mapping)) {
+   ret = PTR_ERR(mapping);
+   goto err_config_cleanup;
+   }
+
+   dma_set_coherent_mask(dev, DMA_BIT_MASK(32));

This is the default coherent mask. If you call this function, you
should normally check the return value, or call dma_set_mask first,
which you apparently don't do here, and in another place in this
patch.

Arnd






--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-23 Thread Mark yao

On 2014年09月23日 03:10, Rob Clark wrote:

Ok, couple more small comments.. this time I actually had time to go
through the entire patch, not just the uapi


On Mon, Sep 22, 2014 at 6:48 AM, Mark yao  wrote:

This patch adds the basic structure of a DRM Driver for Rockchip Socs.

Signed-off-by: Mark yao 
---
Changes in v2:
- use the component framework to defer main drm driver probe
   until all VOP devices have been probed.
- use dma-mapping API with ARM_DMA_USE_IOMMU, create dma mapping by
   master device and each vop device can shared the drm dma mapping.
- use drm_crtc_init_with_planes and drm_universal_plane_init.
- remove unnecessary middle layers.
- add cursor set, move funcs to rockchip drm crtc.
- use vop reset at first init
- reference framebuffer when used and unreference when swap out vop

Changes in v3:
- change "crtc->fb" to "crtc->primary-fb"
Adviced by Daniel Vetter
- init cursor plane with universal api, remove unnecessary cursor set,move

Changes in v4:
Adviced by David Herrmann
- remove drm_platform_*() usage, use register drm device directly.
Adviced by Rob Clark
- remove special mmap ioctl, do userspace mmap with normal mmap() or mmap offset

  drivers/gpu/drm/Kconfig   |2 +
  drivers/gpu/drm/Makefile  |1 +
  drivers/gpu/drm/rockchip/Kconfig  |   19 +
  drivers/gpu/drm/rockchip/Makefile |   10 +
  drivers/gpu/drm/rockchip/rockchip_drm_drv.c   |  524 ++
  drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |  120 +++
  drivers/gpu/drm/rockchip/rockchip_drm_fb.c|  201 
  drivers/gpu/drm/rockchip/rockchip_drm_fb.h|   28 +
  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  231 +
  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h |   20 +
  drivers/gpu/drm/rockchip/rockchip_drm_gem.c   |  404 
  drivers/gpu/drm/rockchip/rockchip_drm_gem.h   |   72 ++
  drivers/gpu/drm/rockchip/rockchip_drm_vop.c   | 1372 +
  drivers/gpu/drm/rockchip/rockchip_drm_vop.h   |  187 
  include/uapi/drm/rockchip_drm.h   |   75 ++
  15 files changed, 3266 insertions(+)
  create mode 100644 drivers/gpu/drm/rockchip/Kconfig
  create mode 100644 drivers/gpu/drm/rockchip/Makefile
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.h
  create mode 100644 include/uapi/drm/rockchip_drm.h

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index b066bb3..7c4c3c6 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -171,6 +171,8 @@ config DRM_SAVAGE

  source "drivers/gpu/drm/exynos/Kconfig"

+source "drivers/gpu/drm/rockchip/Kconfig"
+
  source "drivers/gpu/drm/vmwgfx/Kconfig"

  source "drivers/gpu/drm/gma500/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 4a55d59..d03387a 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
  obj-$(CONFIG_DRM_VIA)  +=via/
  obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/
  obj-$(CONFIG_DRM_EXYNOS) +=exynos/
+obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/
  obj-$(CONFIG_DRM_GMA500) += gma500/
  obj-$(CONFIG_DRM_UDL) += udl/
  obj-$(CONFIG_DRM_AST) += ast/
diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
new file mode 100644
index 000..7146c80
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -0,0 +1,19 @@
+config DRM_ROCKCHIP
+   tristate "DRM Support for Rockchip"
+   depends on DRM && ROCKCHIP_IOMMU
+   select ARM_DMA_USE_IOMMU
+   select IOMMU_API
+   select DRM_KMS_HELPER
+   select DRM_KMS_FB_HELPER
+   select DRM_PANEL
+   select FB_CFB_FILLRECT
+   select FB_CFB_COPYAREA
+   select FB_CFB_IMAGEBLIT
+   select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
+   select VIDEOMODE_HELPERS
+   help
+ Choose this option if you have a Rockchip soc chipset.
+ This driver provides kernel mode setting and buffer
+ management to userspace. This driver does not provides
+ 2D or 3D acceleration; acceleration is performed by other
+ IP found on the SoC.
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
new file mode 100644
index 000..6e6d468
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -0,0 +1,10 @@
+#
+# Makefile for the drm device driver.  This driver provides support for the
+# Direct 

Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-23 Thread Mark yao

On 2014年09月22日 21:24, Boris BREZILLON wrote:

Hi Mark,

You'll find some comments inline.
Anyway, I wouldn't call it a review (your driver is using some concepts
I'm not used to, like IOMMUs) but rather a collection of nitpicks :-).

I haven't been through the whole driver yet, but I'll get back to it
soon ;-).

And remember this is a 2 way thing, I wait for your review too
(here is the last version of my driver [1]) :-)


On Mon, 22 Sep 2014 18:48:54 +0800
Mark yao  wrote:


This patch adds the basic structure of a DRM Driver for Rockchip Socs.

Signed-off-by: Mark yao 
---
Changes in v2:
- use the component framework to defer main drm driver probe
   until all VOP devices have been probed.
- use dma-mapping API with ARM_DMA_USE_IOMMU, create dma mapping by
   master device and each vop device can shared the drm dma mapping.
- use drm_crtc_init_with_planes and drm_universal_plane_init.
- remove unnecessary middle layers.
- add cursor set, move funcs to rockchip drm crtc.
- use vop reset at first init
- reference framebuffer when used and unreference when swap out vop

Changes in v3:
- change "crtc->fb" to "crtc->primary-fb"
Adviced by Daniel Vetter
- init cursor plane with universal api, remove unnecessary cursor set,move

Changes in v4:
Adviced by David Herrmann
- remove drm_platform_*() usage, use register drm device directly.
Adviced by Rob Clark
- remove special mmap ioctl, do userspace mmap with normal mmap() or mmap offset

  drivers/gpu/drm/Kconfig   |2 +
  drivers/gpu/drm/Makefile  |1 +
  drivers/gpu/drm/rockchip/Kconfig  |   19 +
  drivers/gpu/drm/rockchip/Makefile |   10 +
  drivers/gpu/drm/rockchip/rockchip_drm_drv.c   |  524 ++
  drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |  120 +++
  drivers/gpu/drm/rockchip/rockchip_drm_fb.c|  201 
  drivers/gpu/drm/rockchip/rockchip_drm_fb.h|   28 +
  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  231 +
  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h |   20 +
  drivers/gpu/drm/rockchip/rockchip_drm_gem.c   |  404 
  drivers/gpu/drm/rockchip/rockchip_drm_gem.h   |   72 ++
  drivers/gpu/drm/rockchip/rockchip_drm_vop.c   | 1372 +
  drivers/gpu/drm/rockchip/rockchip_drm_vop.h   |  187 
  include/uapi/drm/rockchip_drm.h   |   75 ++
  15 files changed, 3266 insertions(+)
  create mode 100644 drivers/gpu/drm/rockchip/Kconfig
  create mode 100644 drivers/gpu/drm/rockchip/Makefile
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.h
  create mode 100644 include/uapi/drm/rockchip_drm.h

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index b066bb3..7c4c3c6 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -171,6 +171,8 @@ config DRM_SAVAGE
  
  source "drivers/gpu/drm/exynos/Kconfig"
  
+source "drivers/gpu/drm/rockchip/Kconfig"

+
  source "drivers/gpu/drm/vmwgfx/Kconfig"
  
  source "drivers/gpu/drm/gma500/Kconfig"

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 4a55d59..d03387a 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
  obj-$(CONFIG_DRM_VIA) +=via/
  obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/
  obj-$(CONFIG_DRM_EXYNOS) +=exynos/
+obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/
  obj-$(CONFIG_DRM_GMA500) += gma500/
  obj-$(CONFIG_DRM_UDL) += udl/
  obj-$(CONFIG_DRM_AST) += ast/
diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
new file mode 100644
index 000..7146c80
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -0,0 +1,19 @@
+config DRM_ROCKCHIP
+   tristate "DRM Support for Rockchip"
+   depends on DRM && ROCKCHIP_IOMMU
+   select ARM_DMA_USE_IOMMU
+   select IOMMU_API
+   select DRM_KMS_HELPER
+   select DRM_KMS_FB_HELPER
+   select DRM_PANEL
+   select FB_CFB_FILLRECT
+   select FB_CFB_COPYAREA
+   select FB_CFB_IMAGEBLIT
+   select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
+   select VIDEOMODE_HELPERS
+   help
+ Choose this option if you have a Rockchip soc chipset.
+ This driver provides kernel mode setting and buffer
+ management to userspace. This driver does not provides
+ 2D or 3D acceleration; acceleration is performed by other
+ IP found on the SoC.
diff 

Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-23 Thread Mark yao

On 2014年09月22日 21:24, Boris BREZILLON wrote:

Hi Mark,

You'll find some comments inline.
Anyway, I wouldn't call it a review (your driver is using some concepts
I'm not used to, like IOMMUs) but rather a collection of nitpicks :-).

I haven't been through the whole driver yet, but I'll get back to it
soon ;-).

And remember this is a 2 way thing, I wait for your review too
(here is the last version of my driver [1]) :-)


On Mon, 22 Sep 2014 18:48:54 +0800
Mark yao mark@rock-chips.com wrote:


This patch adds the basic structure of a DRM Driver for Rockchip Socs.

Signed-off-by: Mark yao mark@rock-chips.com
---
Changes in v2:
- use the component framework to defer main drm driver probe
   until all VOP devices have been probed.
- use dma-mapping API with ARM_DMA_USE_IOMMU, create dma mapping by
   master device and each vop device can shared the drm dma mapping.
- use drm_crtc_init_with_planes and drm_universal_plane_init.
- remove unnecessary middle layers.
- add cursor set, move funcs to rockchip drm crtc.
- use vop reset at first init
- reference framebuffer when used and unreference when swap out vop

Changes in v3:
- change crtc-fb to crtc-primary-fb
Adviced by Daniel Vetter
- init cursor plane with universal api, remove unnecessary cursor set,move

Changes in v4:
Adviced by David Herrmann
- remove drm_platform_*() usage, use register drm device directly.
Adviced by Rob Clark
- remove special mmap ioctl, do userspace mmap with normal mmap() or mmap offset

  drivers/gpu/drm/Kconfig   |2 +
  drivers/gpu/drm/Makefile  |1 +
  drivers/gpu/drm/rockchip/Kconfig  |   19 +
  drivers/gpu/drm/rockchip/Makefile |   10 +
  drivers/gpu/drm/rockchip/rockchip_drm_drv.c   |  524 ++
  drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |  120 +++
  drivers/gpu/drm/rockchip/rockchip_drm_fb.c|  201 
  drivers/gpu/drm/rockchip/rockchip_drm_fb.h|   28 +
  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  231 +
  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h |   20 +
  drivers/gpu/drm/rockchip/rockchip_drm_gem.c   |  404 
  drivers/gpu/drm/rockchip/rockchip_drm_gem.h   |   72 ++
  drivers/gpu/drm/rockchip/rockchip_drm_vop.c   | 1372 +
  drivers/gpu/drm/rockchip/rockchip_drm_vop.h   |  187 
  include/uapi/drm/rockchip_drm.h   |   75 ++
  15 files changed, 3266 insertions(+)
  create mode 100644 drivers/gpu/drm/rockchip/Kconfig
  create mode 100644 drivers/gpu/drm/rockchip/Makefile
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.h
  create mode 100644 include/uapi/drm/rockchip_drm.h

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index b066bb3..7c4c3c6 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -171,6 +171,8 @@ config DRM_SAVAGE
  
  source drivers/gpu/drm/exynos/Kconfig
  
+source drivers/gpu/drm/rockchip/Kconfig

+
  source drivers/gpu/drm/vmwgfx/Kconfig
  
  source drivers/gpu/drm/gma500/Kconfig

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 4a55d59..d03387a 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
  obj-$(CONFIG_DRM_VIA) +=via/
  obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/
  obj-$(CONFIG_DRM_EXYNOS) +=exynos/
+obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/
  obj-$(CONFIG_DRM_GMA500) += gma500/
  obj-$(CONFIG_DRM_UDL) += udl/
  obj-$(CONFIG_DRM_AST) += ast/
diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
new file mode 100644
index 000..7146c80
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -0,0 +1,19 @@
+config DRM_ROCKCHIP
+   tristate DRM Support for Rockchip
+   depends on DRM  ROCKCHIP_IOMMU
+   select ARM_DMA_USE_IOMMU
+   select IOMMU_API
+   select DRM_KMS_HELPER
+   select DRM_KMS_FB_HELPER
+   select DRM_PANEL
+   select FB_CFB_FILLRECT
+   select FB_CFB_COPYAREA
+   select FB_CFB_IMAGEBLIT
+   select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
+   select VIDEOMODE_HELPERS
+   help
+ Choose this option if you have a Rockchip soc chipset.
+ This driver provides kernel mode setting and buffer
+ management to userspace. This driver does not provides
+ 2D or 3D acceleration; acceleration is performed by other
+ IP 

Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-23 Thread Mark yao

On 2014年09月23日 03:10, Rob Clark wrote:

Ok, couple more small comments.. this time I actually had time to go
through the entire patch, not just the uapi


On Mon, Sep 22, 2014 at 6:48 AM, Mark yao mark@rock-chips.com wrote:

This patch adds the basic structure of a DRM Driver for Rockchip Socs.

Signed-off-by: Mark yao mark@rock-chips.com
---
Changes in v2:
- use the component framework to defer main drm driver probe
   until all VOP devices have been probed.
- use dma-mapping API with ARM_DMA_USE_IOMMU, create dma mapping by
   master device and each vop device can shared the drm dma mapping.
- use drm_crtc_init_with_planes and drm_universal_plane_init.
- remove unnecessary middle layers.
- add cursor set, move funcs to rockchip drm crtc.
- use vop reset at first init
- reference framebuffer when used and unreference when swap out vop

Changes in v3:
- change crtc-fb to crtc-primary-fb
Adviced by Daniel Vetter
- init cursor plane with universal api, remove unnecessary cursor set,move

Changes in v4:
Adviced by David Herrmann
- remove drm_platform_*() usage, use register drm device directly.
Adviced by Rob Clark
- remove special mmap ioctl, do userspace mmap with normal mmap() or mmap offset

  drivers/gpu/drm/Kconfig   |2 +
  drivers/gpu/drm/Makefile  |1 +
  drivers/gpu/drm/rockchip/Kconfig  |   19 +
  drivers/gpu/drm/rockchip/Makefile |   10 +
  drivers/gpu/drm/rockchip/rockchip_drm_drv.c   |  524 ++
  drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |  120 +++
  drivers/gpu/drm/rockchip/rockchip_drm_fb.c|  201 
  drivers/gpu/drm/rockchip/rockchip_drm_fb.h|   28 +
  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  231 +
  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h |   20 +
  drivers/gpu/drm/rockchip/rockchip_drm_gem.c   |  404 
  drivers/gpu/drm/rockchip/rockchip_drm_gem.h   |   72 ++
  drivers/gpu/drm/rockchip/rockchip_drm_vop.c   | 1372 +
  drivers/gpu/drm/rockchip/rockchip_drm_vop.h   |  187 
  include/uapi/drm/rockchip_drm.h   |   75 ++
  15 files changed, 3266 insertions(+)
  create mode 100644 drivers/gpu/drm/rockchip/Kconfig
  create mode 100644 drivers/gpu/drm/rockchip/Makefile
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.h
  create mode 100644 include/uapi/drm/rockchip_drm.h

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index b066bb3..7c4c3c6 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -171,6 +171,8 @@ config DRM_SAVAGE

  source drivers/gpu/drm/exynos/Kconfig

+source drivers/gpu/drm/rockchip/Kconfig
+
  source drivers/gpu/drm/vmwgfx/Kconfig

  source drivers/gpu/drm/gma500/Kconfig
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 4a55d59..d03387a 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
  obj-$(CONFIG_DRM_VIA)  +=via/
  obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/
  obj-$(CONFIG_DRM_EXYNOS) +=exynos/
+obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/
  obj-$(CONFIG_DRM_GMA500) += gma500/
  obj-$(CONFIG_DRM_UDL) += udl/
  obj-$(CONFIG_DRM_AST) += ast/
diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
new file mode 100644
index 000..7146c80
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -0,0 +1,19 @@
+config DRM_ROCKCHIP
+   tristate DRM Support for Rockchip
+   depends on DRM  ROCKCHIP_IOMMU
+   select ARM_DMA_USE_IOMMU
+   select IOMMU_API
+   select DRM_KMS_HELPER
+   select DRM_KMS_FB_HELPER
+   select DRM_PANEL
+   select FB_CFB_FILLRECT
+   select FB_CFB_COPYAREA
+   select FB_CFB_IMAGEBLIT
+   select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
+   select VIDEOMODE_HELPERS
+   help
+ Choose this option if you have a Rockchip soc chipset.
+ This driver provides kernel mode setting and buffer
+ management to userspace. This driver does not provides
+ 2D or 3D acceleration; acceleration is performed by other
+ IP found on the SoC.
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
new file mode 100644
index 000..6e6d468
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -0,0 +1,10 @@
+#
+# Makefile for the drm device driver.  This driver provides 

Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-23 Thread Mark yao

On 2014年09月22日 22:43, Arnd Bergmann wrote:

On Monday 22 September 2014 18:48:54 Mark yao wrote:

diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
new file mode 100644
index 000..7146c80
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -0,0 +1,19 @@
+config DRM_ROCKCHIP
+   tristate DRM Support for Rockchip
+   depends on DRM  ROCKCHIP_IOMMU
+   select ARM_DMA_USE_IOMMU
+   select IOMMU_API
+   select DRM_KMS_HELPER
+   select DRM_KMS_FB_HELPER
+   select DRM_PANEL
+   select FB_CFB_FILLRECT
+   select FB_CFB_COPYAREA
+   select FB_CFB_IMAGEBLIT
+   select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
+   select VIDEOMODE_HELPERS

Be careful with 'select', at least some of these should be 'depends on'.
In particular IOMMU_API and ARM_DMA_USE_IOMMU, but possibly others
as well. Just check how the symbols are used normally, if you get this
wrong, we can end up with incorrect dependencies or loops.


I see, I will change it.

diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
new file mode 100644
index 000..6e6d468
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -0,0 +1,10 @@
+#
+# Makefile for the drm device driver.  This driver provides support for the
+# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
+
+ccflags-y := -Iinclude/drm -Idrivers/gpu/drm/rockchip

The second one should not be required.

Sure, I will change it.

+static int rockchip_drm_load(struct drm_device *drm_dev, unsigned long flags)
+{
+   struct rockchip_drm_private *private;
+   struct dma_iommu_mapping *mapping;
+   struct device *dev = drm_dev-dev;
+   int ret;
+
+   private = devm_kzalloc(drm_dev-dev, sizeof(*private), GFP_KERNEL);
+   if (!private)
+   return -ENOMEM;
+
+   dev_set_drvdata(drm_dev-dev, dev);
+   drm_dev-dev_private = private;
+
+   drm_mode_config_init(drm_dev);
+
+   rockchip_drm_mode_config_init(drm_dev);
+
+   dev-dma_parms = devm_kzalloc(dev, sizeof(*dev-dma_parms),
+ GFP_KERNEL);
+   if (!dev-dma_parms) {
+   ret = -ENOMEM;
+   goto err_config_cleanup;
+   }
+
+   /* TODO(djkurtz): fetch the mapping start/size from somewhere */
+   mapping = arm_iommu_create_mapping(platform_bus_type, 0x1000,
+  SZ_1G);
+   if (IS_ERR(mapping)) {
+   ret = PTR_ERR(mapping);
+   goto err_config_cleanup;
+   }
+
+   dma_set_coherent_mask(dev, DMA_BIT_MASK(32));

This is the default coherent mask. If you call this function, you
should normally check the return value, or call dma_set_mask first,
which you apparently don't do here, and in another place in this
patch.

Arnd






--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-23 Thread Mark yao

On 2014年09月22日 23:54, Arnd Bergmann wrote:

On Monday 22 September 2014 17:15:06 Boris BREZILLON wrote:

+
+   /* TODO(djkurtz): fetch the mapping start/size from somewhere */
+   mapping = arm_iommu_create_mapping(platform_bus_type, 0x1000,
+  SZ_1G);
+   if (IS_ERR(mapping)) {
+   ret = PTR_ERR(mapping);
+   goto err_config_cleanup;
+   }
+
+   dma_set_coherent_mask(dev, DMA_BIT_MASK(32));

This is the default coherent mask. If you call this function, you
should normally check the return value, or call dma_set_mask first,
which you apparently don't do here, and in another place in this
patch.

By This is the default mask do you mean it shouldn't be called at
all ? Cause I ran into some trouble when not calling this in my
atmel-hlcdc driver.

We used to get this wrong in the of_platform code, but it should
work now.


Actually, in my case the platform device is created by the MFD core
which seems to let the coherent_dma_mask uninitialized.

That may well be different, but it seems like a good idea to allow
the MFD core to set this up as well.

In general, we expect that devices that are capable of doing DMA
start with a 32-bit mask for both dma_mask and dma_coherent_mask,
and a driver that requires a smaller masks or wants a larger mask
has to call the appropriate interface to set these, and check the
return value.
so I think we can use dma_set_mask_and_coherent(...) to set dma_mask and 
dma_coherent_mark

at the same time, and check the return value.

Arnd






--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-23 Thread Arnd Bergmann
On Tuesday 23 September 2014 15:09:37 Mark yao wrote:
 On 2014年09月22日 23:54, Arnd Bergmann wrote:
  On Monday 22 September 2014 17:15:06 Boris BREZILLON wrote:
  +
  +   /* TODO(djkurtz): fetch the mapping start/size from somewhere */
  +   mapping = arm_iommu_create_mapping(platform_bus_type, 0x1000,
  +  SZ_1G);
  +   if (IS_ERR(mapping)) {
  +   ret = PTR_ERR(mapping);
  +   goto err_config_cleanup;
  +   }
  +
  +   dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
  This is the default coherent mask. If you call this function, you
  should normally check the return value, or call dma_set_mask first,
  which you apparently don't do here, and in another place in this
  patch.
  By This is the default mask do you mean it shouldn't be called at
  all ? Cause I ran into some trouble when not calling this in my
  atmel-hlcdc driver.
  We used to get this wrong in the of_platform code, but it should
  work now.
 
  Actually, in my case the platform device is created by the MFD core
  which seems to let the coherent_dma_mask uninitialized.
  That may well be different, but it seems like a good idea to allow
  the MFD core to set this up as well.
 
  In general, we expect that devices that are capable of doing DMA
  start with a 32-bit mask for both dma_mask and dma_coherent_mask,
  and a driver that requires a smaller masks or wants a larger mask
  has to call the appropriate interface to set these, and check the
  return value.
 so I think we can use dma_set_mask_and_coherent(...) to set dma_mask and 
 dma_coherent_mark
 at the same time, and check the return value.

Yes, that would be good.

Arnd
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-22 Thread Rob Clark
Ok, couple more small comments.. this time I actually had time to go
through the entire patch, not just the uapi


On Mon, Sep 22, 2014 at 6:48 AM, Mark yao  wrote:
> This patch adds the basic structure of a DRM Driver for Rockchip Socs.
>
> Signed-off-by: Mark yao 
> ---
> Changes in v2:
> - use the component framework to defer main drm driver probe
>   until all VOP devices have been probed.
> - use dma-mapping API with ARM_DMA_USE_IOMMU, create dma mapping by
>   master device and each vop device can shared the drm dma mapping.
> - use drm_crtc_init_with_planes and drm_universal_plane_init.
> - remove unnecessary middle layers.
> - add cursor set, move funcs to rockchip drm crtc.
> - use vop reset at first init
> - reference framebuffer when used and unreference when swap out vop
>
> Changes in v3:
> - change "crtc->fb" to "crtc->primary-fb"
> Adviced by Daniel Vetter
> - init cursor plane with universal api, remove unnecessary cursor set,move
>
> Changes in v4:
> Adviced by David Herrmann
> - remove drm_platform_*() usage, use register drm device directly.
> Adviced by Rob Clark
> - remove special mmap ioctl, do userspace mmap with normal mmap() or mmap 
> offset
>
>  drivers/gpu/drm/Kconfig   |2 +
>  drivers/gpu/drm/Makefile  |1 +
>  drivers/gpu/drm/rockchip/Kconfig  |   19 +
>  drivers/gpu/drm/rockchip/Makefile |   10 +
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c   |  524 ++
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |  120 +++
>  drivers/gpu/drm/rockchip/rockchip_drm_fb.c|  201 
>  drivers/gpu/drm/rockchip/rockchip_drm_fb.h|   28 +
>  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  231 +
>  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h |   20 +
>  drivers/gpu/drm/rockchip/rockchip_drm_gem.c   |  404 
>  drivers/gpu/drm/rockchip/rockchip_drm_gem.h   |   72 ++
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c   | 1372 
> +
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.h   |  187 
>  include/uapi/drm/rockchip_drm.h   |   75 ++
>  15 files changed, 3266 insertions(+)
>  create mode 100644 drivers/gpu/drm/rockchip/Kconfig
>  create mode 100644 drivers/gpu/drm/rockchip/Makefile
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.c
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.h
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.c
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.h
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.h
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.c
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.h
>  create mode 100644 include/uapi/drm/rockchip_drm.h
>
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index b066bb3..7c4c3c6 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -171,6 +171,8 @@ config DRM_SAVAGE
>
>  source "drivers/gpu/drm/exynos/Kconfig"
>
> +source "drivers/gpu/drm/rockchip/Kconfig"
> +
>  source "drivers/gpu/drm/vmwgfx/Kconfig"
>
>  source "drivers/gpu/drm/gma500/Kconfig"
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index 4a55d59..d03387a 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -52,6 +52,7 @@ obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
>  obj-$(CONFIG_DRM_VIA)  +=via/
>  obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/
>  obj-$(CONFIG_DRM_EXYNOS) +=exynos/
> +obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/
>  obj-$(CONFIG_DRM_GMA500) += gma500/
>  obj-$(CONFIG_DRM_UDL) += udl/
>  obj-$(CONFIG_DRM_AST) += ast/
> diff --git a/drivers/gpu/drm/rockchip/Kconfig 
> b/drivers/gpu/drm/rockchip/Kconfig
> new file mode 100644
> index 000..7146c80
> --- /dev/null
> +++ b/drivers/gpu/drm/rockchip/Kconfig
> @@ -0,0 +1,19 @@
> +config DRM_ROCKCHIP
> +   tristate "DRM Support for Rockchip"
> +   depends on DRM && ROCKCHIP_IOMMU
> +   select ARM_DMA_USE_IOMMU
> +   select IOMMU_API
> +   select DRM_KMS_HELPER
> +   select DRM_KMS_FB_HELPER
> +   select DRM_PANEL
> +   select FB_CFB_FILLRECT
> +   select FB_CFB_COPYAREA
> +   select FB_CFB_IMAGEBLIT
> +   select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
> +   select VIDEOMODE_HELPERS
> +   help
> + Choose this option if you have a Rockchip soc chipset.
> + This driver provides kernel mode setting and buffer
> + management to userspace. This driver does not provides
> + 2D or 3D acceleration; acceleration is performed by other
> + IP found on the SoC.
> diff --git a/drivers/gpu/drm/rockchip/Makefile 
> b/drivers/gpu/drm/rockchip/Makefile
> new file mode 100644
> index 000..6e6d468
> --- /dev/null
> +++ 

Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-22 Thread Arnd Bergmann
On Monday 22 September 2014 17:15:06 Boris BREZILLON wrote:
> > > +
> > > +   /* TODO(djkurtz): fetch the mapping start/size from somewhere */
> > > +   mapping = arm_iommu_create_mapping(_bus_type, 0x1000,
> > > +  SZ_1G);
> > > +   if (IS_ERR(mapping)) {
> > > +   ret = PTR_ERR(mapping);
> > > +   goto err_config_cleanup;
> > > +   }
> > > +
> > > +   dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
> > 
> > This is the default coherent mask. If you call this function, you
> > should normally check the return value, or call dma_set_mask first,
> > which you apparently don't do here, and in another place in this
> > patch.
> 
> By "This is the default mask" do you mean it shouldn't be called at
> all ? Cause I ran into some trouble when not calling this in my
> atmel-hlcdc driver.

We used to get this wrong in the of_platform code, but it should
work now.

> Actually, in my case the platform device is created by the MFD core
> which seems to let the coherent_dma_mask uninitialized.

That may well be different, but it seems like a good idea to allow
the MFD core to set this up as well.

In general, we expect that devices that are capable of doing DMA
start with a 32-bit mask for both dma_mask and dma_coherent_mask,
and a driver that requires a smaller masks or wants a larger mask
has to call the appropriate interface to set these, and check the
return value.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-22 Thread Boris BREZILLON
On Mon, 22 Sep 2014 16:43:31 +0200
Arnd Bergmann  wrote:

> On Monday 22 September 2014 18:48:54 Mark yao wrote:
> > diff --git a/drivers/gpu/drm/rockchip/Kconfig 
> > b/drivers/gpu/drm/rockchip/Kconfig
> > new file mode 100644
> > index 000..7146c80
> > --- /dev/null
> > +++ b/drivers/gpu/drm/rockchip/Kconfig
> > @@ -0,0 +1,19 @@
> > +config DRM_ROCKCHIP
> > +   tristate "DRM Support for Rockchip"
> > +   depends on DRM && ROCKCHIP_IOMMU
> > +   select ARM_DMA_USE_IOMMU
> > +   select IOMMU_API
> > +   select DRM_KMS_HELPER
> > +   select DRM_KMS_FB_HELPER
> > +   select DRM_PANEL
> > +   select FB_CFB_FILLRECT
> > +   select FB_CFB_COPYAREA
> > +   select FB_CFB_IMAGEBLIT
> > +   select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
> > +   select VIDEOMODE_HELPERS
> 
> Be careful with 'select', at least some of these should be 'depends on'.
> In particular IOMMU_API and ARM_DMA_USE_IOMMU, but possibly others
> as well. Just check how the symbols are used normally, if you get this
> wrong, we can end up with incorrect dependencies or loops.
> 
> > diff --git a/drivers/gpu/drm/rockchip/Makefile 
> > b/drivers/gpu/drm/rockchip/Makefile
> > new file mode 100644
> > index 000..6e6d468
> > --- /dev/null
> > +++ b/drivers/gpu/drm/rockchip/Makefile
> > @@ -0,0 +1,10 @@
> > +#
> > +# Makefile for the drm device driver.  This driver provides support for the
> > +# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
> > +
> > +ccflags-y := -Iinclude/drm -Idrivers/gpu/drm/rockchip
> 
> The second one should not be required.
> 
> > +static int rockchip_drm_load(struct drm_device *drm_dev, unsigned long 
> > flags)
> > +{
> > +   struct rockchip_drm_private *private;
> > +   struct dma_iommu_mapping *mapping;
> > +   struct device *dev = drm_dev->dev;
> > +   int ret;
> > +
> > +   private = devm_kzalloc(drm_dev->dev, sizeof(*private), GFP_KERNEL);
> > +   if (!private)
> > +   return -ENOMEM;
> > +
> > +   dev_set_drvdata(drm_dev->dev, dev);
> > +   drm_dev->dev_private = private;
> > +
> > +   drm_mode_config_init(drm_dev);
> > +
> > +   rockchip_drm_mode_config_init(drm_dev);
> > +
> > +   dev->dma_parms = devm_kzalloc(dev, sizeof(*dev->dma_parms),
> > + GFP_KERNEL);
> > +   if (!dev->dma_parms) {
> > +   ret = -ENOMEM;
> > +   goto err_config_cleanup;
> > +   }
> > +
> > +   /* TODO(djkurtz): fetch the mapping start/size from somewhere */
> > +   mapping = arm_iommu_create_mapping(_bus_type, 0x1000,
> > +  SZ_1G);
> > +   if (IS_ERR(mapping)) {
> > +   ret = PTR_ERR(mapping);
> > +   goto err_config_cleanup;
> > +   }
> > +
> > +   dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
> 
> This is the default coherent mask. If you call this function, you
> should normally check the return value, or call dma_set_mask first,
> which you apparently don't do here, and in another place in this
> patch.

By "This is the default mask" do you mean it shouldn't be called at
all ? Cause I ran into some trouble when not calling this in my
atmel-hlcdc driver.
Actually, in my case the platform device is created by the MFD core
which seems to let the coherent_dma_mask uninitialized.

Best Regards,

Boris


-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-22 Thread Arnd Bergmann
On Monday 22 September 2014 18:48:54 Mark yao wrote:
> diff --git a/drivers/gpu/drm/rockchip/Kconfig 
> b/drivers/gpu/drm/rockchip/Kconfig
> new file mode 100644
> index 000..7146c80
> --- /dev/null
> +++ b/drivers/gpu/drm/rockchip/Kconfig
> @@ -0,0 +1,19 @@
> +config DRM_ROCKCHIP
> + tristate "DRM Support for Rockchip"
> + depends on DRM && ROCKCHIP_IOMMU
> + select ARM_DMA_USE_IOMMU
> + select IOMMU_API
> + select DRM_KMS_HELPER
> + select DRM_KMS_FB_HELPER
> + select DRM_PANEL
> + select FB_CFB_FILLRECT
> + select FB_CFB_COPYAREA
> + select FB_CFB_IMAGEBLIT
> + select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
> + select VIDEOMODE_HELPERS

Be careful with 'select', at least some of these should be 'depends on'.
In particular IOMMU_API and ARM_DMA_USE_IOMMU, but possibly others
as well. Just check how the symbols are used normally, if you get this
wrong, we can end up with incorrect dependencies or loops.

> diff --git a/drivers/gpu/drm/rockchip/Makefile 
> b/drivers/gpu/drm/rockchip/Makefile
> new file mode 100644
> index 000..6e6d468
> --- /dev/null
> +++ b/drivers/gpu/drm/rockchip/Makefile
> @@ -0,0 +1,10 @@
> +#
> +# Makefile for the drm device driver.  This driver provides support for the
> +# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
> +
> +ccflags-y := -Iinclude/drm -Idrivers/gpu/drm/rockchip

The second one should not be required.

> +static int rockchip_drm_load(struct drm_device *drm_dev, unsigned long flags)
> +{
> + struct rockchip_drm_private *private;
> + struct dma_iommu_mapping *mapping;
> + struct device *dev = drm_dev->dev;
> + int ret;
> +
> + private = devm_kzalloc(drm_dev->dev, sizeof(*private), GFP_KERNEL);
> + if (!private)
> + return -ENOMEM;
> +
> + dev_set_drvdata(drm_dev->dev, dev);
> + drm_dev->dev_private = private;
> +
> + drm_mode_config_init(drm_dev);
> +
> + rockchip_drm_mode_config_init(drm_dev);
> +
> + dev->dma_parms = devm_kzalloc(dev, sizeof(*dev->dma_parms),
> +   GFP_KERNEL);
> + if (!dev->dma_parms) {
> + ret = -ENOMEM;
> + goto err_config_cleanup;
> + }
> +
> + /* TODO(djkurtz): fetch the mapping start/size from somewhere */
> + mapping = arm_iommu_create_mapping(_bus_type, 0x1000,
> +SZ_1G);
> + if (IS_ERR(mapping)) {
> + ret = PTR_ERR(mapping);
> + goto err_config_cleanup;
> + }
> +
> + dma_set_coherent_mask(dev, DMA_BIT_MASK(32));

This is the default coherent mask. If you call this function, you
should normally check the return value, or call dma_set_mask first,
which you apparently don't do here, and in another place in this
patch.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-22 Thread Boris BREZILLON
Hi Mark,

You'll find some comments inline.
Anyway, I wouldn't call it a review (your driver is using some concepts
I'm not used to, like IOMMUs) but rather a collection of nitpicks :-).

I haven't been through the whole driver yet, but I'll get back to it
soon ;-).

And remember this is a 2 way thing, I wait for your review too
(here is the last version of my driver [1]) :-)


On Mon, 22 Sep 2014 18:48:54 +0800
Mark yao  wrote:

> This patch adds the basic structure of a DRM Driver for Rockchip Socs.
> 
> Signed-off-by: Mark yao 
> ---
> Changes in v2:
> - use the component framework to defer main drm driver probe
>   until all VOP devices have been probed.
> - use dma-mapping API with ARM_DMA_USE_IOMMU, create dma mapping by
>   master device and each vop device can shared the drm dma mapping.
> - use drm_crtc_init_with_planes and drm_universal_plane_init.
> - remove unnecessary middle layers.
> - add cursor set, move funcs to rockchip drm crtc.
> - use vop reset at first init
> - reference framebuffer when used and unreference when swap out vop
> 
> Changes in v3:
> - change "crtc->fb" to "crtc->primary-fb"
> Adviced by Daniel Vetter
> - init cursor plane with universal api, remove unnecessary cursor set,move 
> 
> Changes in v4:
> Adviced by David Herrmann
> - remove drm_platform_*() usage, use register drm device directly.
> Adviced by Rob Clark
> - remove special mmap ioctl, do userspace mmap with normal mmap() or mmap 
> offset
> 
>  drivers/gpu/drm/Kconfig   |2 +
>  drivers/gpu/drm/Makefile  |1 +
>  drivers/gpu/drm/rockchip/Kconfig  |   19 +
>  drivers/gpu/drm/rockchip/Makefile |   10 +
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c   |  524 ++
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |  120 +++
>  drivers/gpu/drm/rockchip/rockchip_drm_fb.c|  201 
>  drivers/gpu/drm/rockchip/rockchip_drm_fb.h|   28 +
>  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  231 +
>  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h |   20 +
>  drivers/gpu/drm/rockchip/rockchip_drm_gem.c   |  404 
>  drivers/gpu/drm/rockchip/rockchip_drm_gem.h   |   72 ++
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c   | 1372 
> +
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.h   |  187 
>  include/uapi/drm/rockchip_drm.h   |   75 ++
>  15 files changed, 3266 insertions(+)
>  create mode 100644 drivers/gpu/drm/rockchip/Kconfig
>  create mode 100644 drivers/gpu/drm/rockchip/Makefile
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.c
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.h
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.c
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.h
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.h
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.c
>  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.h
>  create mode 100644 include/uapi/drm/rockchip_drm.h
> 
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index b066bb3..7c4c3c6 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -171,6 +171,8 @@ config DRM_SAVAGE
>  
>  source "drivers/gpu/drm/exynos/Kconfig"
>  
> +source "drivers/gpu/drm/rockchip/Kconfig"
> +
>  source "drivers/gpu/drm/vmwgfx/Kconfig"
>  
>  source "drivers/gpu/drm/gma500/Kconfig"
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index 4a55d59..d03387a 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -52,6 +52,7 @@ obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
>  obj-$(CONFIG_DRM_VIA)+=via/
>  obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/
>  obj-$(CONFIG_DRM_EXYNOS) +=exynos/
> +obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/
>  obj-$(CONFIG_DRM_GMA500) += gma500/
>  obj-$(CONFIG_DRM_UDL) += udl/
>  obj-$(CONFIG_DRM_AST) += ast/
> diff --git a/drivers/gpu/drm/rockchip/Kconfig 
> b/drivers/gpu/drm/rockchip/Kconfig
> new file mode 100644
> index 000..7146c80
> --- /dev/null
> +++ b/drivers/gpu/drm/rockchip/Kconfig
> @@ -0,0 +1,19 @@
> +config DRM_ROCKCHIP
> + tristate "DRM Support for Rockchip"
> + depends on DRM && ROCKCHIP_IOMMU
> + select ARM_DMA_USE_IOMMU
> + select IOMMU_API
> + select DRM_KMS_HELPER
> + select DRM_KMS_FB_HELPER
> + select DRM_PANEL
> + select FB_CFB_FILLRECT
> + select FB_CFB_COPYAREA
> + select FB_CFB_IMAGEBLIT
> + select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
> + select VIDEOMODE_HELPERS
> + help
> +   Choose this option if you have a Rockchip soc chipset.
> +   This driver provides kernel mode setting and buffer
> +   management to userspace. This driver does not provides
> +  

[PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-22 Thread Mark yao
This patch adds the basic structure of a DRM Driver for Rockchip Socs.

Signed-off-by: Mark yao 
---
Changes in v2:
- use the component framework to defer main drm driver probe
  until all VOP devices have been probed.
- use dma-mapping API with ARM_DMA_USE_IOMMU, create dma mapping by
  master device and each vop device can shared the drm dma mapping.
- use drm_crtc_init_with_planes and drm_universal_plane_init.
- remove unnecessary middle layers.
- add cursor set, move funcs to rockchip drm crtc.
- use vop reset at first init
- reference framebuffer when used and unreference when swap out vop

Changes in v3:
- change "crtc->fb" to "crtc->primary-fb"
Adviced by Daniel Vetter
- init cursor plane with universal api, remove unnecessary cursor set,move 

Changes in v4:
Adviced by David Herrmann
- remove drm_platform_*() usage, use register drm device directly.
Adviced by Rob Clark
- remove special mmap ioctl, do userspace mmap with normal mmap() or mmap offset

 drivers/gpu/drm/Kconfig   |2 +
 drivers/gpu/drm/Makefile  |1 +
 drivers/gpu/drm/rockchip/Kconfig  |   19 +
 drivers/gpu/drm/rockchip/Makefile |   10 +
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c   |  524 ++
 drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |  120 +++
 drivers/gpu/drm/rockchip/rockchip_drm_fb.c|  201 
 drivers/gpu/drm/rockchip/rockchip_drm_fb.h|   28 +
 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  231 +
 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h |   20 +
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c   |  404 
 drivers/gpu/drm/rockchip/rockchip_drm_gem.h   |   72 ++
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c   | 1372 +
 drivers/gpu/drm/rockchip/rockchip_drm_vop.h   |  187 
 include/uapi/drm/rockchip_drm.h   |   75 ++
 15 files changed, 3266 insertions(+)
 create mode 100644 drivers/gpu/drm/rockchip/Kconfig
 create mode 100644 drivers/gpu/drm/rockchip/Makefile
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.c
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.h
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.c
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.h
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.c
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.h
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.c
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.h
 create mode 100644 include/uapi/drm/rockchip_drm.h

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index b066bb3..7c4c3c6 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -171,6 +171,8 @@ config DRM_SAVAGE
 
 source "drivers/gpu/drm/exynos/Kconfig"
 
+source "drivers/gpu/drm/rockchip/Kconfig"
+
 source "drivers/gpu/drm/vmwgfx/Kconfig"
 
 source "drivers/gpu/drm/gma500/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 4a55d59..d03387a 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
 obj-$(CONFIG_DRM_VIA)  +=via/
 obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/
 obj-$(CONFIG_DRM_EXYNOS) +=exynos/
+obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/
 obj-$(CONFIG_DRM_GMA500) += gma500/
 obj-$(CONFIG_DRM_UDL) += udl/
 obj-$(CONFIG_DRM_AST) += ast/
diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
new file mode 100644
index 000..7146c80
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -0,0 +1,19 @@
+config DRM_ROCKCHIP
+   tristate "DRM Support for Rockchip"
+   depends on DRM && ROCKCHIP_IOMMU
+   select ARM_DMA_USE_IOMMU
+   select IOMMU_API
+   select DRM_KMS_HELPER
+   select DRM_KMS_FB_HELPER
+   select DRM_PANEL
+   select FB_CFB_FILLRECT
+   select FB_CFB_COPYAREA
+   select FB_CFB_IMAGEBLIT
+   select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
+   select VIDEOMODE_HELPERS
+   help
+ Choose this option if you have a Rockchip soc chipset.
+ This driver provides kernel mode setting and buffer
+ management to userspace. This driver does not provides
+ 2D or 3D acceleration; acceleration is performed by other
+ IP found on the SoC.
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
new file mode 100644
index 000..6e6d468
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -0,0 +1,10 @@
+#
+# Makefile for the drm device driver.  This driver provides support for the
+# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
+
+ccflags-y := -Iinclude/drm -Idrivers/gpu/drm/rockchip
+
+rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o rockchip_drm_fbdev.o \
+   rockchip_drm_gem.o 

[PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-22 Thread Mark yao
This patch adds the basic structure of a DRM Driver for Rockchip Socs.

Signed-off-by: Mark yao mark@rock-chips.com
---
Changes in v2:
- use the component framework to defer main drm driver probe
  until all VOP devices have been probed.
- use dma-mapping API with ARM_DMA_USE_IOMMU, create dma mapping by
  master device and each vop device can shared the drm dma mapping.
- use drm_crtc_init_with_planes and drm_universal_plane_init.
- remove unnecessary middle layers.
- add cursor set, move funcs to rockchip drm crtc.
- use vop reset at first init
- reference framebuffer when used and unreference when swap out vop

Changes in v3:
- change crtc-fb to crtc-primary-fb
Adviced by Daniel Vetter
- init cursor plane with universal api, remove unnecessary cursor set,move 

Changes in v4:
Adviced by David Herrmann
- remove drm_platform_*() usage, use register drm device directly.
Adviced by Rob Clark
- remove special mmap ioctl, do userspace mmap with normal mmap() or mmap offset

 drivers/gpu/drm/Kconfig   |2 +
 drivers/gpu/drm/Makefile  |1 +
 drivers/gpu/drm/rockchip/Kconfig  |   19 +
 drivers/gpu/drm/rockchip/Makefile |   10 +
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c   |  524 ++
 drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |  120 +++
 drivers/gpu/drm/rockchip/rockchip_drm_fb.c|  201 
 drivers/gpu/drm/rockchip/rockchip_drm_fb.h|   28 +
 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  231 +
 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h |   20 +
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c   |  404 
 drivers/gpu/drm/rockchip/rockchip_drm_gem.h   |   72 ++
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c   | 1372 +
 drivers/gpu/drm/rockchip/rockchip_drm_vop.h   |  187 
 include/uapi/drm/rockchip_drm.h   |   75 ++
 15 files changed, 3266 insertions(+)
 create mode 100644 drivers/gpu/drm/rockchip/Kconfig
 create mode 100644 drivers/gpu/drm/rockchip/Makefile
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.c
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.h
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.c
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.h
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.c
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.h
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.c
 create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.h
 create mode 100644 include/uapi/drm/rockchip_drm.h

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index b066bb3..7c4c3c6 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -171,6 +171,8 @@ config DRM_SAVAGE
 
 source drivers/gpu/drm/exynos/Kconfig
 
+source drivers/gpu/drm/rockchip/Kconfig
+
 source drivers/gpu/drm/vmwgfx/Kconfig
 
 source drivers/gpu/drm/gma500/Kconfig
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 4a55d59..d03387a 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
 obj-$(CONFIG_DRM_VIA)  +=via/
 obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/
 obj-$(CONFIG_DRM_EXYNOS) +=exynos/
+obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/
 obj-$(CONFIG_DRM_GMA500) += gma500/
 obj-$(CONFIG_DRM_UDL) += udl/
 obj-$(CONFIG_DRM_AST) += ast/
diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
new file mode 100644
index 000..7146c80
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -0,0 +1,19 @@
+config DRM_ROCKCHIP
+   tristate DRM Support for Rockchip
+   depends on DRM  ROCKCHIP_IOMMU
+   select ARM_DMA_USE_IOMMU
+   select IOMMU_API
+   select DRM_KMS_HELPER
+   select DRM_KMS_FB_HELPER
+   select DRM_PANEL
+   select FB_CFB_FILLRECT
+   select FB_CFB_COPYAREA
+   select FB_CFB_IMAGEBLIT
+   select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
+   select VIDEOMODE_HELPERS
+   help
+ Choose this option if you have a Rockchip soc chipset.
+ This driver provides kernel mode setting and buffer
+ management to userspace. This driver does not provides
+ 2D or 3D acceleration; acceleration is performed by other
+ IP found on the SoC.
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
new file mode 100644
index 000..6e6d468
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -0,0 +1,10 @@
+#
+# Makefile for the drm device driver.  This driver provides support for the
+# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
+
+ccflags-y := -Iinclude/drm -Idrivers/gpu/drm/rockchip
+
+rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o rockchip_drm_fbdev.o \
+   rockchip_drm_gem.o 

Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-22 Thread Boris BREZILLON
Hi Mark,

You'll find some comments inline.
Anyway, I wouldn't call it a review (your driver is using some concepts
I'm not used to, like IOMMUs) but rather a collection of nitpicks :-).

I haven't been through the whole driver yet, but I'll get back to it
soon ;-).

And remember this is a 2 way thing, I wait for your review too
(here is the last version of my driver [1]) :-)


On Mon, 22 Sep 2014 18:48:54 +0800
Mark yao mark@rock-chips.com wrote:

 This patch adds the basic structure of a DRM Driver for Rockchip Socs.
 
 Signed-off-by: Mark yao mark@rock-chips.com
 ---
 Changes in v2:
 - use the component framework to defer main drm driver probe
   until all VOP devices have been probed.
 - use dma-mapping API with ARM_DMA_USE_IOMMU, create dma mapping by
   master device and each vop device can shared the drm dma mapping.
 - use drm_crtc_init_with_planes and drm_universal_plane_init.
 - remove unnecessary middle layers.
 - add cursor set, move funcs to rockchip drm crtc.
 - use vop reset at first init
 - reference framebuffer when used and unreference when swap out vop
 
 Changes in v3:
 - change crtc-fb to crtc-primary-fb
 Adviced by Daniel Vetter
 - init cursor plane with universal api, remove unnecessary cursor set,move 
 
 Changes in v4:
 Adviced by David Herrmann
 - remove drm_platform_*() usage, use register drm device directly.
 Adviced by Rob Clark
 - remove special mmap ioctl, do userspace mmap with normal mmap() or mmap 
 offset
 
  drivers/gpu/drm/Kconfig   |2 +
  drivers/gpu/drm/Makefile  |1 +
  drivers/gpu/drm/rockchip/Kconfig  |   19 +
  drivers/gpu/drm/rockchip/Makefile |   10 +
  drivers/gpu/drm/rockchip/rockchip_drm_drv.c   |  524 ++
  drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |  120 +++
  drivers/gpu/drm/rockchip/rockchip_drm_fb.c|  201 
  drivers/gpu/drm/rockchip/rockchip_drm_fb.h|   28 +
  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  231 +
  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h |   20 +
  drivers/gpu/drm/rockchip/rockchip_drm_gem.c   |  404 
  drivers/gpu/drm/rockchip/rockchip_drm_gem.h   |   72 ++
  drivers/gpu/drm/rockchip/rockchip_drm_vop.c   | 1372 
 +
  drivers/gpu/drm/rockchip/rockchip_drm_vop.h   |  187 
  include/uapi/drm/rockchip_drm.h   |   75 ++
  15 files changed, 3266 insertions(+)
  create mode 100644 drivers/gpu/drm/rockchip/Kconfig
  create mode 100644 drivers/gpu/drm/rockchip/Makefile
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.h
  create mode 100644 include/uapi/drm/rockchip_drm.h
 
 diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
 index b066bb3..7c4c3c6 100644
 --- a/drivers/gpu/drm/Kconfig
 +++ b/drivers/gpu/drm/Kconfig
 @@ -171,6 +171,8 @@ config DRM_SAVAGE
  
  source drivers/gpu/drm/exynos/Kconfig
  
 +source drivers/gpu/drm/rockchip/Kconfig
 +
  source drivers/gpu/drm/vmwgfx/Kconfig
  
  source drivers/gpu/drm/gma500/Kconfig
 diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
 index 4a55d59..d03387a 100644
 --- a/drivers/gpu/drm/Makefile
 +++ b/drivers/gpu/drm/Makefile
 @@ -52,6 +52,7 @@ obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
  obj-$(CONFIG_DRM_VIA)+=via/
  obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/
  obj-$(CONFIG_DRM_EXYNOS) +=exynos/
 +obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/
  obj-$(CONFIG_DRM_GMA500) += gma500/
  obj-$(CONFIG_DRM_UDL) += udl/
  obj-$(CONFIG_DRM_AST) += ast/
 diff --git a/drivers/gpu/drm/rockchip/Kconfig 
 b/drivers/gpu/drm/rockchip/Kconfig
 new file mode 100644
 index 000..7146c80
 --- /dev/null
 +++ b/drivers/gpu/drm/rockchip/Kconfig
 @@ -0,0 +1,19 @@
 +config DRM_ROCKCHIP
 + tristate DRM Support for Rockchip
 + depends on DRM  ROCKCHIP_IOMMU
 + select ARM_DMA_USE_IOMMU
 + select IOMMU_API
 + select DRM_KMS_HELPER
 + select DRM_KMS_FB_HELPER
 + select DRM_PANEL
 + select FB_CFB_FILLRECT
 + select FB_CFB_COPYAREA
 + select FB_CFB_IMAGEBLIT
 + select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
 + select VIDEOMODE_HELPERS
 + help
 +   Choose this option if you have a Rockchip soc chipset.
 +   This driver provides kernel mode setting and buffer
 +   management to userspace. This driver does not provides
 +   2D or 3D acceleration; acceleration is performed by other
 +   IP found on 

Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-22 Thread Arnd Bergmann
On Monday 22 September 2014 18:48:54 Mark yao wrote:
 diff --git a/drivers/gpu/drm/rockchip/Kconfig 
 b/drivers/gpu/drm/rockchip/Kconfig
 new file mode 100644
 index 000..7146c80
 --- /dev/null
 +++ b/drivers/gpu/drm/rockchip/Kconfig
 @@ -0,0 +1,19 @@
 +config DRM_ROCKCHIP
 + tristate DRM Support for Rockchip
 + depends on DRM  ROCKCHIP_IOMMU
 + select ARM_DMA_USE_IOMMU
 + select IOMMU_API
 + select DRM_KMS_HELPER
 + select DRM_KMS_FB_HELPER
 + select DRM_PANEL
 + select FB_CFB_FILLRECT
 + select FB_CFB_COPYAREA
 + select FB_CFB_IMAGEBLIT
 + select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
 + select VIDEOMODE_HELPERS

Be careful with 'select', at least some of these should be 'depends on'.
In particular IOMMU_API and ARM_DMA_USE_IOMMU, but possibly others
as well. Just check how the symbols are used normally, if you get this
wrong, we can end up with incorrect dependencies or loops.

 diff --git a/drivers/gpu/drm/rockchip/Makefile 
 b/drivers/gpu/drm/rockchip/Makefile
 new file mode 100644
 index 000..6e6d468
 --- /dev/null
 +++ b/drivers/gpu/drm/rockchip/Makefile
 @@ -0,0 +1,10 @@
 +#
 +# Makefile for the drm device driver.  This driver provides support for the
 +# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
 +
 +ccflags-y := -Iinclude/drm -Idrivers/gpu/drm/rockchip

The second one should not be required.

 +static int rockchip_drm_load(struct drm_device *drm_dev, unsigned long flags)
 +{
 + struct rockchip_drm_private *private;
 + struct dma_iommu_mapping *mapping;
 + struct device *dev = drm_dev-dev;
 + int ret;
 +
 + private = devm_kzalloc(drm_dev-dev, sizeof(*private), GFP_KERNEL);
 + if (!private)
 + return -ENOMEM;
 +
 + dev_set_drvdata(drm_dev-dev, dev);
 + drm_dev-dev_private = private;
 +
 + drm_mode_config_init(drm_dev);
 +
 + rockchip_drm_mode_config_init(drm_dev);
 +
 + dev-dma_parms = devm_kzalloc(dev, sizeof(*dev-dma_parms),
 +   GFP_KERNEL);
 + if (!dev-dma_parms) {
 + ret = -ENOMEM;
 + goto err_config_cleanup;
 + }
 +
 + /* TODO(djkurtz): fetch the mapping start/size from somewhere */
 + mapping = arm_iommu_create_mapping(platform_bus_type, 0x1000,
 +SZ_1G);
 + if (IS_ERR(mapping)) {
 + ret = PTR_ERR(mapping);
 + goto err_config_cleanup;
 + }
 +
 + dma_set_coherent_mask(dev, DMA_BIT_MASK(32));

This is the default coherent mask. If you call this function, you
should normally check the return value, or call dma_set_mask first,
which you apparently don't do here, and in another place in this
patch.

Arnd
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-22 Thread Boris BREZILLON
On Mon, 22 Sep 2014 16:43:31 +0200
Arnd Bergmann a...@arndb.de wrote:

 On Monday 22 September 2014 18:48:54 Mark yao wrote:
  diff --git a/drivers/gpu/drm/rockchip/Kconfig 
  b/drivers/gpu/drm/rockchip/Kconfig
  new file mode 100644
  index 000..7146c80
  --- /dev/null
  +++ b/drivers/gpu/drm/rockchip/Kconfig
  @@ -0,0 +1,19 @@
  +config DRM_ROCKCHIP
  +   tristate DRM Support for Rockchip
  +   depends on DRM  ROCKCHIP_IOMMU
  +   select ARM_DMA_USE_IOMMU
  +   select IOMMU_API
  +   select DRM_KMS_HELPER
  +   select DRM_KMS_FB_HELPER
  +   select DRM_PANEL
  +   select FB_CFB_FILLRECT
  +   select FB_CFB_COPYAREA
  +   select FB_CFB_IMAGEBLIT
  +   select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
  +   select VIDEOMODE_HELPERS
 
 Be careful with 'select', at least some of these should be 'depends on'.
 In particular IOMMU_API and ARM_DMA_USE_IOMMU, but possibly others
 as well. Just check how the symbols are used normally, if you get this
 wrong, we can end up with incorrect dependencies or loops.
 
  diff --git a/drivers/gpu/drm/rockchip/Makefile 
  b/drivers/gpu/drm/rockchip/Makefile
  new file mode 100644
  index 000..6e6d468
  --- /dev/null
  +++ b/drivers/gpu/drm/rockchip/Makefile
  @@ -0,0 +1,10 @@
  +#
  +# Makefile for the drm device driver.  This driver provides support for the
  +# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
  +
  +ccflags-y := -Iinclude/drm -Idrivers/gpu/drm/rockchip
 
 The second one should not be required.
 
  +static int rockchip_drm_load(struct drm_device *drm_dev, unsigned long 
  flags)
  +{
  +   struct rockchip_drm_private *private;
  +   struct dma_iommu_mapping *mapping;
  +   struct device *dev = drm_dev-dev;
  +   int ret;
  +
  +   private = devm_kzalloc(drm_dev-dev, sizeof(*private), GFP_KERNEL);
  +   if (!private)
  +   return -ENOMEM;
  +
  +   dev_set_drvdata(drm_dev-dev, dev);
  +   drm_dev-dev_private = private;
  +
  +   drm_mode_config_init(drm_dev);
  +
  +   rockchip_drm_mode_config_init(drm_dev);
  +
  +   dev-dma_parms = devm_kzalloc(dev, sizeof(*dev-dma_parms),
  + GFP_KERNEL);
  +   if (!dev-dma_parms) {
  +   ret = -ENOMEM;
  +   goto err_config_cleanup;
  +   }
  +
  +   /* TODO(djkurtz): fetch the mapping start/size from somewhere */
  +   mapping = arm_iommu_create_mapping(platform_bus_type, 0x1000,
  +  SZ_1G);
  +   if (IS_ERR(mapping)) {
  +   ret = PTR_ERR(mapping);
  +   goto err_config_cleanup;
  +   }
  +
  +   dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
 
 This is the default coherent mask. If you call this function, you
 should normally check the return value, or call dma_set_mask first,
 which you apparently don't do here, and in another place in this
 patch.

By This is the default mask do you mean it shouldn't be called at
all ? Cause I ran into some trouble when not calling this in my
atmel-hlcdc driver.
Actually, in my case the platform device is created by the MFD core
which seems to let the coherent_dma_mask uninitialized.

Best Regards,

Boris


-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-22 Thread Arnd Bergmann
On Monday 22 September 2014 17:15:06 Boris BREZILLON wrote:
   +
   +   /* TODO(djkurtz): fetch the mapping start/size from somewhere */
   +   mapping = arm_iommu_create_mapping(platform_bus_type, 0x1000,
   +  SZ_1G);
   +   if (IS_ERR(mapping)) {
   +   ret = PTR_ERR(mapping);
   +   goto err_config_cleanup;
   +   }
   +
   +   dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
  
  This is the default coherent mask. If you call this function, you
  should normally check the return value, or call dma_set_mask first,
  which you apparently don't do here, and in another place in this
  patch.
 
 By This is the default mask do you mean it shouldn't be called at
 all ? Cause I ran into some trouble when not calling this in my
 atmel-hlcdc driver.

We used to get this wrong in the of_platform code, but it should
work now.

 Actually, in my case the platform device is created by the MFD core
 which seems to let the coherent_dma_mask uninitialized.

That may well be different, but it seems like a good idea to allow
the MFD core to set this up as well.

In general, we expect that devices that are capable of doing DMA
start with a 32-bit mask for both dma_mask and dma_coherent_mask,
and a driver that requires a smaller masks or wants a larger mask
has to call the appropriate interface to set these, and check the
return value.

Arnd
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/5] drm/rockchip: Add basic drm driver

2014-09-22 Thread Rob Clark
Ok, couple more small comments.. this time I actually had time to go
through the entire patch, not just the uapi


On Mon, Sep 22, 2014 at 6:48 AM, Mark yao mark@rock-chips.com wrote:
 This patch adds the basic structure of a DRM Driver for Rockchip Socs.

 Signed-off-by: Mark yao mark@rock-chips.com
 ---
 Changes in v2:
 - use the component framework to defer main drm driver probe
   until all VOP devices have been probed.
 - use dma-mapping API with ARM_DMA_USE_IOMMU, create dma mapping by
   master device and each vop device can shared the drm dma mapping.
 - use drm_crtc_init_with_planes and drm_universal_plane_init.
 - remove unnecessary middle layers.
 - add cursor set, move funcs to rockchip drm crtc.
 - use vop reset at first init
 - reference framebuffer when used and unreference when swap out vop

 Changes in v3:
 - change crtc-fb to crtc-primary-fb
 Adviced by Daniel Vetter
 - init cursor plane with universal api, remove unnecessary cursor set,move

 Changes in v4:
 Adviced by David Herrmann
 - remove drm_platform_*() usage, use register drm device directly.
 Adviced by Rob Clark
 - remove special mmap ioctl, do userspace mmap with normal mmap() or mmap 
 offset

  drivers/gpu/drm/Kconfig   |2 +
  drivers/gpu/drm/Makefile  |1 +
  drivers/gpu/drm/rockchip/Kconfig  |   19 +
  drivers/gpu/drm/rockchip/Makefile |   10 +
  drivers/gpu/drm/rockchip/rockchip_drm_drv.c   |  524 ++
  drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |  120 +++
  drivers/gpu/drm/rockchip/rockchip_drm_fb.c|  201 
  drivers/gpu/drm/rockchip/rockchip_drm_fb.h|   28 +
  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  231 +
  drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h |   20 +
  drivers/gpu/drm/rockchip/rockchip_drm_gem.c   |  404 
  drivers/gpu/drm/rockchip/rockchip_drm_gem.h   |   72 ++
  drivers/gpu/drm/rockchip/rockchip_drm_vop.c   | 1372 
 +
  drivers/gpu/drm/rockchip/rockchip_drm_vop.h   |  187 
  include/uapi/drm/rockchip_drm.h   |   75 ++
  15 files changed, 3266 insertions(+)
  create mode 100644 drivers/gpu/drm/rockchip/Kconfig
  create mode 100644 drivers/gpu/drm/rockchip/Makefile
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.h
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.h
  create mode 100644 include/uapi/drm/rockchip_drm.h

 diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
 index b066bb3..7c4c3c6 100644
 --- a/drivers/gpu/drm/Kconfig
 +++ b/drivers/gpu/drm/Kconfig
 @@ -171,6 +171,8 @@ config DRM_SAVAGE

  source drivers/gpu/drm/exynos/Kconfig

 +source drivers/gpu/drm/rockchip/Kconfig
 +
  source drivers/gpu/drm/vmwgfx/Kconfig

  source drivers/gpu/drm/gma500/Kconfig
 diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
 index 4a55d59..d03387a 100644
 --- a/drivers/gpu/drm/Makefile
 +++ b/drivers/gpu/drm/Makefile
 @@ -52,6 +52,7 @@ obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
  obj-$(CONFIG_DRM_VIA)  +=via/
  obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/
  obj-$(CONFIG_DRM_EXYNOS) +=exynos/
 +obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/
  obj-$(CONFIG_DRM_GMA500) += gma500/
  obj-$(CONFIG_DRM_UDL) += udl/
  obj-$(CONFIG_DRM_AST) += ast/
 diff --git a/drivers/gpu/drm/rockchip/Kconfig 
 b/drivers/gpu/drm/rockchip/Kconfig
 new file mode 100644
 index 000..7146c80
 --- /dev/null
 +++ b/drivers/gpu/drm/rockchip/Kconfig
 @@ -0,0 +1,19 @@
 +config DRM_ROCKCHIP
 +   tristate DRM Support for Rockchip
 +   depends on DRM  ROCKCHIP_IOMMU
 +   select ARM_DMA_USE_IOMMU
 +   select IOMMU_API
 +   select DRM_KMS_HELPER
 +   select DRM_KMS_FB_HELPER
 +   select DRM_PANEL
 +   select FB_CFB_FILLRECT
 +   select FB_CFB_COPYAREA
 +   select FB_CFB_IMAGEBLIT
 +   select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
 +   select VIDEOMODE_HELPERS
 +   help
 + Choose this option if you have a Rockchip soc chipset.
 + This driver provides kernel mode setting and buffer
 + management to userspace. This driver does not provides
 + 2D or 3D acceleration; acceleration is performed by other
 + IP found on the SoC.
 diff --git a/drivers/gpu/drm/rockchip/Makefile 
 b/drivers/gpu/drm/rockchip/Makefile
 new file mode 100644
 index 000..6e6d468
 --- /dev/null
 +++ b/drivers/gpu/drm/rockchip/Makefile
 @@ -0,0 +1,10 @@
 +#
 +# Makefile for the drm device