All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm: rockchip: Don't pass DRM fake offset to dma-api
@ 2015-04-16 14:41 ` Ørjan Eide
  0 siblings, 0 replies; 22+ messages in thread
From: Ørjan Eide @ 2015-04-16 14:41 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, dri-devel, linux-rockchip; +Cc: djkurtz

Set vm_pgoff to 0 after using it to look up the GEM node, before passing
it on rockchip_gem_mmap_buf() where the offset must be from the start of
the buffer.

Passing in the fake offset currently works because the
dma_mmap_attrs implementation that is used for this device,
arm_iommu_mmap_attrs, ignores the offset completely.

Signed-off-by: Ørjan Eide <orjan.eide@arm.com>
---
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index 7ca8799e..69f01c3 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -94,6 +94,11 @@ int rockchip_gem_mmap(struct file *filp, struct vm_area_struct *vma)
 		return -EACCES;
 	}
 
+	/* Set vm_pgoff (used as a fake buffer offset by DRM) to 0 and map the
+	 * whole buffer from the start.
+	 */
+	vma->vm_pgoff = 0;
+
 	obj = container_of(node, struct drm_gem_object, vma_node);
 	ret = rockchip_gem_mmap_buf(obj, vma);
 
-- 
1.9.1


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

* [PATCH 1/2] drm: rockchip: Don't pass DRM fake offset to dma-api
@ 2015-04-16 14:41 ` Ørjan Eide
  0 siblings, 0 replies; 22+ messages in thread
From: Ørjan Eide @ 2015-04-16 14:41 UTC (permalink / raw)
  To: linux-arm-kernel

Set vm_pgoff to 0 after using it to look up the GEM node, before passing
it on rockchip_gem_mmap_buf() where the offset must be from the start of
the buffer.

Passing in the fake offset currently works because the
dma_mmap_attrs implementation that is used for this device,
arm_iommu_mmap_attrs, ignores the offset completely.

Signed-off-by: ?rjan Eide <orjan.eide@arm.com>
---
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index 7ca8799e..69f01c3 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -94,6 +94,11 @@ int rockchip_gem_mmap(struct file *filp, struct vm_area_struct *vma)
 		return -EACCES;
 	}
 
+	/* Set vm_pgoff (used as a fake buffer offset by DRM) to 0 and map the
+	 * whole buffer from the start.
+	 */
+	vma->vm_pgoff = 0;
+
 	obj = container_of(node, struct drm_gem_object, vma_node);
 	ret = rockchip_gem_mmap_buf(obj, vma);
 
-- 
1.9.1

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

* [PATCH 2/2] ARM: DMA: Use vm_pgoff for IOMMU mmap
  2015-04-16 14:41 ` Ørjan Eide
@ 2015-04-16 14:41   ` Ørjan Eide
  -1 siblings, 0 replies; 22+ messages in thread
From: Ørjan Eide @ 2015-04-16 14:41 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, dri-devel, linux-rockchip; +Cc: djkurtz

arm_iommu_mmap_attrs() ignores the page offset in vma->vm_pgoff that was
specified in the mmap call. Any user of dma_mmap_* will get an
unexpected result when the device uses the IOMMU DMA ops.

Some DRM driver that use dma_mmap_* seems to depend on it ignoring
vma->vm_pgoff.  Both the Samsung Exynos DRM driver before v3.18, and the
current Rockchip DRM driver, use the page offset to pass GEM cookies
that are used to look up the GEM buffers and then call dma_mmap_attrs()
with the cookie value still in vma->vm_pgoff.

rockchip_gem_mmap_buf() in drivers/gpu/drm/rockchip/rockchip_drm_gem.c
still does this. It should be fixed before fixing
arm_iommu_mmap_attrs().

Signed-off-by: Ørjan Eide <orjan.eide@arm.com>
---
 arch/arm/mm/dma-mapping.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index c274476..07d571b 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -1364,6 +1364,9 @@ static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
 {
 	unsigned long uaddr = vma->vm_start;
 	unsigned long usize = vma->vm_end - vma->vm_start;
+	unsigned long nr_vma_pages = usize >> PAGE_SHIFT;
+	unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
+	unsigned long off = vma->vm_pgoff;
 	struct page **pages = __iommu_get_pages(cpu_addr, attrs);
 
 	vma->vm_page_prot = __get_dma_pgprot(attrs, vma->vm_page_prot);
@@ -1371,6 +1374,11 @@ static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
 	if (!pages)
 		return -ENXIO;
 
+	if (off >= nr_pages || nr_vma_pages > (nr_pages - off))
+		return -ENXIO;
+
+	pages += off;
+
 	do {
 		int ret = vm_insert_page(vma, uaddr, *pages++);
 		if (ret) {
-- 
1.9.1


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

* [PATCH 2/2] ARM: DMA: Use vm_pgoff for IOMMU mmap
@ 2015-04-16 14:41   ` Ørjan Eide
  0 siblings, 0 replies; 22+ messages in thread
From: Ørjan Eide @ 2015-04-16 14:41 UTC (permalink / raw)
  To: linux-arm-kernel

arm_iommu_mmap_attrs() ignores the page offset in vma->vm_pgoff that was
specified in the mmap call. Any user of dma_mmap_* will get an
unexpected result when the device uses the IOMMU DMA ops.

Some DRM driver that use dma_mmap_* seems to depend on it ignoring
vma->vm_pgoff.  Both the Samsung Exynos DRM driver before v3.18, and the
current Rockchip DRM driver, use the page offset to pass GEM cookies
that are used to look up the GEM buffers and then call dma_mmap_attrs()
with the cookie value still in vma->vm_pgoff.

rockchip_gem_mmap_buf() in drivers/gpu/drm/rockchip/rockchip_drm_gem.c
still does this. It should be fixed before fixing
arm_iommu_mmap_attrs().

Signed-off-by: ?rjan Eide <orjan.eide@arm.com>
---
 arch/arm/mm/dma-mapping.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index c274476..07d571b 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -1364,6 +1364,9 @@ static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
 {
 	unsigned long uaddr = vma->vm_start;
 	unsigned long usize = vma->vm_end - vma->vm_start;
+	unsigned long nr_vma_pages = usize >> PAGE_SHIFT;
+	unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
+	unsigned long off = vma->vm_pgoff;
 	struct page **pages = __iommu_get_pages(cpu_addr, attrs);
 
 	vma->vm_page_prot = __get_dma_pgprot(attrs, vma->vm_page_prot);
@@ -1371,6 +1374,11 @@ static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
 	if (!pages)
 		return -ENXIO;
 
+	if (off >= nr_pages || nr_vma_pages > (nr_pages - off))
+		return -ENXIO;
+
+	pages += off;
+
 	do {
 		int ret = vm_insert_page(vma, uaddr, *pages++);
 		if (ret) {
-- 
1.9.1

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

* Re: [PATCH 1/2] drm: rockchip: Don't pass DRM fake offset to dma-api
  2015-04-16 14:41 ` Ørjan Eide
  (?)
@ 2015-04-18 16:55   ` Heiko Stübner
  -1 siblings, 0 replies; 22+ messages in thread
From: Heiko Stübner @ 2015-04-18 16:55 UTC (permalink / raw)
  To: linux-rockchip, mark.yao
  Cc: Ørjan Eide, linux-arm-kernel, linux-kernel, dri-devel, djkurtz

Am Donnerstag, 16. April 2015, 16:41:51 schrieb Ørjan Eide:
> Set vm_pgoff to 0 after using it to look up the GEM node, before passing
> it on rockchip_gem_mmap_buf() where the offset must be from the start of
> the buffer.
> 
> Passing in the fake offset currently works because the
> dma_mmap_attrs implementation that is used for this device,
> arm_iommu_mmap_attrs, ignores the offset completely.
> 
> Signed-off-by: Ørjan Eide <orjan.eide@arm.com>

both patches on a rk3288-veyron-pinky

Tested-by: Heiko Stuebner <heiko@sntech.de>

Through which tree do you want to take these patches? I guess the rockchip-drm 
related patch should go through the tree that will take the dma-mapping patch, 
so you'll probably need an "Ack" from Mark Yao (Cc'ed).


Heiko

> ---
>  drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index 7ca8799e..69f01c3
> 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> @@ -94,6 +94,11 @@ int rockchip_gem_mmap(struct file *filp, struct
> vm_area_struct *vma) return -EACCES;
>  	}
> 
> +	/* Set vm_pgoff (used as a fake buffer offset by DRM) to 0 and map the
> +	 * whole buffer from the start.
> +	 */
> +	vma->vm_pgoff = 0;
> +
>  	obj = container_of(node, struct drm_gem_object, vma_node);
>  	ret = rockchip_gem_mmap_buf(obj, vma);


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

* Re: [PATCH 1/2] drm: rockchip: Don't pass DRM fake offset to dma-api
@ 2015-04-18 16:55   ` Heiko Stübner
  0 siblings, 0 replies; 22+ messages in thread
From: Heiko Stübner @ 2015-04-18 16:55 UTC (permalink / raw)
  To: linux-rockchip, mark.yao
  Cc: dri-devel, Ørjan Eide, linux-kernel, linux-arm-kernel

Am Donnerstag, 16. April 2015, 16:41:51 schrieb Ørjan Eide:
> Set vm_pgoff to 0 after using it to look up the GEM node, before passing
> it on rockchip_gem_mmap_buf() where the offset must be from the start of
> the buffer.
> 
> Passing in the fake offset currently works because the
> dma_mmap_attrs implementation that is used for this device,
> arm_iommu_mmap_attrs, ignores the offset completely.
> 
> Signed-off-by: Ørjan Eide <orjan.eide@arm.com>

both patches on a rk3288-veyron-pinky

Tested-by: Heiko Stuebner <heiko@sntech.de>

Through which tree do you want to take these patches? I guess the rockchip-drm 
related patch should go through the tree that will take the dma-mapping patch, 
so you'll probably need an "Ack" from Mark Yao (Cc'ed).


Heiko

> ---
>  drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index 7ca8799e..69f01c3
> 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> @@ -94,6 +94,11 @@ int rockchip_gem_mmap(struct file *filp, struct
> vm_area_struct *vma) return -EACCES;
>  	}
> 
> +	/* Set vm_pgoff (used as a fake buffer offset by DRM) to 0 and map the
> +	 * whole buffer from the start.
> +	 */
> +	vma->vm_pgoff = 0;
> +
>  	obj = container_of(node, struct drm_gem_object, vma_node);
>  	ret = rockchip_gem_mmap_buf(obj, vma);

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 1/2] drm: rockchip: Don't pass DRM fake offset to dma-api
@ 2015-04-18 16:55   ` Heiko Stübner
  0 siblings, 0 replies; 22+ messages in thread
From: Heiko Stübner @ 2015-04-18 16:55 UTC (permalink / raw)
  To: linux-arm-kernel

Am Donnerstag, 16. April 2015, 16:41:51 schrieb ?rjan Eide:
> Set vm_pgoff to 0 after using it to look up the GEM node, before passing
> it on rockchip_gem_mmap_buf() where the offset must be from the start of
> the buffer.
> 
> Passing in the fake offset currently works because the
> dma_mmap_attrs implementation that is used for this device,
> arm_iommu_mmap_attrs, ignores the offset completely.
> 
> Signed-off-by: ?rjan Eide <orjan.eide@arm.com>

both patches on a rk3288-veyron-pinky

Tested-by: Heiko Stuebner <heiko@sntech.de>

Through which tree do you want to take these patches? I guess the rockchip-drm 
related patch should go through the tree that will take the dma-mapping patch, 
so you'll probably need an "Ack" from Mark Yao (Cc'ed).


Heiko

> ---
>  drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index 7ca8799e..69f01c3
> 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> @@ -94,6 +94,11 @@ int rockchip_gem_mmap(struct file *filp, struct
> vm_area_struct *vma) return -EACCES;
>  	}
> 
> +	/* Set vm_pgoff (used as a fake buffer offset by DRM) to 0 and map the
> +	 * whole buffer from the start.
> +	 */
> +	vma->vm_pgoff = 0;
> +
>  	obj = container_of(node, struct drm_gem_object, vma_node);
>  	ret = rockchip_gem_mmap_buf(obj, vma);

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

* Re: [PATCH 2/2] ARM: DMA: Use vm_pgoff for IOMMU mmap
  2015-04-16 14:41   ` Ørjan Eide
  (?)
@ 2015-04-20  4:13     ` Daniel Kurtz
  -1 siblings, 0 replies; 22+ messages in thread
From: Daniel Kurtz @ 2015-04-20  4:13 UTC (permalink / raw)
  To: Ørjan Eide
  Cc: linux-arm-kernel, linux-kernel, dri-devel, open list:ARM/Rockchip SoC...

Hi Ørjan,

On Thu, Apr 16, 2015 at 10:41 PM, Ørjan Eide <orjan.eide@arm.com> wrote:
> arm_iommu_mmap_attrs() ignores the page offset in vma->vm_pgoff that was
> specified in the mmap call. Any user of dma_mmap_* will get an
> unexpected result when the device uses the IOMMU DMA ops.
>
> Some DRM driver that use dma_mmap_* seems to depend on it ignoring
> vma->vm_pgoff.  Both the Samsung Exynos DRM driver before v3.18, and the
> current Rockchip DRM driver, use the page offset to pass GEM cookies
> that are used to look up the GEM buffers and then call dma_mmap_attrs()
> with the cookie value still in vma->vm_pgoff.
>
> rockchip_gem_mmap_buf() in drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> still does this. It should be fixed before fixing
> arm_iommu_mmap_attrs().
>
> Signed-off-by: Ørjan Eide <orjan.eide@arm.com>

Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>

I tested this patch on my RK3288 board with the corresponding
rockchip_drm patch [0], and it works.  So, also:
Tested-by: Daniel Kurtz <djkurtz@chromium.org>

[0] https://patchwork.kernel.org/patch/6226591/



> ---
>  arch/arm/mm/dma-mapping.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> index c274476..07d571b 100644
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
> @@ -1364,6 +1364,9 @@ static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
>  {
>         unsigned long uaddr = vma->vm_start;
>         unsigned long usize = vma->vm_end - vma->vm_start;
> +       unsigned long nr_vma_pages = usize >> PAGE_SHIFT;
> +       unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
> +       unsigned long off = vma->vm_pgoff;
>         struct page **pages = __iommu_get_pages(cpu_addr, attrs);
>
>         vma->vm_page_prot = __get_dma_pgprot(attrs, vma->vm_page_prot);
> @@ -1371,6 +1374,11 @@ static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
>         if (!pages)
>                 return -ENXIO;
>
> +       if (off >= nr_pages || nr_vma_pages > (nr_pages - off))
> +               return -ENXIO;
> +
> +       pages += off;
> +
>         do {
>                 int ret = vm_insert_page(vma, uaddr, *pages++);
>                 if (ret) {
> --
> 1.9.1
>

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

* Re: [PATCH 2/2] ARM: DMA: Use vm_pgoff for IOMMU mmap
@ 2015-04-20  4:13     ` Daniel Kurtz
  0 siblings, 0 replies; 22+ messages in thread
From: Daniel Kurtz @ 2015-04-20  4:13 UTC (permalink / raw)
  To: Ørjan Eide
  Cc: open list:ARM/Rockchip SoC..., dri-devel, linux-kernel, linux-arm-kernel

Hi Ørjan,

On Thu, Apr 16, 2015 at 10:41 PM, Ørjan Eide <orjan.eide@arm.com> wrote:
> arm_iommu_mmap_attrs() ignores the page offset in vma->vm_pgoff that was
> specified in the mmap call. Any user of dma_mmap_* will get an
> unexpected result when the device uses the IOMMU DMA ops.
>
> Some DRM driver that use dma_mmap_* seems to depend on it ignoring
> vma->vm_pgoff.  Both the Samsung Exynos DRM driver before v3.18, and the
> current Rockchip DRM driver, use the page offset to pass GEM cookies
> that are used to look up the GEM buffers and then call dma_mmap_attrs()
> with the cookie value still in vma->vm_pgoff.
>
> rockchip_gem_mmap_buf() in drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> still does this. It should be fixed before fixing
> arm_iommu_mmap_attrs().
>
> Signed-off-by: Ørjan Eide <orjan.eide@arm.com>

Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>

I tested this patch on my RK3288 board with the corresponding
rockchip_drm patch [0], and it works.  So, also:
Tested-by: Daniel Kurtz <djkurtz@chromium.org>

[0] https://patchwork.kernel.org/patch/6226591/



> ---
>  arch/arm/mm/dma-mapping.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> index c274476..07d571b 100644
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
> @@ -1364,6 +1364,9 @@ static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
>  {
>         unsigned long uaddr = vma->vm_start;
>         unsigned long usize = vma->vm_end - vma->vm_start;
> +       unsigned long nr_vma_pages = usize >> PAGE_SHIFT;
> +       unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
> +       unsigned long off = vma->vm_pgoff;
>         struct page **pages = __iommu_get_pages(cpu_addr, attrs);
>
>         vma->vm_page_prot = __get_dma_pgprot(attrs, vma->vm_page_prot);
> @@ -1371,6 +1374,11 @@ static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
>         if (!pages)
>                 return -ENXIO;
>
> +       if (off >= nr_pages || nr_vma_pages > (nr_pages - off))
> +               return -ENXIO;
> +
> +       pages += off;
> +
>         do {
>                 int ret = vm_insert_page(vma, uaddr, *pages++);
>                 if (ret) {
> --
> 1.9.1
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 2/2] ARM: DMA: Use vm_pgoff for IOMMU mmap
@ 2015-04-20  4:13     ` Daniel Kurtz
  0 siblings, 0 replies; 22+ messages in thread
From: Daniel Kurtz @ 2015-04-20  4:13 UTC (permalink / raw)
  To: linux-arm-kernel

Hi ?rjan,

On Thu, Apr 16, 2015 at 10:41 PM, ?rjan Eide <orjan.eide@arm.com> wrote:
> arm_iommu_mmap_attrs() ignores the page offset in vma->vm_pgoff that was
> specified in the mmap call. Any user of dma_mmap_* will get an
> unexpected result when the device uses the IOMMU DMA ops.
>
> Some DRM driver that use dma_mmap_* seems to depend on it ignoring
> vma->vm_pgoff.  Both the Samsung Exynos DRM driver before v3.18, and the
> current Rockchip DRM driver, use the page offset to pass GEM cookies
> that are used to look up the GEM buffers and then call dma_mmap_attrs()
> with the cookie value still in vma->vm_pgoff.
>
> rockchip_gem_mmap_buf() in drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> still does this. It should be fixed before fixing
> arm_iommu_mmap_attrs().
>
> Signed-off-by: ?rjan Eide <orjan.eide@arm.com>

Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>

I tested this patch on my RK3288 board with the corresponding
rockchip_drm patch [0], and it works.  So, also:
Tested-by: Daniel Kurtz <djkurtz@chromium.org>

[0] https://patchwork.kernel.org/patch/6226591/



> ---
>  arch/arm/mm/dma-mapping.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> index c274476..07d571b 100644
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
> @@ -1364,6 +1364,9 @@ static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
>  {
>         unsigned long uaddr = vma->vm_start;
>         unsigned long usize = vma->vm_end - vma->vm_start;
> +       unsigned long nr_vma_pages = usize >> PAGE_SHIFT;
> +       unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
> +       unsigned long off = vma->vm_pgoff;
>         struct page **pages = __iommu_get_pages(cpu_addr, attrs);
>
>         vma->vm_page_prot = __get_dma_pgprot(attrs, vma->vm_page_prot);
> @@ -1371,6 +1374,11 @@ static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
>         if (!pages)
>                 return -ENXIO;
>
> +       if (off >= nr_pages || nr_vma_pages > (nr_pages - off))
> +               return -ENXIO;
> +
> +       pages += off;
> +
>         do {
>                 int ret = vm_insert_page(vma, uaddr, *pages++);
>                 if (ret) {
> --
> 1.9.1
>

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

* Re: [PATCH 1/2] drm: rockchip: Don't pass DRM fake offset to dma-api
  2015-04-16 14:41 ` Ørjan Eide
  (?)
@ 2015-04-20  4:13   ` Daniel Kurtz
  -1 siblings, 0 replies; 22+ messages in thread
From: Daniel Kurtz @ 2015-04-20  4:13 UTC (permalink / raw)
  To: Ørjan Eide
  Cc: linux-arm-kernel, linux-kernel, dri-devel, open list:ARM/Rockchip SoC...

Hi Ørjan,

On Thu, Apr 16, 2015 at 10:41 PM, Ørjan Eide <orjan.eide@arm.com> wrote:
>
> Set vm_pgoff to 0 after using it to look up the GEM node, before passing
> it on rockchip_gem_mmap_buf() where the offset must be from the start of
> the buffer.
>
> Passing in the fake offset currently works because the
> dma_mmap_attrs implementation that is used for this device,
> arm_iommu_mmap_attrs, ignores the offset completely.
>
> Signed-off-by: Ørjan Eide <orjan.eide@arm.com>
>
> ---
>  drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> index 7ca8799e..69f01c3 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> @@ -94,6 +94,11 @@ int rockchip_gem_mmap(struct file *filp, struct vm_area_struct *vma)
>                 return -EACCES;
>         }
>
> +       /* Set vm_pgoff (used as a fake buffer offset by DRM) to 0 and map the
> +        * whole buffer from the start.
> +        */

One very tiny nit.  According to [0], multi-line comments start are
supposed to start with a single "/*"
[0] https://www.kernel.org/doc/Documentation/CodingStyle

Other than that, this patch is
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>

Thanks for sending this up!


>
> +       vma->vm_pgoff = 0;
> +
>         obj = container_of(node, struct drm_gem_object, vma_node);
>         ret = rockchip_gem_mmap_buf(obj, vma);
>
> --
> 1.9.1
>

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

* Re: [PATCH 1/2] drm: rockchip: Don't pass DRM fake offset to dma-api
@ 2015-04-20  4:13   ` Daniel Kurtz
  0 siblings, 0 replies; 22+ messages in thread
From: Daniel Kurtz @ 2015-04-20  4:13 UTC (permalink / raw)
  To: Ørjan Eide
  Cc: open list:ARM/Rockchip SoC..., dri-devel, linux-kernel, linux-arm-kernel

Hi Ørjan,

On Thu, Apr 16, 2015 at 10:41 PM, Ørjan Eide <orjan.eide@arm.com> wrote:
>
> Set vm_pgoff to 0 after using it to look up the GEM node, before passing
> it on rockchip_gem_mmap_buf() where the offset must be from the start of
> the buffer.
>
> Passing in the fake offset currently works because the
> dma_mmap_attrs implementation that is used for this device,
> arm_iommu_mmap_attrs, ignores the offset completely.
>
> Signed-off-by: Ørjan Eide <orjan.eide@arm.com>
>
> ---
>  drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> index 7ca8799e..69f01c3 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> @@ -94,6 +94,11 @@ int rockchip_gem_mmap(struct file *filp, struct vm_area_struct *vma)
>                 return -EACCES;
>         }
>
> +       /* Set vm_pgoff (used as a fake buffer offset by DRM) to 0 and map the
> +        * whole buffer from the start.
> +        */

One very tiny nit.  According to [0], multi-line comments start are
supposed to start with a single "/*"
[0] https://www.kernel.org/doc/Documentation/CodingStyle

Other than that, this patch is
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>

Thanks for sending this up!


>
> +       vma->vm_pgoff = 0;
> +
>         obj = container_of(node, struct drm_gem_object, vma_node);
>         ret = rockchip_gem_mmap_buf(obj, vma);
>
> --
> 1.9.1
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 1/2] drm: rockchip: Don't pass DRM fake offset to dma-api
@ 2015-04-20  4:13   ` Daniel Kurtz
  0 siblings, 0 replies; 22+ messages in thread
From: Daniel Kurtz @ 2015-04-20  4:13 UTC (permalink / raw)
  To: linux-arm-kernel

Hi ?rjan,

On Thu, Apr 16, 2015 at 10:41 PM, ?rjan Eide <orjan.eide@arm.com> wrote:
>
> Set vm_pgoff to 0 after using it to look up the GEM node, before passing
> it on rockchip_gem_mmap_buf() where the offset must be from the start of
> the buffer.
>
> Passing in the fake offset currently works because the
> dma_mmap_attrs implementation that is used for this device,
> arm_iommu_mmap_attrs, ignores the offset completely.
>
> Signed-off-by: ?rjan Eide <orjan.eide@arm.com>
>
> ---
>  drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> index 7ca8799e..69f01c3 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> @@ -94,6 +94,11 @@ int rockchip_gem_mmap(struct file *filp, struct vm_area_struct *vma)
>                 return -EACCES;
>         }
>
> +       /* Set vm_pgoff (used as a fake buffer offset by DRM) to 0 and map the
> +        * whole buffer from the start.
> +        */

One very tiny nit.  According to [0], multi-line comments start are
supposed to start with a single "/*"
[0] https://www.kernel.org/doc/Documentation/CodingStyle

Other than that, this patch is
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>

Thanks for sending this up!


>
> +       vma->vm_pgoff = 0;
> +
>         obj = container_of(node, struct drm_gem_object, vma_node);
>         ret = rockchip_gem_mmap_buf(obj, vma);
>
> --
> 1.9.1
>

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

* Re: [PATCH 1/2] drm: rockchip: Don't pass DRM fake offset to dma-api
  2015-04-18 16:55   ` Heiko Stübner
  (?)
@ 2015-04-20  5:34     ` Mark yao
  -1 siblings, 0 replies; 22+ messages in thread
From: Mark yao @ 2015-04-20  5:34 UTC (permalink / raw)
  To: Heiko Stübner, linux-rockchip
  Cc: Ørjan Eide, linux-arm-kernel, linux-kernel, dri-devel, djkurtz

On 2015年04月19日 00:55, Heiko Stübner wrote:
> Am Donnerstag, 16. April 2015, 16:41:51 schrieb Ørjan Eide:
>> Set vm_pgoff to 0 after using it to look up the GEM node, before passing
>> it on rockchip_gem_mmap_buf() where the offset must be from the start of
>> the buffer.
>>
>> Passing in the fake offset currently works because the
>> dma_mmap_attrs implementation that is used for this device,
>> arm_iommu_mmap_attrs, ignores the offset completely.
>>
>> Signed-off-by: Ørjan Eide <orjan.eide@arm.com>
> both patches on a rk3288-veyron-pinky
>
> Tested-by: Heiko Stuebner <heiko@sntech.de>
>
> Through which tree do you want to take these patches? I guess the rockchip-drm
> related patch should go through the tree that will take the dma-mapping patch,
> so you'll probably need an "Ack" from Mark Yao (Cc'ed).
>
>
> Heiko
>
>> ---
>>   drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>> b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index 7ca8799e..69f01c3
>> 100644
>> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>> @@ -94,6 +94,11 @@ int rockchip_gem_mmap(struct file *filp, struct
>> vm_area_struct *vma) return -EACCES;
>>   	}
>>
>> +	/* Set vm_pgoff (used as a fake buffer offset by DRM) to 0 and map the
>> +	 * whole buffer from the start.
>> +	 */
>> +	vma->vm_pgoff = 0;
>> +
>>   	obj = container_of(node, struct drm_gem_object, vma_node);
>>   	ret = rockchip_gem_mmap_buf(obj, vma);
>
>
>
Thanks for this fix,
Acked-by: Mark Yao <mark.yao@rock-chips.com>

-- 
Mark


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

* Re: [PATCH 1/2] drm: rockchip: Don't pass DRM fake offset to dma-api
@ 2015-04-20  5:34     ` Mark yao
  0 siblings, 0 replies; 22+ messages in thread
From: Mark yao @ 2015-04-20  5:34 UTC (permalink / raw)
  To: Heiko Stübner, linux-rockchip
  Cc: dri-devel, Ørjan Eide, linux-kernel, linux-arm-kernel

On 2015年04月19日 00:55, Heiko Stübner wrote:
> Am Donnerstag, 16. April 2015, 16:41:51 schrieb Ørjan Eide:
>> Set vm_pgoff to 0 after using it to look up the GEM node, before passing
>> it on rockchip_gem_mmap_buf() where the offset must be from the start of
>> the buffer.
>>
>> Passing in the fake offset currently works because the
>> dma_mmap_attrs implementation that is used for this device,
>> arm_iommu_mmap_attrs, ignores the offset completely.
>>
>> Signed-off-by: Ørjan Eide <orjan.eide@arm.com>
> both patches on a rk3288-veyron-pinky
>
> Tested-by: Heiko Stuebner <heiko@sntech.de>
>
> Through which tree do you want to take these patches? I guess the rockchip-drm
> related patch should go through the tree that will take the dma-mapping patch,
> so you'll probably need an "Ack" from Mark Yao (Cc'ed).
>
>
> Heiko
>
>> ---
>>   drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>> b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index 7ca8799e..69f01c3
>> 100644
>> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>> @@ -94,6 +94,11 @@ int rockchip_gem_mmap(struct file *filp, struct
>> vm_area_struct *vma) return -EACCES;
>>   	}
>>
>> +	/* Set vm_pgoff (used as a fake buffer offset by DRM) to 0 and map the
>> +	 * whole buffer from the start.
>> +	 */
>> +	vma->vm_pgoff = 0;
>> +
>>   	obj = container_of(node, struct drm_gem_object, vma_node);
>>   	ret = rockchip_gem_mmap_buf(obj, vma);
>
>
>
Thanks for this fix,
Acked-by: Mark Yao <mark.yao@rock-chips.com>

