Linux-ARM-Kernel Archive on lore.kernel.org
 help / Atom feed
* [PATCH 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_insert_range
@ 2019-01-11 15:09 Souptick Joarder
  2019-01-28  6:31 ` Souptick Joarder
  0 siblings, 1 reply; 6+ messages in thread
From: Souptick Joarder @ 2019-01-11 15:09 UTC (permalink / raw)
  To: akpm, willy, mhocko, hjc, heiko, airlied, linux, robin.murphy
  Cc: linux-mm, dri-devel, linux-kernel, linux-arm-kernel, linux-rockchip

Convert to use vm_insert_range() to map range of kernel
memory to user vma.

Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
---
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index a8db758..c9e207f 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -221,26 +221,13 @@ static int rockchip_drm_gem_object_mmap_iommu(struct drm_gem_object *obj,
 					      struct vm_area_struct *vma)
 {
 	struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);
-	unsigned int i, count = obj->size >> PAGE_SHIFT;
+	unsigned int count = obj->size >> PAGE_SHIFT;
 	unsigned long user_count = vma_pages(vma);
-	unsigned long uaddr = vma->vm_start;
-	unsigned long offset = vma->vm_pgoff;
-	unsigned long end = user_count + offset;
-	int ret;
 
 	if (user_count == 0)
 		return -ENXIO;
-	if (end > count)
-		return -ENXIO;
 
-	for (i = offset; i < end; i++) {
-		ret = vm_insert_page(vma, uaddr, rk_obj->pages[i]);
-		if (ret)
-			return ret;
-		uaddr += PAGE_SIZE;
-	}
-
-	return 0;
+	return vm_insert_range(vma, rk_obj->pages, count);
 }
 
 static int rockchip_drm_gem_object_mmap_dma(struct drm_gem_object *obj,
-- 
1.9.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_insert_range
  2019-01-11 15:09 [PATCH 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_insert_range Souptick Joarder
@ 2019-01-28  6:31 ` Souptick Joarder
  0 siblings, 0 replies; 6+ messages in thread
From: Souptick Joarder @ 2019-01-28  6:31 UTC (permalink / raw)
  To: Andrew Morton, Matthew Wilcox, Michal Hocko, hjc, Heiko Stuebner,
	airlied, Russell King - ARM Linux, robin.murphy
  Cc: Linux-MM, dri-devel, linux-kernel, linux-arm-kernel, linux-rockchip

On Fri, Jan 11, 2019 at 8:35 PM Souptick Joarder <jrdr.linux@gmail.com> wrote:
>
> Convert to use vm_insert_range() to map range of kernel
> memory to user vma.
>
> Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>

Any comment on this patch ?

> ---
>  drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 17 ++---------------
>  1 file changed, 2 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> index a8db758..c9e207f 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> @@ -221,26 +221,13 @@ static int rockchip_drm_gem_object_mmap_iommu(struct drm_gem_object *obj,
>                                               struct vm_area_struct *vma)
>  {
>         struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);
> -       unsigned int i, count = obj->size >> PAGE_SHIFT;
> +       unsigned int count = obj->size >> PAGE_SHIFT;
>         unsigned long user_count = vma_pages(vma);
> -       unsigned long uaddr = vma->vm_start;
> -       unsigned long offset = vma->vm_pgoff;
> -       unsigned long end = user_count + offset;
> -       int ret;
>
>         if (user_count == 0)
>                 return -ENXIO;
> -       if (end > count)
> -               return -ENXIO;
>
> -       for (i = offset; i < end; i++) {
> -               ret = vm_insert_page(vma, uaddr, rk_obj->pages[i]);
> -               if (ret)
> -                       return ret;
> -               uaddr += PAGE_SIZE;
> -       }
> -
> -       return 0;
> +       return vm_insert_range(vma, rk_obj->pages, count);
>  }
>
>  static int rockchip_drm_gem_object_mmap_dma(struct drm_gem_object *obj,
> --
> 1.9.1
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_insert_range
  2018-11-28 15:19   ` heiko
@ 2018-11-29  6:04     ` jrdr.linux
  0 siblings, 0 replies; 6+ messages in thread
From: jrdr.linux @ 2018-11-29  6:04 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Nov 28, 2018 at 8:49 PM Heiko St?bner <heiko@sntech.de> wrote:
>
> Hi Souptick,
>
> Am Montag, 26. November 2018, 06:36:42 CET schrieb Souptick Joarder:
> > On Thu, Nov 15, 2018 at 9:14 PM Souptick Joarder <jrdr.linux@gmail.com>
> wrote:
> > > Convert to use vm_insert_range() to map range of kernel
> > > memory to user vma.
> > >
> > > Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
> >
> > Any feedback for this patch ?
>
> sorry, took a bit longer to find time for a test-run.
>
> Except the missing EXPORT_SYMBOL already pointed out in patch1,
> my displays are still working on modern (with iommu) and the older
> (without iommu) Rockchip socs, so
>
> On rk3188, rk3288, rk3328 and rk3399
> Tested-by: Heiko Stuebner <heiko@sntech.de>
> and in general
> Acked-by: Heiko Stuebner <heiko@sntech.de>

Thanks Heiko.
>
>
> Heiko
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_insert_range
  2018-11-26  5:36 ` jrdr.linux
@ 2018-11-28 15:19   ` heiko
  2018-11-29  6:04     ` jrdr.linux
  0 siblings, 1 reply; 6+ messages in thread
From: heiko @ 2018-11-28 15:19 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Souptick,

Am Montag, 26. November 2018, 06:36:42 CET schrieb Souptick Joarder:
> On Thu, Nov 15, 2018 at 9:14 PM Souptick Joarder <jrdr.linux@gmail.com> 
wrote:
> > Convert to use vm_insert_range() to map range of kernel
> > memory to user vma.
> > 
> > Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
> 
> Any feedback for this patch ?

sorry, took a bit longer to find time for a test-run.

Except the missing EXPORT_SYMBOL already pointed out in patch1,
my displays are still working on modern (with iommu) and the older
(without iommu) Rockchip socs, so

On rk3188, rk3288, rk3328 and rk3399
Tested-by: Heiko Stuebner <heiko@sntech.de>
and in general
Acked-by: Heiko Stuebner <heiko@sntech.de>


Heiko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_insert_range
  2018-11-15 15:48 jrdr.linux
@ 2018-11-26  5:36 ` jrdr.linux
  2018-11-28 15:19   ` heiko
  0 siblings, 1 reply; 6+ messages in thread
From: jrdr.linux @ 2018-11-26  5:36 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Heiko,

On Thu, Nov 15, 2018 at 9:14 PM Souptick Joarder <jrdr.linux@gmail.com> wrote:
>
> Convert to use vm_insert_range() to map range of kernel
> memory to user vma.
>
> Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>

Any feedback for this patch ?

> ---
>  drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 20 ++------------------
>  1 file changed, 2 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> index a8db758..2cb83bb 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> @@ -221,26 +221,10 @@ static int rockchip_drm_gem_object_mmap_iommu(struct drm_gem_object *obj,
>                                               struct vm_area_struct *vma)
>  {
>         struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);
> -       unsigned int i, count = obj->size >> PAGE_SHIFT;
>         unsigned long user_count = vma_pages(vma);
> -       unsigned long uaddr = vma->vm_start;
> -       unsigned long offset = vma->vm_pgoff;
> -       unsigned long end = user_count + offset;
> -       int ret;
> -
> -       if (user_count == 0)
> -               return -ENXIO;
> -       if (end > count)
> -               return -ENXIO;
>
> -       for (i = offset; i < end; i++) {
> -               ret = vm_insert_page(vma, uaddr, rk_obj->pages[i]);
> -               if (ret)
> -                       return ret;
> -               uaddr += PAGE_SIZE;
> -       }
> -
> -       return 0;
> +       return vm_insert_range(vma, vma->vm_start, rk_obj->pages,
> +                               user_count);
>  }
>
>  static int rockchip_drm_gem_object_mmap_dma(struct drm_gem_object *obj,
> --
> 1.9.1
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_insert_range
@ 2018-11-15 15:48 jrdr.linux
  2018-11-26  5:36 ` jrdr.linux
  0 siblings, 1 reply; 6+ messages in thread
From: jrdr.linux @ 2018-11-15 15:48 UTC (permalink / raw)
  To: linux-arm-kernel

Convert to use vm_insert_range() to map range of kernel
memory to user vma.

Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
---
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 20 ++------------------
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index a8db758..2cb83bb 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -221,26 +221,10 @@ static int rockchip_drm_gem_object_mmap_iommu(struct drm_gem_object *obj,
 					      struct vm_area_struct *vma)
 {
 	struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);
-	unsigned int i, count = obj->size >> PAGE_SHIFT;
 	unsigned long user_count = vma_pages(vma);
-	unsigned long uaddr = vma->vm_start;
-	unsigned long offset = vma->vm_pgoff;
-	unsigned long end = user_count + offset;
-	int ret;
-
-	if (user_count == 0)
-		return -ENXIO;
-	if (end > count)
-		return -ENXIO;
 
-	for (i = offset; i < end; i++) {
-		ret = vm_insert_page(vma, uaddr, rk_obj->pages[i]);
-		if (ret)
-			return ret;
-		uaddr += PAGE_SIZE;
-	}
-
-	return 0;
+	return vm_insert_range(vma, vma->vm_start, rk_obj->pages,
+				user_count);
 }
 
 static int rockchip_drm_gem_object_mmap_dma(struct drm_gem_object *obj,
-- 
1.9.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-11 15:09 [PATCH 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_insert_range Souptick Joarder
2019-01-28  6:31 ` Souptick Joarder
  -- strict thread matches above, loose matches on Subject: below --
2018-11-15 15:48 jrdr.linux
2018-11-26  5:36 ` jrdr.linux
2018-11-28 15:19   ` heiko
2018-11-29  6:04     ` jrdr.linux

Linux-ARM-Kernel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/1 linux-arm-kernel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \
		linux-arm-kernel@lists.infradead.org infradead-linux-arm-kernel@archiver.kernel.org
	public-inbox-index linux-arm-kernel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox