Re: [PATCH 1/4] drm/rockchip: Do not use DMA mapping API if attached to IOMMU domain

2017-02-07 Thread Mark yao

On 2017年02月07日 14:53, Tomasz Figa wrote:

Hi Mark,

Thanks for reviving this series and sorry for not taking care of it
myself. Please see some comments inline.


Hi Tomasz

Thanks for review,

I will add the patches you mentioned  into v2 version.



On Tue, Feb 7, 2017 at 3:09 PM, Mark Yao  wrote:

From: Tomasz Figa 

The API is not suitable for subsystems consisting of multiple devices
and requires severe hacks to use it. To mitigate this, this patch
implements allocation and address space management locally by using
helpers provided by DRM framework, like other DRM drivers do, e.g.
Tegra.

This patch should not introduce any functional changes until the driver
is made to attach subdevices into an IOMMU domain with the generic IOMMU
API, which will happen in following patch. Based heavily on GEM
implementation of Tegra DRM driver.

Signed-off-by: Tomasz Figa 
Signed-off-by: Shunqian Zheng 
Acked-by: Mark Yao 

I believe you need your Signed-off-by here.


---
  drivers/gpu/drm/rockchip/rockchip_drm_drv.h |   4 +-
  drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 217 ++--
  drivers/gpu/drm/rockchip/rockchip_drm_gem.h |   8 +
  3 files changed, 219 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h 
b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
index fb6226c..7c123d9 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
@@ -30,6 +30,7 @@

  struct drm_device;
  struct drm_connector;
+struct iommu_domain;

  /*
   * Rockchip drm private crtc funcs.
@@ -60,7 +61,8 @@ struct rockchip_drm_private {
 struct drm_gem_object *fbdev_bo;
 const struct rockchip_crtc_funcs *crtc_funcs[ROCKCHIP_MAX_CRTC];
 struct drm_atomic_state *state;
-
+   struct iommu_domain *domain;
+   struct drm_mm mm;
 struct list_head psr_list;
 spinlock_t psr_list_lock;
  };
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index b70f942..5209392 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -16,11 +16,135 @@
  #include 
  #include 
  #include 
+#include 

  #include "rockchip_drm_drv.h"
  #include "rockchip_drm_gem.h"

-static int rockchip_gem_alloc_buf(struct rockchip_gem_object *rk_obj,
+static int rockchip_gem_iommu_map(struct rockchip_gem_object *rk_obj)
+{
+   struct drm_device *drm = rk_obj->base.dev;
+   struct rockchip_drm_private *private = drm->dev_private;
+   int prot = IOMMU_READ | IOMMU_WRITE;
+   ssize_t ret;
+
+   ret = drm_mm_insert_node_generic(&private->mm, &rk_obj->mm,
+rk_obj->base.size, PAGE_SIZE,
+0, 0);
+   if (ret < 0) {
+   DRM_ERROR("out of I/O virtual memory: %zd\n", ret);
+   return ret;
+   }
+
+   rk_obj->dma_addr = rk_obj->mm.start;
+
+   ret = iommu_map_sg(private->domain, rk_obj->dma_addr, rk_obj->sgt->sgl,
+  rk_obj->sgt->nents, prot);
+   if (ret < 0) {
+   DRM_ERROR("failed to map buffer: %zd\n", ret);
+   goto err_remove_node;
+   }
+
+   rk_obj->size = ret;
+
+   return 0;
+
+err_remove_node:
+   drm_mm_remove_node(&rk_obj->mm);
+
+   return ret;
+}
+
+static int rockchip_gem_iommu_unmap(struct rockchip_gem_object *rk_obj)
+{
+   struct drm_device *drm = rk_obj->base.dev;
+   struct rockchip_drm_private *private = drm->dev_private;
+
+   iommu_unmap(private->domain, rk_obj->dma_addr, rk_obj->size);
+   drm_mm_remove_node(&rk_obj->mm);
+
+   return 0;
+}
+
+static int rockchip_gem_get_pages(struct rockchip_gem_object *rk_obj)
+{
+   struct drm_device *drm = rk_obj->base.dev;
+   int ret, i;
+   struct scatterlist *s;
+
+   rk_obj->pages = drm_gem_get_pages(&rk_obj->base);
+   if (IS_ERR(rk_obj->pages))
+   return PTR_ERR(rk_obj->pages);
+
+   rk_obj->num_pages = rk_obj->base.size >> PAGE_SHIFT;
+
+   rk_obj->sgt = drm_prime_pages_to_sg(rk_obj->pages, rk_obj->num_pages);
+   if (IS_ERR(rk_obj->sgt)) {
+   ret = PTR_ERR(rk_obj->sgt);
+   goto err_put_pages;
+   }
+
+   /*
+* Fake up the SG table so that dma_sync_sg_for_device() can be used
+* to flush the pages associated with it.
+*
+* TODO: Replace this by drm_clflush_sg() once it can be implemented
+* without relying on symbols that are not exported.
+*/
+   for_each_sg(rk_obj->sgt->sgl, s, rk_obj->sgt->nents, i)
+   sg_dma_address(s) = sg_phys(s);
+
+   dma_sync_sg_for_device(drm->dev, rk_obj->sgt->sgl, rk_obj->sgt->nents,
+  DMA_TO_DEVICE);
+
+   return 0;
+
+err_put_pages:
+   drm_gem_put_pages(&rk_obj->base, rk_obj->pages, false, false);
+   return ret;
+}
+
+stati

[Bug 99078] Desktop icons oversaturated with red after December 11 2016 update

2017-02-07 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99078

Andre Heider  changed:

   What|Removed |Added

   See Also||http://bugs.debian.org/8526
   ||16

--- Comment #34 from Andre Heider  ---
debian already reverted said patch for it's release 3.9.1-4

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=852616

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


Re: [RFC PATCH v2 0/5] Add vblank hooks to struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
On Tue, Feb 07, 2017 at 08:32:46AM +0100, Daniel Vetter wrote:
> On Tue, Jan 24, 2017 at 08:55:35AM +0100, Daniel Vetter wrote:
> > On Sun, Jan 22, 2017 at 02:09:01PM +0800, Shawn Guo wrote:
> > > From: Shawn Guo 
> > > 
> > > The vblank is mostly CRTC specific and implemented as part of CRTC
> > > driver.  The first patch adds 3 vblank core-driver hooks into struct
> > > drm_crtc_funcs, and wraps around core vblank handling code to use the
> > > new hooks for modern MODESET drivers and the ones in struct drm_driver
> > > as fallback for legacy drivers.
> > > 
> > > The other patches in the series are to demonstrate how the new hooks
> > > are going to influence the driver code.  There are more drivers than
> > > the ones included here can be converted.  But before doing that, I would
> > > like to get some feedbacks first, expecially on how .get_vblank_counter
> > > should be converted when it's being drm_vblank_no_hw_counter().
> > > 
> > >   .get_vblank_counter = drm_vblank_no_hw_counter
> > 
> > I dropped some suggestions about this onto patch 3. Thanks for doing this,
> > I think it looks rather pretty.
> 
> Just to check: Do you plan to resend this series with my comments on the
> first patch addressed? I really like this, so I guess you could drop the
> RFC part and then we give maintainers a week or two for reviews and land
> it into drm-misc for 4.12 ...

Sorry for being late due to Chinese New Year Holidays.  The new version
is on the way, and will be on the list in a couple of hours.

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


[PATCH v2 0/7] drm/rockchip: switch to drm_mm for support arm64 iommu

2017-02-07 Thread Mark Yao
Some iommu patches on the series[0] "iommu/rockchip: Fix bugs and
enable on ARM64" already landed, So drm/rockchip related patches [1] and [2]
ready to landed, this series just rebase them to lastest drm-next.

And fix some bugs for drm/rockchip drm_mm

[0]: http://www.spinics.net/lists/arm-kernel/msg513781.html
[1]: https://patchwork.kernel.org/patch/9196367
[2]: https://patchwork.kernel.org/patch/9196369

Changes in v2:
Advices by Tomasz:
  add some fixes patches from chromeos project.

Mark Yao (2):
  drm/rockchip: gem: add mutex lock for drm mm
  drm/rockchip: gem: fixup iommu_map_sg error path

Shunqian Zheng (1):
  drm/rockchip: Use common IOMMU API to attach devices

Tomasz Figa (3):
  drm/rockchip: Do not use DMA mapping API if attached to IOMMU domain
  drm/rockchip: Fix the call to drm_gem_put_pages()
  drm/rockchip: Call drm_gem_object_release() to destroy GEM base

Ørjan Eide (1):
  drm/rockchip: Respect page offset in IOMMU mmap

 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 101 ++--
 drivers/gpu/drm/rockchip/rockchip_drm_drv.h |   6 +-
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 244 ++--
 drivers/gpu/drm/rockchip/rockchip_drm_gem.h |   8 +
 4 files changed, 298 insertions(+), 61 deletions(-)

-- 
1.9.1


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


[PATCH v2 1/7] drm/rockchip: Do not use DMA mapping API if attached to IOMMU domain

2017-02-07 Thread Mark Yao
From: Tomasz Figa 

The API is not suitable for subsystems consisting of multiple devices
and requires severe hacks to use it. To mitigate this, this patch
implements allocation and address space management locally by using
helpers provided by DRM framework, like other DRM drivers do, e.g.
Tegra.

This patch should not introduce any functional changes until the driver
is made to attach subdevices into an IOMMU domain with the generic IOMMU
API, which will happen in following patch. Based heavily on GEM
implementation of Tegra DRM driver.

Signed-off-by: Tomasz Figa 
Signed-off-by: Shunqian Zheng 
Acked-by: Mark Yao 
Signed-off-by: Mark Yao 
---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.h |   4 +-
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 217 ++--
 drivers/gpu/drm/rockchip/rockchip_drm_gem.h |   8 +
 3 files changed, 219 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h 
b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
index fb6226c..7c123d9 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
@@ -30,6 +30,7 @@
 
 struct drm_device;
 struct drm_connector;
+struct iommu_domain;
 
 /*
  * Rockchip drm private crtc funcs.
@@ -60,7 +61,8 @@ struct rockchip_drm_private {
struct drm_gem_object *fbdev_bo;
const struct rockchip_crtc_funcs *crtc_funcs[ROCKCHIP_MAX_CRTC];
struct drm_atomic_state *state;
-
+   struct iommu_domain *domain;
+   struct drm_mm mm;
struct list_head psr_list;
spinlock_t psr_list_lock;
 };
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index b70f942..5209392 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -16,11 +16,135 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "rockchip_drm_drv.h"
 #include "rockchip_drm_gem.h"
 
-static int rockchip_gem_alloc_buf(struct rockchip_gem_object *rk_obj,
+static int rockchip_gem_iommu_map(struct rockchip_gem_object *rk_obj)
+{
+   struct drm_device *drm = rk_obj->base.dev;
+   struct rockchip_drm_private *private = drm->dev_private;
+   int prot = IOMMU_READ | IOMMU_WRITE;
+   ssize_t ret;
+
+   ret = drm_mm_insert_node_generic(&private->mm, &rk_obj->mm,
+rk_obj->base.size, PAGE_SIZE,
+0, 0);
+   if (ret < 0) {
+   DRM_ERROR("out of I/O virtual memory: %zd\n", ret);
+   return ret;
+   }
+
+   rk_obj->dma_addr = rk_obj->mm.start;
+
+   ret = iommu_map_sg(private->domain, rk_obj->dma_addr, rk_obj->sgt->sgl,
+  rk_obj->sgt->nents, prot);
+   if (ret < 0) {
+   DRM_ERROR("failed to map buffer: %zd\n", ret);
+   goto err_remove_node;
+   }
+
+   rk_obj->size = ret;
+
+   return 0;
+
+err_remove_node:
+   drm_mm_remove_node(&rk_obj->mm);
+
+   return ret;
+}
+
+static int rockchip_gem_iommu_unmap(struct rockchip_gem_object *rk_obj)
+{
+   struct drm_device *drm = rk_obj->base.dev;
+   struct rockchip_drm_private *private = drm->dev_private;
+
+   iommu_unmap(private->domain, rk_obj->dma_addr, rk_obj->size);
+   drm_mm_remove_node(&rk_obj->mm);
+
+   return 0;
+}
+
+static int rockchip_gem_get_pages(struct rockchip_gem_object *rk_obj)
+{
+   struct drm_device *drm = rk_obj->base.dev;
+   int ret, i;
+   struct scatterlist *s;
+
+   rk_obj->pages = drm_gem_get_pages(&rk_obj->base);
+   if (IS_ERR(rk_obj->pages))
+   return PTR_ERR(rk_obj->pages);
+
+   rk_obj->num_pages = rk_obj->base.size >> PAGE_SHIFT;
+
+   rk_obj->sgt = drm_prime_pages_to_sg(rk_obj->pages, rk_obj->num_pages);
+   if (IS_ERR(rk_obj->sgt)) {
+   ret = PTR_ERR(rk_obj->sgt);
+   goto err_put_pages;
+   }
+
+   /*
+* Fake up the SG table so that dma_sync_sg_for_device() can be used
+* to flush the pages associated with it.
+*
+* TODO: Replace this by drm_clflush_sg() once it can be implemented
+* without relying on symbols that are not exported.
+*/
+   for_each_sg(rk_obj->sgt->sgl, s, rk_obj->sgt->nents, i)
+   sg_dma_address(s) = sg_phys(s);
+
+   dma_sync_sg_for_device(drm->dev, rk_obj->sgt->sgl, rk_obj->sgt->nents,
+  DMA_TO_DEVICE);
+
+   return 0;
+
+err_put_pages:
+   drm_gem_put_pages(&rk_obj->base, rk_obj->pages, false, false);
+   return ret;
+}
+
+static void rockchip_gem_put_pages(struct rockchip_gem_object *rk_obj)
+{
+   sg_free_table(rk_obj->sgt);
+   kfree(rk_obj->sgt);
+   drm_gem_put_pages(&rk_obj->base, rk_obj->pages, false, false);
+}
+
+static int rockchip_gem_alloc_iommu(struct rockchip_gem_object *rk_obj,
+   bool alloc_kmap)
+{
+ 

[PATCH v2 4/7] drm/rockchip: gem: fixup iommu_map_sg error path

2017-02-07 Thread Mark Yao
The return value of iommu_map_sg is size_t, it's unsigned,
So check ret < 0 is wrong.

And if iommu_map_sg is error, it's return value is zero, but
rockchip_gem_iommu_map feel the zero return value is success,
bug happen:

[5.227458] [drm:rockchip_gem_iommu_map] *ERROR* failed to map buffer: 0
[   12.291590] WARNING: at drivers/gpu/drm/drm_mm.c:369
[   12.291611] Modules linked in:
[   12.291634]
[   12.291658] CPU: 4 PID: 338 Comm: cameraserver Not tainted 4.4.41 #196
[   12.291680] Hardware name: rockchip,rk3399-mid (DT)
[   12.291703] task: ffc0e5a23100 ti: ffc0e5a64000 task.ti: 
ffc0e5a64000
[   12.291739] PC is at drm_mm_remove_node+0xc/0xf8
[   12.291766] LR is at rockchip_gem_iommu_unmap+0x3c/0x54
[   12.303799] [] drm_mm_remove_node+0xc/0xf8
[   12.303827] [] rockchip_gem_free_object+0x98/0x168
[   12.303854] [] drm_gem_object_free+0x2c/0x34
[   12.303878] [] drm_gem_dmabuf_release+0x90/0xa4
[   12.303904] [] dma_buf_release+0x64/0x15c
[   12.303929] [] __fput+0xe0/0x1a4
[   12.303950] [] fput+0xc/0x14
[   12.303977] [] task_work_run+0xa0/0xc0
[   12.304004] [] do_notify_resume+0x40/0x54
[   12.304026] [] work_pending+0x10/0x14

Change-Id: Id79c052691270553c1c60086f9926f39a5296354
Signed-off-by: Mark Yao 
---
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index 8d27965..cc48673 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -44,8 +44,10 @@ static int rockchip_gem_iommu_map(struct rockchip_gem_object 
*rk_obj)
 
ret = iommu_map_sg(private->domain, rk_obj->dma_addr, rk_obj->sgt->sgl,
   rk_obj->sgt->nents, prot);
-   if (ret < 0) {
-   DRM_ERROR("failed to map buffer: %zd\n", ret);
+   if (ret < rk_obj->base.size) {
+   DRM_ERROR("failed to map buffer: size=%zd request_size=%zd\n",
+ ret, rk_obj->base.size);
+   ret = -ENOMEM;
goto err_remove_node;
}
 
-- 
1.9.1


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


[PATCH v2 2/7] drm/rockchip: Use common IOMMU API to attach devices

2017-02-07 Thread Mark Yao
From: Shunqian Zheng 

Rockchip DRM used the arm special API, arm_iommu_*(), to attach
iommu for ARM32 SoCs. This patch convert to common iommu API
so it would support ARM64 like RK3399.

Since previous patch added support for direct IOMMU address space
management, there is no need to use DMA API anymore and this patch wires
things to use the new method.

Signed-off-by: Shunqian Zheng 
Signed-off-by: Tomasz Figa 
Acked-by: Mark Yao 
Signed-off-by: Mark Yao 
---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 100 +++-
 1 file changed, 53 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index c30d649..7a610e9 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -14,19 +14,19 @@
  * GNU General Public License for more details.
  */
 
-#include 
-
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include "rockchip_drm_drv.h"
 #include "rockchip_drm_fb.h"
@@ -50,28 +50,31 @@
 int rockchip_drm_dma_attach_device(struct drm_device *drm_dev,
   struct device *dev)
 {
-   struct dma_iommu_mapping *mapping = drm_dev->dev->archdata.mapping;
+   struct rockchip_drm_private *private = drm_dev->dev_private;
int ret;
 
if (!is_support_iommu)
return 0;
 
-   ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
-   if (ret)
+   ret = iommu_attach_device(private->domain, dev);
+   if (ret) {
+   dev_err(dev, "Failed to attach iommu device\n");
return ret;
+   }
 
-   dma_set_max_seg_size(dev, DMA_BIT_MASK(32));
-
-   return arm_iommu_attach_device(dev, mapping);
+   return 0;
 }
 
 void rockchip_drm_dma_detach_device(struct drm_device *drm_dev,
struct device *dev)
 {
+   struct rockchip_drm_private *private = drm_dev->dev_private;
+   struct iommu_domain *domain = private->domain;
+
if (!is_support_iommu)
return;
 
-   arm_iommu_detach_device(dev);
+   iommu_detach_device(domain, dev);
 }
 
 int rockchip_register_crtc_funcs(struct drm_crtc *crtc,
@@ -123,11 +126,45 @@ static void rockchip_drm_crtc_disable_vblank(struct 
drm_device *dev,
priv->crtc_funcs[pipe]->disable_vblank(crtc);
 }
 
+static int rockchip_drm_init_iommu(struct drm_device *drm_dev)
+{
+   struct rockchip_drm_private *private = drm_dev->dev_private;
+   struct iommu_domain_geometry *geometry;
+   u64 start, end;
+
+   if (!is_support_iommu)
+   return 0;
+
+   private->domain = iommu_domain_alloc(&platform_bus_type);
+   if (!private->domain)
+   return -ENOMEM;
+
+   geometry = &private->domain->geometry;
+   start = geometry->aperture_start;
+   end = geometry->aperture_end;
+
+   DRM_DEBUG("IOMMU context initialized (aperture: %#llx-%#llx)\n",
+ start, end);
+   drm_mm_init(&private->mm, start, end - start + 1);
+
+   return 0;
+}
+
+static void rockchip_iommu_cleanup(struct drm_device *drm_dev)
+{
+   struct rockchip_drm_private *private = drm_dev->dev_private;
+
+   if (!is_support_iommu)
+   return;
+
+   drm_mm_takedown(&private->mm);
+   iommu_domain_free(private->domain);
+}
+
 static int rockchip_drm_bind(struct device *dev)
 {
struct drm_device *drm_dev;
struct rockchip_drm_private *private;
-   struct dma_iommu_mapping *mapping = NULL;
int ret;
 
drm_dev = drm_dev_alloc(&rockchip_drm_driver, dev);
@@ -151,38 +188,14 @@ static int rockchip_drm_bind(struct device *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;
+   ret = rockchip_drm_init_iommu(drm_dev);
+   if (ret)
goto err_config_cleanup;
-   }
-
-   if (is_support_iommu) {
-   /* TODO(djkurtz): fetch the mapping start/size from somewhere */
-   mapping = arm_iommu_create_mapping(&platform_bus_type,
-  0x,
-  SZ_2G);
-   if (IS_ERR(mapping)) {
-   ret = PTR_ERR(mapping);
-   goto err_config_cleanup;
-   }
-
-   ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
-   if (ret)
-   goto err_release_mapping;
-
-   dma_set_max_seg_size(dev, DMA_BIT_MASK(32));
-
-   ret = arm_iommu_attach_device(dev, mapping);
-   if (ret)
-   goto err_release_mapping;
-   }
 
  

[PATCH v2 3/7] drm/rockchip: gem: add mutex lock for drm mm

2017-02-07 Thread Mark Yao
drm_mm_insert_node_generic and drm_mm_remove_node may access same
resource with list ops, it's not threads safe, so protect this context
with mutex lock.

Fix bug:
[49451.856244] 
==
[49451.856350] BUG: KASAN: wild-memory-access on address dead0108
[49451.856379] Write of size 8 by task Binder:218_4/683
[49451.856417] CPU: 2 PID: 683 Comm: Binder:218_4 Not tainted 4.4.36 #62
[49451.856443] Hardware name: Rockchip RK3399 Excavator Board edp (Android) (DT)
[49451.856469] Call trace:
[49451.856519] [] dump_backtrace+0x0/0x230
[49451.856556] [] show_stack+0x14/0x1c
[49451.856592] [] dump_stack+0xa0/0xc8
[49451.856633] [] kasan_report+0x110/0x4dc
[49451.856670] [] __asan_store8+0x24/0x7c
[49451.856715] [] drm_mm_insert_node_generic+0x2dc/0x464
[49451.856760] [] rockchip_gem_iommu_map+0x60/0x158
[49451.856794] [] rockchip_gem_create_object+0x278/0x488
[49451.856827] [] rockchip_gem_create_with_handle+0x24/0x10c
[49451.856862] [] rockchip_gem_create_ioctl+0x3c/0x50
[49451.856896] [] drm_ioctl+0x354/0x52c
[49451.856939] [] do_vfs_ioctl+0x670/0x78c
[49451.856976] [] SyS_ioctl+0x60/0x88
[49451.857009] [] el0_svc_naked+0x24/0x28

Change-Id: I2ea377aa9ca24f70c59e2d86f2a6ad5ccb9c0891
Signed-off-by: Mark Yao 
---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 1 +
 drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 2 ++
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 9 +
 3 files changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index 7a610e9..b360e62 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -146,6 +146,7 @@ static int rockchip_drm_init_iommu(struct drm_device 
*drm_dev)
DRM_DEBUG("IOMMU context initialized (aperture: %#llx-%#llx)\n",
  start, end);
drm_mm_init(&private->mm, start, end - start + 1);
+   mutex_init(&private->mm_lock);
 
return 0;
 }
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h 
b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
index 7c123d9..adc3930 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
@@ -62,6 +62,8 @@ struct rockchip_drm_private {
const struct rockchip_crtc_funcs *crtc_funcs[ROCKCHIP_MAX_CRTC];
struct drm_atomic_state *state;
struct iommu_domain *domain;
+   /* protect drm_mm on multi-threads */
+   struct mutex mm_lock;
struct drm_mm mm;
struct list_head psr_list;
spinlock_t psr_list_lock;
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index 5209392..8d27965 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -28,9 +28,13 @@ static int rockchip_gem_iommu_map(struct rockchip_gem_object 
*rk_obj)
int prot = IOMMU_READ | IOMMU_WRITE;
ssize_t ret;
 
+   mutex_lock(&private->mm_lock);
+
ret = drm_mm_insert_node_generic(&private->mm, &rk_obj->mm,
 rk_obj->base.size, PAGE_SIZE,
 0, 0);
+
+   mutex_unlock(&private->mm_lock);
if (ret < 0) {
DRM_ERROR("out of I/O virtual memory: %zd\n", ret);
return ret;
@@ -61,8 +65,13 @@ static int rockchip_gem_iommu_unmap(struct 
rockchip_gem_object *rk_obj)
struct rockchip_drm_private *private = drm->dev_private;
 
iommu_unmap(private->domain, rk_obj->dma_addr, rk_obj->size);
+
+   mutex_lock(&private->mm_lock);
+
drm_mm_remove_node(&rk_obj->mm);
 
+   mutex_unlock(&private->mm_lock);
+
return 0;
 }
 
-- 
1.9.1


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


[PATCH v2 5/7] drm/rockchip: Fix the call to drm_gem_put_pages()

2017-02-07 Thread Mark Yao
From: Tomasz Figa 

When freeing the buffer we don't have any means of determining if the
buffer was read or written, so we must assume both and pass true for
both arguments of drm_gem_put_pages(). Let's fix the code which
currently passes false.

TEST=while true; do backlight_dbus_tool --set --percent=0 && sleep 8 &&
 backlight_dbus_tool --set --percent=100 && sleep 3 ; done

Signed-off-by: Tomasz Figa 
Signed-off-by: Mark Yao 
Reviewed-on: https://chromium-review.googlesource.com/382934
Reviewed-by: Daniel Kurtz 
---
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index cc48673..1daa531 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -119,7 +119,7 @@ static void rockchip_gem_put_pages(struct 
rockchip_gem_object *rk_obj)
 {
sg_free_table(rk_obj->sgt);
kfree(rk_obj->sgt);
-   drm_gem_put_pages(&rk_obj->base, rk_obj->pages, false, false);
+   drm_gem_put_pages(&rk_obj->base, rk_obj->pages, true, true);
 }
 
 static int rockchip_gem_alloc_iommu(struct rockchip_gem_object *rk_obj,
-- 
1.9.1


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


[PATCH v2 7/7] drm/rockchip: Call drm_gem_object_release() to destroy GEM base

2017-02-07 Thread Mark Yao
From: Tomasz Figa 

When converting the driver to use shmem-backed GEMs for IOMMU-enabled
systems, we forgot to add calls to drm_gem_object_release(), which gave
us a quite nice memory leak. This patch adds the missing calls.

Fixes: f11d5f0 ("FROMLIST: drm/rockchip: Do not use DMA mapping API if
attached to IOMMU domain")

TEST=while true; do backlight_dbus_tool --set --percent=0 && sleep 8 &&
 backlight_dbus_tool --set --percent=100 && sleep 3 ; done

Signed-off-by: Tomasz Figa 
Signed-off-by: Mark Yao 
Reviewed-on: https://chromium-review.googlesource.com/385456
Reviewed-by: Douglas Anderson 
Reviewed-by: Daniel Kurtz 
---
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index 1769146..df9e570 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -301,6 +301,12 @@ int rockchip_gem_mmap(struct file *filp, struct 
vm_area_struct *vma)
return rockchip_drm_gem_object_mmap(obj, vma);
 }
 
+static void rockchip_gem_release_object(struct rockchip_gem_object *rk_obj)
+{
+   drm_gem_object_release(&rk_obj->base);
+   kfree(rk_obj);
+}
+
 struct rockchip_gem_object *
rockchip_gem_create_object(struct drm_device *drm, unsigned int size,
   bool alloc_kmap)
@@ -326,7 +332,7 @@ struct rockchip_gem_object *
return rk_obj;
 
 err_free_rk_obj:
-   kfree(rk_obj);
+   rockchip_gem_release_object(rk_obj);
return ERR_PTR(ret);
 }
 
@@ -338,13 +344,11 @@ void rockchip_gem_free_object(struct drm_gem_object *obj)
 {
struct rockchip_gem_object *rk_obj;
 
-   drm_gem_free_mmap_offset(obj);
-
rk_obj = to_rockchip_obj(obj);
 
rockchip_gem_free_buf(rk_obj);
 
-   kfree(rk_obj);
+   rockchip_gem_release_object(rk_obj);
 }
 
 /*
-- 
1.9.1


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


[PATCH v2 6/7] drm/rockchip: Respect page offset in IOMMU mmap

2017-02-07 Thread Mark Yao
From: Ørjan Eide 

When mapping buffers through the PRIME DMA-buf mmap path we might be
given an offset which has to be respected. The DRM GEM mmap path already
takes care of zeroing out the fake mmap offset, so we can just make the
IOMMU mmap implementation always respect the offset.

TEST=graphics_GLBench

Signed-off-by: rjan Eide 
Signed-off-by: Tomasz Figa 
Signed-off-by: Mark Yao 
Reviewed-on: https://chromium-review.googlesource.com/386477
Reviewed-by: Daniel Kurtz 
---
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index 1daa531..1769146 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -221,12 +221,16 @@ static int rockchip_drm_gem_object_mmap_iommu(struct 
drm_gem_object *obj,
unsigned int i, count = obj->size >> PAGE_SHIFT;
unsigned long user_count = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
unsigned long uaddr = vma->vm_start;
+   unsigned long offset = vma->vm_pgoff;
+   unsigned long end = user_count + offset;
int ret;
 
-   if (user_count == 0 || user_count > count)
+   if (user_count == 0)
+   return -ENXIO;
+   if (end > count)
return -ENXIO;
 
-   for (i = 0; i < user_count; i++) {
+   for (i = offset; i < end; i++) {
ret = vm_insert_page(vma, uaddr, rk_obj->pages[i]);
if (ret)
return ret;
-- 
1.9.1


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


Re: [PATCH v4] drm/imx: ipuv3-plane: use drm_plane_helper_check_state, clipped coordinates

2017-02-07 Thread Philipp Zabel
On Fri, 2017-02-03 at 15:20 +0200, Ville Syrjälä wrote:
> On Fri, Feb 03, 2017 at 10:31:39AM +0100, Philipp Zabel wrote:
> > Use drm_plane_helper_check_state to clip raw user coordinates to crtc
> > bounds. This checks for full plane coverage and scaling already, so
> > we can drop some custom checks. Use the clipped coordinates everywhere.
> > 
> > Suggested-by: Ville Syrjälä 
> > Signed-off-by: Philipp Zabel 
> > ---
> > Changes since v3:
> >  - Disallow target frames that start offscreen (state->crtc_x/y < 0), to 
> > avoid
> >confusing userspace: due to the necessary line start address alignment, 
> > we
> >could only support very specific negative values for crtc_x/y, depending 
> > on
> >the pixel format.
> 
> That's really no different to the user specifying non-zero src
> coordinates. So I'm wondering what's the point of special casing
> crtc coordinates this way because you'll need to check the src
> coordinates anyway.

User expectations.

For the src_x/y / src.x1/y1 source coordinates we have format specific
alignment requirements due to limitations of the DMA unit, there is no
way around it.
For the crtc_x/y plane coordinates there are no alignment requirements
at all, the partial plane can be positioned at any integer x/y position.
If we allow to simulate a partially offscreen plane at negative
positions by clipping and setting src.x1/y1, suddenly the crtc_x/y have
alignment requirements, but only if the values are negative.
I assume that would rather confuse any user space application that tries
to reason about which crtc_x/y values are valid, so it's probably better
to disallow it altogether.

regards
Philipp

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


[Bug 99078] Desktop icons oversaturated with red after December 11 2016 update

2017-02-07 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99078

--- Comment #35 from Matt Turner  ---
As did Gentoo in 3.9.1-r1.

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


[PATCH v3 00/23] Add vblank hooks to struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank is mostly CRTC specific and implemented as part of CRTC
driver.  The first patch adds 3 vblank core<->driver hooks into struct
drm_crtc_funcs, and plug them into core by adding wrapper functions for
vblank handling code.  We effectively make the .get_vblank_counter hook
optional by providing drm_vblank_no_hw_counter() as the default fallback
in the wrapper function.

Patch #2 and #3 unexport function drm_vblank_no_hw_counter() by cleaning
up its use, since it's already the default implememention for
.get_vblank_counter hook anyway.

The rest of the series is trying to do a massive conversion to the new
hooks for DRIVER_MODESET drivers.  But it only handles low-hanging
fruit, and leaves out the ones that need a bit surgery, like gma500,
i915, msm etc.  Most of conversion get done by simply moving code and
making functions static, but imx and rockchip are great examples showing
how driver code can be cleaned up with these new hooks.

The series is generated against branch drm-next.

Changes for v3:
 - Let drm_vblank_no_hw_counter() be the last fallback for
   .get_vblank_counter() hook.
 - Improve the kernel-doc for .get_vblank_counter() hook.
 - Convert more DRIVER_MODESET drivers to new hooks.

Changes for v2:
 - Wrap around core vblank handling code to save
   drm_crtc_enable[disable]_vblank() helpers
 - Add .get_vblank_counter to struct drm_crtc_funcs
 - Add some comments to link between two sets of hooks
 - Add one hdlcd driver patch for example

Shawn Guo (23):
  drm: add vblank hooks to struct drm_crtc_funcs
  drm: remove drm_vblank_no_hw_counter assignment from driver code
  drm: unexport function drm_vblank_no_hw_counter()
  drm: hdlcd: use vblank hooks in struct drm_crtc_funcs
  drm: malidp: use vblank hooks in struct drm_crtc_funcs
  drm: armada: use vblank hooks in struct drm_crtc_funcs
  drm: atmel: use vblank hooks in struct drm_crtc_funcs
  drm: exynos: use vblank hooks in struct drm_crtc_funcs
  drm: fsl-dcu: use vblank hooks in struct drm_crtc_funcs
  drm: hibmc: use vblank hooks in struct drm_crtc_funcs
  drm: kirin: use vblank hooks in struct drm_crtc_funcs
  drm: imx: remove struct imx_drm_crtc and imx_drm_crtc_helper_funcs
  drm: mediatek: use vblank hooks in struct drm_crtc_funcs
  drm: meson: use vblank hooks in struct drm_crtc_funcs
  drm: qxl: use vblank hooks in struct drm_crtc_funcs
  drm: rcar-du: use vblank hooks in struct drm_crtc_funcs
  drm: rockchip: remove struct rockchip_crtc_funcs
  drm: shmobile: use vblank hooks in struct drm_crtc_funcs
  drm: sun4i: use vblank hooks in struct drm_crtc_funcs
  drm: tegra: use vblank hooks in struct drm_crtc_funcs
  drm: tilcdc: use vblank hooks in struct drm_crtc_funcs
  drm: vc4: use vblank hooks in struct drm_crtc_funcs
  drm: zte: use vblank hooks in struct drm_crtc_funcs

 drivers/gpu/drm/arc/arcpgu_drv.c|   1 -
 drivers/gpu/drm/arm/hdlcd_crtc.c|  20 +
 drivers/gpu/drm/arm/hdlcd_drv.c |  21 -
 drivers/gpu/drm/arm/malidp_crtc.c   |  21 +
 drivers/gpu/drm/arm/malidp_drv.c|  22 -
 drivers/gpu/drm/armada/armada_crtc.c|  56 -
 drivers/gpu/drm/armada/armada_crtc.h|   2 -
 drivers/gpu/drm/armada/armada_drv.c |  17 
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c  |  21 +
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c|  22 -
 drivers/gpu/drm/drm_irq.c   |  81 +--
 drivers/gpu/drm/exynos/exynos_drm_crtc.c|  40 +-
 drivers/gpu/drm/exynos/exynos_drm_crtc.h|   2 -
 drivers/gpu/drm/exynos/exynos_drm_drv.c |   4 -
 drivers/gpu/drm/exynos/exynos_drm_drv.h |   8 --
 drivers/gpu/drm/exynos/exynos_hdmi.c|   7 +-
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c  |  26 ++
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c   |  26 --
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c  |  20 +
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c |  23 --
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c |  11 +--
 drivers/gpu/drm/i915/i915_irq.c |   1 -
 drivers/gpu/drm/imx/imx-drm-core.c  | 102 
 drivers/gpu/drm/imx/imx-drm.h   |  13 ---
 drivers/gpu/drm/imx/ipuv3-crtc.c|  58 +-
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c |   8 +-
 drivers/gpu/drm/mediatek/mtk_drm_crtc.h |   2 -
 drivers/gpu/drm/mediatek/mtk_drm_drv.c  |   4 -
 drivers/gpu/drm/meson/meson_crtc.c  |  22 +
 drivers/gpu/drm/meson/meson_drv.c   |  21 -
 drivers/gpu/drm/msm/msm_drv.c   |   1 -
 drivers/gpu/drm/mxsfb/mxsfb_drv.c   |   1 -
 drivers/gpu/drm/nouveau/nouveau_drm.c   |   1 -
 drivers/gpu/drm/omapdrm/omap_drv.c  |   1 -
 drivers/gpu/drm/qxl/qxl_display.c   |  16 
 drivers/gpu/drm/qxl/qxl_drv.c   

[PATCH v3 03/23] drm: unexport function drm_vblank_no_hw_counter()

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The function drm_vblank_no_hw_counter() is now only used in core vblank
wrapper code.  Let's unexport it by making it a static function.

Signed-off-by: Shawn Guo 
---
 drivers/gpu/drm/drm_irq.c | 28 ++--
 include/drm/drm_drv.h |  7 +++
 include/drm/drm_irq.h |  1 -
 3 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 646b3e57b9ad..1906723af389 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -89,6 +89,16 @@ static void store_vblank(struct drm_device *dev, unsigned 
int pipe,
write_sequnlock(&vblank->seqlock);
 }
 
+/*
+ * "No hw counter" fallback implementation of .get_vblank_counter() hook,
+ * if there is no useable hardware frame counter available.
+ */
+static u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe)
+{
+   WARN_ON_ONCE(dev->max_vblank_count != 0);
+   return 0;
+}
+
 static u32 __get_vblank_counter(struct drm_device *dev, unsigned int pipe)
 {
if (drm_core_check_feature(dev, DRIVER_MODESET)) {
@@ -1748,21 +1758,3 @@ bool drm_crtc_handle_vblank(struct drm_crtc *crtc)
return drm_handle_vblank(crtc->dev, drm_crtc_index(crtc));
 }
 EXPORT_SYMBOL(drm_crtc_handle_vblank);
-
-/**
- * drm_vblank_no_hw_counter - "No hw counter" implementation of 
.get_vblank_counter()
- * @dev: DRM device
- * @pipe: CRTC for which to read the counter
- *
- * Drivers can plug this into the .get_vblank_counter() function if
- * there is no useable hardware frame counter available.
- *
- * Returns:
- * 0
- */
-u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe)
-{
-   WARN_ON_ONCE(dev->max_vblank_count != 0);
-   return 0;
-}
-EXPORT_SYMBOL(drm_vblank_no_hw_counter);
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index 40ae89106594..661ca24a4c97 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -120,10 +120,9 @@ struct drm_driver {
 *
 * Driver callback for fetching a raw hardware vblank counter for the
 * CRTC specified with the pipe argument.  If a device doesn't have a
-* hardware counter, the driver can simply use
-* drm_vblank_no_hw_counter() function. The DRM core will account for
-* missed vblank events while interrupts where disabled based on system
-* timestamps.
+* hardware counter, the driver can simply leave the hook as NULL.
+* The DRM core will account for missed vblank events while interrupts
+* where disabled based on system timestamps.
 *
 * Wraparound handling and loss of events due to modesetting is dealt
 * with in the DRM core code, as long as drivers call
diff --git a/include/drm/drm_irq.h b/include/drm/drm_irq.h
index 2fb880462a57..cf0be6594c8c 100644
--- a/include/drm/drm_irq.h
+++ b/include/drm/drm_irq.h
@@ -152,7 +152,6 @@ void drm_crtc_arm_vblank_event(struct drm_crtc *crtc,
 void drm_crtc_vblank_on(struct drm_crtc *crtc);
 void drm_vblank_cleanup(struct drm_device *dev);
 u32 drm_accurate_vblank_count(struct drm_crtc *crtc);
-u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe);
 
 int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
  unsigned int pipe, int *max_error,
-- 
1.9.1

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


[PATCH v3 02/23] drm: remove drm_vblank_no_hw_counter assignment from driver code

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

Core code already makes drm_driver.get_vblank_counter hook optional by
letting drm_vblank_no_hw_counter be the default implementation for the
function hook.  So the drm_vblank_no_hw_counter assignment in the driver
code becomes redundant and can be removed now.

Signed-off-by: Shawn Guo 
Cc: Alexey Brodkin 
Cc: Liviu Dudau 
Cc: Mali DP Maintainers 
Cc: Russell King 
Cc: Boris Brezillon 
Cc: Inki Dae 
Cc: Stefan Agner 
Cc: Xinliang Liu 
Cc: Daniel Vetter 
Cc: Philipp Zabel 
Cc: CK Hu 
Cc: Neil Armstrong 
Cc: Rob Clark 
Cc: Marek Vasut 
Cc: Ben Skeggs 
Cc: Tomi Valkeinen 
Cc: Laurent Pinchart 
Cc: Mark Yao 
Cc: Benjamin Gaignard 
Cc: Maxime Ripard 
Cc: Jyri Sarha 
Cc: Eric Anholt 
---
 drivers/gpu/drm/arc/arcpgu_drv.c| 1 -
 drivers/gpu/drm/arm/hdlcd_drv.c | 1 -
 drivers/gpu/drm/arm/malidp_drv.c| 1 -
 drivers/gpu/drm/armada/armada_drv.c | 1 -
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c| 1 -
 drivers/gpu/drm/exynos/exynos_drm_drv.c | 1 -
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c   | 1 -
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 1 -
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 1 -
 drivers/gpu/drm/i915/i915_irq.c | 1 -
 drivers/gpu/drm/imx/imx-drm-core.c  | 1 -
 drivers/gpu/drm/mediatek/mtk_drm_drv.c  | 1 -
 drivers/gpu/drm/meson/meson_drv.c   | 1 -
 drivers/gpu/drm/msm/msm_drv.c   | 1 -
 drivers/gpu/drm/mxsfb/mxsfb_drv.c   | 1 -
 drivers/gpu/drm/nouveau/nouveau_drm.c   | 1 -
 drivers/gpu/drm/omapdrm/omap_drv.c  | 1 -
 drivers/gpu/drm/rcar-du/rcar_du_drv.c   | 1 -
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 1 -
 drivers/gpu/drm/shmobile/shmob_drm_drv.c| 1 -
 drivers/gpu/drm/sti/sti_drv.c   | 1 -
 drivers/gpu/drm/sun4i/sun4i_drv.c   | 1 -
 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 1 -
 drivers/gpu/drm/vc4/vc4_drv.c   | 1 -
 drivers/gpu/drm/zte/zx_drm_drv.c| 1 -
 25 files changed, 25 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index 8d8344ed655e..1926b200e4cb 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -175,7 +175,6 @@ static int arcpgu_unload(struct drm_device *drm)
.dumb_create = drm_gem_cma_dumb_create,
.dumb_map_offset = drm_gem_cma_dumb_map_offset,
.dumb_destroy = drm_gem_dumb_destroy,
-   .get_vblank_counter = drm_vblank_no_hw_counter,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_free_object_unlocked = drm_gem_cma_free_object,
diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index 4ce4f970920b..5d79e87f7421 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -278,7 +278,6 @@ static int hdlcd_debugfs_init(struct drm_minor *minor)
.irq_preinstall = hdlcd_irq_preinstall,
.irq_postinstall = hdlcd_irq_postinstall,
.irq_uninstall = hdlcd_irq_uninstall,
-   .get_vblank_counter = drm_vblank_no_hw_counter,
.enable_vblank = hdlcd_enable_vblank,
.disable_vblank = hdlcd_disable_vblank,
.gem_free_object_unlocked = drm_gem_cma_free_object,
diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index 8b0672d4aee9..ca6ccd172de3 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -213,7 +213,6 @@ static void malidp_lastclose(struct drm_device *drm)
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC |
   DRIVER_PRIME,
.lastclose = malidp_lastclose,
-   .get_vblank_counter = drm_vblank_no_hw_counter,
.enable_vblank = malidp_enable_vblank,
.disable_vblank = malidp_disable_vblank,
.gem_free_object_unlocked = drm_gem_cma_free_object,
diff --git a/drivers/gpu/drm/armada/armada_drv.c 
b/drivers/gpu/drm/armada/armada_drv.c
index 63f42d001f33..bb27892012de 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -87,7 +87,6 @@ static void armada_drm_lastclose(struct drm_device *dev)
 
 static struct drm_driver armada_drm_driver = {
.lastclose  = armada_drm_lastclose,
-   .get_vblank_counter = drm_vblank_no_hw_counter,
.enable_vblank  = armada_drm_enable_vblank,
.disable_vblank = armada_drm_disable_vblank,
.gem_free_object_unlocked = armada_gem_free_object,
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index 427bdff425c2..5cba65b5ea16 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -760,7 +760,6 @@ static void atmel_hlcdc_dc_disable_vblank(struct drm_device 
*

[PATCH v3 01/23] drm: add vblank hooks to struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank is mostly CRTC specific and implemented as part of CRTC
driver.  Let's keep the vblank hooks struct drm_driver for legacy
drivers, and add corresponding hooks in struct drm_crtc_funcs.  These
hooks take struct drm_crtc pointer as argument, and will be called by
core vblank handling code for DRIVER_MODESET drivers.

The new hooks get plugged into core by adding wrapper functions for
vblank handling code.  The .get_vblank_counter hook is effectively
optional, as we provide drm_vblank_no_hw_counter() as the default
fallback in the wrapper function.

Signed-off-by: Shawn Guo 
---
 drivers/gpu/drm/drm_irq.c | 53 +--
 include/drm/drm_crtc.h| 44 +++
 include/drm/drm_drv.h |  9 
 3 files changed, 100 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index e06cf11ebb4a..646b3e57b9ad 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -89,6 +89,21 @@ static void store_vblank(struct drm_device *dev, unsigned 
int pipe,
write_sequnlock(&vblank->seqlock);
 }
 
+static u32 __get_vblank_counter(struct drm_device *dev, unsigned int pipe)
+{
+   if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+   struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
+
+   if (crtc->funcs->get_vblank_counter)
+   return crtc->funcs->get_vblank_counter(crtc);
+   }
+
+   if (dev->driver->get_vblank_counter)
+   return dev->driver->get_vblank_counter(dev, pipe);
+
+   return drm_vblank_no_hw_counter(dev, pipe);
+}
+
 /*
  * Reset the stored timestamp for the current vblank count to correspond
  * to the last vblank occurred.
@@ -112,9 +127,9 @@ static void drm_reset_vblank_timestamp(struct drm_device 
*dev, unsigned int pipe
 * when drm_vblank_enable() applies the diff
 */
do {
-   cur_vblank = dev->driver->get_vblank_counter(dev, pipe);
+   cur_vblank = __get_vblank_counter(dev, pipe);
rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, 0);
-   } while (cur_vblank != dev->driver->get_vblank_counter(dev, pipe) && 
--count > 0);
+   } while (cur_vblank != __get_vblank_counter(dev, pipe) && --count > 0);
 
/*
 * Only reinitialize corresponding vblank timestamp if high-precision 
query
@@ -168,9 +183,9 @@ static void drm_update_vblank_count(struct drm_device *dev, 
unsigned int pipe,
 * corresponding vblank timestamp.
 */
do {
-   cur_vblank = dev->driver->get_vblank_counter(dev, pipe);
+   cur_vblank = __get_vblank_counter(dev, pipe);
rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, flags);
-   } while (cur_vblank != dev->driver->get_vblank_counter(dev, pipe) && 
--count > 0);
+   } while (cur_vblank != __get_vblank_counter(dev, pipe) && --count > 0);
 
if (dev->max_vblank_count != 0) {
/* trust the hw counter when it's around */
@@ -275,6 +290,20 @@ u32 drm_accurate_vblank_count(struct drm_crtc *crtc)
 }
 EXPORT_SYMBOL(drm_accurate_vblank_count);
 
+static void __disable_vblank(struct drm_device *dev, unsigned int pipe)
+{
+   if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+   struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
+
+   if (crtc->funcs->disable_vblank) {
+   crtc->funcs->disable_vblank(crtc);
+   return;
+   }
+   }
+
+   dev->driver->disable_vblank(dev, pipe);
+}
+
 /*
  * Disable vblank irq's on crtc, make sure that last vblank count
  * of hardware and corresponding consistent software vblank counter
@@ -298,7 +327,7 @@ static void vblank_disable_and_save(struct drm_device *dev, 
unsigned int pipe)
 * hardware potentially runtime suspended.
 */
