diff mbox

[1/2] drm: rockchip: Don't pass DRM fake offset to dma-api

Message ID 1429195312-25898-1-git-send-email-orjan.eide@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ørjan Eide April 16, 2015, 2:41 p.m. UTC
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(+)

Comments

Heiko Stübner April 18, 2015, 4:55 p.m. UTC | #1
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);
Daniel Kurtz April 20, 2015, 4:13 a.m. UTC | #2
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
>
yao mark April 20, 2015, 5:34 a.m. UTC | #3
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>
yao mark April 20, 2015, 5:44 a.m. UTC | #4
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. :-)
Daniel Kurtz July 7, 2015, 7:02 a.m. UTC | #5
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);
>
diff mbox

Patch

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);