-- 
Mark

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 1/2] drm: rockchip: Don't pass DRM fake offset to dma-api
@ 2015-04-20  5:34     ` Mark yao
  0 siblings, 0 replies; 22+ messages in thread
From: Mark yao @ 2015-04-20  5:34 UTC (permalink / raw)
  To: linux-arm-kernel

On 2015?04?19? 00:55, Heiko St?bner wrote:
> Am Donnerstag, 16. April 2015, 16:41:51 schrieb ?rjan Eide:
>> Set vm_pgoff to 0 after using it to look up the GEM node, before passing
>> it on rockchip_gem_mmap_buf() where the offset must be from the start of
>> the buffer.
>>
>> Passing in the fake offset currently works because the
>> dma_mmap_attrs implementation that is used for this device,
>> arm_iommu_mmap_attrs, ignores the offset completely.
>>
>> Signed-off-by: ?rjan Eide <orjan.eide@arm.com>
> both patches on a rk3288-veyron-pinky
>
> Tested-by: Heiko Stuebner <heiko@sntech.de>
>
> Through which tree do you want to take these patches? I guess the rockchip-drm
> related patch should go through the tree that will take the dma-mapping patch,
> so you'll probably need an "Ack" from Mark Yao (Cc'ed).
>
>
> Heiko
>
>> ---
>>   drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>> b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index 7ca8799e..69f01c3
>> 100644
>> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>> @@ -94,6 +94,11 @@ int rockchip_gem_mmap(struct file *filp, struct
>> vm_area_struct *vma) return -EACCES;
>>   	}
>>
>> +	/* Set vm_pgoff (used as a fake buffer offset by DRM) to 0 and map the
>> +	 * whole buffer from the start.
>> +	 */
>> +	vma->vm_pgoff = 0;
>> +
>>   	obj = container_of(node, struct drm_gem_object, vma_node);
>>   	ret = rockchip_gem_mmap_buf(obj, vma);
>
>
>
Thanks for this fix,
Acked-by: Mark Yao <mark.yao@rock-chips.com>

-- 
?ark

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

* Re: [PATCH 1/2] drm: rockchip: Don't pass DRM fake offset to dma-api
  2015-04-20  5:34     ` Mark yao
  (?)
@ 2015-04-20  5:44       ` Mark yao
  -1 siblings, 0 replies; 22+ messages in thread
From: Mark yao @ 2015-04-20  5:44 UTC (permalink / raw)
  To: Heiko Stübner, linux-rockchip
  Cc: Ørjan Eide, linux-arm-kernel, linux-kernel, dri-devel, djkurtz

On 2015年04月20日 13:34, Mark yao wrote:
> On 2015年04月19日 00:55, Heiko Stübner wrote:
>> Am Donnerstag, 16. April 2015, 16:41:51 schrieb Ørjan Eide:
>>> Set vm_pgoff to 0 after using it to look up the GEM node, before 
>>> passing
>>> it on rockchip_gem_mmap_buf() where the offset must be from the 
>>> start of
>>> the buffer.
>>>
>>> Passing in the fake offset currently works because the
>>> dma_mmap_attrs implementation that is used for this device,
>>> arm_iommu_mmap_attrs, ignores the offset completely.
>>>
>>> Signed-off-by: Ørjan Eide <orjan.eide@arm.com>
>> both patches on a rk3288-veyron-pinky
>>
>> Tested-by: Heiko Stuebner <heiko@sntech.de>
>>
>> Through which tree do you want to take these patches? I guess the 
>> rockchip-drm
>> related patch should go through the tree that will take the 
>> dma-mapping patch,
>> so you'll probably need an "Ack" from Mark Yao (Cc'ed).
>>
>>
>> Heiko
>>
>>> ---
>>>   drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++++
>>>   1 file changed, 5 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>>> b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index 7ca8799e..69f01c3
>>> 100644
>>> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>>> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>>> @@ -94,6 +94,11 @@ int rockchip_gem_mmap(struct file *filp, struct
>>> vm_area_struct *vma) return -EACCES;
>>>       }
>>>
>>> +    /* Set vm_pgoff (used as a fake buffer offset by DRM) to 0 and 
>>> map the
>>> +     * whole buffer from the start.
>>> +     */
>>> +    vma->vm_pgoff = 0;
>>> +
>>>       obj = container_of(node, struct drm_gem_object, vma_node);
>>>       ret = rockchip_gem_mmap_buf(obj, vma);
>>
>>
>>
> Thanks for this fix,
> Acked-by: Mark Yao <mark.yao@rock-chips.com>
>
I met this problem when work with gem non-iommu path, set vma->vm_pgoff 
= 0 solved it. :-)

-- 
Mark


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

* Re: [PATCH 1/2] drm: rockchip: Don't pass DRM fake offset to dma-api
@ 2015-04-20  5:44       ` Mark yao
  0 siblings, 0 replies; 22+ messages in thread
From: Mark yao @ 2015-04-20  5:44 UTC (permalink / raw)
  To: Heiko Stübner, linux-rockchip
  Cc: dri-devel, Ørjan Eide, linux-kernel, linux-arm-kernel