if (vblank->enabled) {
-   dev->driver->disable_vblank(dev, pipe);
+   __disable_vblank(dev, pipe);
vblank->enabled = false;
}
 
@@ -1027,6 +1056,18 @@ void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
 }
 EXPORT_SYMBOL(drm_crtc_send_vblank_event);
 
+static int __enable_vblank(struct drm_device *dev, unsigned int pipe)
+{
+   if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+   struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
+
+   if (crtc->funcs->enable_vblank)
+   return crtc->funcs->enable_vblank(crtc);
+   }
+
+   return dev->driver->enable_vblank(dev, pipe);
+}
+
 /**
  * drm_vblank_enable - enable the vblank interrupt on a CRTC
  * @dev: DRM device
@@ -1052,7 +1093,7 @@ static int drm_vblank_enable(struct drm_device *dev, 
unsigned int pipe)
 * timestamps. Filtercode in drm_handle_vblank() will
 * prevent double-accounting of same vblank interval.
  

[PATCH v3 04/23] drm: hdlcd: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo 
Acked-by: Liviu Dudau 
---
 drivers/gpu/drm/arm/hdlcd_crtc.c | 20 
 drivers/gpu/drm/arm/hdlcd_drv.c  | 20 
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c
index 20ebfb4fbdfa..798a3cc480a2 100644
--- a/drivers/gpu/drm/arm/hdlcd_crtc.c
+++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
@@ -42,6 +42,24 @@ static void hdlcd_crtc_cleanup(struct drm_crtc *crtc)
drm_crtc_cleanup(crtc);
 }
 
+static int hdlcd_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+   struct hdlcd_drm_private *hdlcd = crtc_to_hdlcd_priv(crtc);
+   unsigned int mask = hdlcd_read(hdlcd, HDLCD_REG_INT_MASK);
+
+   hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, mask | HDLCD_INTERRUPT_VSYNC);
+
+   return 0;
+}
+
+static void hdlcd_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+   struct hdlcd_drm_private *hdlcd = crtc_to_hdlcd_priv(crtc);
+   unsigned int mask = hdlcd_read(hdlcd, HDLCD_REG_INT_MASK);
+
+   hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, mask & ~HDLCD_INTERRUPT_VSYNC);
+}
+
 static const struct drm_crtc_funcs hdlcd_crtc_funcs = {
.destroy = hdlcd_crtc_cleanup,
.set_config = drm_atomic_helper_set_config,
@@ -49,6 +67,8 @@ static void hdlcd_crtc_cleanup(struct drm_crtc *crtc)
.reset = drm_atomic_helper_crtc_reset,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+   .enable_vblank = hdlcd_crtc_enable_vblank,
+   .disable_vblank = hdlcd_crtc_disable_vblank,
 };
 
 static struct simplefb_format supported_formats[] = SIMPLEFB_FORMATS;
diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index 5d79e87f7421..4840dc277339 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -199,24 +199,6 @@ static void hdlcd_irq_uninstall(struct drm_device *drm)
hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, irq_mask);
 }
 
-static int hdlcd_enable_vblank(struct drm_device *drm, unsigned int crtc)
-{
-   struct hdlcd_drm_private *hdlcd = drm->dev_private;
-   unsigned int mask = hdlcd_read(hdlcd, HDLCD_REG_INT_MASK);
-
-   hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, mask | HDLCD_INTERRUPT_VSYNC);
-
-   return 0;
-}
-
-static void hdlcd_disable_vblank(struct drm_device *drm, unsigned int crtc)
-{
-   struct hdlcd_drm_private *hdlcd = drm->dev_private;
-   unsigned int mask = hdlcd_read(hdlcd, HDLCD_REG_INT_MASK);
-
-   hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, mask & ~HDLCD_INTERRUPT_VSYNC);
-}
-
 #ifdef CONFIG_DEBUG_FS
 static int hdlcd_show_underrun_count(struct seq_file *m, void *arg)
 {
@@ -278,8 +260,6 @@ static int hdlcd_debugfs_init(struct drm_minor *minor)
.irq_preinstall = hdlcd_irq_preinstall,
.irq_postinstall = hdlcd_irq_postinstall,
.irq_uninstall = hdlcd_irq_uninstall,
-   .enable_vblank = hdlcd_enable_vblank,
-   .disable_vblank = hdlcd_disable_vblank,
.gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.dumb_create = drm_gem_cma_dumb_create,
-- 
1.9.1

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


[PATCH v3 07/23] drm: atmel: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo 
Cc: Boris Brezillon 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 21 +
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c   | 21 -
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
index 9b17a66cf0e1..fabeeea0e899 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -434,6 +434,25 @@ static void atmel_hlcdc_crtc_destroy_state(struct drm_crtc 
*crtc,
kfree(state);
 }
 
+static int atmel_hlcdc_crtc_enable_vblank(struct drm_crtc *c)
+{
+   struct atmel_hlcdc_crtc *crtc = drm_crtc_to_atmel_hlcdc_crtc(c);
+   struct regmap *regmap = crtc->dc->hlcdc->regmap;
+
+   /* Enable SOF (Start Of Frame) interrupt for vblank counting */
+   regmap_write(regmap, ATMEL_HLCDC_IER, ATMEL_HLCDC_SOF);
+
+   return 0;
+}
+
+static void atmel_hlcdc_crtc_disable_vblank(struct drm_crtc *c)
+{
+   struct atmel_hlcdc_crtc *crtc = drm_crtc_to_atmel_hlcdc_crtc(c);
+   struct regmap *regmap = crtc->dc->hlcdc->regmap;
+
+   regmap_write(regmap, ATMEL_HLCDC_IDR, ATMEL_HLCDC_SOF);
+}
+
 static const struct drm_crtc_funcs atmel_hlcdc_crtc_funcs = {
.page_flip = drm_atomic_helper_page_flip,
.set_config = drm_atomic_helper_set_config,
@@ -441,6 +460,8 @@ static void atmel_hlcdc_crtc_destroy_state(struct drm_crtc 
*crtc,
.reset = atmel_hlcdc_crtc_reset,
.atomic_duplicate_state =  atmel_hlcdc_crtc_duplicate_state,
.atomic_destroy_state = atmel_hlcdc_crtc_destroy_state,
+   .enable_vblank = atmel_hlcdc_crtc_enable_vblank,
+   .disable_vblank = atmel_hlcdc_crtc_disable_vblank,
 };
 
 int atmel_hlcdc_crtc_create(struct drm_device *dev)
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index 5cba65b5ea16..fd1a2d0c870d 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -720,25 +720,6 @@ static void atmel_hlcdc_dc_irq_uninstall(struct drm_device 
*dev)
regmap_read(dc->hlcdc->regmap, ATMEL_HLCDC_ISR, &isr);
 }
 
-static int atmel_hlcdc_dc_enable_vblank(struct drm_device *dev,
-   unsigned int pipe)
-{
-   struct atmel_hlcdc_dc *dc = dev->dev_private;
-
-   /* Enable SOF (Start Of Frame) interrupt for vblank counting */
-   regmap_write(dc->hlcdc->regmap, ATMEL_HLCDC_IER, ATMEL_HLCDC_SOF);
-
-   return 0;
-}
-
-static void atmel_hlcdc_dc_disable_vblank(struct drm_device *dev,
- unsigned int pipe)
-{
-   struct atmel_hlcdc_dc *dc = dev->dev_private;
-
-   regmap_write(dc->hlcdc->regmap, ATMEL_HLCDC_IDR, ATMEL_HLCDC_SOF);
-}
-
 static const struct file_operations fops = {
.owner  = THIS_MODULE,
.open   = drm_open,
@@ -760,8 +741,6 @@ static void atmel_hlcdc_dc_disable_vblank(struct drm_device 
*dev,
.irq_preinstall = atmel_hlcdc_dc_irq_uninstall,
.irq_postinstall = atmel_hlcdc_dc_irq_postinstall,
.irq_uninstall = atmel_hlcdc_dc_irq_uninstall,
-   .enable_vblank = atmel_hlcdc_dc_enable_vblank,
-   .disable_vblank = atmel_hlcdc_dc_disable_vblank,
.gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
-- 
1.9.1

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


[PATCH v3 09/23] drm: fsl-dcu: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo 
Cc: Stefan Agner 
---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c | 26 ++
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c  | 25 -
 2 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c 
b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
index deb57435cc89..cc4e944a1d3c 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
@@ -137,6 +137,30 @@ static void fsl_dcu_drm_crtc_mode_set_nofb(struct drm_crtc 
*crtc)
.mode_set_nofb = fsl_dcu_drm_crtc_mode_set_nofb,
 };
 
+static int fsl_dcu_drm_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+   struct drm_device *dev = crtc->dev;
+   struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
+   unsigned int value;
+
+   regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value);
+   value &= ~DCU_INT_MASK_VBLANK;
+   regmap_write(fsl_dev->regmap, DCU_INT_MASK, value);
+
+   return 0;
+}
+
+static void fsl_dcu_drm_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+   struct drm_device *dev = crtc->dev;
+   struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
+   unsigned int value;
+
+   regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value);
+   value |= DCU_INT_MASK_VBLANK;
+   regmap_write(fsl_dev->regmap, DCU_INT_MASK, value);
+}
+
 static const struct drm_crtc_funcs fsl_dcu_drm_crtc_funcs = {
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
@@ -144,6 +168,8 @@ static void fsl_dcu_drm_crtc_mode_set_nofb(struct drm_crtc 
*crtc)
.page_flip = drm_atomic_helper_page_flip,
.reset = drm_atomic_helper_crtc_reset,
.set_config = drm_atomic_helper_set_config,
+   .enable_vblank = fsl_dcu_drm_crtc_enable_vblank,
+   .disable_vblank = fsl_dcu_drm_crtc_disable_vblank,
 };
 
 int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev)
diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c 
b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
index b59b816a1d7d..b5391c124c64 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
@@ -154,29 +154,6 @@ static irqreturn_t fsl_dcu_drm_irq(int irq, void *arg)
return IRQ_HANDLED;
 }
 
-static int fsl_dcu_drm_enable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-   struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
-   unsigned int value;
-
-   regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value);
-   value &= ~DCU_INT_MASK_VBLANK;
-   regmap_write(fsl_dev->regmap, DCU_INT_MASK, value);
-
-   return 0;
-}
-
-static void fsl_dcu_drm_disable_vblank(struct drm_device *dev,
-  unsigned int pipe)
-{
-   struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
-   unsigned int value;
-
-   regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value);
-   value |= DCU_INT_MASK_VBLANK;
-   regmap_write(fsl_dev->regmap, DCU_INT_MASK, value);
-}
-
 static void fsl_dcu_drm_lastclose(struct drm_device *dev)
 {
struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
@@ -203,8 +180,6 @@ static void fsl_dcu_drm_lastclose(struct drm_device *dev)
.load   = fsl_dcu_load,
.unload = fsl_dcu_unload,
.irq_handler= fsl_dcu_drm_irq,
-   .enable_vblank  = fsl_dcu_drm_enable_vblank,
-   .disable_vblank = fsl_dcu_drm_disable_vblank,
.gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
-- 
1.9.1

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


[PATCH v3 06/23] drm: armada: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.  As the result,
functions armada_drm_crtc_enable[disable]_irq() can be static, although
they are moved around a bit to save forward declaration.

The armada_crtc pointer array in struct armada_private is still kept in
there, because armada_debugfs.c still have reference to it.

Signed-off-by: Shawn Guo 
Cc: Russell King 
---
 drivers/gpu/drm/armada/armada_crtc.c | 56 
 drivers/gpu/drm/armada/armada_crtc.h |  2 --
 drivers/gpu/drm/armada/armada_drv.c  | 16 ---
 3 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_crtc.c 
b/drivers/gpu/drm/armada/armada_crtc.c
index e62ee4498ce4..1341e0b9368a 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -418,6 +418,25 @@ static bool armada_drm_crtc_mode_fixup(struct drm_crtc 
*crtc,
return true;
 }
 
+/* These are locked by dev->vbl_lock */
+static void armada_drm_crtc_disable_irq(struct armada_crtc *dcrtc, u32 mask)
+{
+   if (dcrtc->irq_ena & mask) {
+   dcrtc->irq_ena &= ~mask;
+   writel(dcrtc->irq_ena, dcrtc->base + LCD_SPU_IRQ_ENA);
+   }
+}
+
+static void armada_drm_crtc_enable_irq(struct armada_crtc *dcrtc, u32 mask)
+{
+   if ((dcrtc->irq_ena & mask) != mask) {
+   dcrtc->irq_ena |= mask;
+   writel(dcrtc->irq_ena, dcrtc->base + LCD_SPU_IRQ_ENA);
+   if (readl_relaxed(dcrtc->base + LCD_SPU_IRQ_ISR) & mask)
+   writel(0, dcrtc->base + LCD_SPU_IRQ_ISR);
+   }
+}
+
 static void armada_drm_crtc_irq(struct armada_crtc *dcrtc, u32 stat)
 {
void __iomem *base = dcrtc->base;
@@ -491,25 +510,6 @@ static irqreturn_t armada_drm_irq(int irq, void *arg)
return IRQ_NONE;
 }
 
-/* These are locked by dev->vbl_lock */
-void armada_drm_crtc_disable_irq(struct armada_crtc *dcrtc, u32 mask)
-{
-   if (dcrtc->irq_ena & mask) {
-   dcrtc->irq_ena &= ~mask;
-   writel(dcrtc->irq_ena, dcrtc->base + LCD_SPU_IRQ_ENA);
-   }
-}
-
-void armada_drm_crtc_enable_irq(struct armada_crtc *dcrtc, u32 mask)
-{
-   if ((dcrtc->irq_ena & mask) != mask) {
-   dcrtc->irq_ena |= mask;
-   writel(dcrtc->irq_ena, dcrtc->base + LCD_SPU_IRQ_ENA);
-   if (readl_relaxed(dcrtc->base + LCD_SPU_IRQ_ISR) & mask)
-   writel(0, dcrtc->base + LCD_SPU_IRQ_ISR);
-   }
-}
-
 static uint32_t armada_drm_crtc_calculate_csc(struct armada_crtc *dcrtc)
 {
struct drm_display_mode *adj = &dcrtc->crtc.mode;
@@ -1109,6 +1109,22 @@ static int armada_drm_crtc_page_flip(struct drm_crtc 
*crtc,
return 0;
 }
 
+/* These are called under the vbl_lock. */
+static int armada_drm_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+   struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
+
+   armada_drm_crtc_enable_irq(dcrtc, VSYNC_IRQ_ENA);
+   return 0;
+}
+
+static void armada_drm_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+   struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
+
+   armada_drm_crtc_disable_irq(dcrtc, VSYNC_IRQ_ENA);
+}
+
 static const struct drm_crtc_funcs armada_crtc_funcs = {
.cursor_set = armada_drm_crtc_cursor_set,
.cursor_move= armada_drm_crtc_cursor_move,
@@ -1116,6 +1132,8 @@ static int armada_drm_crtc_page_flip(struct drm_crtc 
*crtc,
.set_config = drm_crtc_helper_set_config,
.page_flip  = armada_drm_crtc_page_flip,
.set_property   = armada_drm_crtc_set_property,
+   .enable_vblank  = armada_drm_crtc_enable_vblank,
+   .disable_vblank = armada_drm_crtc_disable_vblank,
 };
 
 static const struct drm_plane_funcs armada_primary_plane_funcs = {
diff --git a/drivers/gpu/drm/armada/armada_crtc.h 
b/drivers/gpu/drm/armada/armada_crtc.h
index b08043e8cc3b..7e8906d3ae26 100644
--- a/drivers/gpu/drm/armada/armada_crtc.h
+++ b/drivers/gpu/drm/armada/armada_crtc.h
@@ -104,8 +104,6 @@ struct armada_crtc {
 
 void armada_drm_crtc_gamma_set(struct drm_crtc *, u16, u16, u16, int);
 void armada_drm_crtc_gamma_get(struct drm_crtc *, u16 *, u16 *, u16 *, int);
-void armada_drm_crtc_disable_irq(struct armada_crtc *, u32);
-void armada_drm_crtc_enable_irq(struct armada_crtc *, u32);
 void armada_drm_crtc_update_regs(struct armada_crtc *, struct armada_regs *);
 
 void armada_drm_crtc_plane_disable(struct armada_crtc *dcrtc,
diff --git a/drivers/gpu/drm/armada/armada_drv.c 
b/drivers/gpu/drm/armada/armada_drv.c
index bb27892012de..737bfcbce87b 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -49,20 +49,6 @@ void armada_drm_queue_unref_work(struct drm_device *dev,
spin_unlock_irqrestore(&dev->event_lock, flags);
 }
 
-/* These are 

[PATCH v3 08/23] drm: exynos: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

As the result, exynos_drm_crtc_enable[disable]_vblank() become static
functions.  They are moved around a bit to save forward declaration
though.  Also while at it, we move one step further to kill
exynos_drm_crtc_from_pipe() completely by updating hdmi_bind() a bit.

Signed-off-by: Shawn Guo 
Cc: Inki Dae 
---
 drivers/gpu/drm/exynos/exynos_drm_crtc.c | 40 
 drivers/gpu/drm/exynos/exynos_drm_crtc.h |  2 --
 drivers/gpu/drm/exynos/exynos_drm_drv.c  |  3 ---
 drivers/gpu/drm/exynos/exynos_drm_drv.h  |  8 ---
 drivers/gpu/drm/exynos/exynos_hdmi.c |  7 --
 5 files changed, 25 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c 
b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index 5367b6664fe3..fa32091af924 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -122,6 +122,24 @@ static void exynos_drm_crtc_destroy(struct drm_crtc *crtc)
kfree(exynos_crtc);
 }
 
+static int exynos_drm_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+   struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
+
+   if (exynos_crtc->ops->enable_vblank)
+   return exynos_crtc->ops->enable_vblank(exynos_crtc);
+
+   return 0;
+}
+
+static void exynos_drm_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+   struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
+
+   if (exynos_crtc->ops->disable_vblank)
+   exynos_crtc->ops->disable_vblank(exynos_crtc);
+}
+
 static const struct drm_crtc_funcs exynos_crtc_funcs = {
.set_config = drm_atomic_helper_set_config,
.page_flip  = drm_atomic_helper_page_flip,
@@ -129,6 +147,8 @@ static void exynos_drm_crtc_destroy(struct drm_crtc *crtc)
.reset = drm_atomic_helper_crtc_reset,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+   .enable_vblank = exynos_drm_crtc_enable_vblank,
+   .disable_vblank = exynos_drm_crtc_disable_vblank,
 };
 
 struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev,
@@ -168,26 +188,6 @@ struct exynos_drm_crtc *exynos_drm_crtc_create(struct 
drm_device *drm_dev,
return ERR_PTR(ret);
 }
 
-int exynos_drm_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-   struct exynos_drm_crtc *exynos_crtc = exynos_drm_crtc_from_pipe(dev,
-   pipe);
-
-   if (exynos_crtc->ops->enable_vblank)
-   return exynos_crtc->ops->enable_vblank(exynos_crtc);
-
-   return 0;
-}
-
-void exynos_drm_crtc_disable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-   struct exynos_drm_crtc *exynos_crtc = exynos_drm_crtc_from_pipe(dev,
-   pipe);
-
-   if (exynos_crtc->ops->disable_vblank)
-   exynos_crtc->ops->disable_vblank(exynos_crtc);
-}
-
 int exynos_drm_crtc_get_pipe_from_type(struct drm_device *drm_dev,
   enum exynos_drm_output_type out_type)
 {
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.h 
b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
index 6a581a8af465..4e986ba92320 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
@@ -23,8 +23,6 @@ struct exynos_drm_crtc *exynos_drm_crtc_create(struct 
drm_device *drm_dev,
enum exynos_drm_output_type type,
const struct exynos_drm_crtc_ops *ops,
void *context);
-int exynos_drm_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe);
-void exynos_drm_crtc_disable_vblank(struct drm_device *dev, unsigned int pipe);
 void exynos_drm_crtc_wait_pending_update(struct exynos_drm_crtc *exynos_crtc);
 void exynos_drm_crtc_finish_update(struct exynos_drm_crtc *exynos_crtc,
   struct exynos_drm_plane *exynos_plane);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c 
b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index a1c22eb12f4b..b4522f67b3cb 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -22,7 +22,6 @@
 #include 
 
 #include "exynos_drm_drv.h"
-#include "exynos_drm_crtc.h"
 #include "exynos_drm_fbdev.h"
 #include "exynos_drm_fb.h"
 #include "exynos_drm_gem.h"
@@ -263,8 +262,6 @@ static void exynos_drm_lastclose(struct drm_device *dev)
.preclose   = exynos_drm_preclose,
.lastclose  = exynos_drm_lastclose,
.postclose  = exynos_drm_postclose,
-   .enable_vblank  = e

[PATCH v3 05/23] drm: malidp: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo 
Cc: Mali DP Maintainers 
---
 drivers/gpu/drm/arm/malidp_crtc.c | 21 +
 drivers/gpu/drm/arm/malidp_drv.c  | 21 -
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/arm/malidp_crtc.c 
b/drivers/gpu/drm/arm/malidp_crtc.c
index 08e6a71f5d05..bad4d80cb711 100644
--- a/drivers/gpu/drm/arm/malidp_crtc.c
+++ b/drivers/gpu/drm/arm/malidp_crtc.c
@@ -167,6 +167,25 @@ static int malidp_crtc_atomic_check(struct drm_crtc *crtc,
.atomic_check = malidp_crtc_atomic_check,
 };
 
+static int malidp_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+   struct malidp_drm *malidp = crtc_to_malidp_device(crtc);
+   struct malidp_hw_device *hwdev = malidp->dev;
+
+   malidp_hw_enable_irq(hwdev, MALIDP_DE_BLOCK,
+hwdev->map.de_irq_map.vsync_irq);
+   return 0;
+}
+
+static void malidp_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+   struct malidp_drm *malidp = crtc_to_malidp_device(crtc);
+   struct malidp_hw_device *hwdev = malidp->dev;
+
+   malidp_hw_disable_irq(hwdev, MALIDP_DE_BLOCK,
+ hwdev->map.de_irq_map.vsync_irq);
+}
+
 static const struct drm_crtc_funcs malidp_crtc_funcs = {
.destroy = drm_crtc_cleanup,
.set_config = drm_atomic_helper_set_config,
@@ -174,6 +193,8 @@ static int malidp_crtc_atomic_check(struct drm_crtc *crtc,
.reset = drm_atomic_helper_crtc_reset,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+   .enable_vblank = malidp_crtc_enable_vblank,
+   .disable_vblank = malidp_crtc_disable_vblank,
 };
 
 int malidp_crtc_init(struct drm_device *drm)
diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index ca6ccd172de3..5dfcdb05c96e 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -111,25 +111,6 @@ static void malidp_atomic_commit_tail(struct 
drm_atomic_state *state)
.atomic_commit = drm_atomic_helper_commit,
 };
 
-static int malidp_enable_vblank(struct drm_device *drm, unsigned int crtc)
-{
-   struct malidp_drm *malidp = drm->dev_private;
-   struct malidp_hw_device *hwdev = malidp->dev;
-
-   malidp_hw_enable_irq(hwdev, MALIDP_DE_BLOCK,
-hwdev->map.de_irq_map.vsync_irq);
-   return 0;
-}
-
-static void malidp_disable_vblank(struct drm_device *drm, unsigned int pipe)
-{
-   struct malidp_drm *malidp = drm->dev_private;
-   struct malidp_hw_device *hwdev = malidp->dev;
-
-   malidp_hw_disable_irq(hwdev, MALIDP_DE_BLOCK,
- hwdev->map.de_irq_map.vsync_irq);
-}
-
 static int malidp_init(struct drm_device *drm)
 {
int ret;
@@ -213,8 +194,6 @@ static void malidp_lastclose(struct drm_device *drm)
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC |
   DRIVER_PRIME,
.lastclose = malidp_lastclose,
-   .enable_vblank = malidp_enable_vblank,
-   .disable_vblank = malidp_disable_vblank,
.gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.dumb_create = drm_gem_cma_dumb_create,
-- 
1.9.1

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


[PATCH v3 10/23] drm: hibmc: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo 
Cc: Xinliang Liu 
---
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c  | 20 
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 22 --
 2 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
index c655883d3613..59542bddc980 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
@@ -423,6 +423,24 @@ static void hibmc_crtc_atomic_flush(struct drm_crtc *crtc,
spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
 }
 
+static int hibmc_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+   struct hibmc_drm_private *priv = crtc->dev->dev_private;
+
+   writel(HIBMC_RAW_INTERRUPT_EN_VBLANK(1),
+  priv->mmio + HIBMC_RAW_INTERRUPT_EN);
+
+   return 0;
+}
+
+static void hibmc_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+   struct hibmc_drm_private *priv = crtc->dev->dev_private;
+
+   writel(HIBMC_RAW_INTERRUPT_EN_VBLANK(0),
+  priv->mmio + HIBMC_RAW_INTERRUPT_EN);
+}
+
 static const struct drm_crtc_funcs hibmc_crtc_funcs = {
.page_flip = drm_atomic_helper_page_flip,
.set_config = drm_atomic_helper_set_config,
@@ -430,6 +448,8 @@ static void hibmc_crtc_atomic_flush(struct drm_crtc *crtc,
.reset = drm_atomic_helper_crtc_reset,
.atomic_duplicate_state =  drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+   .enable_vblank = hibmc_crtc_enable_vblank,
+   .disable_vblank = hibmc_crtc_disable_vblank,
 };
 
 static const struct drm_crtc_helper_funcs hibmc_crtc_helper_funcs = {
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
index 8cac70454b57..2ffdbf9801bd 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
@@ -37,26 +37,6 @@
.llseek = no_llseek,
 };
 
-static int hibmc_enable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-   struct hibmc_drm_private *priv =
-   (struct hibmc_drm_private *)dev->dev_private;
-
-   writel(HIBMC_RAW_INTERRUPT_EN_VBLANK(1),
-  priv->mmio + HIBMC_RAW_INTERRUPT_EN);
-
-   return 0;
-}
-
-static void hibmc_disable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-   struct hibmc_drm_private *priv =
-   (struct hibmc_drm_private *)dev->dev_private;
-
-   writel(HIBMC_RAW_INTERRUPT_EN_VBLANK(0),
-  priv->mmio + HIBMC_RAW_INTERRUPT_EN);
-}
-
 irqreturn_t hibmc_drm_interrupt(int irq, void *arg)
 {
struct drm_device *dev = (struct drm_device *)arg;
@@ -84,8 +64,6 @@ irqreturn_t hibmc_drm_interrupt(int irq, void *arg)
.desc   = "hibmc drm driver",
.major  = 1,
.minor  = 0,
-   .enable_vblank  = hibmc_enable_vblank,
-   .disable_vblank = hibmc_disable_vblank,
.gem_free_object_unlocked = hibmc_gem_free_object,
.dumb_create= hibmc_dumb_create,
.dumb_map_offset= hibmc_dumb_mmap_offset,
-- 
1.9.1

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


[PATCH v3 12/23] drm: imx: remove struct imx_drm_crtc and imx_drm_crtc_helper_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

With the vblank hooks in struct drm_crtc_funcs, we do not need to
maintain the CRTC specific vblank callbacks with struct
imx_drm_crtc_helper_funcs any more.  By moving the stuff that we
currently do in imx_drm_add_crtc(), like of_node setting and
drm_crtc_helper_add()/drm_crtc_init_with_planes() invoking, we can kill
things like struct imx_drm_crtc, imx_drm_crtc_helper_funcs and related
functions completely.

Functions ipu_enable_vblank() and ipu_disable_vblank() are moved around
without changes, only for saving the forward declarations.

Signed-off-by: Shawn Guo 
Cc: Philipp Zabel 
---
 drivers/gpu/drm/imx/imx-drm-core.c | 101 -
 drivers/gpu/drm/imx/imx-drm.h  |  13 -
 drivers/gpu/drm/imx/ipuv3-crtc.c   |  58 -
 3 files changed, 22 insertions(+), 150 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c 
b/drivers/gpu/drm/imx/imx-drm-core.c
index 4badbb66d69e..65bd8b8a2494 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -40,17 +40,11 @@ struct imx_drm_component {
 
 struct imx_drm_device {
struct drm_device   *drm;
-   struct imx_drm_crtc *crtc[MAX_CRTC];
unsigned intpipes;
struct drm_fbdev_cma*fbhelper;
struct drm_atomic_state *state;
 };
 
-struct imx_drm_crtc {
-   struct drm_crtc *crtc;
-   struct imx_drm_crtc_helper_funcsimx_drm_helper_funcs;
-};
-
 #if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION)
 static int legacyfb_depth = 16;
 module_param(legacyfb_depth, int, 0444);
@@ -63,38 +57,6 @@ static void imx_drm_driver_lastclose(struct drm_device *drm)
drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
 }
 
-static int imx_drm_enable_vblank(struct drm_device *drm, unsigned int pipe)
-{
-   struct imx_drm_device *imxdrm = drm->dev_private;
-   struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[pipe];
-   int ret;
-
-   if (!imx_drm_crtc)
-   return -EINVAL;
-
-   if (!imx_drm_crtc->imx_drm_helper_funcs.enable_vblank)
-   return -ENOSYS;
-
-   ret = imx_drm_crtc->imx_drm_helper_funcs.enable_vblank(
-   imx_drm_crtc->crtc);
-
-   return ret;
-}
-
-static void imx_drm_disable_vblank(struct drm_device *drm, unsigned int pipe)
-{
-   struct imx_drm_device *imxdrm = drm->dev_private;
-   struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[pipe];
-
-   if (!imx_drm_crtc)
-   return;
-
-   if (!imx_drm_crtc->imx_drm_helper_funcs.disable_vblank)
-   return;
-
-   imx_drm_crtc->imx_drm_helper_funcs.disable_vblank(imx_drm_crtc->crtc);
-}
-
 static const struct file_operations imx_drm_driver_fops = {
.owner = THIS_MODULE,
.open = drm_open,
@@ -180,67 +142,6 @@ static void imx_drm_atomic_commit_tail(struct 
drm_atomic_state *state)
.atomic_commit_tail = imx_drm_atomic_commit_tail,
 };
 
-/*
- * imx_drm_add_crtc - add a new crtc
- */
-int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc,
-   struct imx_drm_crtc **new_crtc, struct drm_plane *primary_plane,
-   const struct imx_drm_crtc_helper_funcs *imx_drm_helper_funcs,
-   struct device_node *port)
-{
-   struct imx_drm_device *imxdrm = drm->dev_private;
-   struct imx_drm_crtc *imx_drm_crtc;
-
-   /*
-* The vblank arrays are dimensioned by MAX_CRTC - we can't
-* pass IDs greater than this to those functions.
-*/
-   if (imxdrm->pipes >= MAX_CRTC)
-   return -EINVAL;
-
-   if (imxdrm->drm->open_count)
-   return -EBUSY;
-
-   imx_drm_crtc = kzalloc(sizeof(*imx_drm_crtc), GFP_KERNEL);
-   if (!imx_drm_crtc)
-   return -ENOMEM;
-
-   imx_drm_crtc->imx_drm_helper_funcs = *imx_drm_helper_funcs;
-   imx_drm_crtc->crtc = crtc;
-
-   crtc->port = port;
-
-   imxdrm->crtc[imxdrm->pipes++] = imx_drm_crtc;
-
-   *new_crtc = imx_drm_crtc;
-
-   drm_crtc_helper_add(crtc,
-   imx_drm_crtc->imx_drm_helper_funcs.crtc_helper_funcs);
-
-   drm_crtc_init_with_planes(drm, crtc, primary_plane, NULL,
-   imx_drm_crtc->imx_drm_helper_funcs.crtc_funcs, NULL);
-
-   return 0;
-}
-EXPORT_SYMBOL_GPL(imx_drm_add_crtc);
-
-/*
- * imx_drm_remove_crtc - remove a crtc
- */
-int imx_drm_remove_crtc(struct imx_drm_crtc *imx_drm_crtc)
-{
-   struct imx_drm_device *imxdrm = imx_drm_crtc->crtc->dev->dev_private;
-   unsigned int pipe = drm_crtc_index(imx_drm_crtc->crtc);
-
-   drm_crtc_cleanup(imx_drm_crtc->crtc);
-
-   imxdrm->crtc[pipe] = NULL;
-
-   kfree(imx_drm_crtc);
-
-   return 0;
-}
-EXPORT_SYMBOL_GPL(imx_drm_remove_crtc);
 
 int imx_drm_encoder_parse_of(struct drm_device *drm,
struct drm_encoder *encoder, struct devi

[PATCH v3 11/23] drm: kirin: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo 
Cc: Xinliang Liu 
---
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c 
b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
index 0624fab8046f..c96c228a9898 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
@@ -302,9 +302,8 @@ static void ade_set_medianoc_qos(struct ade_crtc *acrtc)
   SOCKET_QOS_EN, SOCKET_QOS_EN);
 }
 
-static int ade_enable_vblank(struct drm_device *dev, unsigned int pipe)
+static int ade_crtc_enable_vblank(struct drm_crtc *crtc)
 {
-   struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
struct ade_crtc *acrtc = to_ade_crtc(crtc);
struct ade_hw_ctx *ctx = acrtc->ctx;
void __iomem *base = ctx->base;
@@ -318,9 +317,8 @@ static int ade_enable_vblank(struct drm_device *dev, 
unsigned int pipe)
return 0;
 }
 
-static void ade_disable_vblank(struct drm_device *dev, unsigned int pipe)
+static void ade_crtc_disable_vblank(struct drm_crtc *crtc)
 {
-   struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
struct ade_crtc *acrtc = to_ade_crtc(crtc);
struct ade_hw_ctx *ctx = acrtc->ctx;
void __iomem *base = ctx->base;
@@ -570,6 +568,8 @@ static void ade_crtc_atomic_flush(struct drm_crtc *crtc,
.set_property = drm_atomic_helper_crtc_set_property,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state   = drm_atomic_helper_crtc_destroy_state,
+   .enable_vblank  = ade_crtc_enable_vblank,
+   .disable_vblank = ade_crtc_disable_vblank,
 };
 
 static int ade_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
@@ -1025,8 +1025,6 @@ static int ade_drm_init(struct platform_device *pdev)
   IRQF_SHARED, dev->driver->name, acrtc);
if (ret)
return ret;
-   dev->driver->enable_vblank = ade_enable_vblank;
-   dev->driver->disable_vblank = ade_disable_vblank;
 
return 0;
 }
-- 
1.9.1

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


[PATCH v3 13/23] drm: mediatek: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo 
Cc: CK Hu 
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 8 
 drivers/gpu/drm/mediatek/mtk_drm_crtc.h | 2 --
 drivers/gpu/drm/mediatek/mtk_drm_drv.c  | 3 ---
 3 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c 
b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index a73de1e669c2..69982f5a6198 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -168,9 +168,8 @@ static void mtk_drm_crtc_mode_set_nofb(struct drm_crtc 
*crtc)
state->pending_config = true;
 }
 
-int mtk_drm_crtc_enable_vblank(struct drm_device *drm, unsigned int pipe)
+static int mtk_drm_crtc_enable_vblank(struct drm_crtc *crtc)
 {
-   struct drm_crtc *crtc = drm_crtc_from_index(drm, pipe);
struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
struct mtk_ddp_comp *ovl = mtk_crtc->ddp_comp[0];
 
@@ -179,9 +178,8 @@ int mtk_drm_crtc_enable_vblank(struct drm_device *drm, 
unsigned int pipe)
return 0;
 }
 
-void mtk_drm_crtc_disable_vblank(struct drm_device *drm, unsigned int pipe)
+static void mtk_drm_crtc_disable_vblank(struct drm_crtc *crtc)
 {
-   struct drm_crtc *crtc = drm_crtc_from_index(drm, pipe);
struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
struct mtk_ddp_comp *ovl = mtk_crtc->ddp_comp[0];
 
@@ -436,6 +434,8 @@ static void mtk_drm_crtc_atomic_flush(struct drm_crtc *crtc,
.atomic_duplicate_state = mtk_drm_crtc_duplicate_state,
.atomic_destroy_state   = mtk_drm_crtc_destroy_state,
.gamma_set  = drm_atomic_helper_legacy_gamma_set,
+   .enable_vblank  = mtk_drm_crtc_enable_vblank,
+   .disable_vblank = mtk_drm_crtc_disable_vblank,
 };
 
 static const struct drm_crtc_helper_funcs mtk_crtc_helper_funcs = {
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.h 
b/drivers/gpu/drm/mediatek/mtk_drm_crtc.h
index a1550fa3c9d2..9d9410c67ae9 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.h
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.h
@@ -23,8 +23,6 @@
 #define MTK_MAX_BPC10
 #define MTK_MIN_BPC3
 
-int mtk_drm_crtc_enable_vblank(struct drm_device *drm, unsigned int pipe);
-void mtk_drm_crtc_disable_vblank(struct drm_device *drm, unsigned int pipe);
 void mtk_drm_crtc_commit(struct drm_crtc *crtc);
 void mtk_crtc_ddp_irq(struct drm_crtc *crtc, struct mtk_ddp_comp *ovl);
 int mtk_drm_crtc_create(struct drm_device *drm_dev,
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c 
b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index ef8675336465..f5a1fd9b3ecc 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -256,9 +256,6 @@ static void mtk_drm_kms_deinit(struct drm_device *drm)
.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME |
   DRIVER_ATOMIC,
 
-   .enable_vblank = mtk_drm_crtc_enable_vblank,
-   .disable_vblank = mtk_drm_crtc_disable_vblank,
-
.gem_free_object_unlocked = mtk_drm_gem_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.dumb_create = mtk_drm_gem_dumb_create,
-- 
1.9.1

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


[PATCH v3 15/23] drm: qxl: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo 
Cc: Dave Airlie 
---
 drivers/gpu/drm/qxl/qxl_display.c | 16 
 drivers/gpu/drm/qxl/qxl_drv.c | 18 --
 2 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_display.c 
b/drivers/gpu/drm/qxl/qxl_display.c
index 1094cd33eb06..2ce805a7ce5e 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -548,6 +548,19 @@ static int qxl_crtc_cursor_move(struct drm_crtc *crtc,
return 0;
 }
 
+static u32 qxl_noop_get_vblank_counter(struct drm_crtc *crtc)
+{
+   return 0;
+}
+
+static int qxl_noop_enable_vblank(struct drm_crtc *crtc)
+{
+   return 0;
+}
+
+static void qxl_noop_disable_vblank(struct drm_crtc *crtc)
+{
+}
 
 static const struct drm_crtc_funcs qxl_crtc_funcs = {
.cursor_set2 = qxl_crtc_cursor_set2,
@@ -555,6 +568,9 @@ static int qxl_crtc_cursor_move(struct drm_crtc *crtc,
.set_config = drm_crtc_helper_set_config,
.destroy = qxl_crtc_destroy,
.page_flip = qxl_crtc_page_flip,
+   .get_vblank_counter = qxl_noop_get_vblank_counter,
+   .enable_vblank = qxl_noop_enable_vblank,
+   .disable_vblank = qxl_noop_disable_vblank,
 };
 
 void qxl_user_framebuffer_destroy(struct drm_framebuffer *fb)
diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index 8e17c241e63c..48d51a2f3bd8 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -247,21 +247,6 @@ static int qxl_pm_restore(struct device *dev)
return qxl_drm_resume(drm_dev, false);
 }
 
-static u32 qxl_noop_get_vblank_counter(struct drm_device *dev,
-  unsigned int pipe)
-{
-   return 0;
-}
-
-static int qxl_noop_enable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-   return 0;
-}
-
-static void qxl_noop_disable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-}
-
 static const struct dev_pm_ops qxl_pm_ops = {
.suspend = qxl_pm_suspend,
.resume = qxl_pm_resume,
@@ -281,9 +266,6 @@ static void qxl_noop_disable_vblank(struct drm_device *dev, 
unsigned int pipe)
 static struct drm_driver qxl_driver = {
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
   DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
-   .get_vblank_counter = qxl_noop_get_vblank_counter,
-   .enable_vblank = qxl_noop_enable_vblank,
-   .disable_vblank = qxl_noop_disable_vblank,
 
.set_busid = drm_pci_set_busid,
 
-- 
1.9.1

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


[PATCH v3 16/23] drm: rcar-du: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo 
Cc: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 29 +++--
 drivers/gpu/drm/rcar-du/rcar_du_crtc.h |  1 -
 drivers/gpu/drm/rcar-du/rcar_du_drv.c  | 19 ---
 3 files changed, 19 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index a2ec6d8796a0..edcbe2e3625d 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -529,6 +529,23 @@ static void rcar_du_crtc_atomic_flush(struct drm_crtc 
*crtc,
.atomic_flush = rcar_du_crtc_atomic_flush,
 };
 
+static int rcar_du_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+   struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
+
+   rcar_du_crtc_write(rcrtc, DSRCR, DSRCR_VBCL);
+   rcar_du_crtc_set(rcrtc, DIER, DIER_VBE);
+
+   return 0;
+}
+
+static void rcar_du_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+   struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
+
+   rcar_du_crtc_clr(rcrtc, DIER, DIER_VBE);
+}
+
 static const struct drm_crtc_funcs crtc_funcs = {
.reset = drm_atomic_helper_crtc_reset,
.destroy = drm_crtc_cleanup,
@@ -536,6 +553,8 @@ static void rcar_du_crtc_atomic_flush(struct drm_crtc *crtc,
.page_flip = drm_atomic_helper_page_flip,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+   .enable_vblank = rcar_du_crtc_enable_vblank,
+   .disable_vblank = rcar_du_crtc_disable_vblank,
 };
 
 /* 
-
@@ -650,13 +669,3 @@ int rcar_du_crtc_create(struct rcar_du_group *rgrp, 
unsigned int index)
 
return 0;
 }
-
-void rcar_du_crtc_enable_vblank(struct rcar_du_crtc *rcrtc, bool enable)
-{
-   if (enable) {
-   rcar_du_crtc_write(rcrtc, DSRCR, DSRCR_VBCL);
-   rcar_du_crtc_set(rcrtc, DIER, DIER_VBE);
-   } else {
-   rcar_du_crtc_clr(rcrtc, DIER, DIER_VBE);
-   }
-}
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
index 6f08b7e7db06..a7194812997e 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
@@ -66,7 +66,6 @@ enum rcar_du_output {
 };
 
 int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int index);
-void rcar_du_crtc_enable_vblank(struct rcar_du_crtc *rcrtc, bool enable);
 void rcar_du_crtc_suspend(struct rcar_du_crtc *rcrtc);
 void rcar_du_crtc_resume(struct rcar_du_crtc *rcrtc);
 
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 094da3ef49d1..192346d4fb34 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -26,7 +26,6 @@
 #include 
 #include 
 
-#include "rcar_du_crtc.h"
 #include "rcar_du_drv.h"
 #include "rcar_du_kms.h"
 #include "rcar_du_regs.h"
@@ -227,22 +226,6 @@ static void rcar_du_lastclose(struct drm_device *dev)
drm_fbdev_cma_restore_mode(rcdu->fbdev);
 }
 
-static int rcar_du_enable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-   struct rcar_du_device *rcdu = dev->dev_private;
-
-   rcar_du_crtc_enable_vblank(&rcdu->crtcs[pipe], true);
-
-   return 0;
-}
-
-static void rcar_du_disable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-   struct rcar_du_device *rcdu = dev->dev_private;
-
-   rcar_du_crtc_enable_vblank(&rcdu->crtcs[pipe], false);
-}
-
 static const struct file_operations rcar_du_fops = {
.owner  = THIS_MODULE,
.open   = drm_open,
@@ -259,8 +242,6 @@ static void rcar_du_disable_vblank(struct drm_device *dev, 
unsigned int pipe)
.driver_features= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME
| DRIVER_ATOMIC,
.lastclose  = rcar_du_lastclose,
-   .enable_vblank  = rcar_du_enable_vblank,
-   .disable_vblank = rcar_du_disable_vblank,
.gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
-- 
1.9.1

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


[PATCH v3 17/23] drm: rockchip: remove struct rockchip_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

With the vblank hooks in struct drm_crtc_funcs, we do not need to
maintain struct rockchip_crtc_funcs and the related registration
functions.  Remove them.

Signed-off-by: Shawn Guo 
Cc: Mark Yao 
---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 51 -
 drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 14 
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c |  9 ++---
 3 files changed, 2 insertions(+), 72 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index 39243480c834..7719b9cd5b74 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -74,55 +74,6 @@ void rockchip_drm_dma_detach_device(struct drm_device 
*drm_dev,
arm_iommu_detach_device(dev);
 }
 
-int rockchip_register_crtc_funcs(struct drm_crtc *crtc,
-const struct rockchip_crtc_funcs *crtc_funcs)
-{
-   int pipe = drm_crtc_index(crtc);
-   struct rockchip_drm_private *priv = crtc->dev->dev_private;
-
-   if (pipe >= ROCKCHIP_MAX_CRTC)
-   return -EINVAL;
-
-   priv->crtc_funcs[pipe] = crtc_funcs;
-
-   return 0;
-}
-
-void rockchip_unregister_crtc_funcs(struct drm_crtc *crtc)
-{
-   int pipe = drm_crtc_index(crtc);
-   struct rockchip_drm_private *priv = crtc->dev->dev_private;
-
-   if (pipe >= ROCKCHIP_MAX_CRTC)
-   return;
-
-   priv->crtc_funcs[pipe] = NULL;
-}
-
-static int rockchip_drm_crtc_enable_vblank(struct drm_device *dev,
-  unsigned int pipe)
-{
-   struct rockchip_drm_private *priv = dev->dev_private;
-   struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
-
-   if (crtc && priv->crtc_funcs[pipe] &&
-   priv->crtc_funcs[pipe]->enable_vblank)
-   return priv->crtc_funcs[pipe]->enable_vblank(crtc);
-
-   return 0;
-}
-
-static void rockchip_drm_crtc_disable_vblank(struct drm_device *dev,
-unsigned int pipe)
-{
-   struct rockchip_drm_private *priv = dev->dev_private;
-   struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
-
-   if (crtc && priv->crtc_funcs[pipe] &&
-   priv->crtc_funcs[pipe]->enable_vblank)
-   priv->crtc_funcs[pipe]->disable_vblank(crtc);
-}
-
 static int rockchip_drm_bind(struct device *dev)
 {
struct drm_device *drm_dev;
@@ -270,8 +221,6 @@ static void rockchip_drm_lastclose(struct drm_device *dev)
.driver_features= DRIVER_MODESET | DRIVER_GEM |
  DRIVER_PRIME | DRIVER_ATOMIC,
.lastclose  = rockchip_drm_lastclose,
-   .enable_vblank  = rockchip_drm_crtc_enable_vblank,
-   .disable_vblank = rockchip_drm_crtc_disable_vblank,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.gem_free_object_unlocked = rockchip_gem_free_object,
.dumb_create= rockchip_gem_dumb_create,
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h 
b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
index fb6226cf84b7..9f9bc959b108 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
@@ -31,16 +31,6 @@
 struct drm_device;
 struct drm_connector;
 
-/*
- * Rockchip drm private crtc funcs.
- * @enable_vblank: enable crtc vblank irq.
- * @disable_vblank: disable crtc vblank irq.
- */
-struct rockchip_crtc_funcs {
-   int (*enable_vblank)(struct drm_crtc *crtc);
-   void (*disable_vblank)(struct drm_crtc *crtc);
-};
-
 struct rockchip_crtc_state {
struct drm_crtc_state base;
int output_type;
@@ -58,16 +48,12 @@ struct rockchip_crtc_state {
 struct rockchip_drm_private {
struct drm_fb_helper fbdev_helper;
struct drm_gem_object *fbdev_bo;
-   const struct rockchip_crtc_funcs *crtc_funcs[ROCKCHIP_MAX_CRTC];
struct drm_atomic_state *state;
 
struct list_head psr_list;
spinlock_t psr_list_lock;
 };
 
-int rockchip_register_crtc_funcs(struct drm_crtc *crtc,
-const struct rockchip_crtc_funcs *crtc_funcs);
-void rockchip_unregister_crtc_funcs(struct drm_crtc *crtc);
 int rockchip_drm_dma_attach_device(struct drm_device *drm_dev,
   struct device *dev);
 void rockchip_drm_dma_detach_device(struct drm_device *drm_dev,
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index fb5f001f51c3..ffee8d8c3794 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -853,11 +853,6 @@ static void vop_crtc_disable_vblank(struct drm_crtc *crtc)
spin_unlock_irqrestore(&vop->irq_lock, flags);
 }
 
-static const struct rockchip_crtc_funcs private_crtc_funcs = {
-   .enable_vblank = vop_crtc_enable_vblank,
-   .disable_vblank = v

[PATCH v3 14/23] drm: meson: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo 
Cc: Neil Armstrong 
---
 drivers/gpu/drm/meson/meson_crtc.c | 22 ++
 drivers/gpu/drm/meson/meson_drv.c  | 20 
 2 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/meson/meson_crtc.c 
b/drivers/gpu/drm/meson/meson_crtc.c
index 749770e5c65f..0fe49eccda65 100644
--- a/drivers/gpu/drm/meson/meson_crtc.c
+++ b/drivers/gpu/drm/meson/meson_crtc.c
@@ -33,6 +33,7 @@
 
 #include "meson_crtc.h"
 #include "meson_plane.h"
+#include "meson_venc.h"
 #include "meson_vpp.h"
 #include "meson_viu.h"
 #include "meson_registers.h"
@@ -48,6 +49,24 @@ struct meson_crtc {
 
 /* CRTC */
 
+static int meson_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+   struct meson_crtc *meson_crtc = to_meson_crtc(crtc);
+   struct meson_drm *priv = meson_crtc->priv;
+
+   meson_venc_enable_vsync(priv);
+
+   return 0;
+}
+
+static void meson_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+   struct meson_crtc *meson_crtc = to_meson_crtc(crtc);
+   struct meson_drm *priv = meson_crtc->priv;
+
+   meson_venc_disable_vsync(priv);
+}
+
 static const struct drm_crtc_funcs meson_crtc_funcs = {
.atomic_destroy_state   = drm_atomic_helper_crtc_destroy_state,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
@@ -55,6 +74,9 @@ struct meson_crtc {
.page_flip  = drm_atomic_helper_page_flip,
.reset  = drm_atomic_helper_crtc_reset,
.set_config = drm_atomic_helper_set_config,
+   .enable_vblank  = meson_crtc_enable_vblank,
+   .disable_vblank = meson_crtc_disable_vblank,
+
 };
 
 static void meson_crtc_enable(struct drm_crtc *crtc)
diff --git a/drivers/gpu/drm/meson/meson_drv.c 
b/drivers/gpu/drm/meson/meson_drv.c
index c0a59889c45f..8d17d0e59cbe 100644
--- a/drivers/gpu/drm/meson/meson_drv.c
+++ b/drivers/gpu/drm/meson/meson_drv.c
@@ -79,22 +79,6 @@ static void meson_fb_output_poll_changed(struct drm_device 
*dev)
.fb_create   = drm_fb_cma_create,
 };
 
-static int meson_enable_vblank(struct drm_device *dev, unsigned int crtc)
-{
-   struct meson_drm *priv = dev->dev_private;
-
-   meson_venc_enable_vsync(priv);
-
-   return 0;
-}
-
-static void meson_disable_vblank(struct drm_device *dev, unsigned int crtc)
-{
-   struct meson_drm *priv = dev->dev_private;
-
-   meson_venc_disable_vsync(priv);
-}
-
 static irqreturn_t meson_irq(int irq, void *arg)
 {
struct drm_device *dev = arg;
@@ -126,10 +110,6 @@ static irqreturn_t meson_irq(int irq, void *arg)
  DRIVER_MODESET | DRIVER_PRIME |
  DRIVER_ATOMIC,
 
-   /* Vblank */
-   .enable_vblank  = meson_enable_vblank,
-   .disable_vblank = meson_disable_vblank,
-
/* IRQ */
.irq_handler= meson_irq,
 
-- 
1.9.1

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


[PATCH v3 18/23] drm: shmobile: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

As the result, shmob_drm_crtc_enable_vblank() becomes a static function,
although it gets moved around a bit to save forward declaration.

Signed-off-by: Shawn Guo 
Cc: Laurent Pinchart 
---
 drivers/gpu/drm/shmobile/shmob_drm_crtc.c | 51 +--
 drivers/gpu/drm/shmobile/shmob_drm_crtc.h |  1 -
 drivers/gpu/drm/shmobile/shmob_drm_drv.c  | 19 
 3 files changed, 35 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c 
b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c
index 445476551695..8244890e6d53 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c
@@ -476,10 +476,45 @@ static int shmob_drm_crtc_page_flip(struct drm_crtc *crtc,
return 0;
 }
 
+static void shmob_drm_crtc_enable_vblank(struct shmob_drm_device *sdev,
+bool enable)
+{
+   unsigned long flags;
+   u32 ldintr;
+
+   /* Be careful not to acknowledge any pending interrupt. */
+   spin_lock_irqsave(&sdev->irq_lock, flags);
+   ldintr = lcdc_read(sdev, LDINTR) | LDINTR_STATUS_MASK;
+   if (enable)
+   ldintr |= LDINTR_VEE;
+   else
+   ldintr &= ~LDINTR_VEE;
+   lcdc_write(sdev, LDINTR, ldintr);
+   spin_unlock_irqrestore(&sdev->irq_lock, flags);
+}
+
+static int shmob_drm_enable_vblank(struct drm_crtc *crtc)
+{
+   struct shmob_drm_device *sdev = crtc->dev->dev_private;
+
+   shmob_drm_crtc_enable_vblank(sdev, true);
+
+   return 0;
+}
+
+static void shmob_drm_disable_vblank(struct drm_crtc *crtc)
+{
+   struct shmob_drm_device *sdev = crtc->dev->dev_private;
+
+   shmob_drm_crtc_enable_vblank(sdev, false);
+}
+
 static const struct drm_crtc_funcs crtc_funcs = {
.destroy = drm_crtc_cleanup,
.set_config = drm_crtc_helper_set_config,
.page_flip = shmob_drm_crtc_page_flip,
+   .enable_vblank = shmob_drm_enable_vblank,
+   .disable_vblank = shmob_drm_disable_vblank,
 };
 
 int shmob_drm_crtc_create(struct shmob_drm_device *sdev)
@@ -594,22 +629,6 @@ int shmob_drm_encoder_create(struct shmob_drm_device *sdev)
return 0;
 }
 
-void shmob_drm_crtc_enable_vblank(struct shmob_drm_device *sdev, bool enable)
-{
-   unsigned long flags;
-   u32 ldintr;
-
-   /* Be careful not to acknowledge any pending interrupt. */
-   spin_lock_irqsave(&sdev->irq_lock, flags);
-   ldintr = lcdc_read(sdev, LDINTR) | LDINTR_STATUS_MASK;
-   if (enable)
-   ldintr |= LDINTR_VEE;
-   else
-   ldintr &= ~LDINTR_VEE;
-   lcdc_write(sdev, LDINTR, ldintr);
-   spin_unlock_irqrestore(&sdev->irq_lock, flags);
-}
-
 /* 
-
  * Connector
  */
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_crtc.h 
b/drivers/gpu/drm/shmobile/shmob_drm_crtc.h
index 818b31549ddc..f152973df11c 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_crtc.h
+++ b/drivers/gpu/drm/shmobile/shmob_drm_crtc.h
@@ -47,7 +47,6 @@ struct shmob_drm_connector {
 };
 
 int shmob_drm_crtc_create(struct shmob_drm_device *sdev);
-void shmob_drm_crtc_enable_vblank(struct shmob_drm_device *sdev, bool enable);
 void shmob_drm_crtc_finish_page_flip(struct shmob_drm_crtc *scrtc);
 void shmob_drm_crtc_suspend(struct shmob_drm_crtc *scrtc);
 void shmob_drm_crtc_resume(struct shmob_drm_crtc *scrtc);
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c 
b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index d6b0545d252d..34fefa0ba0f0 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -23,7 +23,6 @@
 #include 
 #include 
 
-#include "shmob_drm_crtc.h"
 #include "shmob_drm_drv.h"
 #include "shmob_drm_kms.h"
 #include "shmob_drm_plane.h"
@@ -222,22 +221,6 @@ static irqreturn_t shmob_drm_irq(int irq, void *arg)
return IRQ_HANDLED;
 }
 
-static int shmob_drm_enable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-   struct shmob_drm_device *sdev = dev->dev_private;
-
-   shmob_drm_crtc_enable_vblank(sdev, true);
-
-   return 0;
-}
-
-static void shmob_drm_disable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-   struct shmob_drm_device *sdev = dev->dev_private;
-
-   shmob_drm_crtc_enable_vblank(sdev, false);
-}
-
 static const struct file_operations shmob_drm_fops = {
.owner  = THIS_MODULE,
.open   = drm_open,
@@ -256,8 +239,6 @@ static void shmob_drm_disable_vblank(struct drm_device 
*dev, unsigned int pipe)
.load   = shmob_drm_load,
.unload = shmob_drm_unload,
.irq_handler= shmob_drm_irq,
-   .enable_vblank  = shmob_drm_enable_v

[PATCH v3 19/23] drm: sun4i: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo 
Cc: Maxime Ripard 
---
 drivers/gpu/drm/sun4i/sun4i_crtc.c | 24 
 drivers/gpu/drm/sun4i/sun4i_drv.c  | 27 ---
 2 files changed, 24 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_crtc.c 
b/drivers/gpu/drm/sun4i/sun4i_crtc.c
index 4a192210574f..a5d546a68e16 100644
--- a/drivers/gpu/drm/sun4i/sun4i_crtc.c
+++ b/drivers/gpu/drm/sun4i/sun4i_crtc.c
@@ -104,6 +104,28 @@ static void sun4i_crtc_enable(struct drm_crtc *crtc)
.enable = sun4i_crtc_enable,
 };
 
+static int sun4i_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+   struct sun4i_crtc *scrtc = drm_crtc_to_sun4i_crtc(crtc);
+   struct sun4i_drv *drv = scrtc->drv;
+
+   DRM_DEBUG_DRIVER("Enabling VBLANK on crtc %p\n", crtc);
+
+   sun4i_tcon_enable_vblank(drv->tcon, true);
+
+   return 0;
+}
+
+static void sun4i_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+   struct sun4i_crtc *scrtc = drm_crtc_to_sun4i_crtc(crtc);
+   struct sun4i_drv *drv = scrtc->drv;
+
+   DRM_DEBUG_DRIVER("Disabling VBLANK on crtc %p\n", crtc);
+
+   sun4i_tcon_enable_vblank(drv->tcon, false);
+}
+
 static const struct drm_crtc_funcs sun4i_crtc_funcs = {
.atomic_destroy_state   = drm_atomic_helper_crtc_destroy_state,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
@@ -111,6 +133,8 @@ static void sun4i_crtc_enable(struct drm_crtc *crtc)
.page_flip  = drm_atomic_helper_page_flip,
.reset  = drm_atomic_helper_crtc_reset,
.set_config = drm_atomic_helper_set_config,
+   .enable_vblank  = sun4i_crtc_enable_vblank,
+   .disable_vblank = sun4i_crtc_disable_vblank,
 };
 
 struct sun4i_crtc *sun4i_crtc_init(struct drm_device *drm)
diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c 
b/drivers/gpu/drm/sun4i/sun4i_drv.c
index 0816c635df20..9ccf7c4deb6d 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -24,29 +24,6 @@
 #include "sun4i_drv.h"
 #include "sun4i_framebuffer.h"
 #include "sun4i_layer.h"
-#include "sun4i_tcon.h"
-
-static int sun4i_drv_enable_vblank(struct drm_device *drm, unsigned int pipe)
-{
-   struct sun4i_drv *drv = drm->dev_private;
-   struct sun4i_tcon *tcon = drv->tcon;
-
-   DRM_DEBUG_DRIVER("Enabling VBLANK on pipe %d\n", pipe);
-
-   sun4i_tcon_enable_vblank(tcon, true);
-
-   return 0;
-}
-
-static void sun4i_drv_disable_vblank(struct drm_device *drm, unsigned int pipe)
-{
-   struct sun4i_drv *drv = drm->dev_private;
-   struct sun4i_tcon *tcon = drv->tcon;
-
-   DRM_DEBUG_DRIVER("Disabling VBLANK on pipe %d\n", pipe);
-
-   sun4i_tcon_enable_vblank(tcon, false);
-}
 
 static const struct file_operations sun4i_drv_fops = {
.owner  = THIS_MODULE,
@@ -90,10 +67,6 @@ static void sun4i_drv_disable_vblank(struct drm_device *drm, 
unsigned int pipe)
.gem_prime_mmap = drm_gem_cma_prime_mmap,
 
/* Frame Buffer Operations */
-
-   /* VBlank Operations */
-   .enable_vblank  = sun4i_drv_enable_vblank,
-   .disable_vblank = sun4i_drv_disable_vblank,
 };
 
 static void sun4i_remove_framebuffers(void)
-- 
1.9.1

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


[PATCH v3 23/23] drm: zte: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

The functions are moved around to save forward declaration.

Signed-off-by: Shawn Guo 
---
 drivers/gpu/drm/zte/zx_drm_drv.c |  2 --
 drivers/gpu/drm/zte/zx_vou.c | 61 +++-
 drivers/gpu/drm/zte/zx_vou.h |  3 --
 3 files changed, 23 insertions(+), 43 deletions(-)

diff --git a/drivers/gpu/drm/zte/zx_drm_drv.c b/drivers/gpu/drm/zte/zx_drm_drv.c
index afd713a954c6..b24a70ba4b83 100644
--- a/drivers/gpu/drm/zte/zx_drm_drv.c
+++ b/drivers/gpu/drm/zte/zx_drm_drv.c
@@ -71,8 +71,6 @@ static void zx_drm_lastclose(struct drm_device *drm)
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
   DRIVER_ATOMIC,
.lastclose = zx_drm_lastclose,
-   .enable_vblank = zx_vou_enable_vblank,
-   .disable_vblank = zx_vou_disable_vblank,
.gem_free_object = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.dumb_create = drm_gem_cma_dumb_create,
diff --git a/drivers/gpu/drm/zte/zx_vou.c b/drivers/gpu/drm/zte/zx_vou.c
index cf92d675feaa..b500c8dd0d9d 100644
--- a/drivers/gpu/drm/zte/zx_vou.c
+++ b/drivers/gpu/drm/zte/zx_vou.c
@@ -470,6 +470,27 @@ static void zx_crtc_atomic_flush(struct drm_crtc *crtc,
.atomic_flush = zx_crtc_atomic_flush,
 };
 