On 2015年04月20日 13:34, Mark yao wrote:
> On 2015年04月19日 00:55, Heiko Stübner wrote:
>> Am Donnerstag, 16. April 2015, 16:41:51 schrieb Ørjan Eide:
>>> Set vm_pgoff to 0 after using it to look up the GEM node, before 
>>> passing
>>> it on rockchip_gem_mmap_buf() where the offset must be from the 
>>> start of
>>> the buffer.
>>>
>>> Passing in the fake offset currently works because the
>>> dma_mmap_attrs implementation that is used for this device,
>>> arm_iommu_mmap_attrs, ignores the offset completely.
>>>
>>> Signed-off-by: Ørjan Eide <orjan.eide@arm.com>
>> both patches on a rk3288-veyron-pinky
>>
>> Tested-by: Heiko Stuebner <heiko@sntech.de>
>>
>> Through which tree do you want to take these patches? I guess the 
>> rockchip-drm
>> related patch should go through the tree that will take the 
>> dma-mapping patch,
>> so you'll probably need an "Ack" from Mark Yao (Cc'ed).
>>
>>
>> Heiko
>>
>>> ---
>>>   drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++++
>>>   1 file changed, 5 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>>> b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index 7ca8799e..69f01c3
>>> 100644
>>> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>>> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>>> @@ -94,6 +94,11 @@ int rockchip_gem_mmap(struct file *filp, struct
>>> vm_area_struct *vma) return -EACCES;
>>>       }
>>>
>>> +    /* Set vm_pgoff (used as a fake buffer offset by DRM) to 0 and 
>>> map the
>>> +     * whole buffer from the start.
>>> +     */
>>> +    vma->vm_pgoff = 0;
>>> +
>>>       obj = container_of(node, struct drm_gem_object, vma_node);
>>>       ret = rockchip_gem_mmap_buf(obj, vma);
>>
>>
>>
> Thanks for this fix,
> Acked-by: Mark Yao <mark.yao@rock-chips.com>
>
I met this problem when work with gem non-iommu path, set vma->vm_pgoff 
= 0 solved it. :-)

-- 
Mark

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 1/2] drm: rockchip: Don't pass DRM fake offset to dma-api
@ 2015-04-20  5:44       ` Mark yao
  0 siblings, 0 replies; 22+ messages in thread
From: Mark yao @ 2015-04-20  5:44 UTC (permalink / raw)
  To: linux-arm-kernel

On 2015?04?20? 13:34, Mark yao wrote:
> On 2015?04?19? 00:55, Heiko St?bner wrote:
>> Am Donnerstag, 16. April 2015, 16:41:51 schrieb ?rjan Eide:
>>> Set vm_pgoff to 0 after using it to look up the GEM node, before 
>>> passing
>>> it on rockchip_gem_mmap_buf() where the offset must be from the 
>>> start of
>>> the buffer.
>>>
>>> Passing in the fake offset currently works because the
>>> dma_mmap_attrs implementation that is used for this device,
>>> arm_iommu_mmap_attrs, ignores the offset completely.
>>>
>>> Signed-off-by: ?rjan Eide <orjan.eide@arm.com>
>> both patches on a rk3288-veyron-pinky
>>
>> Tested-by: Heiko Stuebner <heiko@sntech.de>
>>
>> Through which tree do you want to take these patches? I guess the 
>> rockchip-drm
>> related patch should go through the tree that will take the 
>> dma-mapping patch,
>> so you'll probably need an "Ack" from Mark Yao (Cc'ed).
>>
>>
>> Heiko
>>
>>> ---
>>>   drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++++
>>>   1 file changed, 5 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>>> b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index 7ca8799e..69f01c3
>>> 100644
>>> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>>> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>>> @@ -94,6 +94,11 @@ int rockchip_gem_mmap(struct file *filp, struct
>>> vm_area_struct *vma) return -EACCES;
>>>       }
>>>
>>> +    /* Set vm_pgoff (used as a fake buffer offset by DRM) to 0 and 
>>> map the
>>> +     * whole buffer from the start.
>>> +     */
>>> +    vma->vm_pgoff = 0;
>>> +
>>>       obj = container_of(node, struct drm_gem_object, vma_node);
>>>       ret = rockchip_gem_mmap_buf(obj, vma);
>>
>>
>>
> Thanks for this fix,
> Acked-by: Mark Yao <mark.yao@rock-chips.com>
>
I met this problem when work with gem non-iommu path, set vma->vm_pgoff 
= 0 solved it. :-)

-- 
?ark

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

* Re: [PATCH 1/2] drm: rockchip: Don't pass DRM fake offset to dma-api
  2015-04-18 16:55   ` Heiko Stübner
  (?)
@ 2015-07-07  7:02     ` Daniel Kurtz
  -1 siblings, 0 replies; 22+ messages in thread
From: Daniel Kurtz @ 2015-07-07  7:02 UTC (permalink / raw)
  To: Heiko Stübner, Russell King
  Cc: open list:ARM/Rockchip SoC..., 姚智情,
	Ørjan Eide, linux-arm-kernel, linux-kernel, dri-devel

On Sun, Apr 19, 2015 at 12:55 AM, Heiko Stübner <heiko@sntech.de> wrote:
>
> Am Donnerstag, 16. April 2015, 16:41:51 schrieb Ørjan Eide:
> > Set vm_pgoff to 0 after using it to look up the GEM node, before passing
> > it on rockchip_gem_mmap_buf() where the offset must be from the start of
> > the buffer.
> >
> > Passing in the fake offset currently works because the
> > dma_mmap_attrs implementation that is used for this device,
> > arm_iommu_mmap_attrs, ignores the offset completely.
> >
> > Signed-off-by: Ørjan Eide <orjan.eide@arm.com>
>
> both patches on a rk3288-veyron-pinky
>
> Tested-by: Heiko Stuebner <heiko@sntech.de>
>
> Through which tree do you want to take these patches? I guess the rockchip-drm
> related patch should go through the tree that will take the dma-mapping patch,
> so you'll probably need an "Ack" from Mark Yao (Cc'ed).

As far as I can tell, these two patches ([0] & [1]) were never picked up.
Russell, can you pick both of them up in your tree?

[0] https://patchwork.kernel.org/patch/6226591/
[1] https://patchwork.kernel.org/patch/6226581/

-Dan

> Heiko
>
> > ---
> >  drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> > b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index 7ca8799e..69f01c3
> > 100644
> > --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> > @@ -94,6 +94,11 @@ int rockchip_gem_mmap(struct file *filp, struct
> > vm_area_struct *vma) return -EACCES;
> >       }
> >
> > +     /* Set vm_pgoff (used as a fake buffer offset by DRM) to 0 and map the
> > +      * whole buffer from the start.
> > +      */
> > +     vma->vm_pgoff = 0;
> > +
> >       obj = container_of(node, struct drm_gem_object, vma_node);
> >       ret = rockchip_gem_mmap_buf(obj, vma);
>

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

* Re: [PATCH 1/2] drm: rockchip: Don't pass DRM fake offset to dma-api
@ 2015-07-07  7:02     ` Daniel Kurtz
  0 siblings, 0 replies; 22+ messages in thread