+static int zx_vou_enable_vblank(struct drm_crtc *crtc)
+{
+   struct zx_crtc *zcrtc = to_zx_crtc(crtc);
+   struct zx_vou_hw *vou = crtc_to_vou(crtc);
+   u32 int_frame_mask = zcrtc->bits->int_frame_mask;
+
+   zx_writel_mask(vou->timing + TIMING_INT_CTRL, int_frame_mask,
+  int_frame_mask);
+
+   return 0;
+}
+
+static void zx_vou_disable_vblank(struct drm_crtc *crtc)
+{
+   struct zx_crtc *zcrtc = to_zx_crtc(crtc);
+   struct zx_vou_hw *vou = crtc_to_vou(crtc);
+
+   zx_writel_mask(vou->timing + TIMING_INT_CTRL,
+  zcrtc->bits->int_frame_mask, 0);
+}
+
 static const struct drm_crtc_funcs zx_crtc_funcs = {
.destroy = drm_crtc_cleanup,
.set_config = drm_atomic_helper_set_config,
@@ -477,6 +498,8 @@ static void zx_crtc_atomic_flush(struct drm_crtc *crtc,
.reset = drm_atomic_helper_crtc_reset,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+   .enable_vblank = zx_vou_enable_vblank,
+   .disable_vblank = zx_vou_disable_vblank,
 };
 
 static int zx_crtc_init(struct drm_device *drm, struct zx_vou_hw *vou,
@@ -553,44 +576,6 @@ static int zx_crtc_init(struct drm_device *drm, struct 
zx_vou_hw *vou,
return 0;
 }
 
-int zx_vou_enable_vblank(struct drm_device *drm, unsigned int pipe)
-{
-   struct drm_crtc *crtc;
-   struct zx_crtc *zcrtc;
-   struct zx_vou_hw *vou;
-   u32 int_frame_mask;
-
-   crtc = drm_crtc_from_index(drm, pipe);
-   if (!crtc)
-   return 0;
-
-   vou = crtc_to_vou(crtc);
-   zcrtc = to_zx_crtc(crtc);
-   int_frame_mask = zcrtc->bits->int_frame_mask;
-
-   zx_writel_mask(vou->timing + TIMING_INT_CTRL, int_frame_mask,
-  int_frame_mask);
-
-   return 0;
-}
-
-void zx_vou_disable_vblank(struct drm_device *drm, unsigned int pipe)
-{
-   struct drm_crtc *crtc;
-   struct zx_crtc *zcrtc;
-   struct zx_vou_hw *vou;
-
-   crtc = drm_crtc_from_index(drm, pipe);
-   if (!crtc)
-   return;
-
-   vou = crtc_to_vou(crtc);
-   zcrtc = to_zx_crtc(crtc);
-
-   zx_writel_mask(vou->timing + TIMING_INT_CTRL,
-  zcrtc->bits->int_frame_mask, 0);
-}
-
 void zx_vou_layer_enable(struct drm_plane *plane)
 {
struct zx_crtc *zcrtc = to_zx_crtc(plane->state->crtc);
diff --git a/drivers/gpu/drm/zte/zx_vou.h b/drivers/gpu/drm/zte/zx_vou.h
index 57e3c31ee6a5..97d72bfce982 100644
--- a/drivers/gpu/drm/zte/zx_vou.h
+++ b/drivers/gpu/drm/zte/zx_vou.h
@@ -61,9 +61,6 @@ struct vou_div_config {
 void zx_vou_config_dividers(struct drm_crtc *crtc,
struct vou_div_config *configs, int num);
 
-int zx_vou_enable_vblank(struct drm_device *drm, unsigned int pipe);
-void zx_vou_disable_vblank(struct drm_device *drm, unsigned int pipe);
-
 void zx_vou_layer_enable(struct drm_plane *plane);
 void zx_vou_layer_disable(struct drm_plane *plane);
 
-- 
1.9.1

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


[PATCH v3 20/23] drm: tegra: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

As the result, the wrapper functions tegra_drm_xxx get killed
completely, and tegra_dc_xxx are filled into struct drm_crtc_funcs as
vblank hooks directly.

Signed-off-by: Shawn Guo 
Cc: Thierry Reding 
---
 drivers/gpu/drm/tegra/dc.c  | 15 ---
 drivers/gpu/drm/tegra/drm.c | 38 --
 drivers/gpu/drm/tegra/drm.h |  3 ---
 3 files changed, 12 insertions(+), 44 deletions(-)

diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 7561a95a54e3..0db5d5a8d3b9 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -909,8 +909,10 @@ static int tegra_dc_add_planes(struct drm_device *drm, 
struct tegra_dc *dc)
return 0;
 }
 
-u32 tegra_dc_get_vblank_counter(struct tegra_dc *dc)
+static u32 tegra_dc_get_vblank_counter(struct drm_crtc *crtc)
 {
+   struct tegra_dc *dc = to_tegra_dc(crtc);
+
if (dc->syncpt)
return host1x_syncpt_read(dc->syncpt);
 
@@ -918,8 +920,9 @@ u32 tegra_dc_get_vblank_counter(struct tegra_dc *dc)
return drm_crtc_vblank_count(&dc->base);
 }
 
-void tegra_dc_enable_vblank(struct tegra_dc *dc)
+static int tegra_dc_enable_vblank(struct drm_crtc *crtc)
 {
+   struct tegra_dc *dc = to_tegra_dc(crtc);
unsigned long value, flags;
 
spin_lock_irqsave(&dc->lock, flags);
@@ -929,10 +932,13 @@ void tegra_dc_enable_vblank(struct tegra_dc *dc)
tegra_dc_writel(dc, value, DC_CMD_INT_MASK);
 
spin_unlock_irqrestore(&dc->lock, flags);
+
+   return 0;
 }
 
-void tegra_dc_disable_vblank(struct tegra_dc *dc)
+static void tegra_dc_disable_vblank(struct drm_crtc *crtc)
 {
+   struct tegra_dc *dc = to_tegra_dc(crtc);
unsigned long value, flags;
 
spin_lock_irqsave(&dc->lock, flags);
@@ -1036,6 +1042,9 @@ static void tegra_crtc_atomic_destroy_state(struct 
drm_crtc *crtc,
.reset = tegra_crtc_reset,
.atomic_duplicate_state = tegra_crtc_atomic_duplicate_state,
.atomic_destroy_state = tegra_crtc_atomic_destroy_state,
+   .get_vblank_counter = tegra_dc_get_vblank_counter,
+   .enable_vblank = tegra_dc_enable_vblank,
+   .disable_vblank = tegra_dc_disable_vblank,
 };
 
 static int tegra_dc_set_timings(struct tegra_dc *dc,
diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index ef215fef63d6..dba4e090d3df 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -804,40 +804,6 @@ static int tegra_gem_get_flags(struct drm_device *drm, 
void *data,
.llseek = noop_llseek,
 };
 
-static u32 tegra_drm_get_vblank_counter(struct drm_device *drm,
-   unsigned int pipe)
-{
-   struct drm_crtc *crtc = drm_crtc_from_index(drm, pipe);
-   struct tegra_dc *dc = to_tegra_dc(crtc);
-
-   if (!crtc)
-   return 0;
-
-   return tegra_dc_get_vblank_counter(dc);
-}
-
-static int tegra_drm_enable_vblank(struct drm_device *drm, unsigned int pipe)
-{
-   struct drm_crtc *crtc = drm_crtc_from_index(drm, pipe);
-   struct tegra_dc *dc = to_tegra_dc(crtc);
-
-   if (!crtc)
-   return -ENODEV;
-
-   tegra_dc_enable_vblank(dc);
-
-   return 0;
-}
-
-static void tegra_drm_disable_vblank(struct drm_device *drm, unsigned int pipe)
-{
-   struct drm_crtc *crtc = drm_crtc_from_index(drm, pipe);
-   struct tegra_dc *dc = to_tegra_dc(crtc);
-
-   if (crtc)
-   tegra_dc_disable_vblank(dc);
-}
-
 static void tegra_drm_preclose(struct drm_device *drm, struct drm_file *file)
 {
struct tegra_drm_file *fpriv = file->driver_priv;
@@ -905,10 +871,6 @@ static int tegra_debugfs_init(struct drm_minor *minor)
.preclose = tegra_drm_preclose,
.lastclose = tegra_drm_lastclose,
 
-   .get_vblank_counter = tegra_drm_get_vblank_counter,
-   .enable_vblank = tegra_drm_enable_vblank,
-   .disable_vblank = tegra_drm_disable_vblank,
-
 #if defined(CONFIG_DEBUG_FS)
.debugfs_init = tegra_debugfs_init,
 #endif
diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h
index 5205790dd679..5747accb2271 100644
--- a/drivers/gpu/drm/tegra/drm.h
+++ b/drivers/gpu/drm/tegra/drm.h
@@ -193,9 +193,6 @@ struct tegra_dc_window {
 };
 
 /* from dc.c */
-u32 tegra_dc_get_vblank_counter(struct tegra_dc *dc);
-void tegra_dc_enable_vblank(struct tegra_dc *dc);
-void tegra_dc_disable_vblank(struct tegra_dc *dc);
 void tegra_dc_commit(struct tegra_dc *dc);
 int tegra_dc_state_setup_clock(struct tegra_dc *dc,
   struct drm_crtc_state *crtc_state,
-- 
1.9.1

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


[PATCH v3 21/23] drm: tilcdc: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

While at it, the 'return' of .disable_vblank is dropped to fix the
following checkpatch warning.

 WARNING: void function return statements are not generally useful

Signed-off-by: Shawn Guo 
Cc: Jyri Sarha 
---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 11 +++
 drivers/gpu/drm/tilcdc/tilcdc_drv.c  | 12 
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index f80bf9385e41..93505bcfdf4b 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -695,6 +695,15 @@ static int tilcdc_crtc_atomic_check(struct drm_crtc *crtc,
return 0;
 }
 
+static int tilcdc_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+   return 0;
+}
+
+static void tilcdc_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+}
+
 static const struct drm_crtc_funcs tilcdc_crtc_funcs = {
.destroy= tilcdc_crtc_destroy,
.set_config = drm_atomic_helper_set_config,
@@ -702,6 +711,8 @@ static int tilcdc_crtc_atomic_check(struct drm_crtc *crtc,
.reset  = drm_atomic_helper_crtc_reset,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+   .enable_vblank  = tilcdc_crtc_enable_vblank,
+   .disable_vblank = tilcdc_crtc_disable_vblank,
 };
 
 static const struct drm_crtc_helper_funcs tilcdc_crtc_helper_funcs = {
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index d5bc98e283d9..81d80a2ffeb1 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -437,16 +437,6 @@ static irqreturn_t tilcdc_irq(int irq, void *arg)
return tilcdc_crtc_irq(priv->crtc);
 }
 
-static int tilcdc_enable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-   return 0;
-}
-
-static void tilcdc_disable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-   return;
-}
-
 #if defined(CONFIG_DEBUG_FS)
 static const struct {
const char *name;
@@ -557,8 +547,6 @@ static int tilcdc_debugfs_init(struct drm_minor *minor)
   DRIVER_PRIME | DRIVER_ATOMIC),
.lastclose  = tilcdc_lastclose,
.irq_handler= tilcdc_irq,
-   .enable_vblank  = tilcdc_enable_vblank,
-   .disable_vblank = tilcdc_disable_vblank,
.gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.dumb_create= drm_gem_cma_dumb_create,
-- 
1.9.1

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


[PATCH v3 22/23] drm: vc4: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo 
Cc: Eric Anholt 
---
 drivers/gpu/drm/vc4/vc4_crtc.c | 8 
 drivers/gpu/drm/vc4/vc4_drv.c  | 2 --
 drivers/gpu/drm/vc4/vc4_drv.h  | 2 --
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
index 93aece203c54..87b4445cb286 100644
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
@@ -654,9 +654,8 @@ static void vc4_crtc_atomic_flush(struct drm_crtc *crtc,
}
 }
 
-int vc4_enable_vblank(struct drm_device *dev, unsigned int crtc_id)
+static int vc4_enable_vblank(struct drm_crtc *crtc)
 {
-   struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
 
CRTC_WRITE(PV_INTEN, PV_INT_VFP_START);
@@ -664,9 +663,8 @@ int vc4_enable_vblank(struct drm_device *dev, unsigned int 
crtc_id)
return 0;
 }
 
-void vc4_disable_vblank(struct drm_device *dev, unsigned int crtc_id)
+static void vc4_disable_vblank(struct drm_crtc *crtc)
 {
-   struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
 
CRTC_WRITE(PV_INTEN, 0);
@@ -857,6 +855,8 @@ static void vc4_crtc_destroy_state(struct drm_crtc *crtc,
.atomic_duplicate_state = vc4_crtc_duplicate_state,
.atomic_destroy_state = vc4_crtc_destroy_state,
.gamma_set = vc4_crtc_gamma_set,
+   .enable_vblank = vc4_enable_vblank,
+   .disable_vblank = vc4_disable_vblank,
 };
 
 static const struct drm_crtc_helper_funcs vc4_crtc_helper_funcs = {
diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index 3a8709d85da1..4f93328a2f20 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -137,8 +137,6 @@ static void vc4_lastclose(struct drm_device *dev)
.irq_postinstall = vc4_irq_postinstall,
.irq_uninstall = vc4_irq_uninstall,
 
-   .enable_vblank = vc4_enable_vblank,
-   .disable_vblank = vc4_disable_vblank,
.get_scanout_position = vc4_crtc_get_scanoutpos,
.get_vblank_timestamp = vc4_crtc_get_vblank_timestamp,
 
diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
index 0e59f3ee1b83..dffce6293d87 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -444,8 +444,6 @@ int vc4_get_hang_state_ioctl(struct drm_device *dev, void 
*data,
 
 /* vc4_crtc.c */
 extern struct platform_driver vc4_crtc_driver;
-int vc4_enable_vblank(struct drm_device *dev, unsigned int crtc_id);
-void vc4_disable_vblank(struct drm_device *dev, unsigned int crtc_id);
 bool vc4_event_pending(struct drm_crtc *crtc);
 int vc4_crtc_debugfs_regs(struct seq_file *m, void *arg);
 int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
-- 
1.9.1

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


Re: [PATCH v3 02/23] drm: remove drm_vblank_no_hw_counter assignment from driver code

2017-02-07 Thread Maxime Ripard
On Tue, Feb 07, 2017 at 05:16:14PM +0800, Shawn Guo wrote:
> From: Shawn Guo 
> 
> Core code already makes drm_driver.get_vblank_counter hook optional by
> letting drm_vblank_no_hw_counter be the default implementation for the
> function hook.  So the drm_vblank_no_hw_counter assignment in the driver
> code becomes redundant and can be removed now.
> 
> Signed-off-by: Shawn Guo 
> Cc: Alexey Brodkin 
> Cc: Liviu Dudau 
> Cc: Mali DP Maintainers 
> Cc: Russell King 
> Cc: Boris Brezillon 
> Cc: Inki Dae 
> Cc: Stefan Agner 
> Cc: Xinliang Liu 
> Cc: Daniel Vetter 
> Cc: Philipp Zabel 
> Cc: CK Hu 
> Cc: Neil Armstrong 
> Cc: Rob Clark 
> Cc: Marek Vasut 
> Cc: Ben Skeggs 
> Cc: Tomi Valkeinen 
> Cc: Laurent Pinchart 
> Cc: Mark Yao 
> Cc: Benjamin Gaignard 
> Cc: Maxime Ripard 
> Cc: Jyri Sarha 
> Cc: Eric Anholt 
> ---
>  drivers/gpu/drm/arc/arcpgu_drv.c| 1 -
>  drivers/gpu/drm/arm/hdlcd_drv.c | 1 -
>  drivers/gpu/drm/arm/malidp_drv.c| 1 -
>  drivers/gpu/drm/armada/armada_drv.c | 1 -
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c| 1 -
>  drivers/gpu/drm/exynos/exynos_drm_drv.c | 1 -
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c   | 1 -
>  drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 1 -
>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 1 -
>  drivers/gpu/drm/i915/i915_irq.c | 1 -
>  drivers/gpu/drm/imx/imx-drm-core.c  | 1 -
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c  | 1 -
>  drivers/gpu/drm/meson/meson_drv.c   | 1 -
>  drivers/gpu/drm/msm/msm_drv.c   | 1 -
>  drivers/gpu/drm/mxsfb/mxsfb_drv.c   | 1 -
>  drivers/gpu/drm/nouveau/nouveau_drm.c   | 1 -
>  drivers/gpu/drm/omapdrm/omap_drv.c  | 1 -
>  drivers/gpu/drm/rcar-du/rcar_du_drv.c   | 1 -
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 1 -
>  drivers/gpu/drm/shmobile/shmob_drm_drv.c| 1 -
>  drivers/gpu/drm/sti/sti_drv.c   | 1 -
>  drivers/gpu/drm/sun4i/sun4i_drv.c   | 1 -

For sun4i,

Acked-by: Maxime Ripard 

Maxime

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


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


Re: [PATCH v3 19/23] drm: sun4i: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Maxime Ripard
On Tue, Feb 07, 2017 at 05:16:31PM +0800, Shawn Guo wrote:
> From: Shawn Guo 
> 
> The vblank hooks in struct drm_driver are deprecated and only meant for
> legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
> in struct drm_crtc_funcs should be used instead.
> 
> Signed-off-by: Shawn Guo 
> Cc: Maxime Ripard 

Acked-by: Maxime Ripard 

Maxime

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


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


Re: [PATCH v3 21/23] drm: tilcdc: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Jyri Sarha
On 02/07/17 11:16, Shawn Guo wrote:
> From: Shawn Guo 
> 
> The vblank hooks in struct drm_driver are deprecated and only meant for
> legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
> in struct drm_crtc_funcs should be used instead.
> 
> While at it, the 'return' of .disable_vblank is dropped to fix the
> following checkpatch warning.
> 
>  WARNING: void function return statements are not generally useful
> 
> Signed-off-by: Shawn Guo 
> Cc: Jyri Sarha 

Acked-by: Jyri Sarha 

> ---
>  drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 11 +++
>  drivers/gpu/drm/tilcdc/tilcdc_drv.c  | 12 
>  2 files changed, 11 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
> b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> index f80bf9385e41..93505bcfdf4b 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> @@ -695,6 +695,15 @@ static int tilcdc_crtc_atomic_check(struct drm_crtc 
> *crtc,
>   return 0;
>  }
>  
> +static int tilcdc_crtc_enable_vblank(struct drm_crtc *crtc)
> +{
> + return 0;
> +}
> +
> +static void tilcdc_crtc_disable_vblank(struct drm_crtc *crtc)
> +{
> +}
> +
>  static const struct drm_crtc_funcs tilcdc_crtc_funcs = {
>   .destroy= tilcdc_crtc_destroy,
>   .set_config = drm_atomic_helper_set_config,
> @@ -702,6 +711,8 @@ static int tilcdc_crtc_atomic_check(struct drm_crtc *crtc,
>   .reset  = drm_atomic_helper_crtc_reset,
>   .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
>   .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
> + .enable_vblank  = tilcdc_crtc_enable_vblank,
> + .disable_vblank = tilcdc_crtc_disable_vblank,
>  };
>  
>  static const struct drm_crtc_helper_funcs tilcdc_crtc_helper_funcs = {
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c 
> b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> index d5bc98e283d9..81d80a2ffeb1 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> @@ -437,16 +437,6 @@ static irqreturn_t tilcdc_irq(int irq, void *arg)
>   return tilcdc_crtc_irq(priv->crtc);
>  }
>  
> -static int tilcdc_enable_vblank(struct drm_device *dev, unsigned int pipe)
> -{
> - return 0;
> -}
> -
> -static void tilcdc_disable_vblank(struct drm_device *dev, unsigned int pipe)
> -{
> - return;
> -}
> -
>  #if defined(CONFIG_DEBUG_FS)
>  static const struct {
>   const char *name;
> @@ -557,8 +547,6 @@ static int tilcdc_debugfs_init(struct drm_minor *minor)
>  DRIVER_PRIME | DRIVER_ATOMIC),
>   .lastclose  = tilcdc_lastclose,
>   .irq_handler= tilcdc_irq,
> - .enable_vblank  = tilcdc_enable_vblank,
> - .disable_vblank = tilcdc_disable_vblank,
>   .gem_free_object_unlocked = drm_gem_cma_free_object,
>   .gem_vm_ops = &drm_gem_cma_vm_ops,
>   .dumb_create= drm_gem_cma_dumb_create,
> 

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


Re: [PATCH v3 02/23] drm: remove drm_vblank_no_hw_counter assignment from driver code

2017-02-07 Thread Boris Brezillon
On Tue,  7 Feb 2017 17:16:14 +0800
Shawn Guo  wrote:

> From: Shawn Guo 
> 
> Core code already makes drm_driver.get_vblank_counter hook optional by
> letting drm_vblank_no_hw_counter be the default implementation for the
> function hook.  So the drm_vblank_no_hw_counter assignment in the driver
> code becomes redundant and can be removed now.
> 
> Signed-off-by: Shawn Guo 
> Cc: Alexey Brodkin 
> Cc: Liviu Dudau 
> Cc: Mali DP Maintainers 
> Cc: Russell King 
> Cc: Boris Brezillon 

Acked-by: Boris Brezillon 

> Cc: Inki Dae 
> Cc: Stefan Agner 
> Cc: Xinliang Liu 
> Cc: Daniel Vetter 
> Cc: Philipp Zabel 
> Cc: CK Hu 
> Cc: Neil Armstrong 
> Cc: Rob Clark 
> Cc: Marek Vasut 
> Cc: Ben Skeggs 
> Cc: Tomi Valkeinen 
> Cc: Laurent Pinchart 
> Cc: Mark Yao 
> Cc: Benjamin Gaignard 
> Cc: Maxime Ripard 
> Cc: Jyri Sarha 
> Cc: Eric Anholt 
> ---
>  drivers/gpu/drm/arc/arcpgu_drv.c| 1 -
>  drivers/gpu/drm/arm/hdlcd_drv.c | 1 -
>  drivers/gpu/drm/arm/malidp_drv.c| 1 -
>  drivers/gpu/drm/armada/armada_drv.c | 1 -
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c| 1 -
>  drivers/gpu/drm/exynos/exynos_drm_drv.c | 1 -
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c   | 1 -
>  drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 1 -
>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 1 -
>  drivers/gpu/drm/i915/i915_irq.c | 1 -
>  drivers/gpu/drm/imx/imx-drm-core.c  | 1 -
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c  | 1 -
>  drivers/gpu/drm/meson/meson_drv.c   | 1 -
>  drivers/gpu/drm/msm/msm_drv.c   | 1 -
>  drivers/gpu/drm/mxsfb/mxsfb_drv.c   | 1 -
>  drivers/gpu/drm/nouveau/nouveau_drm.c   | 1 -
>  drivers/gpu/drm/omapdrm/omap_drv.c  | 1 -
>  drivers/gpu/drm/rcar-du/rcar_du_drv.c   | 1 -
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 1 -
>  drivers/gpu/drm/shmobile/shmob_drm_drv.c| 1 -
>  drivers/gpu/drm/sti/sti_drv.c   | 1 -
>  drivers/gpu/drm/sun4i/sun4i_drv.c   | 1 -
>  drivers/gpu/drm/tilcdc/tilcdc_drv.c | 1 -
>  drivers/gpu/drm/vc4/vc4_drv.c   | 1 -
>  drivers/gpu/drm/zte/zx_drm_drv.c| 1 -
>  25 files changed, 25 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c 
> b/drivers/gpu/drm/arc/arcpgu_drv.c
> index 8d8344ed655e..1926b200e4cb 100644
> --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> @@ -175,7 +175,6 @@ static int arcpgu_unload(struct drm_device *drm)
>   .dumb_create = drm_gem_cma_dumb_create,
>   .dumb_map_offset = drm_gem_cma_dumb_map_offset,
>   .dumb_destroy = drm_gem_dumb_destroy,
> - .get_vblank_counter = drm_vblank_no_hw_counter,
>   .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
>   .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
>   .gem_free_object_unlocked = drm_gem_cma_free_object,
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index 4ce4f970920b..5d79e87f7421 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -278,7 +278,6 @@ static int hdlcd_debugfs_init(struct drm_minor *minor)
>   .irq_preinstall = hdlcd_irq_preinstall,
>   .irq_postinstall = hdlcd_irq_postinstall,
>   .irq_uninstall = hdlcd_irq_uninstall,
> - .get_vblank_counter = drm_vblank_no_hw_counter,
>   .enable_vblank = hdlcd_enable_vblank,
>   .disable_vblank = hdlcd_disable_vblank,
>   .gem_free_object_unlocked = drm_gem_cma_free_object,
> diff --git a/drivers/gpu/drm/arm/malidp_drv.c 
> b/drivers/gpu/drm/arm/malidp_drv.c
> index 8b0672d4aee9..ca6ccd172de3 100644
> --- a/drivers/gpu/drm/arm/malidp_drv.c
> +++ b/drivers/gpu/drm/arm/malidp_drv.c
> @@ -213,7 +213,6 @@ static void malidp_lastclose(struct drm_device *drm)
>   .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC |
>  DRIVER_PRIME,
>   .lastclose = malidp_lastclose,
> - .get_vblank_counter = drm_vblank_no_hw_counter,
>   .enable_vblank = malidp_enable_vblank,
>   .disable_vblank = malidp_disable_vblank,
>   .gem_free_object_unlocked = drm_gem_cma_free_object,
> diff --git a/drivers/gpu/drm/armada/armada_drv.c 
> b/drivers/gpu/drm/armada/armada_drv.c
> index 63f42d001f33..bb27892012de 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -87,7 +87,6 @@ static void armada_drm_lastclose(struct drm_device *dev)
>  
>  static struct drm_driver armada_drm_driver = {
>   .lastclose  = armada_drm_lastclose,
> - .get_vblank_counter = drm_vblank_no_hw_counter,
>   .enable_vblank  = armada_drm_enable_vblank,
>   .disable_vblank = armada_drm_disable_vblank,
>   .gem_free_object_unlocked = armada_gem_free_object,
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
> b/drivers/gpu/dr

Re: [PATCH v3 07/23] drm: atmel: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Boris Brezillon
On Tue,  7 Feb 2017 17:16:19 +0800
Shawn Guo  wrote:

> From: Shawn Guo 
> 
> The vblank hooks in struct drm_driver are deprecated and only meant for
> legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
> in struct drm_crtc_funcs should be used instead.
> 
> Signed-off-by: Shawn Guo 
> Cc: Boris Brezillon 

Acked-by: Boris Brezillon 

> ---
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 21 +
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c   | 21 -
>  2 files changed, 21 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c 
> b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
> index 9b17a66cf0e1..fabeeea0e899 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
> @@ -434,6 +434,25 @@ static void atmel_hlcdc_crtc_destroy_state(struct 
> drm_crtc *crtc,
>   kfree(state);
>  }
>  
> +static int atmel_hlcdc_crtc_enable_vblank(struct drm_crtc *c)
> +{
> + struct atmel_hlcdc_crtc *crtc = drm_crtc_to_atmel_hlcdc_crtc(c);
> + struct regmap *regmap = crtc->dc->hlcdc->regmap;
> +
> + /* Enable SOF (Start Of Frame) interrupt for vblank counting */
> + regmap_write(regmap, ATMEL_HLCDC_IER, ATMEL_HLCDC_SOF);
> +
> + return 0;
> +}
> +
> +static void atmel_hlcdc_crtc_disable_vblank(struct drm_crtc *c)
> +{
> + struct atmel_hlcdc_crtc *crtc = drm_crtc_to_atmel_hlcdc_crtc(c);
> + struct regmap *regmap = crtc->dc->hlcdc->regmap;
> +
> + regmap_write(regmap, ATMEL_HLCDC_IDR, ATMEL_HLCDC_SOF);
> +}
> +
>  static const struct drm_crtc_funcs atmel_hlcdc_crtc_funcs = {
>   .page_flip = drm_atomic_helper_page_flip,
>   .set_config = drm_atomic_helper_set_config,
> @@ -441,6 +460,8 @@ static void atmel_hlcdc_crtc_destroy_state(struct 
> drm_crtc *crtc,
>   .reset = atmel_hlcdc_crtc_reset,
>   .atomic_duplicate_state =  atmel_hlcdc_crtc_duplicate_state,
>   .atomic_destroy_state = atmel_hlcdc_crtc_destroy_state,
> + .enable_vblank = atmel_hlcdc_crtc_enable_vblank,
> + .disable_vblank = atmel_hlcdc_crtc_disable_vblank,
>  };
>  
>  int atmel_hlcdc_crtc_create(struct drm_device *dev)
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
> b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> index 5cba65b5ea16..fd1a2d0c870d 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> @@ -720,25 +720,6 @@ static void atmel_hlcdc_dc_irq_uninstall(struct 
> drm_device *dev)
>   regmap_read(dc->hlcdc->regmap, ATMEL_HLCDC_ISR, &isr);
>  }
>  
> -static int atmel_hlcdc_dc_enable_vblank(struct drm_device *dev,
> - unsigned int pipe)
> -{
> - struct atmel_hlcdc_dc *dc = dev->dev_private;
> -
> - /* Enable SOF (Start Of Frame) interrupt for vblank counting */
> - regmap_write(dc->hlcdc->regmap, ATMEL_HLCDC_IER, ATMEL_HLCDC_SOF);
> -
> - return 0;
> -}
> -
> -static void atmel_hlcdc_dc_disable_vblank(struct drm_device *dev,
> -   unsigned int pipe)
> -{
> - struct atmel_hlcdc_dc *dc = dev->dev_private;
> -
> - regmap_write(dc->hlcdc->regmap, ATMEL_HLCDC_IDR, ATMEL_HLCDC_SOF);
> -}
> -
>  static const struct file_operations fops = {
>   .owner  = THIS_MODULE,
>   .open   = drm_open,
> @@ -760,8 +741,6 @@ static void atmel_hlcdc_dc_disable_vblank(struct 
> drm_device *dev,
>   .irq_preinstall = atmel_hlcdc_dc_irq_uninstall,
>   .irq_postinstall = atmel_hlcdc_dc_irq_postinstall,
>   .irq_uninstall = atmel_hlcdc_dc_irq_uninstall,
> - .enable_vblank = atmel_hlcdc_dc_enable_vblank,
> - .disable_vblank = atmel_hlcdc_dc_disable_vblank,
>   .gem_free_object_unlocked = drm_gem_cma_free_object,
>   .gem_vm_ops = &drm_gem_cma_vm_ops,
>   .prime_handle_to_fd = drm_gem_prime_handle_to_fd,

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


Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board

2017-02-07 Thread Andrzej Hajda
On 06.02.2017 11:39, Thierry Reding wrote:
> On Fri, Feb 03, 2017 at 09:54:42AM +0100, Andrzej Hajda wrote:
>> Hi Thierry,
>>
>> Finally something technical :)
>>
>> On 02.02.2017 18:58, Thierry Reding wrote:
>>> On Tue, Jan 31, 2017 at 01:05:20PM +0100, Andrzej Hajda wrote:
 On 31.01.2017 09:54, Thierry Reding wrote:
> On Tue, Jan 31, 2017 at 09:01:07AM +0900, Inki Dae wrote:
>> 2017년 01월 24일 10:50에 Hoegeun Kwon 이(가) 쓴 글:
>>> Dear Thierry,
>>>
>>> Could you please review this patch?
>> Thierry, I think this patch has been reviewed enough but no comment
>> from you. Seems you are busy. I will pick up this.
> Sorry, but that's not how it works. This patch has gone through 8
> revisions within 4 weeks, and I tend to ignore patches like that until
> the dust settles.
>
> Other than that, this continues the same madness that I've repeatedly
> complained about in the past. The whole mechanism of running through a
> series of writes and not caring about errors until the very end is
> something we've discussed at length in the past. 
 Yes, we have discussed the pattern, but without any conclusion. The
 pattern is correct, used in different places in kernel (see below for
 examples) and significantly decreases source code size. Disallowing it
 in panels subsystem just because of personal preferences of the
 maintainer does not seem to be proper.

> It also in large parts
> duplicates a bunch of functions from other Samsung panel drivers that I
> already said should eventually be moved to something saner.
 Currently there are two Samsung panel drivers, one is on SPI bus,
 another one is on DSI.
 I am (co-)author of both drivers, they have some similarities but I did
 not see any gain in making additional abstractions over transport layer
 just to make one or two small functions common.
 Could you be more precise what are you talking about, or could you give
 a link to the mail where you said it. Anything I remember was a
 discussion about ugly magic initialization sequences due to poor
 documentation.

 And below promised examples of the error pattern, it was time consuming
 to find them, so please at least read them :)
>>> I've done better, below is what I hope a list of good arguments why the
>>> pattern is a bad idea, and why in some cases it can be justified.
>>>
 Almost exactly the same patterns for the same purpose:

 1. http://lxr.free-electrons.com/source/drivers/net/ieee802154/atusb.c#L63
 Citation from the code:
 To reduce the number of error checks in the code, we record the
 first error
 in atusb->err and reject all subsequent requests until the error is
 cleared.
>>> That's about the worst example you could've used. Have you even looked
>>> at the code that uses this? It's completely crazy. So here we have the
>>> atusb_control_msg() function that stores this error, but then also
>>> propagates it to its caller. One of these callers is atusb_read_reg(),
>>> which also propagates the error or returns the register value if the
>>> read was successful.
>>>
>>> Now the really insane part is how this is then used in something like
>>> atusb_write_subreg():
>>>
>>> orig = atusb_read_reg(atusb, reg);
>>> tmp = orig & ~mask;
>>> tmp |= (value << shift) & mask;
>>> 
>>> if (tmp != orig)
>>> ret = atusb_write_reg(atusb, reg, tmp);
>>>
>>> So let's assume that atusb_control_msg() fails in the call to
>>> atusb_read_reg(). You'll be returning an error code, mask out some bits,
>>> OR in new ones and write the result to the register. So not only does
>>> the code not bother to check for errors, but it will also happily go and
>>> corrupt registers when an error has occurred while reading.
>> Not true, in case of error in atusb_read_reg atusb_write_reg will do
>> nothing because atusb->err is set !
>> And this is strong point of the idiom - you will not be able to perform
>> transfer until the error is explicitly cleared.
> Yes, I see now that there's an additional check before further accesses
> can be made. So I have to apologize to the author and it turns out that
> the code isn't crazy. I suppose it's me that's too stupid to understand
> how this works.
>
> I wouldn't have been confused if this was using a more idiomatic way of
> doing things. The mere fact that code will read/modify/write registers
> unconditionally suggests that there's no error checking going on. Even
> if the code doesn't actually corrupt registers, it does have the effect
> of executing a bunch of instructions completely unnecessarily.

If there are really time consuming tasks you can add always error check
before, as I showed below. Anyway this is error path so the delay
because of the idiom will be usually insignificant comparing to time of
hw error handling/recovery/timeouts etc.

>
> To add to the confusion there are

Re: [PATCH v3 02/23] drm: remove drm_vblank_no_hw_counter assignment from driver code

2017-02-07 Thread Neil Armstrong
On 02/07/2017 10:16 AM, Shawn Guo wrote:
> From: Shawn Guo 
> 
> Core code already makes drm_driver.get_vblank_counter hook optional by
> letting drm_vblank_no_hw_counter be the default implementation for the
> function hook.  So the drm_vblank_no_hw_counter assignment in the driver
> code becomes redundant and can be removed now.
> 
> Signed-off-by: Shawn Guo 
> Cc: Alexey Brodkin 
> Cc: Liviu Dudau 
> Cc: Mali DP Maintainers 
> Cc: Russell King 
> Cc: Boris Brezillon 
> Cc: Inki Dae 
> Cc: Stefan Agner 
> Cc: Xinliang Liu 
> Cc: Daniel Vetter 
> Cc: Philipp Zabel 
> Cc: CK Hu 
> Cc: Neil Armstrong 

For the meson drm driver :

Acked-by: Neil Armstrong 

> Cc: Rob Clark 
> Cc: Marek Vasut 
> Cc: Ben Skeggs 
> Cc: Tomi Valkeinen 
> Cc: Laurent Pinchart 
> Cc: Mark Yao 
> Cc: Benjamin Gaignard 
> Cc: Maxime Ripard 
> Cc: Jyri Sarha 
> Cc: Eric Anholt 
> ---
>  drivers/gpu/drm/arc/arcpgu_drv.c| 1 -
>  drivers/gpu/drm/arm/hdlcd_drv.c | 1 -
>  drivers/gpu/drm/arm/malidp_drv.c| 1 -
>  drivers/gpu/drm/armada/armada_drv.c | 1 -
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c| 1 -
>  drivers/gpu/drm/exynos/exynos_drm_drv.c | 1 -
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c   | 1 -
>  drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 1 -
>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 1 -
>  drivers/gpu/drm/i915/i915_irq.c | 1 -
>  drivers/gpu/drm/imx/imx-drm-core.c  | 1 -
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c  | 1 -
>  drivers/gpu/drm/meson/meson_drv.c   | 1 -
>  drivers/gpu/drm/msm/msm_drv.c   | 1 -
>  drivers/gpu/drm/mxsfb/mxsfb_drv.c   | 1 -
>  drivers/gpu/drm/nouveau/nouveau_drm.c   | 1 -
>  drivers/gpu/drm/omapdrm/omap_drv.c  | 1 -
>  drivers/gpu/drm/rcar-du/rcar_du_drv.c   | 1 -
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 1 -
>  drivers/gpu/drm/shmobile/shmob_drm_drv.c| 1 -
>  drivers/gpu/drm/sti/sti_drv.c   | 1 -
>  drivers/gpu/drm/sun4i/sun4i_drv.c   | 1 -
>  drivers/gpu/drm/tilcdc/tilcdc_drv.c | 1 -
>  drivers/gpu/drm/vc4/vc4_drv.c   | 1 -
>  drivers/gpu/drm/zte/zx_drm_drv.c| 1 -
>  25 files changed, 25 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c 
> b/drivers/gpu/drm/arc/arcpgu_drv.c
> index 8d8344ed655e..1926b200e4cb 100644
> --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> @@ -175,7 +175,6 @@ static int arcpgu_unload(struct drm_device *drm)
>   .dumb_create = drm_gem_cma_dumb_create,
>   .dumb_map_offset = drm_gem_cma_dumb_map_offset,
>   .dumb_destroy = drm_gem_dumb_destroy,
> - .get_vblank_counter = drm_vblank_no_hw_counter,
>   .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
>   .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
>   .gem_free_object_unlocked = drm_gem_cma_free_object,
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index 4ce4f970920b..5d79e87f7421 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -278,7 +278,6 @@ static int hdlcd_debugfs_init(struct drm_minor *minor)
>   .irq_preinstall = hdlcd_irq_preinstall,
>   .irq_postinstall = hdlcd_irq_postinstall,
>   .irq_uninstall = hdlcd_irq_uninstall,
> - .get_vblank_counter = drm_vblank_no_hw_counter,
>   .enable_vblank = hdlcd_enable_vblank,
>   .disable_vblank = hdlcd_disable_vblank,
>   .gem_free_object_unlocked = drm_gem_cma_free_object,
> diff --git a/drivers/gpu/drm/arm/malidp_drv.c 
> b/drivers/gpu/drm/arm/malidp_drv.c
> index 8b0672d4aee9..ca6ccd172de3 100644
> --- a/drivers/gpu/drm/arm/malidp_drv.c
> +++ b/drivers/gpu/drm/arm/malidp_drv.c
> @@ -213,7 +213,6 @@ static void malidp_lastclose(struct drm_device *drm)
>   .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC |
>  DRIVER_PRIME,
>   .lastclose = malidp_lastclose,
> - .get_vblank_counter = drm_vblank_no_hw_counter,
>   .enable_vblank = malidp_enable_vblank,
>   .disable_vblank = malidp_disable_vblank,
>   .gem_free_object_unlocked = drm_gem_cma_free_object,
> diff --git a/drivers/gpu/drm/armada/armada_drv.c 
> b/drivers/gpu/drm/armada/armada_drv.c
> index 63f42d001f33..bb27892012de 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -87,7 +87,6 @@ static void armada_drm_lastclose(struct drm_device *dev)
>  
>  static struct drm_driver armada_drm_driver = {
>   .lastclose  = armada_drm_lastclose,
> - .get_vblank_counter = drm_vblank_no_hw_counter,
>   .enable_vblank  = armada_drm_enable_vblank,
>   .disable_vblank = armada_drm_disable_vblank,
>   .gem_free_object_unlocked = armada_gem_free_object,
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
> b/

Re: [PATCH v3 14/23] drm: meson: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Neil Armstrong
On 02/07/2017 10:16 AM, Shawn Guo wrote:
> From: Shawn Guo 
> 
> The vblank hooks in struct drm_driver are deprecated and only meant for
> legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
> in struct drm_crtc_funcs should be used instead.
> 
> Signed-off-by: Shawn Guo 
> Cc: Neil Armstrong 
> ---
>  drivers/gpu/drm/meson/meson_crtc.c | 22 ++
>  drivers/gpu/drm/meson/meson_drv.c  | 20 
>  2 files changed, 22 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/gpu/drm/meson/meson_crtc.c 
> b/drivers/gpu/drm/meson/meson_crtc.c
> index 749770e5c65f..0fe49eccda65 100644
> --- a/drivers/gpu/drm/meson/meson_crtc.c
> +++ b/drivers/gpu/drm/meson/meson_crtc.c
> @@ -33,6 +33,7 @@
>  
>  #include "meson_crtc.h"
>  #include "meson_plane.h"
> +#include "meson_venc.h"
>  #include "meson_vpp.h"
>  #include "meson_viu.h"
>  #include "meson_registers.h"
> @@ -48,6 +49,24 @@ struct meson_crtc {
>  
>  /* CRTC */
>  
> +static int meson_crtc_enable_vblank(struct drm_crtc *crtc)
> +{
> + struct meson_crtc *meson_crtc = to_meson_crtc(crtc);
> + struct meson_drm *priv = meson_crtc->priv;
> +
> + meson_venc_enable_vsync(priv);
> +
> + return 0;
> +}
> +
> +static void meson_crtc_disable_vblank(struct drm_crtc *crtc)
> +{
> + struct meson_crtc *meson_crtc = to_meson_crtc(crtc);
> + struct meson_drm *priv = meson_crtc->priv;
> +
> + meson_venc_disable_vsync(priv);
> +}
> +
>  static const struct drm_crtc_funcs meson_crtc_funcs = {
>   .atomic_destroy_state   = drm_atomic_helper_crtc_destroy_state,
>   .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
> @@ -55,6 +74,9 @@ struct meson_crtc {
>   .page_flip  = drm_atomic_helper_page_flip,
>   .reset  = drm_atomic_helper_crtc_reset,
>   .set_config = drm_atomic_helper_set_config,
> + .enable_vblank  = meson_crtc_enable_vblank,
> + .disable_vblank = meson_crtc_disable_vblank,
> +
>  };
>  
>  static void meson_crtc_enable(struct drm_crtc *crtc)
> diff --git a/drivers/gpu/drm/meson/meson_drv.c 
> b/drivers/gpu/drm/meson/meson_drv.c
> index c0a59889c45f..8d17d0e59cbe 100644
> --- a/drivers/gpu/drm/meson/meson_drv.c
> +++ b/drivers/gpu/drm/meson/meson_drv.c
> @@ -79,22 +79,6 @@ static void meson_fb_output_poll_changed(struct drm_device 
> *dev)
>   .fb_create   = drm_fb_cma_create,
>  };
>  
> -static int meson_enable_vblank(struct drm_device *dev, unsigned int crtc)
> -{
> - struct meson_drm *priv = dev->dev_private;
> -
> - meson_venc_enable_vsync(priv);
> -
> - return 0;
> -}
> -
> -static void meson_disable_vblank(struct drm_device *dev, unsigned int crtc)
> -{
> - struct meson_drm *priv = dev->dev_private;
> -
> - meson_venc_disable_vsync(priv);
> -}
> -
>  static irqreturn_t meson_irq(int irq, void *arg)
>  {
>   struct drm_device *dev = arg;
> @@ -126,10 +110,6 @@ static irqreturn_t meson_irq(int irq, void *arg)
> DRIVER_MODESET | DRIVER_PRIME |
> DRIVER_ATOMIC,
>  
> - /* Vblank */
> - .enable_vblank  = meson_enable_vblank,
> - .disable_vblank = meson_disable_vblank,
> -
>   /* IRQ */
>   .irq_handler= meson_irq,
>  
> 

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


Re: [PATCH v3 12/23] drm: imx: remove struct imx_drm_crtc and imx_drm_crtc_helper_funcs

2017-02-07 Thread Philipp Zabel
Hi Shawn,

On Tue, 2017-02-07 at 17:16 +0800, Shawn Guo wrote:
> From: Shawn Guo 
> 
> With the vblank hooks in struct drm_crtc_funcs, we do not need to
> maintain the CRTC specific vblank callbacks with struct
> imx_drm_crtc_helper_funcs any more.  By moving the stuff that we
> currently do in imx_drm_add_crtc(), like of_node setting and
> drm_crtc_helper_add()/drm_crtc_init_with_planes() invoking, we can kill
> things like struct imx_drm_crtc, imx_drm_crtc_helper_funcs and related
> functions completely.

Thanks for removing the imx_drm_crtc indirection.

> Functions ipu_enable_vblank() and ipu_disable_vblank() are moved around
> without changes, only for saving the forward declarations.
> 
> Signed-off-by: Shawn Guo 
> Cc: Philipp Zabel 

Acked-by: Philipp Zabel 

regards
Philipp

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


Re: [PATCH v2 5/6] drm/i915: enable scrambling

2017-02-07 Thread Jani Nikula
On Mon, 06 Feb 2017, Shashank Sharma  wrote:
> Geminilake platform sports a native HDMI 2.0 controller, and is
> capable of driving pixel-clocks upto 594Mhz. HDMI 2.0 spec
> mendates scrambling for these higher clocks, for reduced RF footprint.
>
> This patch checks if the monitor supports scrambling, and if required,
> enables it during the modeset.

Throughout this series, but particularly in this patch, I'd prefer using
the term "sink" instead of "monitor" everywhere. The HDMI specifications
use source and sink almost exclusively.

BR,
Jani.

> V2: Addressed review comments from Ville:
> - Do not track scrambling status in DRM layer, track somewhere in
>   driver like in intel_crtc_state.
> - Don't talk to monitor at such a low layer, set monitor scrambling
>   in intel_enable_ddi() before enabling the port.
>
> Signed-off-by: Shashank Sharma 
> ---
>  drivers/gpu/drm/i915/i915_reg.h   |  2 ++
>  drivers/gpu/drm/i915/intel_ddi.c  | 26 +++
>  drivers/gpu/drm/i915/intel_drv.h  | 11 ++
>  drivers/gpu/drm/i915/intel_hdmi.c | 70 
> +++
>  4 files changed, 109 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index 495b789..cc85892 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -7807,6 +7807,8 @@ enum {
>  #define  TRANS_DDI_EDP_INPUT_C_ONOFF (6<<12)
>  #define  TRANS_DDI_DP_VC_PAYLOAD_ALLOC   (1<<8)
>  #define  TRANS_DDI_BFI_ENABLE(1<<4)
> +#define  TRANS_DDI_HIGH_TMDS_CHAR_RATE   (1<<4)
> +#define  TRANS_DDI_HDMI_SCRAMBLING   (1<<0)
>  
>  /* DisplayPort Transport Control */
>  #define _DP_TP_CTL_A 0x64040
> diff --git a/drivers/gpu/drm/i915/intel_ddi.c 
> b/drivers/gpu/drm/i915/intel_ddi.c
> index 9a9a670..cc7e091 100644
> --- a/drivers/gpu/drm/i915/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/intel_ddi.c
> @@ -1278,6 +1278,11 @@ void intel_ddi_enable_transcoder_func(struct drm_crtc 
> *crtc)
>   temp |= TRANS_DDI_MODE_SELECT_HDMI;
>   else
>   temp |= TRANS_DDI_MODE_SELECT_DVI;
> +
> + if (IS_GEMINILAKE(dev_priv))
> + temp = intel_hdmi_handle_source_scrambling(
> + intel_encoder,
> + &intel_crtc->config->base.adjusted_mode, temp);
>   } else if (type == INTEL_OUTPUT_ANALOG) {
>   temp |= TRANS_DDI_MODE_SELECT_FDI;
>   temp |= (intel_crtc->config->fdi_lanes - 1) << 1;
> @@ -1845,6 +1850,21 @@ static void intel_enable_ddi(struct intel_encoder 
> *intel_encoder,
>   struct intel_digital_port *intel_dig_port =
>   enc_to_dig_port(encoder);
>  
> + if (IS_GEMINILAKE(dev_priv)) {
> + /*
> +  * GLK sports a native HDMI 2.0 controller. If required
> +  * clock rate is > 340 Mhz && scrambling is supported
> +  * by monitor, enable scrambling before enabling the
> +  * HDMI 2.0 port. The sink can choose to disable the
> +  * scrambling if it doesn't detect a scrambled within
> +  * 100 ms.
> +  */
> + intel_hdmi_handle_monitor_scrambling(intel_encoder,
> + conn_state->connector,
> + intel_crtc->config,
> + true);
> + }
> +
>   /* In HDMI/DVI mode, the port width, and swing/emphasis values
>* are ignored so nothing special needs to be done besides
>* enabling the port.
> @@ -1885,6 +1905,12 @@ static void intel_disable_ddi(struct intel_encoder 
> *intel_encoder,
>   intel_display_power_put(dev_priv, POWER_DOMAIN_AUDIO);
>   }
>  
> + if (type == INTEL_OUTPUT_HDMI) {
> + intel_hdmi_handle_monitor_scrambling(intel_encoder,
> + old_conn_state->connector,
> + intel_crtc->config, false);
> + }
> +
>   if (type == INTEL_OUTPUT_EDP) {
>   struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
>  
> diff --git a/drivers/gpu/drm/i915/intel_drv.h 
> b/drivers/gpu/drm/i915/intel_drv.h
> index 393f243..300353c 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -681,6 +681,9 @@ struct intel_crtc_state {
>  
>   /* Gamma mode programmed on the pipe */
>   uint32_t gamma_mode;
> +
> + /* HDMI scrambling status (monitor) */
> + bool scrambling;
>  };
>  
>  struct vlv_wm_state {
> @@ -1588,6 +1591,14 @@ void intel_hdmi_init_connector(struct 
> intel_digital_port *intel_dig_port,
>  bool intel_hdmi_compute_config(struct intel_encoder *encoder,
>   

[Bug 98856] [Regression, SI] DIRT: Showdown broken graphics

2017-02-07 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=98856

--- Comment #7 from Gregor Münch  ---
I finally was able to start bisecting this, I was going back to Mesa from early
October but couldnt find the culprit. I used PKGBUILD provided from here:
https://aur.archlinux.org/packages/lib32-mesa-git/
Then I followed these instructions:
https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_packages
https://wiki.archlinux.org/index.php/Bisecting_bugs

I guess since the executable name of the game is dirt.i386 so bisecting the
32bit package is the right one?

Im a bit lost here, I will try older Kernel and libdrm but after that Im
running out of ideas what could caused this, any other ideas would be
appreciated.

BTW, judging from the screenshots in
https://bugs.freedesktop.org/show_bug.cgi?id=99136 it looks this is the same
problem. Its interesting to see that enabling a minor heavy graphic option
causes such crazy graphical corruption. He enables blood effects and in Dirt
you have to set Crowd from OFF to LOW or higher. While ULTRA option makes the
problem even worse.


Fun Fact: I tested Tomb Raider Benchmark, and the average FPS on went from
48fps with Mesa from October to 58fps with current Mesa git. So really good job
on this!

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


[Bug 99136] Blood Effects Total War: Warhammer

2017-02-07 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99136

--- Comment #20 from Gregor Münch  ---
(In reply to Samuel Pitoiset from comment #19)
> Created attachment 129356 [details]
> no blood effects option (v 1.5)

Maybe you need the Blood DLC? (just wild guess)
http://store.steampowered.com/app/404011/

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


Re: [PATCH v3 01/23] drm: add vblank hooks to struct drm_crtc_funcs

2017-02-07 Thread Andrzej Hajda
On 07.02.2017 10:16, Shawn Guo wrote:
> From: Shawn Guo 
>
> The vblank is mostly CRTC specific and implemented as part of CRTC
> driver.  Let's keep the vblank hooks struct drm_driver for legacy
> drivers, and add corresponding hooks in struct drm_crtc_funcs.  These
> hooks take struct drm_crtc pointer as argument, and will be called by
> core vblank handling code for DRIVER_MODESET drivers.
>
> The new hooks get plugged into core by adding wrapper functions for
> vblank handling code.  The .get_vblank_counter hook is effectively
> optional, as we provide drm_vblank_no_hw_counter() as the default
> fallback in the wrapper function.
>
> Signed-off-by: Shawn Guo 

Every time I have lurked into vblank code I was wondering why it is not
a part of crtc, thanks for clearing it up.
Small comment below, anyway:

Reviewed-by: Andrzej Hajda 


> ---
>  drivers/gpu/drm/drm_irq.c | 53 
> +--
>  include/drm/drm_crtc.h| 44 +++
>  include/drm/drm_drv.h |  9 
>  3 files changed, 100 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index e06cf11ebb4a..646b3e57b9ad 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -89,6 +89,21 @@ static void store_vblank(struct drm_device *dev, unsigned 
> int pipe,
>   write_sequnlock(&vblank->seqlock);
>  }
>  
> +static u32 __get_vblank_counter(struct drm_device *dev, unsigned int pipe)
> +{
> + if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> + struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
> +
> + if (crtc->funcs->get_vblank_counter)
> + return crtc->funcs->get_vblank_counter(crtc);
> + }
> +
> + if (dev->driver->get_vblank_counter)
> + return dev->driver->get_vblank_counter(dev, pipe);

After converting all modeset drivers dev->driver->get_vblank_counter
could be called only for non-modeset drivers, ie 'else' can be put
before last if, the same for two other callbacks.

Regards
Andrzej

> +
> + return drm_vblank_no_hw_counter(dev, pipe);
> +}
> +
>  /*
>   * Reset the stored timestamp for the current vblank count to correspond
>   * to the last vblank occurred.
> @@ -112,9 +127,9 @@ static void drm_reset_vblank_timestamp(struct drm_device 
> *dev, unsigned int pipe
>* when drm_vblank_enable() applies the diff
>*/
>   do {
> - cur_vblank = dev->driver->get_vblank_counter(dev, pipe);
> + cur_vblank = __get_vblank_counter(dev, pipe);
>   rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, 0);
> - } while (cur_vblank != dev->driver->get_vblank_counter(dev, pipe) && 
> --count > 0);
> + } while (cur_vblank != __get_vblank_counter(dev, pipe) && --count > 0);
>  
>   /*
>* Only reinitialize corresponding vblank timestamp if high-precision 
> query
> @@ -168,9 +183,9 @@ static void drm_update_vblank_count(struct drm_device 
> *dev, unsigned int pipe,
>* corresponding vblank timestamp.
>*/
>   do {
> - cur_vblank = dev->driver->get_vblank_counter(dev, pipe);
> + cur_vblank = __get_vblank_counter(dev, pipe);
>   rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, flags);
> - } while (cur_vblank != dev->driver->get_vblank_counter(dev, pipe) && 
> --count > 0);
> + } while (cur_vblank != __get_vblank_counter(dev, pipe) && --count > 0);
>  
>   if (dev->max_vblank_count != 0) {
>   /* trust the hw counter when it's around */
> @@ -275,6 +290,20 @@ u32 drm_accurate_vblank_count(struct drm_crtc *crtc)
>  }
>  EXPORT_SYMBOL(drm_accurate_vblank_count);
>  
> +static void __disable_vblank(struct drm_device *dev, unsigned int pipe)
> +{
> + if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> + struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
> +
> + if (crtc->funcs->disable_vblank) {
> + crtc->funcs->disable_vblank(crtc);
> + return;
> + }
> + }
> +
> + dev->driver->disable_vblank(dev, pipe);
> +}
> +
>  /*
>   * Disable vblank irq's on crtc, make sure that last vblank count
>   * of hardware and corresponding consistent software vblank counter
> @@ -298,7 +327,7 @@ static void vblank_disable_and_save(struct drm_device 
> *dev, unsigned int pipe)
>* hardware potentially runtime suspended.
>*/
>   if (vblank->enabled) {
> - dev->driver->disable_vblank(dev, pipe);
> + __disable_vblank(dev, pipe);
>   vblank->enabled = false;
>   }
>  
> @@ -1027,6 +1056,18 @@ void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
>  }
>  EXPORT_SYMBOL(drm_crtc_send_vblank_event);
>  
> +static int __enable_vblank(struct drm_device *dev, unsigned int pipe)
> +{
> + if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> + struct drm_crtc

[Bug 97879] [amdgpu] Rocket League: long hangs (several seconds) when loading assets (models/textures/shaders?)

2017-02-07 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=97879

Marek Olšák  changed:

   What|Removed |Added

   Assignee|mesa-dev@lists.freedesktop. |dri-devel@lists.freedesktop
   |org |.org
Version|12.0|git
 QA Contact|intel-3d-bugs@lists.freedes |dri-devel@lists.freedesktop
   |ktop.org|.org
  Component|glsl-compiler   |Drivers/Gallium/radeonsi

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


Re: [PATCH v3 02/23] drm: remove drm_vblank_no_hw_counter assignment from driver code

2017-02-07 Thread Laurent Pinchart
Hi Shawn,

Thank you for the patch.

On Tuesday 07 Feb 2017 17:16:14 Shawn Guo wrote:
> From: Shawn Guo 
> 
> Core code already makes drm_driver.get_vblank_counter hook optional by
> letting drm_vblank_no_hw_counter be the default implementation for the
> function hook.  So the drm_vblank_no_hw_counter assignment in the driver
> code becomes redundant and can be removed now.
> 
> Signed-off-by: Shawn Guo 
> Cc: Alexey Brodkin 
> Cc: Liviu Dudau 
> Cc: Mali DP Maintainers 
> Cc: Russell King 
> Cc: Boris Brezillon 
> Cc: Inki Dae 
> Cc: Stefan Agner 
> Cc: Xinliang Liu 
> Cc: Daniel Vetter 
> Cc: Philipp Zabel 
> Cc: CK Hu 
> Cc: Neil Armstrong 
> Cc: Rob Clark 
> Cc: Marek Vasut 
> Cc: Ben Skeggs 
> Cc: Tomi Valkeinen 
> Cc: Laurent Pinchart 
> Cc: Mark Yao 
> Cc: Benjamin Gaignard 
> Cc: Maxime Ripard 
> Cc: Jyri Sarha 
> Cc: Eric Anholt 
> ---
>  drivers/gpu/drm/arc/arcpgu_drv.c| 1 -
>  drivers/gpu/drm/arm/hdlcd_drv.c | 1 -
>  drivers/gpu/drm/arm/malidp_drv.c| 1 -
>  drivers/gpu/drm/armada/armada_drv.c | 1 -
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c| 1 -
>  drivers/gpu/drm/exynos/exynos_drm_drv.c | 1 -
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c   | 1 -
>  drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 1 -
>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 1 -
>  drivers/gpu/drm/i915/i915_irq.c | 1 -
>  drivers/gpu/drm/imx/imx-drm-core.c  | 1 -
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c  | 1 -
>  drivers/gpu/drm/meson/meson_drv.c   | 1 -
>  drivers/gpu/drm/msm/msm_drv.c   | 1 -
>  drivers/gpu/drm/mxsfb/mxsfb_drv.c   | 1 -
>  drivers/gpu/drm/nouveau/nouveau_drm.c   | 1 -
>  drivers/gpu/drm/omapdrm/omap_drv.c  | 1 -
>  drivers/gpu/drm/rcar-du/rcar_du_drv.c   | 1 -
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 1 -
>  drivers/gpu/drm/shmobile/shmob_drm_drv.c| 1 -
>  drivers/gpu/drm/sti/sti_drv.c   | 1 -
>  drivers/gpu/drm/sun4i/sun4i_drv.c   | 1 -
>  drivers/gpu/drm/tilcdc/tilcdc_drv.c | 1 -
>  drivers/gpu/drm/vc4/vc4_drv.c   | 1 -
>  drivers/gpu/drm/zte/zx_drm_drv.c| 1 -
>  25 files changed, 25 deletions(-)

[snip]

> diff --git a/drivers/gpu/drm/i915/i915_irq.c
> b/drivers/gpu/drm/i915/i915_irq.c index 47d6131e977f..5aab08172faf 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -4218,7 +4218,6 @@ void intel_irq_init(struct drm_i915_private *dev_priv)
> if (IS_GEN2(dev_priv)) {
>   /* Gen2 doesn't have a hardware frame counter */
>   dev->max_vblank_count = 0;
> - dev->driver->get_vblank_counter = drm_vblank_no_hw_counter;
>   } else if (IS_G4X(dev_priv) || INTEL_INFO(dev_priv)->gen >= 5) {
>   dev->max_vblank_count = 0x; /* full 32 bit counter */
>   dev->driver->get_vblank_counter = g4x_get_vblank_counter;

On an unrelated note, for security reasons we should try to make the driver 
structure static, or at least move ops to a static structure.

Anyway, for this patch,

Reviewed-by: Laurent Pinchart 

-- 
Regards,

Laurent Pinchart

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


[Bug 97879] [amdgpu] Rocket League: long hangs (several seconds) when loading assets (models/textures/shaders?)

2017-02-07 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=97879

--- Comment #61 from Marek Olšák  ---
Created attachment 129379
  --> https://bugs.freedesktop.org/attachment.cgi?id=129379&action=edit
patch - possible workaround

Does the attached patch help?

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


Re: [PATCH v3 08/23] drm: exynos: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Andrzej Hajda
On 07.02.2017 10:16, Shawn Guo wrote:
> From: Shawn Guo 
>
> The vblank hooks in struct drm_driver are deprecated and only meant for
> legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
> in struct drm_crtc_funcs should be used instead.
>
> As the result, exynos_drm_crtc_enable[disable]_vblank() become static
> functions.  They are moved around a bit to save forward declaration
> though.  Also while at it, we move one step further to kill
> exynos_drm_crtc_from_pipe() completely by updating hdmi_bind() a bit.
>
> Signed-off-by: Shawn Guo 
> Cc: Inki Dae 

Reviewed-by: Andrzej Hajda 
--
Regards
Andrzej

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


Re: [PATCH v3 01/23] drm: add vblank hooks to struct drm_crtc_funcs

2017-02-07 Thread Daniel Vetter
On Tue, Feb 07, 2017 at 11:38:08AM +0100, Andrzej Hajda wrote:
> On 07.02.2017 10:16, Shawn Guo wrote:
> > +static u32 __get_vblank_counter(struct drm_device *dev, unsigned int pipe)
> > +{
> > +   if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> > +   struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
> > +
> > +   if (crtc->funcs->get_vblank_counter)
> > +   return crtc->funcs->get_vblank_counter(crtc);
> > +   }
> > +
> > +   if (dev->driver->get_vblank_counter)
> > +   return dev->driver->get_vblank_counter(dev, pipe);
> 
> After converting all modeset drivers dev->driver->get_vblank_counter
> could be called only for non-modeset drivers, ie 'else' can be put
> before last if, the same for two other callbacks.

Shawn converted a lot of drivers, but not yet all of them. There's a lot
more kms drivers, so probably will take some time until we can do this.
But a good long-term goal indeed.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 03/23] drm: unexport function drm_vblank_no_hw_counter()

2017-02-07 Thread Laurent Pinchart
Hi Shawn,

Thank you for the patch.

On Tuesday 07 Feb 2017 17:16:15 Shawn Guo wrote:
> From: Shawn Guo 
> 
> The function drm_vblank_no_hw_counter() is now only used in core vblank
> wrapper code.  Let's unexport it by making it a static function.
> 
> Signed-off-by: Shawn Guo 

Reviewed-by: Laurent Pinchart 

> ---
>  drivers/gpu/drm/drm_irq.c | 28 ++--
>  include/drm/drm_drv.h |  7 +++
>  include/drm/drm_irq.h |  1 -
>  3 files changed, 13 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 646b3e57b9ad..1906723af389 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -89,6 +89,16 @@ static void store_vblank(struct drm_device *dev, unsigned
> int pipe, write_sequnlock(&vblank->seqlock);
>  }
> 
> +/*
> + * "No hw counter" fallback implementation of .get_vblank_counter() hook,
> + * if there is no useable hardware frame counter available.
> + */
> +static u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int
> pipe) +{
> + WARN_ON_ONCE(dev->max_vblank_count != 0);
> + return 0;
> +}
> +
>  static u32 __get_vblank_counter(struct drm_device *dev, unsigned int pipe)
>  {
>   if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> @@ -1748,21 +1758,3 @@ bool drm_crtc_handle_vblank(struct drm_crtc *crtc)
>   return drm_handle_vblank(crtc->dev, drm_crtc_index(crtc));
>  }
>  EXPORT_SYMBOL(drm_crtc_handle_vblank);
> -
> -/**
> - * drm_vblank_no_hw_counter - "No hw counter" implementation of
> .get_vblank_counter() - * @dev: DRM device
> - * @pipe: CRTC for which to read the counter
> - *
> - * Drivers can plug this into the .get_vblank_counter() function if
> - * there is no useable hardware frame counter available.
> - *
> - * Returns:
> - * 0
> - */
> -u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe)
> -{
> - WARN_ON_ONCE(dev->max_vblank_count != 0);
> - return 0;
> -}
> -EXPORT_SYMBOL(drm_vblank_no_hw_counter);
> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> index 40ae89106594..661ca24a4c97 100644
> --- a/include/drm/drm_drv.h
> +++ b/include/drm/drm_drv.h
> @@ -120,10 +120,9 @@ struct drm_driver {
>*
>* Driver callback for fetching a raw hardware vblank counter for the
>* CRTC specified with the pipe argument.  If a device doesn't have a
> -  * hardware counter, the driver can simply use
> -  * drm_vblank_no_hw_counter() function. The DRM core will account for
> -  * missed vblank events while interrupts where disabled based on 
system
> -  * timestamps.
> +  * hardware counter, the driver can simply leave the hook as NULL.
> +  * The DRM core will account for missed vblank events while interrupts
> +  * where disabled based on system timestamps.
>*
>* Wraparound handling and loss of events due to modesetting is dealt
>* with in the DRM core code, as long as drivers call
> diff --git a/include/drm/drm_irq.h b/include/drm/drm_irq.h
> index 2fb880462a57..cf0be6594c8c 100644
> --- a/include/drm/drm_irq.h
> +++ b/include/drm/drm_irq.h
> @@ -152,7 +152,6 @@ void drm_crtc_arm_vblank_event(struct drm_crtc *crtc,
>  void drm_crtc_vblank_on(struct drm_crtc *crtc);
>  void drm_vblank_cleanup(struct drm_device *dev);
>  u32 drm_accurate_vblank_count(struct drm_crtc *crtc);
> -u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe);
> 
>  int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
> unsigned int pipe, int *max_error,

-- 
Regards,

Laurent Pinchart

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


Re: [PATCH v3 02/23] drm: remove drm_vblank_no_hw_counter assignment from driver code

2017-02-07 Thread Laurent Pinchart
Hi Russell,

On Tuesday 07 Feb 2017 10:44:49 Russell King - ARM Linux wrote:
> On Tue, Feb 07, 2017 at 12:42:15PM +0200, Laurent Pinchart wrote:
> > On an unrelated note, for security reasons we should try to make the
> > driver
> > structure static, or at least move ops to a static structure.
> 
> ITYM "const" not "static".
> 
> "static" doesn't get you anything from a security point of view.  "const"
> gets you write protection, so code can't modify the function pointers.

That's what I meant, sorry. My brain-fingers link seems to be have a high 
noise level this week.

-- 
Regards,

Laurent Pinchart

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


Re: [PATCH] drm/radeon: avoid kernel segfault in vce when gpu fails to resume

2017-02-07 Thread Christian König

Am 06.02.2017 um 21:13 schrieb j.gli...@gmail.com:

From: Jérôme Glisse 

When GPU fails to resume we can not trust that value we write to GPU
memory will post and we might get garbage (more like 0x on
x86) when reading them back. This trigger out of range memory access
in the kernel inside the vce resume code path.

This patch use canonical value to compute offset instead of reading
back value from GPU memory.

Signed-off-by: Jérôme Glisse 


Good point, path is Reviewed-by: Christian König .

Regards,
Christian.


---
  drivers/gpu/drm/radeon/vce_v1_0.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/vce_v1_0.c 
b/drivers/gpu/drm/radeon/vce_v1_0.c
index a01efe3..f541a4b 100644
--- a/drivers/gpu/drm/radeon/vce_v1_0.c
+++ b/drivers/gpu/drm/radeon/vce_v1_0.c
@@ -196,7 +196,7 @@ int vce_v1_0_load_fw(struct radeon_device *rdev, uint32_t 
*data)
memset(&data[5], 0, 44);
memcpy(&data[16], &sign[1], rdev->vce_fw->size - sizeof(*sign));
  
-	data += le32_to_cpu(data[4]) / 4;

+   data += (le32_to_cpu(sign->len) + 64) / 4;
data[0] = sign->val[i].sigval[0];
data[1] = sign->val[i].sigval[1];
data[2] = sign->val[i].sigval[2];



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


Re: [PATCH v3 02/23] drm: remove drm_vblank_no_hw_counter assignment from driver code

2017-02-07 Thread Thierry Reding
On Tue, Feb 07, 2017 at 10:44:49AM +, Russell King - ARM Linux wrote:
> On Tue, Feb 07, 2017 at 12:42:15PM +0200, Laurent Pinchart wrote:
> > On an unrelated note, for security reasons we should try to make the driver 
> > structure static, or at least move ops to a static structure.
> 
> ITYM "const" not "static".
> 
> "static" doesn't get you anything from a security point of view.  "const"
> gets you write protection, so code can't modify the function pointers.

We can't easily do that for struct drm_driver at the moment because some
fields end up being modified at runtime. I suppose we could move some of
those fields over to struct drm_device, which, in many cases, would make
more sense anyway.

What i915 is currently doing is probably fine for all existing cases,
but it sets a bad example for other drivers that may end up having to
drive multiple devices with one driver, so modifying the global driver
is likely going to break things.

Thierry


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


Re: [PATCH v3 20/23] drm: tegra: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Thierry Reding
On Tue, Feb 07, 2017 at 05:16:32PM +0800, Shawn Guo wrote:
> From: Shawn Guo 
> 
> The vblank hooks in struct drm_driver are deprecated and only meant for
> legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
> in struct drm_crtc_funcs should be used instead.
> 
> As the result, the wrapper functions tegra_drm_xxx get killed
> completely, and tegra_dc_xxx are filled into struct drm_crtc_funcs as
> vblank hooks directly.
> 
> Signed-off-by: Shawn Guo 
> Cc: Thierry Reding 
> ---
>  drivers/gpu/drm/tegra/dc.c  | 15 ---
>  drivers/gpu/drm/tegra/drm.c | 38 --
>  drivers/gpu/drm/tegra/drm.h |  3 ---
>  3 files changed, 12 insertions(+), 44 deletions(-)

Acked-by: Thierry Reding 


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


Re: [PATCH v3 01/23] drm: add vblank hooks to struct drm_crtc_funcs

2017-02-07 Thread Thierry Reding
On Tue, Feb 07, 2017 at 05:16:13PM +0800, Shawn Guo wrote:
> From: Shawn Guo 
> 
> The vblank is mostly CRTC specific and implemented as part of CRTC
> driver.  Let's keep the vblank hooks struct drm_driver for legacy
> drivers, and add corresponding hooks in struct drm_crtc_funcs.  These
> hooks take struct drm_crtc pointer as argument, and will be called by
> core vblank handling code for DRIVER_MODESET drivers.
> 
> The new hooks get plugged into core by adding wrapper functions for
> vblank handling code.  The .get_vblank_counter hook is effectively
> optional, as we provide drm_vblank_no_hw_counter() as the default
> fallback in the wrapper function.
> 
> Signed-off-by: Shawn Guo 
> ---
>  drivers/gpu/drm/drm_irq.c | 53 
> +--
>  include/drm/drm_crtc.h| 44 +++
>  include/drm/drm_drv.h |  9 
>  3 files changed, 100 insertions(+), 6 deletions(-)

I had been meaning to do this for a long time myself but never got
around to it. Great stuff.

Acked-by: Thierry Reding 


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


Re: [PATCH v3 2/7] drm/tinydrm: Add helper functions

2017-02-07 Thread Thierry Reding
On Tue, Feb 07, 2017 at 08:28:16AM +1000, Dave Airlie wrote:
> >
> > I definitely don't want that we don't attempt this. But brought from years
> > of experience, I recommend to merge first (with pre-refactoring already
> > applied, but helpers only extracted, not yet at the right spot), and then
> > follow up with. Because on average, there's way too many trees with
> > overloaded maintainers who maybe look at your patch once per kernel
> > release cycle.
> >
> > If you know that backlight and spi isn't one of these areas (anything that
> > goes through takashi/sound is a similar good experience for us on the i915
> > side), then I guess we can try. But then Noralf has already written a few
> > months worth of really great refactoring, and I'm seriously starting to
> > feel guilty for volunteering him for all of this. Even though he seems to
> > be really good at it, and seems to not mind, it's getting a bit silly.
> > Given that I'd say up to Noralf.
> >
> > In short, there's always a balance.
> 
> I don't think we can make a rule for this, it will always depend on the
> code. There is always going to be stuff we put in drm that should go
> elsewhere, and stuff that is elsewhere that drm should use.
> 
> I think however if we do add stuff like this, someone should keep track
> of them and try to make them get further into the kernel.

Yes, I think having some sort of TODO in drivers/gpu/drm could help
track things that we know should eventually be moved out. It could serve
as a list of janitorial tasks for newcomers that want to get their hands
dirty and tackle relatively trivial tasks.

That's not meant to devalue such contributions. Code would be in a
mostly finished form, so it'd be mostly about moving things into the
correct subsystem, interacting with maintainers, making sure things are
kept working along the way, that kind of thing. No in-depth knowledge
of DRM/KMS would be required, but perhaps be picked up along the way.

Thierry


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


Re: [PATCH v4] drm/imx: ipuv3-plane: use drm_plane_helper_check_state, clipped coordinates

2017-02-07 Thread Ville Syrjälä
On Tue, Feb 07, 2017 at 09:51:50AM +0100, Philipp Zabel wrote:
> On Fri, 2017-02-03 at 15:20 +0200, Ville Syrjälä wrote:
> > On Fri, Feb 03, 2017 at 10:31:39AM +0100, Philipp Zabel wrote:
> > > Use drm_plane_helper_check_state to clip raw user coordinates to crtc
> > > bounds. This checks for full plane coverage and scaling already, so
> > > we can drop some custom checks. Use the clipped coordinates everywhere.
> > > 
> > > Suggested-by: Ville Syrjälä 
> > > Signed-off-by: Philipp Zabel 
> > > ---
> > > Changes since v3:
> > >  - Disallow target frames that start offscreen (state->crtc_x/y < 0), to 
> > > avoid
> > >confusing userspace: due to the necessary line start address 
> > > alignment, we
> > >could only support very specific negative values for crtc_x/y, 
> > > depending on
> > >the pixel format.
> > 
> > That's really no different to the user specifying non-zero src
> > coordinates. So I'm wondering what's the point of special casing
> > crtc coordinates this way because you'll need to check the src
> > coordinates anyway.
> 
> User expectations.
> 
> For the src_x/y / src.x1/y1 source coordinates we have format specific
> alignment requirements due to limitations of the DMA unit, there is no
> way around it.
> For the crtc_x/y plane coordinates there are no alignment requirements
> at all, the partial plane can be positioned at any integer x/y position.
> If we allow to simulate a partially offscreen plane at negative
> positions by clipping and setting src.x1/y1, suddenly the crtc_x/y have
> alignment requirements, but only if the values are negative.
> I assume that would rather confuse any user space application that tries
> to reason about which crtc_x/y values are valid, so it's probably better
> to disallow it altogether.

I don't really agree. Userspace has to be prepared for anything
to fail really. Whether it fails every time or sometimes is not that
much different IMO. Given the simple return value userspace can't
really draw any real conclusions about the reason for the failure.

A related question is how strict we should really be. In the past we've
been very lax in fudging the coordinates to make something appear on the
screen. Probably I went a bit too far in the laxness actually, and with
atomic we want to tighten things up a little. Just no one has managed to
really answer how tight we should make things. Is it OK to round things
to pixel boundaries perhaps? Maybe even macropixel boundaries?

-- 
Ville Syrjälä
Intel OTC
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 2/7] drm/tinydrm: Add helper functions

2017-02-07 Thread Daniel Vetter
On Tue, Feb 07, 2017 at 12:11:28PM +0100, Thierry Reding wrote:
> On Tue, Feb 07, 2017 at 08:28:16AM +1000, Dave Airlie wrote:
> > >
> > > I definitely don't want that we don't attempt this. But brought from years
> > > of experience, I recommend to merge first (with pre-refactoring already
> > > applied, but helpers only extracted, not yet at the right spot), and then
> > > follow up with. Because on average, there's way too many trees with
> > > overloaded maintainers who maybe look at your patch once per kernel
> > > release cycle.
> > >
> > > If you know that backlight and spi isn't one of these areas (anything that
> > > goes through takashi/sound is a similar good experience for us on the i915
> > > side), then I guess we can try. But then Noralf has already written a few
> > > months worth of really great refactoring, and I'm seriously starting to
> > > feel guilty for volunteering him for all of this. Even though he seems to
> > > be really good at it, and seems to not mind, it's getting a bit silly.
> > > Given that I'd say up to Noralf.
> > >
> > > In short, there's always a balance.
> > 
> > I don't think we can make a rule for this, it will always depend on the
> > code. There is always going to be stuff we put in drm that should go
> > elsewhere, and stuff that is elsewhere that drm should use.
> > 
> > I think however if we do add stuff like this, someone should keep track
> > of them and try to make them get further into the kernel.
> 
> Yes, I think having some sort of TODO in drivers/gpu/drm could help
> track things that we know should eventually be moved out. It could serve
> as a list of janitorial tasks for newcomers that want to get their hands
> dirty and tackle relatively trivial tasks.

We have this list already, it's at: http://www.x.org/wiki/DRMJanitors/

I guess I should highlight it more, maybe even add it to the docs? Eric
just asked about it last week too.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 2/7] drm/tinydrm: Add helper functions

2017-02-07 Thread Thierry Reding
On Mon, Feb 06, 2017 at 11:11:27PM +0100, Noralf Trønnes wrote:
> 
> Den 06.02.2017 16.53, skrev Daniel Vetter:
> > On Mon, Feb 06, 2017 at 12:08:47PM +0100, Thierry Reding wrote:
> > > On Mon, Feb 06, 2017 at 11:07:42AM +0100, Daniel Vetter wrote:
> > > > On Mon, Feb 6, 2017 at 10:35 AM, Thierry Reding 
> > > > 
> > > > wrote:
> > > > 
> > > > > > > > +EXPORT_SYMBOL(tinydrm_disable_backlight);
> > > > > > > > +#endif
> > > > > > > These look like they really should be part of the backlight 
> > > > > > > subsystem.
> > > > > I
> > > > > > > don't see anything DRM specific about them. Well, except for the 
> > > > > > > error
> > > > > > > messages.
> > > > > > So this is a bit an unpopular opinion with some folks, but I don't
> > > > > require
> > > > > > anyone to submit new code to subsystems outside of drm for new 
> > > > > > drivers.
> > > > > > Simply because it takes months to get stuff landed, and in general 
> > > > > > it's
> > > > > > not worth the trouble.
> > > > > "Not worth the trouble" is very subjective. If you look at the Linux
> > > > > kernel in general, one of the reasons why it works so well is because
> > > > > the changes we make apply to the kernel as a whole. Yes, sometimes 
> > > > > that
> > > > > makes things more difficult and time-consuming, but it also means that
> > > > > the end result will be much more widely usable and therefore benefits
> > > > > everyone else in return. In my opinion that's a large part of why the
> > > > > kernel is so successful.
> > > > > 
> > > > > > We have piles of stuff in drm and drm drivers that should be in 
> > > > > > core but
> > > > > > isn't.
> > > > > > 
> > > > > > Imo the only reasonable way is to merge as-is, then follow-up with a
> > > > > patch
> > > > > > series to move the helper into the right subsystem. Most often
> > > > > > unfortunately that follow-up patch series will just die.
> > > > > Of course follow-up series die. That's because nobody cares to 
> > > > > follow-up
> > > > > once their code has been merged.
> > > > > 
> > > > > Collecting our own helpers or variants of subsystems is a great way of
> > > > > isolating ourselves from the rest of the community. I don't think 
> > > > > that's
> > > > > a good solution in the long run at all.
> > > > > 
> > > > We have a bunch of patch series that we resubmit for months and they go
> > > > exactly nowhere. They don't die because we stop caring, they die because
> > > > they die. Some of them we even need to constantly rebase and carry 
> > > > around
> > > > in drm-tip since our CI would Oops or spew WARNIGs all over the place.
> > > > There's simply some areas of the kernel which seem overloaded under 
> > > > patches
> > > > and no one is willing or able to fix things, and I can't fix the entire
> > > > kernel. Nor expect contributors (who have much less political weight to
> > > > throw around than me) to do that and succeed. And we don't end up with
> > > > worse code in the drm subsystem, since we can still do the refactoring
> > > > within drm helpers and end up with clean drivers.
> > > > 
> > > > I fully agree that it's not great for the kernel's future, but when I'm
> > > > stuck with the option to get shit done or burning out playing the
> > > > upstreaming game, the choice is easy. And in the end I care about open
> > > > source gfx much more than the kernel, and I think for open source gfx's
> > > > success it's crucial that we're welcoming to new contributors and don't
> > > > throw up massive roadblocks. Open source gfx is tiny and still far away
> > > > from world domination, we need _lots_ more people. If that means routing
> > > > around other subsystems for them, I'm all for it.
> > > I can't say I fully agree with that sentiment. I do see how routing
> > > around subsystems can be useful occasionally. If nobody will merge the
> > > code, or if nobody cares, then by all means, let's make them DRM-
> > > specific helpers.
> > > 
> > > But I think we need to at least try to do the right thing. If only to
> > > teach people what the right way is. If we start accepting such things
> > > by default, how can we expect contributors to even try?
> > > 
> > > I also think that contributors will often end up contributing not only
> > > to DRM but to the kernel as a whole. As such it should be part of our
> > > mentoring to teach them about how the process works as a rule, even if
> > > the occasional exception is necessary to get things done.
> > > 
> > > In this particular case, I know for a fact that both backlight and SPI
> > > maintainers are very responsive, so that's not a good excuse.
> > I definitely don't want that we don't attempt this. But brought from years
> > of experience, I recommend to merge first (with pre-refactoring already
> > applied, but helpers only extracted, not yet at the right spot), and then
> > follow up with. Because on average, there's way too many trees with
> > overloaded maintainers who maybe look at your patch once per kernel
> 

Re: [PATCH v3 2/7] drm/tinydrm: Add helper functions

2017-02-07 Thread Thierry Reding
On Tue, Feb 07, 2017 at 12:21:28PM +0100, Daniel Vetter wrote:
> On Tue, Feb 07, 2017 at 12:11:28PM +0100, Thierry Reding wrote:
> > On Tue, Feb 07, 2017 at 08:28:16AM +1000, Dave Airlie wrote:
> > > >
> > > > I definitely don't want that we don't attempt this. But brought from 
> > > > years
> > > > of experience, I recommend to merge first (with pre-refactoring already
> > > > applied, but helpers only extracted, not yet at the right spot), and 
> > > > then
> > > > follow up with. Because on average, there's way too many trees with
> > > > overloaded maintainers who maybe look at your patch once per kernel
> > > > release cycle.
> > > >
> > > > If you know that backlight and spi isn't one of these areas (anything 
> > > > that
> > > > goes through takashi/sound is a similar good experience for us on the 
> > > > i915
> > > > side), then I guess we can try. But then Noralf has already written a 
> > > > few
> > > > months worth of really great refactoring, and I'm seriously starting to
> > > > feel guilty for volunteering him for all of this. Even though he seems 
> > > > to
> > > > be really good at it, and seems to not mind, it's getting a bit silly.
> > > > Given that I'd say up to Noralf.
> > > >
> > > > In short, there's always a balance.
> > > 
> > > I don't think we can make a rule for this, it will always depend on the
> > > code. There is always going to be stuff we put in drm that should go
> > > elsewhere, and stuff that is elsewhere that drm should use.
> > > 
> > > I think however if we do add stuff like this, someone should keep track
> > > of them and try to make them get further into the kernel.
> > 
> > Yes, I think having some sort of TODO in drivers/gpu/drm could help
> > track things that we know should eventually be moved out. It could serve
> > as a list of janitorial tasks for newcomers that want to get their hands
> > dirty and tackle relatively trivial tasks.
> 
> We have this list already, it's at: http://www.x.org/wiki/DRMJanitors/
> 
> I guess I should highlight it more, maybe even add it to the docs? Eric
> just asked about it last week too.

Yeah, I'm aware of that list. I think it's a little problematic that
it's in a wiki and far removed from where the actual work is happening.
I think we should just take that list and add it as a TODO in
drivers/gpu/drm, or alternatively keep it as part of the GPU
documentation. That way we can more easily mark things as done or add
new stuff as work gets done.

For cases like this I think we could just add new items as they are
pointed out during review. For things that are already merged we can
add items separately. Once the refactoring is done, the patch series
can contain a final patch that simply removes the items again. I think
that has much less potential to become out-dated than a separate wiki
page.

FWIW, I'll volunteer to move the list to git if we decide to go ahead
with that.

Thierry


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


Re: [PATCH v3 1/7] drm: Add DRM support for tiny LCD displays

2017-02-07 Thread Thierry Reding
On Tue, Feb 07, 2017 at 07:58:52AM +0100, Daniel Vetter wrote:
> On Mon, Feb 06, 2017 at 08:23:36PM +0100, Noralf Trønnes wrote:
> > 
> > Den 06.02.2017 10.17, skrev Thierry Reding:
> > > On Tue, Jan 31, 2017 at 05:03:13PM +0100, Noralf Trønnes wrote:
> > > > tinydrm provides helpers for very simple displays that can use
> > > > CMA backed framebuffers and need flushing on changes.
> > > > 
> > > > Signed-off-by: Noralf Trønnes 
> > > > Acked-by: Daniel Vetter 
> > > > ---
> > > > 
> > > > Changes since version 2:
> > > > - Remove fbdev after drm unregister, not before.
> > > > 
> > > > Changes since version 1:
> > > > - Add tinydrm.rst
> > > > - Set tdev->fbdev_cma=NULL on unregister (lastclose is called after 
> > > > that).
> > > > - Remove some DRM_DEBUG*()
> > > > 
> > > >   Documentation/gpu/index.rst |   1 +
> > > >   Documentation/gpu/tinydrm.rst   |  21 ++
> > > >   drivers/gpu/drm/Kconfig |   2 +
> > > >   drivers/gpu/drm/Makefile|   1 +
> > > >   drivers/gpu/drm/tinydrm/Kconfig |   8 +
> > > >   drivers/gpu/drm/tinydrm/Makefile|   1 +
> > > >   drivers/gpu/drm/tinydrm/core/Makefile   |   3 +
> > > >   drivers/gpu/drm/tinydrm/core/tinydrm-core.c | 377 
> > > > 
> > > >   drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c | 234 +
> > > >   include/drm/tinydrm/tinydrm.h   | 115 +
> > > >   10 files changed, 763 insertions(+)
> > > >   create mode 100644 Documentation/gpu/tinydrm.rst
> > > >   create mode 100644 drivers/gpu/drm/tinydrm/Kconfig
> > > >   create mode 100644 drivers/gpu/drm/tinydrm/Makefile
> > > >   create mode 100644 drivers/gpu/drm/tinydrm/core/Makefile
> > > >   create mode 100644 drivers/gpu/drm/tinydrm/core/tinydrm-core.c
> > > >   create mode 100644 drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c
> > > >   create mode 100644 include/drm/tinydrm/tinydrm.h
> > > I realize this is totally subjective, but this feels somewhat too much
> > > of a separation. Given the helper nature of TinyDRM, I think it would be
> > > more appropriate to move the helpers themselves into drm_tiny.[ch] and
> > > then maybe add a subdirectory drivers/gpu/drm/tiny that contains all the
> > > drivers that use the helpers.
> > > 
> > > The separation above further shows in subsequent patches where helpers
> > > are added to tinydrm that aren't specific to TinyDRM. So this make the
> > > new helpers appear as more of a subsystem in DRM rather than a helper
> > > library. It also makes things somewhat inconsistent with existing
> > > infrastructure.
> > 
> > What I have done with tinydrm is to do as little as possible in the
> > core helper. The minimum required to pull together
> > drm_simple_display_pipe, cma helper + fbdev and framebuffer flushing.
> > 
> > Then I have added a set of functions that ease the writing of drivers
> > for RGB565 displays with optional backlight and regulator.
> > 
> > Added to that is a controller library that handles register access (will
> > use regmap for non-mipi) and framebuffer flushing (set the windowing
> > registers and write the buffer to the pixel register).
> > 
> > And at last there's the display driver that initializes the controller
> > to match a particular panel.
> > 
> > Maybe I should narrow tinydrm to _just_ support "RGB565 displays with
> > optional backlight and regulator". It looks like I split it up to much,
> > unless someone sees a need for the core of tinydrm elsewhere.
> > 
> > I think it's hard to avoid the subsystem smell here. These displays are
> > really simple, fbdev is more than enough to cover their needs.
> > But fbdev is closed.
> > 
> > I'm glad you pick on this, as getting the architecture right will save
> > me maintenance down the line. I did paint me into a corner with
> > staging/fbtft and I'm not keen on repeating that (to my defence it was
> > my first C code since university and I had 2 displays that had some
> > similarities which ended up as fbtft).
> 
> tbh I'm not sure either whether the tinydrm midlayer is good or not. But
> then it is what it says on the tin, i.e. tiny, so not much work to
> demidlayer if we notice a clear need for that change. I wouldn't worry
> about this for now, but good to keep in mind. In the end, good design is
> design that can be changed, because you'll only get it right until the
> next unforseen thing happens :-)

Agreed, there's nothing in this that couldn't easily be tweaked later
on. It's clearly drm-misc material, too, so even cross-tree dependencies
wouldn't be an issue.

Thierry


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


Re: [PATCH v4] drm/imx: ipuv3-plane: use drm_plane_helper_check_state, clipped coordinates

2017-02-07 Thread Philipp Zabel
On Tue, 2017-02-07 at 13:19 +0200, Ville Syrjälä wrote:
> On Tue, Feb 07, 2017 at 09:51:50AM +0100, Philipp Zabel wrote:
> > On Fri, 2017-02-03 at 15:20 +0200, Ville Syrjälä wrote:
> > > On Fri, Feb 03, 2017 at 10:31:39AM +0100, Philipp Zabel wrote:
> > > > Use drm_plane_helper_check_state to clip raw user coordinates to crtc
> > > > bounds. This checks for full plane coverage and scaling already, so
> > > > we can drop some custom checks. Use the clipped coordinates everywhere.
> > > > 
> > > > Suggested-by: Ville Syrjälä 
> > > > Signed-off-by: Philipp Zabel 
> > > > ---
> > > > Changes since v3:
> > > >  - Disallow target frames that start offscreen (state->crtc_x/y < 0), 
> > > > to avoid
> > > >confusing userspace: due to the necessary line start address 
> > > > alignment, we
> > > >could only support very specific negative values for crtc_x/y, 
> > > > depending on
> > > >the pixel format.
> > > 
> > > That's really no different to the user specifying non-zero src
> > > coordinates. So I'm wondering what's the point of special casing
> > > crtc coordinates this way because you'll need to check the src
> > > coordinates anyway.
> > 
> > User expectations.
> > 
> > For the src_x/y / src.x1/y1 source coordinates we have format specific
> > alignment requirements due to limitations of the DMA unit, there is no
> > way around it.
> > For the crtc_x/y plane coordinates there are no alignment requirements
> > at all, the partial plane can be positioned at any integer x/y position.
> > If we allow to simulate a partially offscreen plane at negative
> > positions by clipping and setting src.x1/y1, suddenly the crtc_x/y have
> > alignment requirements, but only if the values are negative.
> > I assume that would rather confuse any user space application that tries
> > to reason about which crtc_x/y values are valid, so it's probably better
> > to disallow it altogether.
> 
> I don't really agree. Userspace has to be prepared for anything
> to fail really. Whether it fails every time or sometimes is not that
> much different IMO. Given the simple return value userspace can't
> really draw any real conclusions about the reason for the failure.

So you say we should allow negative crtc_x, even if the valid range with
something on the screen ist [ - plane width ... crtc width ]
with the [- plane width ... 0] range in steps of 2, 4, or 8 pixels
depending on the pixel format and the [0 ... crtc width] range in steps
of 1 pixels?

> A related question is how strict we should really be. In the past we've
> been very lax in fudging the coordinates to make something appear on the
> screen. Probably I went a bit too far in the laxness actually, and with
> atomic we want to tighten things up a little. Just no one has managed to
> really answer how tight we should make things. Is it OK to round things
> to pixel boundaries perhaps?

In my opinion: yes.

> Maybe even macropixel boundaries?

Maybe even memory burst size / line start address boundaries?

regards
Philipp

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


Re: [PATCH v3 01/23] drm: add vblank hooks to struct drm_crtc_funcs

2017-02-07 Thread Thierry Reding
On Tue, Feb 07, 2017 at 11:52:06AM +0100, Daniel Vetter wrote:
> On Tue, Feb 07, 2017 at 11:38:08AM +0100, Andrzej Hajda wrote:
> > On 07.02.2017 10:16, Shawn Guo wrote:
> > > +static u32 __get_vblank_counter(struct drm_device *dev, unsigned int 
> > > pipe)
> > > +{
> > > + if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> > > + struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
> > > +
> > > + if (crtc->funcs->get_vblank_counter)
> > > + return crtc->funcs->get_vblank_counter(crtc);
> > > + }
> > > +
> > > + if (dev->driver->get_vblank_counter)
> > > + return dev->driver->get_vblank_counter(dev, pipe);
> > 
> > After converting all modeset drivers dev->driver->get_vblank_counter
> > could be called only for non-modeset drivers, ie 'else' can be put
> > before last if, the same for two other callbacks.
> 
> Shawn converted a lot of drivers, but not yet all of them. There's a lot
> more kms drivers, so probably will take some time until we can do this.
> But a good long-term goal indeed.

Probably should be added to that new TODO list thing... =)

Thierry


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


Re: [PATCH v3 0/7] drm: Add support for tiny LCD displays

2017-02-07 Thread Thierry Reding
On Tue, Jan 31, 2017 at 05:03:12PM +0100, Noralf Trønnes wrote:
> drm: Add support for tiny LCD displays
> 
> This is an attempt at providing a DRM version of drivers/staging/fbtft.
> 
> The tinydrm library provides a very simplified view of DRM in particular
> for tiny displays that has onboard video memory and is connected through
> a slow bus like SPI/I2C.
> 
> The main change this time is adding 'rotation' as a common display
> Device Tree property.
> 
> 
> Noralf.
> 
> Changes since version 2:
> - Remove fbdev after drm unregister, not before.
> - Added Documentation/devicetree/bindings/display/display.txt
> 
> Changes since version 1:
> - Add tinydrm.rst
> - Set tdev->fbdev_cma=NULL on unregister (lastclose is called after that).
> - Remove some DRM_DEBUG*()
> - Write-combined memory has uncached reads, so speed up by copying/buffering
>   one pixel line before conversion.
> 
> Changes since RFC v2:
> - Rebased on new core helpers
> - Don't use drm_panel
> - Flush when the framebuffer is changed on the plane
> - Add devm_tinydrm_init()
> - Fix PRIME support, set vaddr
> - Use atomic helpers in suspend/resume
> - Add a tinydrm_connector with one display mode
> - Set mode_config.preferred_depth and use it for fbdev
> - Subclass tinydrm_device in drivers instead of bloating the structure
> - The PiTFT display uses a MI0283QT panel, write driver for that instead.
> - Drop homegrown lcdreg module, it ended up as a collection of special
>   cases.
> - Add more documentation
> 
> Changes since RFC v1:
> - Add fb_deferred_io support to drm_fb_helper and drm_fb_cma_helper,
>   and use drm_fb_cma_helper instead.
> - Move display pipeline code to drm_simple_kms_helper.
> - Don't use (struct drm_driver *)->load().
> - Make tinydrm more like a library, exporting the internals.
> - Move the struct drm_driver definition from the tinydrm module to the
>   driver using a helper macro: TINYDRM_DRM_DRIVER.
> - Remove dirtyfb() async code.
> - Added support for partial display updates.
> 
> 
> Noralf Trønnes (7):
>   drm: Add DRM support for tiny LCD displays
>   drm/tinydrm: Add helper functions
>   drm/tinydrm: Add MIPI DBI support
>   of: Add vendor prefix for Multi-Inno
>   dt-bindings: display: Add common rotation property
>   dt-bindings: Add Multi-Inno MI0283QT binding
>   drm/tinydrm: Add support for Multi-Inno MI0283QT display
> 
>  .../devicetree/bindings/display/display.txt|4 +
>  .../bindings/display/multi-inno,mi0283qt.txt   |   27 +
>  .../devicetree/bindings/vendor-prefixes.txt|1 +
>  Documentation/gpu/index.rst|1 +
>  Documentation/gpu/tinydrm.rst  |   42 +
>  MAINTAINERS|6 +
>  drivers/gpu/drm/Kconfig|2 +
>  drivers/gpu/drm/Makefile   |1 +
>  drivers/gpu/drm/tinydrm/Kconfig|   19 +
>  drivers/gpu/drm/tinydrm/Makefile   |7 +
>  drivers/gpu/drm/tinydrm/core/Makefile  |3 +
>  drivers/gpu/drm/tinydrm/core/tinydrm-core.c|  377 
>  drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c |  462 +
>  drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c|  234 +
>  drivers/gpu/drm/tinydrm/mi0283qt.c |  279 ++
>  drivers/gpu/drm/tinydrm/mipi-dbi.c | 1005 
> 
>  include/drm/tinydrm/ili9341.h  |   54 ++
>  include/drm/tinydrm/mipi-dbi.h |  107 +++
>  include/drm/tinydrm/tinydrm-helpers.h  |  100 ++
>  include/drm/tinydrm/tinydrm.h  |  115 +++
>  20 files changed, 2846 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/display/display.txt
>  create mode 100644 
> Documentation/devicetree/bindings/display/multi-inno,mi0283qt.txt
>  create mode 100644 Documentation/gpu/tinydrm.rst
>  create mode 100644 drivers/gpu/drm/tinydrm/Kconfig
>  create mode 100644 drivers/gpu/drm/tinydrm/Makefile
>  create mode 100644 drivers/gpu/drm/tinydrm/core/Makefile
>  create mode 100644 drivers/gpu/drm/tinydrm/core/tinydrm-core.c
>  create mode 100644 drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
>  create mode 100644 drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c
>  create mode 100644 drivers/gpu/drm/tinydrm/mi0283qt.c
>  create mode 100644 drivers/gpu/drm/tinydrm/mipi-dbi.c
>  create mode 100644 include/drm/tinydrm/ili9341.h
>  create mode 100644 include/drm/tinydrm/mipi-dbi.h
>  create mode 100644 include/drm/tinydrm/tinydrm-helpers.h
>  create mode 100644 include/drm/tinydrm/tinydrm.h

The series:

Acked-by: Thierry Reding 


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


Re: [PATCH v2 3/7] drm/rockchip: gem: add mutex lock for drm mm

2017-02-07 Thread Thierry Reding
On Tue, Feb 07, 2017 at 04:35:38PM +0800, Mark Yao wrote:
> drm_mm_insert_node_generic and drm_mm_remove_node may access same
> resource with list ops, it's not threads safe, so protect this context
> with mutex lock.
> 
> Fix bug:
> [49451.856244] 
> ==
> [49451.856350] BUG: KASAN: wild-memory-access on address dead0108
> [49451.856379] Write of size 8 by task Binder:218_4/683
> [49451.856417] CPU: 2 PID: 683 Comm: Binder:218_4 Not tainted 4.4.36 #62
> [49451.856443] Hardware name: Rockchip RK3399 Excavator Board edp (Android) 
> (DT)
> [49451.856469] Call trace:
> [49451.856519] [] dump_backtrace+0x0/0x230
> [49451.856556] [] show_stack+0x14/0x1c
> [49451.856592] [] dump_stack+0xa0/0xc8
> [49451.856633] [] kasan_report+0x110/0x4dc
> [49451.856670] [] __asan_store8+0x24/0x7c
> [49451.856715] [] drm_mm_insert_node_generic+0x2dc/0x464
> [49451.856760] [] rockchip_gem_iommu_map+0x60/0x158
> [49451.856794] [] rockchip_gem_create_object+0x278/0x488
> [49451.856827] [] rockchip_gem_create_with_handle+0x24/0x10c
> [49451.856862] [] rockchip_gem_create_ioctl+0x3c/0x50
> [49451.856896] [] drm_ioctl+0x354/0x52c
> [49451.856939] [] do_vfs_ioctl+0x670/0x78c
> [49451.856976] [] SyS_ioctl+0x60/0x88
> [49451.857009] [] el0_svc_naked+0x24/0x28
> 
> Change-Id: I2ea377aa9ca24f70c59e2d86f2a6ad5ccb9c0891

This is meaningless in an upstream tree. Please remove.

Thierry


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


[Bug 97879] [amdgpu] Rocket League: long hangs (several seconds) when loading assets (models/textures/shaders?)

2017-02-07 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=97879

--- Comment #62 from lod  ---
the patch kind of works for me.
The Game loads much faster now, so does the options menu and I can play the
game without any lags, but know I only get 30-40fps (60+ before) at Radeon
6950(r600g)

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


Re: [PATCH v2 6/7] drm/rockchip: Respect page offset in IOMMU mmap

2017-02-07 Thread Thierry Reding
On Tue, Feb 07, 2017 at 04:39:09PM +0800, Mark Yao wrote:
> From: Ørjan Eide 
> 
> When mapping buffers through the PRIME DMA-buf mmap path we might be
> given an offset which has to be respected. The DRM GEM mmap path already
> takes care of zeroing out the fake mmap offset, so we can just make the
> IOMMU mmap implementation always respect the offset.
> 
> TEST=graphics_GLBench

This is useless in an upstream context, please remove.

Thierry


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


Re: [PATCH v2 7/7] drm/rockchip: Call drm_gem_object_release() to destroy GEM base

2017-02-07 Thread Thierry Reding
On Tue, Feb 07, 2017 at 04:39:33PM +0800, Mark Yao wrote:
> From: Tomasz Figa 
> 
> When converting the driver to use shmem-backed GEMs for IOMMU-enabled
> systems, we forgot to add calls to drm_gem_object_release(), which gave
> us a quite nice memory leak. This patch adds the missing calls.
> 
> Fixes: f11d5f0 ("FROMLIST: drm/rockchip: Do not use DMA mapping API if
> attached to IOMMU domain")
> 
> TEST=while true; do backlight_dbus_tool --set --percent=0 && sleep 8 &&
>  backlight_dbus_tool --set --percent=100 && sleep 3 ; done

Ugh... please clean up your commit messages before posting to the
mailing list. FROMLIST: patches clearly aren't what will be merged
upstream and the SHA1 isn't going to match, so nobody but you will
find this anywhere.

> Signed-off-by: Tomasz Figa 
> Signed-off-by: Mark Yao 
> Reviewed-on: https://chromium-review.googlesource.com/385456

This is also present in some of the patches you posted, but it's not
typical for these to be included in upstream patches because usually
by the time patches from some gerrit make it to upstream, upstream
can have diverged significantly enough for the review to no longer
apply.

Thierry


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


Re: [PATCH v2 0/7] drm/rockchip: switch to drm_mm for support arm64 iommu

2017-02-07 Thread Thierry Reding
On Tue, Feb 07, 2017 at 04:35:35PM +0800, Mark Yao wrote:
> Some iommu patches on the series[0] "iommu/rockchip: Fix bugs and
> enable on ARM64" already landed, So drm/rockchip related patches [1] and [2]
> ready to landed, this series just rebase them to lastest drm-next.
> 
> And fix some bugs for drm/rockchip drm_mm
> 
> [0]: http://www.spinics.net/lists/arm-kernel/msg513781.html
> [1]: https://patchwork.kernel.org/patch/9196367
> [2]: https://patchwork.kernel.org/patch/9196369
> 
> Changes in v2:
> Advices by Tomasz:
>   add some fixes patches from chromeos project.

I think those fixes should've been squashed into the patches that they
fix. It's very unusual to merge patches upstream that are know to have
been fixed already.

Thierry


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


[PATCH 2/2] drm: Cancel drm_fb_helper_resume_work on unload

2017-02-07 Thread Chris Wilson
We can not allow the worker to run after its fbdev, or even the module,
has been removed.

Fixes: cfe63423d9be ("drm/fb-helper: Add drm_fb_helper_set_suspend_unlocked()")
Signed-off-by: Chris Wilson 
Cc: Noralf Trønnes 
Cc: Daniel Vetter 
Cc: Jani Nikula 
Cc: Sean Paul 
Cc: dri-devel@lists.freedesktop.org
Cc:  # v4.9+
---
 drivers/gpu/drm/drm_fb_helper.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 2d0810c9f3dc..842c461b0b21 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -860,6 +860,7 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)
if (!drm_fbdev_emulation)
return;
 
+   cancel_work_sync(&fb_helper->resume_work);
cancel_work_sync(&fb_helper->dirty_work);
 
mutex_lock(&kernel_fb_helper_lock);
-- 
2.11.0

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


[PATCH 1/2] drm: Cancel drm_fb_helper_dirty_work on unload

2017-02-07 Thread Chris Wilson
We can not allow the worker to run after its fbdev, or even the module,
has been removed.

Fixes: eaa434defaca ("drm/fb-helper: Add fb_deferred_io support")
Signed-off-by: Chris Wilson 
Cc: Noralf Trønnes 
Cc: Daniel Vetter 
Cc: Jani Nikula 
Cc: Sean Paul 
Cc: dri-devel@lists.freedesktop.org
Cc:  # v4.7+
---
 drivers/gpu/drm/drm_fb_helper.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index ee7cbcd3cfeb..2d0810c9f3dc 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -860,6 +860,8 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)
if (!drm_fbdev_emulation)
return;
 
+   cancel_work_sync(&fb_helper->dirty_work);
+
mutex_lock(&kernel_fb_helper_lock);
if (!list_empty(&fb_helper->kernel_fb_list)) {
list_del(&fb_helper->kernel_fb_list);
-- 
2.11.0

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


Re: [PATCH v2 7/7] drm/rockchip: Call drm_gem_object_release() to destroy GEM base

2017-02-07 Thread Tomasz Figa
Hi Mark,

On Tue, Feb 7, 2017 at 9:37 PM, Thierry Reding  wrote:
> On Tue, Feb 07, 2017 at 04:39:33PM +0800, Mark Yao wrote:
>> From: Tomasz Figa 
>>
>> When converting the driver to use shmem-backed GEMs for IOMMU-enabled
>> systems, we forgot to add calls to drm_gem_object_release(), which gave
>> us a quite nice memory leak. This patch adds the missing calls.
>>
>> Fixes: f11d5f0 ("FROMLIST: drm/rockchip: Do not use DMA mapping API if
>> attached to IOMMU domain")

Since the patch being fixed is also a part of this series, the fix
could be just squashed directly (with sign-off lists merged). Same for
patch 6/7.

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


[patch] drm/radeon: remove some dead code

2017-02-07 Thread Dan Carpenter
If "rdev->bios" is NULL then we don't need to free it.

Signed-off-by: Dan Carpenter 

diff --git a/drivers/gpu/drm/radeon/radeon_bios.c 
b/drivers/gpu/drm/radeon/radeon_bios.c
index 00cfb5d2875f..04c0ed41374f 100644
--- a/drivers/gpu/drm/radeon/radeon_bios.c
+++ b/drivers/gpu/drm/radeon/radeon_bios.c
@@ -638,10 +638,8 @@ static bool radeon_acpi_vfct_bios(struct radeon_device 
*rdev)
 vhdr->ImageLength,
 GFP_KERNEL);
 
-   if (!rdev->bios) {
-   kfree(rdev->bios);
+   if (!rdev->bios)
return false;
-   }
return true;
}
}
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[patch] drm/amdgpu/virt: double free in amdgpu_map_static_csa()