From: Daniel Kurtz @ 2015-07-07  7:02 UTC (permalink / raw)
  To: Heiko Stübner, Russell King
  Cc: linux-kernel, dri-devel, open list:ARM/Rockchip SoC...,
	Ørjan Eide, linux-arm-kernel

On Sun, Apr 19, 2015 at 12:55 AM, Heiko Stübner <heiko@sntech.de> wrote:
>
> Am Donnerstag, 16. April 2015, 16:41:51 schrieb Ørjan Eide:
> > Set vm_pgoff to 0 after using it to look up the GEM node, before passing
> > it on rockchip_gem_mmap_buf() where the offset must be from the start of
> > the buffer.
> >
> > Passing in the fake offset currently works because the
> > dma_mmap_attrs implementation that is used for this device,
> > arm_iommu_mmap_attrs, ignores the offset completely.
> >
> > Signed-off-by: Ørjan Eide <orjan.eide@arm.com>
>
> both patches on a rk3288-veyron-pinky
>
> Tested-by: Heiko Stuebner <heiko@sntech.de>
>
> Through which tree do you want to take these patches? I guess the rockchip-drm
> related patch should go through the tree that will take the dma-mapping patch,
> so you'll probably need an "Ack" from Mark Yao (Cc'ed).

As far as I can tell, these two patches ([0] & [1]) were never picked up.
Russell, can you pick both of them up in your tree?

[0] https://patchwork.kernel.org/patch/6226591/
[1] https://patchwork.kernel.org/patch/6226581/

-Dan

> Heiko
>
> > ---
> >  drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> > b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index 7ca8799e..69f01c3
> > 100644
> > --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> > @@ -94,6 +94,11 @@ int rockchip_gem_mmap(struct file *filp, struct
> > vm_area_struct *vma) return -EACCES;
> >       }
> >
> > +     /* Set vm_pgoff (used as a fake buffer offset by DRM) to 0 and map the
> > +      * whole buffer from the start.
> > +      */
> > +     vma->vm_pgoff = 0;
> > +
> >       obj = container_of(node, struct drm_gem_object, vma_node);
> >       ret = rockchip_gem_mmap_buf(obj, vma);
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 1/2] drm: rockchip: Don't pass DRM fake offset to dma-api
@ 2015-07-07  7:02     ` Daniel Kurtz
  0 siblings, 0 replies; 22+ messages in thread
From: Daniel Kurtz @ 2015-07-07  7:02 UTC (permalink / raw)
  To: linux-arm-kernel

On Sun, Apr 19, 2015 at 12:55 AM, Heiko St?bner <heiko@sntech.de> wrote:
>
> Am Donnerstag, 16. April 2015, 16:41:51 schrieb ?rjan Eide:
> > Set vm_pgoff to 0 after using it to look up the GEM node, before passing
> > it on rockchip_gem_mmap_buf() where the offset must be from the start of
> > the buffer.
> >
> > Passing in the fake offset currently works because the
> > dma_mmap_attrs implementation that is used for this device,
> > arm_iommu_mmap_attrs, ignores the offset completely.
> >
> > Signed-off-by: ?rjan Eide <orjan.eide@arm.com>
>
> both patches on a rk3288-veyron-pinky
>
> Tested-by: Heiko Stuebner <heiko@sntech.de>
>
> Through which tree do you want to take these patches? I guess the rockchip-drm
> related patch should go through the tree that will take the dma-mapping patch,
> so you'll probably need an "Ack" from Mark Yao (Cc'ed).

As far as I can tell, these two patches ([0] & [1]) were never picked up.
Russell, can you pick both of them up in your tree?

[0] https://patchwork.kernel.org/patch/6226591/
[1] https://patchwork.kernel.org/patch/6226581/

-Dan

> Heiko
>
> > ---
> >  drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> > b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index 7ca8799e..69f01c3
> > 100644
> > --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> > @@ -94,6 +94,11 @@ int rockchip_gem_mmap(struct file *filp, struct
> > vm_area_struct *vma) return -EACCES;
> >       }
> >
> > +     /* Set vm_pgoff (used as a fake buffer offset by DRM) to 0 and map the
> > +      * whole buffer from the start.
> > +      */
> > +     vma->vm_pgoff = 0;
> > +
> >       obj = container_of(node, struct drm_gem_object, vma_node);
> >       ret = rockchip_gem_mmap_buf(obj, vma);
>

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

end of thread, other threads:[~2015-07-07  7:02 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-16 14:41 [PATCH 1/2] drm: rockchip: Don't pass DRM fake offset to dma-api Ørjan Eide
2015-04-16 14:41 ` Ørjan Eide
2015-04-16 14:41 ` [PATCH 2/2] ARM: DMA: Use vm_pgoff for IOMMU mmap Ørjan Eide
2015-04-16 14:41   ` Ørjan Eide
2015-04-20  4:13   ` Daniel Kurtz
2015-04-20  4:13     ` Daniel Kurtz
2015-04-20  4:13     ` Daniel Kurtz
2015-04-18 16:55 ` [PATCH 1/2] drm: rockchip: Don't pass DRM fake offset to dma-api Heiko Stübner
2015-04-18 16:55   ` Heiko Stübner
2015-04-18 16:55   ` Heiko Stübner
2015-04-20  5:34   ` Mark yao
2015-04-20  5:34     ` Mark yao
2015-04-20  5:34     ` Mark yao
2015-04-20  5:44     ` Mark yao
2015-04-20  5:44       ` Mark yao
2015-04-20  5:44       ` Mark yao
2015-07-07  7:02   ` Daniel Kurtz
2015-07-07  7:02     ` Daniel Kurtz
2015-07-07  7:02     ` Daniel Kurtz
2015-04-20  4:13 ` Daniel Kurtz
2015-04-20  4:13   ` Daniel Kurtz
2015-04-20  4:13   ` Daniel Kurtz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.