2017-02-07 Thread Dan Carpenter
The amdgpu_vm_bo_rmv() function frees "bo_va" so we shouldn't free it
a second time.

Fixes: 4e4bbe7343a6 ("drm/amdgpu:add new file for SRIOV")
Signed-off-by: Dan Carpenter 

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index 3fd951c71d1b..dcfb7df3caf4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
@@ -83,7 +83,6 @@ int amdgpu_map_static_csa(struct amdgpu_device *adev, struct 
amdgpu_vm *vm)
DRM_ERROR("failed to do bo_map on static CSA, err=%d\n", r);
amdgpu_vm_bo_rmv(adev, bo_va);
ttm_eu_backoff_reservation(&ticket, &list);
-   kfree(bo_va);
return r;
}
 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[patch] drm/i915/gvt/kvmgt: remove some dead code

2017-02-07 Thread Dan Carpenter
If "caps.buf" is already NULL then it doesn't need to be freed or set to
NULL.

Signed-off-by: Dan Carpenter 

diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 3f656e3a6e5a..de2a55178a37 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -965,11 +965,8 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, 
unsigned int cmd,
sparse->areas[0].offset =
PAGE_ALIGN(vgpu_aperture_offset(vgpu));
sparse->areas[0].size = vgpu_aperture_sz(vgpu);
-   if (!caps.buf) {
-   kfree(caps.buf);
-   caps.buf = NULL;
+   if (!caps.buf)
caps.size = 0;
-   }
break;
 
case VFIO_PCI_BAR3_REGION_INDEX ... VFIO_PCI_BAR5_REGION_INDEX:
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 2/7] drm/tinydrm: Add helper functions

2017-02-07 Thread Daniel Vetter
On Tue, Feb 07, 2017 at 12:44:19PM +0100, Thierry Reding wrote:
> On Tue, Feb 07, 2017 at 12:21:28PM +0100, Daniel Vetter wrote:
> > On Tue, Feb 07, 2017 at 12:11:28PM +0100, Thierry Reding wrote:
> > > On Tue, Feb 07, 2017 at 08:28:16AM +1000, Dave Airlie wrote:
> > > > >
> > > > > I definitely don't want that we don't attempt this. But brought from 
> > > > > years
> > > > > of experience, I recommend to merge first (with pre-refactoring 
> > > > > already
> > > > > applied, but helpers only extracted, not yet at the right spot), and 
> > > > > then
> > > > > follow up with. Because on average, there's way too many trees with
> > > > > overloaded maintainers who maybe look at your patch once per kernel
> > > > > release cycle.
> > > > >
> > > > > If you know that backlight and spi isn't one of these areas (anything 
> > > > > that
> > > > > goes through takashi/sound is a similar good experience for us on the 
> > > > > i915
> > > > > side), then I guess we can try. But then Noralf has already written a 
> > > > > few
> > > > > months worth of really great refactoring, and I'm seriously starting 
> > > > > to
> > > > > feel guilty for volunteering him for all of this. Even though he 
> > > > > seems to
> > > > > be really good at it, and seems to not mind, it's getting a bit silly.
> > > > > Given that I'd say up to Noralf.
> > > > >
> > > > > In short, there's always a balance.
> > > > 
> > > > I don't think we can make a rule for this, it will always depend on the
> > > > code. There is always going to be stuff we put in drm that should go
> > > > elsewhere, and stuff that is elsewhere that drm should use.
> > > > 
> > > > I think however if we do add stuff like this, someone should keep track
> > > > of them and try to make them get further into the kernel.
> > > 
> > > Yes, I think having some sort of TODO in drivers/gpu/drm could help
> > > track things that we know should eventually be moved out. It could serve
> > > as a list of janitorial tasks for newcomers that want to get their hands
> > > dirty and tackle relatively trivial tasks.
> > 
> > We have this list already, it's at: http://www.x.org/wiki/DRMJanitors/
> > 
> > I guess I should highlight it more, maybe even add it to the docs? Eric
> > just asked about it last week too.
> 
> Yeah, I'm aware of that list. I think it's a little problematic that
> it's in a wiki and far removed from where the actual work is happening.
> I think we should just take that list and add it as a TODO in
> drivers/gpu/drm, or alternatively keep it as part of the GPU
> documentation. That way we can more easily mark things as done or add
> new stuff as work gets done.
> 
> For cases like this I think we could just add new items as they are
> pointed out during review. For things that are already merged we can
> add items separately. Once the refactoring is done, the patch series
> can contain a final patch that simply removes the items again. I think
> that has much less potential to become out-dated than a separate wiki
> page.
> 
> FWIW, I'll volunteer to move the list to git if we decide to go ahead
> with that.

One upside of a wiki is that it's quicker to edit, if someone spots a
drive-by refactoring they might not bother with the formal requirements of
a full patch. Otoh, having it in-source-tree definitely has benefits, too.

If you do the conversion I'd vote for Documentation/gpu/TODO.rst, and
linking it into our documentation (maybe even cross-link from
introduction.rst under a "Getting Started" heading, as reasonable ramp-up
tasks after some checkpatch patches). I think that would help highlight it
a bit. And of course the wiki page needs to be removed and replaced with a
link to the new canonical thing (probably best to point at the source-file
in drm-tip.git, that should be the most up-to-date).

Thanks, Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 97879] [amdgpu] Rocket League: long hangs (several seconds) when loading assets (models/textures/shaders?)

2017-02-07 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=97879

--- Comment #63 from Marek Olšák  ---
OK. Let's wait for more people to report the same findings.

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


Re: [PATCH v2 4/6] drm: scrambling support in drm layer

2017-02-07 Thread Jani Nikula
On Tue, 07 Feb 2017, Jose Abreu  wrote:
>> +bool drm_scdc_check_scrambling_status(struct i2c_adapter *adapter)
>> +{
>> +u8 status;
>> +int ret;
>> +
>> +ret = drm_scdc_readb(adapter, SCDC_SCRAMBLER_STATUS, &status);
>> +if (ret < 0) {
>> +DRM_ERROR("Failed to read scrambling status, error %d\n", ret);
>> +return false;
>> +}
>> +
>> +return status & SCDC_SCRAMBLING_STATUS;
>
> "return (status & SCDC_SCRAMBLING_STATUS) > 0;" ?

What's the point in that?

BR,
Jani.


-- 
Jani Nikula, Intel Open Source Technology Center
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/i915/debugfs: Add i915_hpd_storm_ctl

2017-02-07 Thread Jani Nikula
On Sat, 04 Feb 2017, Lyude  wrote:
> This adds a file in i915's debugfs directory that allows userspace to
> manually control HPD storm detection. This is mainly for hotplugging
> tests, where we might want to test HPD storm functionality or disable
> storm detection to speed up hotplugging tests without breaking anything.
>
> Signed-off-by: Lyude 
> Cc: Tomeu Vizoso 
> ---
>  drivers/gpu/drm/i915/i915_debugfs.c  | 102 
> ++-
>  drivers/gpu/drm/i915/i915_drv.h  |   2 +
>  drivers/gpu/drm/i915/i915_irq.c  |   2 +
>  drivers/gpu/drm/i915/intel_hotplug.c |   3 +-
>  4 files changed, 107 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
> b/drivers/gpu/drm/i915/i915_debugfs.c
> index 3ae0656..b985c7b 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -4624,6 +4624,105 @@ static int i915_forcewake_create(struct dentry *root, 
> struct drm_minor *minor)
>   return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops);
>  }
>  
> +static int i915_hpd_storm_ctl_show(struct seq_file *m, void *data)
> +{
> + struct drm_i915_private *dev_priv = m->private;
> +
> + if (delayed_work_pending(&dev_priv->hotplug.reenable_work))
> + seq_printf(m, "detected\n");
> + else if (dev_priv->hotplug.hpd_storm_detect_enabled)
> + seq_printf(m, "on\n");
> + else
> + seq_printf(m, "off\n");
> +
> + return 0;
> +}
> +
> +static void i915_hpd_storm_reset(struct drm_i915_private *dev_priv)
> +{
> + int i;
> +
> + spin_lock_irq(&dev_priv->irq_lock);
> + for (i = 0; i < ARRAY_SIZE(dev_priv->hotplug.stats); i++) {
> + dev_priv->hotplug.stats[i].count = 0;
> + dev_priv->hotplug.stats[i].last_jiffies = jiffies;
> + }
> + spin_unlock_irq(&dev_priv->irq_lock);
> +
> + if (delayed_work_pending(&dev_priv->hotplug.reenable_work))
> + flush_delayed_work(&dev_priv->hotplug.reenable_work);
> + else
> + schedule_delayed_work(&dev_priv->hotplug.reenable_work, 0);
> +}
> +
> +static ssize_t i915_hpd_storm_ctl_write(struct file *file,
> + const char __user *ubuf, size_t len,
> + loff_t *offp)
> +{
> + struct seq_file *m = file->private_data;
> + struct drm_i915_private *dev_priv = m->private;
> + struct i915_hotplug *hotplug = &dev_priv->hotplug;
> + char tmp[16];
> + enum {
> + HPD_STORM_DISABLE = 0,
> + HPD_STORM_ENABLE,
> + HPD_STORM_RESET
> + } action;
> +
> + if (len >= sizeof(tmp))
> + return -EINVAL;
> +
> + if (copy_from_user(tmp, ubuf, len))
> + return -EFAULT;
> +
> + tmp[len] = '\0';
> +
> + if (strcmp(tmp, "off") == 0 || strcmp(tmp, "off\n") == 0)
> + action = HPD_STORM_DISABLE;
> + else if (strcmp(tmp, "on") == 0 || strcmp(tmp, "on\n") == 0)
> + action = HPD_STORM_ENABLE;
> + else if (strcmp(tmp, "reset") == 0 || strcmp(tmp, "reset\n") == 0)
> + action = HPD_STORM_RESET;
> + else
> + return -EINVAL;
> +
> + switch (action) {
> + case HPD_STORM_DISABLE:
> + DRM_DEBUG_KMS("Disabling HPD storm detection\n");
> +
> + WRITE_ONCE(hotplug->hpd_storm_detect_enabled, false);
> + i915_hpd_storm_reset(dev_priv);
> + break;
> + case HPD_STORM_ENABLE:
> + DRM_DEBUG_KMS("Enabling HPD storm detection\n");
> +
> + i915_hpd_storm_reset(dev_priv);
> + hotplug->hpd_storm_detect_enabled = true;
> + break;
> + case HPD_STORM_RESET:
> + DRM_DEBUG_KMS("Resetting HPD storm stats\n");
> +
> + i915_hpd_storm_reset(dev_priv);
> + break;
> + }
> +
> + return len;
> +}
> +
> +static int i915_hpd_storm_ctl_open(struct inode *inode, struct file *file)
> +{
> + return single_open(file, i915_hpd_storm_ctl_show, inode->i_private);
> +}
> +
> +static const struct file_operations i915_hpd_storm_ctl_fops = {
> + .owner = THIS_MODULE,
> + .open = i915_hpd_storm_ctl_open,
> + .read = seq_read,
> + .llseek = seq_lseek,
> + .release = single_release,
> + .write = i915_hpd_storm_ctl_write
> +};
> +
>  static int i915_debugfs_create(struct dentry *root,
>  struct drm_minor *minor,
>  const char *name,
> @@ -4717,7 +4816,8 @@ static const struct i915_debugfs_files {
>   {"i915_dp_test_data", &i915_displayport_test_data_fops},
>   {"i915_dp_test_type", &i915_displayport_test_type_fops},
>   {"i915_dp_test_active", &i915_displayport_test_active_fops},
> - {"i915_guc_log_control", &i915_guc_log_control_fops}
> + {"i915_guc_log_control", 

Re: [PATCH v3 01/23] drm: add vblank hooks to struct drm_crtc_funcs

2017-02-07 Thread Laurent Pinchart
Hi Shawn,

Thank you for the patch.

On Tuesday 07 Feb 2017 17:16:13 Shawn Guo wrote:
> From: Shawn Guo 
> 
> The vblank is mostly CRTC specific and implemented as part of CRTC
> driver.  Let's keep the vblank hooks struct drm_driver for legacy
> drivers, and add corresponding hooks in struct drm_crtc_funcs.  These
> hooks take struct drm_crtc pointer as argument, and will be called by
> core vblank handling code for DRIVER_MODESET drivers.
> 
> The new hooks get plugged into core by adding wrapper functions for
> vblank handling code.  The .get_vblank_counter hook is effectively
> optional, as we provide drm_vblank_no_hw_counter() as the default
> fallback in the wrapper function.
> 
> Signed-off-by: Shawn Guo 

Reviewed-by: Laurent Pinchart 

> ---
>  drivers/gpu/drm/drm_irq.c | 53 ++--
>  include/drm/drm_crtc.h| 44 +++
>  include/drm/drm_drv.h |  9 
>  3 files changed, 100 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index e06cf11ebb4a..646b3e57b9ad 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -89,6 +89,21 @@ static void store_vblank(struct drm_device *dev, unsigned
> int pipe, write_sequnlock(&vblank->seqlock);
>  }
> 
> +static u32 __get_vblank_counter(struct drm_device *dev, unsigned int pipe)
> +{
> + if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> + struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
> +
> + if (crtc->funcs->get_vblank_counter)
> + return crtc->funcs->get_vblank_counter(crtc);
> + }
> +
> + if (dev->driver->get_vblank_counter)
> + return dev->driver->get_vblank_counter(dev, pipe);
> +
> + return drm_vblank_no_hw_counter(dev, pipe);
> +}
> +
>  /*
>   * Reset the stored timestamp for the current vblank count to correspond
>   * to the last vblank occurred.
> @@ -112,9 +127,9 @@ static void drm_reset_vblank_timestamp(struct drm_device
> *dev, unsigned int pipe * when drm_vblank_enable() applies the diff
>*/
>   do {
> - cur_vblank = dev->driver->get_vblank_counter(dev, pipe);
> + cur_vblank = __get_vblank_counter(dev, pipe);
>   rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, 0);
> - } while (cur_vblank != dev->driver->get_vblank_counter(dev, pipe) &&
> --count > 0); +   } while (cur_vblank != __get_vblank_counter(dev, pipe) 
&&
> --count > 0);
> 
>   /*
>* Only reinitialize corresponding vblank timestamp if high-precision
> query @@ -168,9 +183,9 @@ static void drm_update_vblank_count(struct
> drm_device *dev, unsigned int pipe, * corresponding vblank timestamp.
>*/
>   do {
> - cur_vblank = dev->driver->get_vblank_counter(dev, pipe);
> + cur_vblank = __get_vblank_counter(dev, pipe);
>   rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, flags);
> - } while (cur_vblank != dev->driver->get_vblank_counter(dev, pipe) &&
> --count > 0); +   } while (cur_vblank != __get_vblank_counter(dev, pipe) 
&&
> --count > 0);
> 
>   if (dev->max_vblank_count != 0) {
>   /* trust the hw counter when it's around */
> @@ -275,6 +290,20 @@ u32 drm_accurate_vblank_count(struct drm_crtc *crtc)
>  }
>  EXPORT_SYMBOL(drm_accurate_vblank_count);
> 
> +static void __disable_vblank(struct drm_device *dev, unsigned int pipe)
> +{
> + if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> + struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
> +
> + if (crtc->funcs->disable_vblank) {
> + crtc->funcs->disable_vblank(crtc);
> + return;
> + }
> + }
> +
> + dev->driver->disable_vblank(dev, pipe);
> +}
> +
>  /*
>   * Disable vblank irq's on crtc, make sure that last vblank count
>   * of hardware and corresponding consistent software vblank counter
> @@ -298,7 +327,7 @@ static void vblank_disable_and_save(struct drm_device
> *dev, unsigned int pipe) * hardware potentially runtime suspended.
>*/
>   if (vblank->enabled) {
> - dev->driver->disable_vblank(dev, pipe);
> + __disable_vblank(dev, pipe);
>   vblank->enabled = false;
>   }
> 
> @@ -1027,6 +1056,18 @@ void drm_crtc_send_vblank_event(struct drm_crtc
> *crtc, }
>  EXPORT_SYMBOL(drm_crtc_send_vblank_event);
> 
> +static int __enable_vblank(struct drm_device *dev, unsigned int pipe)
> +{
> + if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> + struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
> +
> + if (crtc->funcs->enable_vblank)
> + return crtc->funcs->enable_vblank(crtc);
> + }
> +
> + return dev->driver->enable_vblank(dev, pipe);
> +}
> +
>  /**
>   * drm_vblank_enable - enable the vblank interrupt on a CRTC
>   * @dev: DRM device
> @@ -1052,7 +1093

Re: [PATCH v3 16/23] drm: rcar-du: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Laurent Pinchart
Hi Shawn,

Thank you for the patch.

On Tuesday 07 Feb 2017 17:16:28 Shawn Guo wrote:
> From: Shawn Guo 
> 
> The vblank hooks in struct drm_driver are deprecated and only meant for
> legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
> in struct drm_crtc_funcs should be used instead.
> 
> Signed-off-by: Shawn Guo 
> Cc: Laurent Pinchart 

Reviewed-by: Laurent Pinchart 

> ---
>  drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 29 +++--
>  drivers/gpu/drm/rcar-du/rcar_du_crtc.h |  1 -
>  drivers/gpu/drm/rcar-du/rcar_du_drv.c  | 19 ---
>  3 files changed, 19 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c index a2ec6d8796a0..edcbe2e3625d
> 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> @@ -529,6 +529,23 @@ static void rcar_du_crtc_atomic_flush(struct drm_crtc
> *crtc, .atomic_flush = rcar_du_crtc_atomic_flush,
>  };
> 
> +static int rcar_du_crtc_enable_vblank(struct drm_crtc *crtc)
> +{
> + struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
> +
> + rcar_du_crtc_write(rcrtc, DSRCR, DSRCR_VBCL);
> + rcar_du_crtc_set(rcrtc, DIER, DIER_VBE);
> +
> + return 0;
> +}
> +
> +static void rcar_du_crtc_disable_vblank(struct drm_crtc *crtc)
> +{
> + struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
> +
> + rcar_du_crtc_clr(rcrtc, DIER, DIER_VBE);
> +}
> +
>  static const struct drm_crtc_funcs crtc_funcs = {
>   .reset = drm_atomic_helper_crtc_reset,
>   .destroy = drm_crtc_cleanup,
> @@ -536,6 +553,8 @@ static void rcar_du_crtc_atomic_flush(struct drm_crtc
> *crtc, .page_flip = drm_atomic_helper_page_flip,
>   .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
>   .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
> + .enable_vblank = rcar_du_crtc_enable_vblank,
> + .disable_vblank = rcar_du_crtc_disable_vblank,
>  };
> 
>  /*
> ---
> -- @@ -650,13 +669,3 @@ int rcar_du_crtc_create(struct rcar_du_group *rgrp,
> unsigned int index)
> 
>   return 0;
>  }
> -
> -void rcar_du_crtc_enable_vblank(struct rcar_du_crtc *rcrtc, bool enable)
> -{
> - if (enable) {
> - rcar_du_crtc_write(rcrtc, DSRCR, DSRCR_VBCL);
> - rcar_du_crtc_set(rcrtc, DIER, DIER_VBE);
> - } else {
> - rcar_du_crtc_clr(rcrtc, DIER, DIER_VBE);
> - }
> -}
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
> b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h index 6f08b7e7db06..a7194812997e
> 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
> @@ -66,7 +66,6 @@ enum rcar_du_output {
>  };
> 
>  int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int index);
> -void rcar_du_crtc_enable_vblank(struct rcar_du_crtc *rcrtc, bool enable);
>  void rcar_du_crtc_suspend(struct rcar_du_crtc *rcrtc);
>  void rcar_du_crtc_resume(struct rcar_du_crtc *rcrtc);
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index 094da3ef49d1..192346d4fb34
> 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> @@ -26,7 +26,6 @@
>  #include 
>  #include 
> 
> -#include "rcar_du_crtc.h"
>  #include "rcar_du_drv.h"
>  #include "rcar_du_kms.h"
>  #include "rcar_du_regs.h"
> @@ -227,22 +226,6 @@ static void rcar_du_lastclose(struct drm_device *dev)
>   drm_fbdev_cma_restore_mode(rcdu->fbdev);
>  }
> 
> -static int rcar_du_enable_vblank(struct drm_device *dev, unsigned int pipe)
> -{
> - struct rcar_du_device *rcdu = dev->dev_private;
> -
> - rcar_du_crtc_enable_vblank(&rcdu->crtcs[pipe], true);
> -
> - return 0;
> -}
> -
> -static void rcar_du_disable_vblank(struct drm_device *dev, unsigned int
> pipe) -{
> - struct rcar_du_device *rcdu = dev->dev_private;
> -
> - rcar_du_crtc_enable_vblank(&rcdu->crtcs[pipe], false);
> -}
> -
>  static const struct file_operations rcar_du_fops = {
>   .owner  = THIS_MODULE,
>   .open   = drm_open,
> @@ -259,8 +242,6 @@ static void rcar_du_disable_vblank(struct drm_device
> *dev, unsigned int pipe) .driver_features = DRIVER_GEM | DRIVER_MODESET 
|
> DRIVER_PRIME
> 
>   | DRIVER_ATOMIC,
> 
>   .lastclose  = rcar_du_lastclose,
> - .enable_vblank  = rcar_du_enable_vblank,
> - .disable_vblank = rcar_du_disable_vblank,
>   .gem_free_object_unlocked = drm_gem_cma_free_object,
>   .gem_vm_ops = &drm_gem_cma_vm_ops,
>   .prime_handle_to_fd = drm_gem_prime_handle_to_fd,

-- 
Regards,

Laurent Pinchart

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


Re: [PATCH v3 18/23] drm: shmobile: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Laurent Pinchart
Hi Shawn,

Thank you for the patch.

On Tuesday 07 Feb 2017 17:16:30 Shawn Guo wrote:
> From: Shawn Guo 
> 
> The vblank hooks in struct drm_driver are deprecated and only meant for
> legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
> in struct drm_crtc_funcs should be used instead.
> 
> As the result, shmob_drm_crtc_enable_vblank() becomes a static function,
> although it gets moved around a bit to save forward declaration.
> 
> Signed-off-by: Shawn Guo 
> Cc: Laurent Pinchart 

Reviewed-by: Laurent Pinchart 

> ---
>  drivers/gpu/drm/shmobile/shmob_drm_crtc.c | 51 +++-
>  drivers/gpu/drm/shmobile/shmob_drm_crtc.h |  1 -
>  drivers/gpu/drm/shmobile/shmob_drm_drv.c  | 19 
>  3 files changed, 35 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c
> b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c index
> 445476551695..8244890e6d53 100644
> --- a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c
> +++ b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c
> @@ -476,10 +476,45 @@ static int shmob_drm_crtc_page_flip(struct drm_crtc
> *crtc, return 0;
>  }
> 
> +static void shmob_drm_crtc_enable_vblank(struct shmob_drm_device *sdev,
> +  bool enable)
> +{
> + unsigned long flags;
> + u32 ldintr;
> +
> + /* Be careful not to acknowledge any pending interrupt. */
> + spin_lock_irqsave(&sdev->irq_lock, flags);
> + ldintr = lcdc_read(sdev, LDINTR) | LDINTR_STATUS_MASK;
> + if (enable)
> + ldintr |= LDINTR_VEE;
> + else
> + ldintr &= ~LDINTR_VEE;
> + lcdc_write(sdev, LDINTR, ldintr);
> + spin_unlock_irqrestore(&sdev->irq_lock, flags);
> +}
> +
> +static int shmob_drm_enable_vblank(struct drm_crtc *crtc)
> +{
> + struct shmob_drm_device *sdev = crtc->dev->dev_private;
> +
> + shmob_drm_crtc_enable_vblank(sdev, true);
> +
> + return 0;
> +}
> +
> +static void shmob_drm_disable_vblank(struct drm_crtc *crtc)
> +{
> + struct shmob_drm_device *sdev = crtc->dev->dev_private;
> +
> + shmob_drm_crtc_enable_vblank(sdev, false);
> +}
> +
>  static const struct drm_crtc_funcs crtc_funcs = {
>   .destroy = drm_crtc_cleanup,
>   .set_config = drm_crtc_helper_set_config,
>   .page_flip = shmob_drm_crtc_page_flip,
> + .enable_vblank = shmob_drm_enable_vblank,
> + .disable_vblank = shmob_drm_disable_vblank,
>  };
> 
>  int shmob_drm_crtc_create(struct shmob_drm_device *sdev)
> @@ -594,22 +629,6 @@ int shmob_drm_encoder_create(struct shmob_drm_device
> *sdev) return 0;
>  }
> 
> -void shmob_drm_crtc_enable_vblank(struct shmob_drm_device *sdev, bool
> enable)
> -{
> - unsigned long flags;
> - u32 ldintr;
> -
> - /* Be careful not to acknowledge any pending interrupt. */
> - spin_lock_irqsave(&sdev->irq_lock, flags);
> - ldintr = lcdc_read(sdev, LDINTR) | LDINTR_STATUS_MASK;
> - if (enable)
> - ldintr |= LDINTR_VEE;
> - else
> - ldintr &= ~LDINTR_VEE;
> - lcdc_write(sdev, LDINTR, ldintr);
> - spin_unlock_irqrestore(&sdev->irq_lock, flags);
> -}
> -
>  /* 
>   * Connector
>   */
> diff --git a/drivers/gpu/drm/shmobile/shmob_drm_crtc.h
> b/drivers/gpu/drm/shmobile/shmob_drm_crtc.h index
> 818b31549ddc..f152973df11c 100644
> --- a/drivers/gpu/drm/shmobile/shmob_drm_crtc.h
> +++ b/drivers/gpu/drm/shmobile/shmob_drm_crtc.h
> @@ -47,7 +47,6 @@ struct shmob_drm_connector {
>  };
> 
>  int shmob_drm_crtc_create(struct shmob_drm_device *sdev);
> -void shmob_drm_crtc_enable_vblank(struct shmob_drm_device *sdev, bool
> enable);
>  void shmob_drm_crtc_finish_page_flip(struct shmob_drm_crtc *scrtc);
>  void shmob_drm_crtc_suspend(struct shmob_drm_crtc *scrtc);
>  void shmob_drm_crtc_resume(struct shmob_drm_crtc *scrtc);
> diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> b/drivers/gpu/drm/shmobile/shmob_drm_drv.c index d6b0545d252d..34fefa0ba0f0
> 100644
> --- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> +++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> @@ -23,7 +23,6 @@
>  #include 
>  #include 
> 
> -#include "shmob_drm_crtc.h"
>  #include "shmob_drm_drv.h"
>  #include "shmob_drm_kms.h"
>  #include "shmob_drm_plane.h"
> @@ -222,22 +221,6 @@ static irqreturn_t shmob_drm_irq(int irq, void *arg)
>   return IRQ_HANDLED;
>  }
> 
> -static int shmob_drm_enable_vblank(struct drm_device *dev, unsigned int
> pipe) -{
> - struct shmob_drm_device *sdev = dev->dev_private;
> -
> - shmob_drm_crtc_enable_vblank(sdev, true);
> -
> - return 0;
> -}
> -
> -static void shmob_drm_disable_vblank(struct drm_device *dev, unsigned int
> pipe) -{
> - struct shmob_drm_device *sdev = dev->dev_private;
> -
> - shmob_drm_crtc_enable_vblank(sdev, false);
> -}
> -
>  static const struct file_operations shmob_drm_fops = {
>   .owner  = THIS_MODULE,
>   .open   = drm_open,
> @@ -256,8 +239,

Re: [PATCH 2/2] drm: Cancel drm_fb_helper_resume_work on unload

2017-02-07 Thread Daniel Vetter
On Tue, Feb 07, 2017 at 12:49:56PM +, Chris Wilson wrote:
> We can not allow the worker to run after its fbdev, or even the module,
> has been removed.
> 
> Fixes: cfe63423d9be ("drm/fb-helper: Add 
> drm_fb_helper_set_suspend_unlocked()")
> Signed-off-by: Chris Wilson 
> Cc: Noralf Trønnes 
> Cc: Daniel Vetter 
> Cc: Jani Nikula 
> Cc: Sean Paul 
> Cc: dri-devel@lists.freedesktop.org
> Cc:  # v4.9+

Both applied to drm-misc-next-fixes (since imo not that pressing that we
need to rush them in for 4.10 ...).
-Daniel

> ---
>  drivers/gpu/drm/drm_fb_helper.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 2d0810c9f3dc..842c461b0b21 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -860,6 +860,7 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)
>   if (!drm_fbdev_emulation)
>   return;
>  
> + cancel_work_sync(&fb_helper->resume_work);
>   cancel_work_sync(&fb_helper->dirty_work);
>  
>   mutex_lock(&kernel_fb_helper_lock);
> -- 
> 2.11.0
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/2] drm/fb-helper: Explain unload sequence a bit better

2017-02-07 Thread Daniel Vetter
While reviewing Chris' patches to properly cancel our async workers I
checked that this happens after the fbdev is already unregistered.
That's the case, but I found a small gap in our docs, fill that in.

Note that I don't explain what release_fbi does, because that function
will disappear in the next patch ...

Cc: Chris Wilson 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_fb_helper.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index c7fafa175755..5220a7b5e6ff 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -63,7 +63,8 @@ static DEFINE_MUTEX(kernel_fb_helper_lock);
  * drm_fb_helper_init(), drm_fb_helper_single_add_all_connectors() and
  * drm_fb_helper_initial_config(). Drivers with fancier requirements than the
  * default behaviour can override the third step with their own code.
- * Teardown is done with drm_fb_helper_fini().
+ * Teardown is done with drm_fb_helper_fini() after the fbdev device is
+ * unregisters using drm_fb_helper_unregister_fbi().
  *
  * At runtime drivers should restore the fbdev console by calling
  * drm_fb_helper_restore_fbdev_mode_unlocked() from their &drm_driver.lastclose
@@ -709,7 +710,7 @@ void drm_fb_helper_prepare(struct drm_device *dev, struct 
drm_fb_helper *helper,
 EXPORT_SYMBOL(drm_fb_helper_prepare);
 
 /**
- * drm_fb_helper_init - initialize a drm_fb_helper structure
+ * drm_fb_helper_init - initialize a &struct drm_fb_helper
  * @dev: drm device
  * @fb_helper: driver-allocated fbdev helper structure to initialize
  * @crtc_count: maximum number of crtcs to support in this fbdev emulation
@@ -823,7 +824,8 @@ EXPORT_SYMBOL(drm_fb_helper_alloc_fbi);
  * @fb_helper: driver-allocated fbdev helper
  *
  * A wrapper around unregister_framebuffer, to release the fb_info
- * framebuffer device
+ * framebuffer device. This must be called before releasing all resources for
+ * @fb_helper by calling drm_fb_helper_fini().
  */
 void drm_fb_helper_unregister_fbi(struct drm_fb_helper *fb_helper)
 {
@@ -855,6 +857,13 @@ void drm_fb_helper_release_fbi(struct drm_fb_helper 
*fb_helper)
 }
 EXPORT_SYMBOL(drm_fb_helper_release_fbi);
 
+/**
+ * drm_fb_helper_fini - finialize a &struct drm_fb_helper
+ * @fb_helper: driver-allocated fbdev helper
+ *
+ * This cleans up all remaining resources associated with @fb_helper. Must be
+ * called after drm_fb_helper_unlink_fbi() was called.
+ */
 void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)
 {
if (!drm_fbdev_emulation)
-- 
2.11.0

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


[PATCH 2/2] drm/fb-helper: Automatically clean up fb_info

2017-02-07 Thread Daniel Vetter
Noticed that everyone duplicates the same logic here and we could safe
a few lines per driver. Yay for lots of drivers to make such tiny
refactors worth-while!

Cc: Chris Wilson 
Cc: Sean Paul 
Cc: Noralf Trønnes 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c| 11 ---
 drivers/gpu/drm/armada/armada_fbdev.c |  2 --
 drivers/gpu/drm/ast/ast_fb.c  |  9 +++--
 drivers/gpu/drm/bochs/bochs_fbdev.c   |  5 +
 drivers/gpu/drm/cirrus/cirrus_fbdev.c |  1 -
 drivers/gpu/drm/drm_fb_cma_helper.c   |  3 +--
 drivers/gpu/drm/drm_fb_helper.c   | 16 ++--
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c |  2 --
 drivers/gpu/drm/gma500/framebuffer.c  |  9 +++--
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c |  3 +--
 drivers/gpu/drm/i915/intel_fbdev.c|  5 +
 drivers/gpu/drm/mgag200/mgag200_fb.c  |  5 +
 drivers/gpu/drm/msm/msm_fbdev.c   |  1 -
 drivers/gpu/drm/nouveau/nouveau_fbcon.c   |  1 -
 drivers/gpu/drm/omapdrm/omap_fbdev.c  |  4 
 drivers/gpu/drm/qxl/qxl_fb.c  |  5 +
 drivers/gpu/drm/radeon/radeon_fb.c| 11 ---
 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  9 +++--
 drivers/gpu/drm/tegra/fb.c|  5 +
 drivers/gpu/drm/udl/udl_fb.c  |  5 +
 drivers/gpu/drm/virtio/virtgpu_fb.c   |  5 +
 include/drm/drm_fb_helper.h   |  4 
 22 files changed, 40 insertions(+), 81 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
index 838943d0962e..f4a2f1f0a6ca 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
@@ -224,7 +224,7 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
info = drm_fb_helper_alloc_fbi(helper);
if (IS_ERR(info)) {
ret = PTR_ERR(info);
-   goto out_unref;
+   goto out;
}
 
info->par = rfbdev;
@@ -233,7 +233,7 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
ret = amdgpu_framebuffer_init(adev->ddev, &rfbdev->rfb, &mode_cmd, 
gobj);
if (ret) {
DRM_ERROR("failed to initialize framebuffer %d\n", ret);
-   goto out_destroy_fbi;
+   goto out;
}
 
fb = &rfbdev->rfb.base;
@@ -266,7 +266,7 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
 
if (info->screen_base == NULL) {
ret = -ENOSPC;
-   goto out_destroy_fbi;
+   goto out;
}
 
DRM_INFO("fb mappable at 0x%lX\n",  info->fix.smem_start);
@@ -278,9 +278,7 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
vga_switcheroo_client_fb_set(adev->ddev->pdev, info);
return 0;
 
-out_destroy_fbi:
-   drm_fb_helper_release_fbi(helper);
-out_unref:
+out:
if (abo) {
 
}
@@ -304,7 +302,6 @@ static int amdgpu_fbdev_destroy(struct drm_device *dev, 
struct amdgpu_fbdev *rfb
struct amdgpu_framebuffer *rfb = &rfbdev->rfb;
 
drm_fb_helper_unregister_fbi(&rfbdev->helper);
-   drm_fb_helper_release_fbi(&rfbdev->helper);
 
if (rfb->obj) {
amdgpufb_destroy_pinned_object(rfb->obj);
diff --git a/drivers/gpu/drm/armada/armada_fbdev.c 
b/drivers/gpu/drm/armada/armada_fbdev.c
index 78335100cbc3..7f184a52594e 100644
--- a/drivers/gpu/drm/armada/armada_fbdev.c
+++ b/drivers/gpu/drm/armada/armada_fbdev.c
@@ -157,7 +157,6 @@ int armada_fbdev_init(struct drm_device *dev)
 
return 0;
  err_fb_setup:
-   drm_fb_helper_release_fbi(fbh);
drm_fb_helper_fini(fbh);
  err_fb_helper:
priv->fbdev = NULL;
@@ -179,7 +178,6 @@ void armada_fbdev_fini(struct drm_device *dev)
 
if (fbh) {
drm_fb_helper_unregister_fbi(fbh);
-   drm_fb_helper_release_fbi(fbh);
 
drm_fb_helper_fini(fbh);
 
diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c
index b085140fae95..f8421d23946a 100644
--- a/drivers/gpu/drm/ast/ast_fb.c
+++ b/drivers/gpu/drm/ast/ast_fb.c
@@ -215,13 +215,13 @@ static int astfb_create(struct drm_fb_helper *helper,
info = drm_fb_helper_alloc_fbi(helper);
if (IS_ERR(info)) {
ret = PTR_ERR(info);
-   goto err_free_vram;
+   goto out;
}
info->par = afbdev;
 
ret = ast_framebuffer_init(dev, &afbdev->afb, &mode_cmd, gobj);
if (ret)
-   goto err_release_fbi;
+   goto out;
 
afbdev->sysram = sysram;
afbdev->size = size;
@@ -250,9 +250,7 @@ static int astfb_create(struct drm_fb_helper *helper,
 
return 0;
 
-err_release_fbi:
-   drm_fb_helper_release_fbi(helper);
-err_free_vram:
+

Re: [PATCH 1/2] drm/fb-helper: Explain unload sequence a bit better

2017-02-07 Thread Chris Wilson
On Tue, Feb 07, 2017 at 03:10:49PM +0100, Daniel Vetter wrote:
> While reviewing Chris' patches to properly cancel our async workers I
> checked that this happens after the fbdev is already unregistered.
> That's the case, but I found a small gap in our docs, fill that in.
> 
> Note that I don't explain what release_fbi does, because that function
> will disappear in the next patch ...
> 
> Cc: Chris Wilson 
> Signed-off-by: Daniel Vetter 
Reviewed-by: Chris Wilson 
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/fb-helper: Automatically clean up fb_info

2017-02-07 Thread Daniel Vetter
Noticed that everyone duplicates the same logic here and we could safe
a few lines per driver. Yay for lots of drivers to make such tiny
refactors worth-while!

v2: Forgot to git add everything :(

Cc: Chris Wilson 
Cc: Sean Paul 
Cc: Noralf Trønnes 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c| 11 ---
 drivers/gpu/drm/armada/armada_fbdev.c |  2 --
 drivers/gpu/drm/ast/ast_fb.c  |  9 +++--
 drivers/gpu/drm/bochs/bochs_fbdev.c   |  5 +
 drivers/gpu/drm/cirrus/cirrus_fbdev.c |  1 -
 drivers/gpu/drm/drm_fb_cma_helper.c   |  3 +--
 drivers/gpu/drm/drm_fb_helper.c   | 16 ++--
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c |  2 --
 drivers/gpu/drm/gma500/framebuffer.c  |  9 +++--
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c |  2 --
 drivers/gpu/drm/i915/intel_fbdev.c|  5 +
 drivers/gpu/drm/mgag200/mgag200_fb.c  |  5 +
 drivers/gpu/drm/msm/msm_fbdev.c   |  1 -
 drivers/gpu/drm/nouveau/nouveau_fbcon.c   |  1 -
 drivers/gpu/drm/omapdrm/omap_fbdev.c  |  4 
 drivers/gpu/drm/qxl/qxl_fb.c  |  5 +
 drivers/gpu/drm/radeon/radeon_fb.c| 11 ---
 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  9 +++--
 drivers/gpu/drm/tegra/fb.c|  5 +
 drivers/gpu/drm/udl/udl_fb.c  |  5 +
 drivers/gpu/drm/virtio/virtgpu_fb.c   |  5 +
 include/drm/drm_fb_helper.h   |  4 
 22 files changed, 39 insertions(+), 81 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
index 838943d0962e..f4a2f1f0a6ca 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
@@ -224,7 +224,7 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
info = drm_fb_helper_alloc_fbi(helper);
if (IS_ERR(info)) {
ret = PTR_ERR(info);
-   goto out_unref;
+   goto out;
}
 
info->par = rfbdev;
@@ -233,7 +233,7 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
ret = amdgpu_framebuffer_init(adev->ddev, &rfbdev->rfb, &mode_cmd, 
gobj);
if (ret) {
DRM_ERROR("failed to initialize framebuffer %d\n", ret);
-   goto out_destroy_fbi;
+   goto out;
}
 
fb = &rfbdev->rfb.base;
@@ -266,7 +266,7 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
 
if (info->screen_base == NULL) {
ret = -ENOSPC;
-   goto out_destroy_fbi;
+   goto out;
}
 
DRM_INFO("fb mappable at 0x%lX\n",  info->fix.smem_start);
@@ -278,9 +278,7 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
vga_switcheroo_client_fb_set(adev->ddev->pdev, info);
return 0;
 
-out_destroy_fbi:
-   drm_fb_helper_release_fbi(helper);
-out_unref:
+out:
if (abo) {
 
}
@@ -304,7 +302,6 @@ static int amdgpu_fbdev_destroy(struct drm_device *dev, 
struct amdgpu_fbdev *rfb
struct amdgpu_framebuffer *rfb = &rfbdev->rfb;
 
drm_fb_helper_unregister_fbi(&rfbdev->helper);
-   drm_fb_helper_release_fbi(&rfbdev->helper);
 
if (rfb->obj) {
amdgpufb_destroy_pinned_object(rfb->obj);
diff --git a/drivers/gpu/drm/armada/armada_fbdev.c 
b/drivers/gpu/drm/armada/armada_fbdev.c
index 78335100cbc3..7f184a52594e 100644
--- a/drivers/gpu/drm/armada/armada_fbdev.c
+++ b/drivers/gpu/drm/armada/armada_fbdev.c
@@ -157,7 +157,6 @@ int armada_fbdev_init(struct drm_device *dev)
 
return 0;
  err_fb_setup:
-   drm_fb_helper_release_fbi(fbh);
drm_fb_helper_fini(fbh);
  err_fb_helper:
priv->fbdev = NULL;
@@ -179,7 +178,6 @@ void armada_fbdev_fini(struct drm_device *dev)
 
if (fbh) {
drm_fb_helper_unregister_fbi(fbh);
-   drm_fb_helper_release_fbi(fbh);
 
drm_fb_helper_fini(fbh);
 
diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c
index b085140fae95..f8421d23946a 100644
--- a/drivers/gpu/drm/ast/ast_fb.c
+++ b/drivers/gpu/drm/ast/ast_fb.c
@@ -215,13 +215,13 @@ static int astfb_create(struct drm_fb_helper *helper,
info = drm_fb_helper_alloc_fbi(helper);
if (IS_ERR(info)) {
ret = PTR_ERR(info);
-   goto err_free_vram;
+   goto out;
}
info->par = afbdev;
 
ret = ast_framebuffer_init(dev, &afbdev->afb, &mode_cmd, gobj);
if (ret)
-   goto err_release_fbi;
+   goto out;
 
afbdev->sysram = sysram;
afbdev->size = size;
@@ -250,9 +250,7 @@ static int astfb_create(struct drm_fb_helper *helper,
 
return 0;
 
-err_release_fbi:
-   drm_fb_helper_re

Re: [Intel-gfx] [patch] drm/i915/gvt/kvmgt: remove some dead code

2017-02-07 Thread Joonas Lahtinen
On ti, 2017-02-07 at 16:16 +0300, Dan Carpenter wrote:
> If "caps.buf" is already NULL then it doesn't need to be freed or set to
> NULL.
> 
> Signed-off-by: Dan Carpenter 



> @@ -965,11 +965,8 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, 
> unsigned int cmd,
>   sparse->areas[0].offset =
>   PAGE_ALIGN(vgpu_aperture_offset(vgpu));
>   sparse->areas[0].size = vgpu_aperture_sz(vgpu);
> - if (!caps.buf) {

Looking at the code around, the right thing would be to just remove the
negation? This currently seems like a memory leak.

> - kfree(caps.buf);
> - caps.buf = NULL;
> + if (!caps.buf)
>   caps.size = 0;
> - }

And quickly looking, the caps is pre-initialized but unused at this
point, so the whole if could just be removed, right?

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 2/2] drm/fb-helper: Automatically clean up fb_info

2017-02-07 Thread Chris Wilson
On Tue, Feb 07, 2017 at 03:10:50PM +0100, Daniel Vetter wrote:
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 5220a7b5e6ff..074ab22a7cf3 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -781,7 +781,9 @@ EXPORT_SYMBOL(drm_fb_helper_init);
>   * @fb_helper: driver-allocated fbdev helper
>   *
>   * A helper to alloc fb_info and the members cmap and apertures. Called
> - * by the driver within the fb_probe fb_helper callback function.
> + * by the driver within the fb_probe fb_helper callback function. Drivers do 
> not
> + * need to release the allocated fb_info structure themselves, this is
> + * automatically done when calling drm_fb_helper_fini().
>   *
>   * RETURNS:
>   * fb_info pointer if things went okay, pointer containing error code
> @@ -866,9 +868,19 @@ EXPORT_SYMBOL(drm_fb_helper_release_fbi);

I was expecting to see drm_fb_helper_release_fbi() removed.

>   */
>  void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)
>  {
> - if (!drm_fbdev_emulation)
> + struct fb_info *info;
> +
> + if (!drm_fbdev_emulation || !fb_helper)
>   return;
>  
> + info = fb_helper->fbdev;
> + if (info) {
> + if (info->cmap.len)
> + fb_dealloc_cmap(&info->cmap);
> + framebuffer_release(info);
> + }
> + fb_helper->fbdev = NULL;
> +
>   mutex_lock(&kernel_fb_helper_lock);
>   if (!list_empty(&fb_helper->kernel_fb_list)) {
>   list_del(&fb_helper->kernel_fb_list);
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c 
> b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c

-- 
Chris Wilson, Intel Open Source Technology Centre
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [Intel-gfx] [PATCH] drm/fb-helper: Automatically clean up fb_info

2017-02-07 Thread Emil Velikov
On 7 February 2017 at 14:29, Daniel Vetter  wrote:
> Noticed that everyone duplicates the same logic here and we could safe
> a few lines per driver. Yay for lots of drivers to make such tiny
> refactors worth-while!
>
> v2: Forgot to git add everything :(
>
Hmm afaict this patch inlines drm_fb_helper_release_fbi within
drm_fb_helper_fini yet it is missing:
 - removal of the (now unused ?) drm_fb_helper_release_fbi
 - the leaks which now occur in the error paths.

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


[PATCH] drm/omapdrm: dispc: Refuse x-decimation above 4 for all but 8-bit formats

2017-02-07 Thread Jyri Sarha
Let's disable all scaling that requires horizontal decimation with
higher factor than 4, until we have better estimates of what we can
and can not do. However, 1 byte per pixel color format appear to work
Ok with all decimation factors.

When decimating horizontally by more that 4 the dss is not able to
fetch the data in burst mode. When this happens it is hard to tell if
there enough bandwidth. Despite what theory says this appears to be
true also for 16-bit color formats.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/omapdrm/dss/dispc.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 5554b72..61daef6 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -2506,6 +2506,25 @@ static int dispc_ovl_calc_scaling_44xx(unsigned long 
pclk, unsigned long lclk,
return -EINVAL;
}
 
+   if (*decim_x > 4 && color_mode_to_bpp(color_mode) > 8) {
+   /*
+ Let's disable all scaling that requires horizontal
+ decimation with higher factor than 4, until we have
+ better estimates of what we can and can not
+ do. However, 1 byte per pixel color format appear to
+ work Ok with all decimation factors.
+
+ When decimating horizontally by more that 4 the dss
+ is not able to fetch the data in burst mode. When
+ this happens it is hard to tell if there enough
+ bandwidth. Despite what theory says this appears to
+ be true also for 16-bit color formats.
+   */
+   DSSERR("Not enough bandwidth (x-decimation factor %d > 4)",
+   *decim_x);
+   return -EINVAL;
+   }
+
*core_clk = dispc.feat->calc_core_clk(pclk, in_width, in_height,
out_width, out_height, mem_to_mem);
return 0;
-- 
1.9.1

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


Re: [Intel-gfx] [patch] drm/i915/gvt/kvmgt: remove some dead code

2017-02-07 Thread Dan Carpenter
On Tue, Feb 07, 2017 at 04:34:57PM +0200, Joonas Lahtinen wrote:
> On ti, 2017-02-07 at 16:16 +0300, Dan Carpenter wrote:
> > If "caps.buf" is already NULL then it doesn't need to be freed or set to
> > NULL.
> > 
> > Signed-off-by: Dan Carpenter 
> 
> 
> 
> > @@ -965,11 +965,8 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, 
> > unsigned int cmd,
> >     sparse->areas[0].offset =
> >     PAGE_ALIGN(vgpu_aperture_offset(vgpu));
> >     sparse->areas[0].size = vgpu_aperture_sz(vgpu);
> > -   if (!caps.buf) {
> 
> Looking at the code around, the right thing would be to just remove the
> negation? This currently seems like a memory leak.
> 
> > -   kfree(caps.buf);
> > -   caps.buf = NULL;
> > +   if (!caps.buf)
> >     caps.size = 0;
> > -   }
> 
> And quickly looking, the caps is pre-initialized but unused at this
> point, so the whole if could just be removed, right?

Hm...  Duh.  You're right.  Let me resend.

regards,
dan carpenter

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


[Bug 99136] Blood Effects Total War: Warhammer

2017-02-07 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99136

--- Comment #21 from siyia  ---
(In reply to Gregor Münch from comment #20)
> (In reply to Samuel Pitoiset from comment #19)
> > Created attachment 129356 [details]
> > no blood effects option (v 1.5)
> 
> Maybe you need the Blood DLC? (just wild guess)
> http://store.steampowered.com/app/404011/

If you have the blood dlc,can you reproduce the bug Gregor Münch?

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


Re: [Intel-gfx] [PATCH] drm/fb-helper: Automatically clean up fb_info

2017-02-07 Thread Chris Wilson
On Tue, Feb 07, 2017 at 02:38:16PM +, Emil Velikov wrote:
> On 7 February 2017 at 14:29, Daniel Vetter  wrote:
> > Noticed that everyone duplicates the same logic here and we could safe
> > a few lines per driver. Yay for lots of drivers to make such tiny
> > refactors worth-while!
> >
> > v2: Forgot to git add everything :(
> >
> Hmm afaict this patch inlines drm_fb_helper_release_fbi within
> drm_fb_helper_fini yet it is missing:
>  - removal of the (now unused ?) drm_fb_helper_release_fbi
>  - the leaks which now occur in the error paths.

The error cleanup is a bit unobvious. The fbi is allocated during the
create/initial_fb callback, which is after a successful
framebuffer_init. The caller must be prepared to do a framebuffer_fini
(and so release_fbi will be handled if required) on failure or success.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


  1   2   >