All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sedat Dilek <sedat.dilek@gmail.com>
To: David Herrmann <dh.herrmann@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH v2] drm/gem: fix mmap vma size calculations
Date: Wed, 31 Jul 2013 19:13:01 +0200	[thread overview]
Message-ID: <CA+icZUXr7731NMi2o74P2-E01YQqdFe0cjzCxt7G_GRZxO7-hw@mail.gmail.com> (raw)
In-Reply-To: <CANq1E4T=WwAQY+jNGO0shjmGQegrb35rOmNajkVQWHc9GivG5A@mail.gmail.com>

On Wed, Jul 31, 2013 at 6:46 PM, David Herrmann <dh.herrmann@gmail.com> wrote:
> Hi
>
> On Tue, Jul 30, 2013 at 9:52 AM, Sedat Dilek <sedat.dilek@gmail.com> wrote:
>> On Tue, Jul 30, 2013 at 9:41 AM, Sedat Dilek <sedat.dilek@gmail.com> wrote:
>>> On Fri, Jul 26, 2013 at 10:15 PM, Daniel Vetter <daniel@ffwll.ch> wrote:
>>>> On Fri, Jul 26, 2013 at 12:09:32PM +0200, David Herrmann wrote:
>>>>> The VMA manager is page-size based so drm_vma_node_size() returns the size
>>>>> in pages. However, drm_gem_mmap_obj() requires the size in bytes. Apply
>>>>> PAGE_SHIFT so we no longer get EINVAL during mmaps due to too small
>>>>> buffers.
>>>>>
>>>>> This bug was introduced in commit:
>>>>>   0de23977cfeb5b357ec884ba15417ae118ff9e9b
>>>>>   "drm/gem: convert to new unified vma manager"
>>>>>
>>>>> Fixes i915 gtt mmap failure reported by Sedat Dilek in:
>>>>>   Re: linux-next: Tree for Jul 25 [ call-trace: drm | drm-intel related? ]
>>>>>
>>>>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>>>>> Cc: Chris Wilson <chris@chris-wilson.co.uk>
>>>>> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
>>>>> Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
>>>>> Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
>>>>
>>>> I remember that I even checked whether v4 was consistent with pages vs.
>>>> bytes ;-) So
>>>>
>>>
>>> Hi David, Daniel, and Dave,
>>>
>>> Just reading quickly "drm: add unified vma offset manager"... is that
>>> below in the docs?
>>>
>>> "The VMA manager is page-size based so drm_vma_node_size() returns the size
>>> in pages. However, drm_gem_mmap_obj() requires the size in bytes. Apply
>>> PAGE_SHIFT so we no longer get EINVAL during mmaps due to too small
>>> buffers."
>>>
>>> If not, do you mind adding it?
>>>
>>
>> To quote this two:
>>
>> [ include/drm/drm_vma_manager.h ]
>>
>> /**
>>  * drm_vma_node_size() - Return size (page-based)
>>  * @node: Node to inspect
>>  *
>>  * Return the size as number of pages for the given node. This is the same size
>>  * that was passed to drm_vma_offset_add(). If no offset is allocated for the
>>  * node, this is 0.
>>  *
>>  * RETURNS:
>>  * Size of @node as number of pages. 0 if the node does not have an offset
>>  * allocated.
>>  */
>>
>> [ drivers/gpu/drm/drm_gem.c ]
>
> It's actually "drm_gem_mmap_obj" which we have to look at and it says:
>   * @obj_size: the object size to be mapped, in bytes
>
> So both are already documented.
>

Good. I had only a quick view, you are the expert.

> Regards
> David
>
>> /**
>>  * drm_gem_mmap - memory map routine for GEM objects
>>  * @filp: DRM file pointer
>>  * @vma: VMA for the area to be mapped
>>  *
>>  * If a driver supports GEM object mapping, mmap calls on the DRM file
>>  * descriptor will end up here.
>>  *
>>  * Look up the GEM object based on the offset passed in (vma->vm_pgoff will
>>  * contain the fake offset we created when the GTT map ioctl was called on
>>  * the object) and map it with a call to drm_gem_mmap_obj().
>>  */
>>
>> - Sedat -
>>
>>> Thanks in advance!
>>>
>>> - Sedat -
>>>
>>>> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
>>>>
>>>> on this little fixup.
>>>> -Daniel
>>>>
>>>>> ---
>>>>>  drivers/gpu/drm/drm_gem.c | 2 +-
>>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
>>>>> index 3613b50..1f76572 100644
>>>>> --- a/drivers/gpu/drm/drm_gem.c
>>>>> +++ b/drivers/gpu/drm/drm_gem.c
>>>>> @@ -666,7 +666,7 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
>>>>>       }
>>>>>
>>>>>       obj = container_of(node, struct drm_gem_object, vma_node);
>>>>> -     ret = drm_gem_mmap_obj(obj, drm_vma_node_size(node), vma);
>>>>> +     ret = drm_gem_mmap_obj(obj, drm_vma_node_size(node) << PAGE_SHIFT, vma);
>>>>>
>>>>>       mutex_unlock(&dev->struct_mutex);
>>>>>
>>>>> --
>>>>> 1.8.3.4
>>>>>
>>>>
>>>> --
>>>> Daniel Vetter
>>>> Software Engineer, Intel Corporation
>>>> +41 (0) 79 365 57 48 - http://blog.ffwll.ch

  reply	other threads:[~2013-07-31 17:13 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-25  8:54 linux-next: Tree for Jul 25 [ call-trace: drm | drm-intel related? ] Sedat Dilek
2013-07-25  9:44 ` [Intel-gfx] " Jani Nikula
2013-07-25 10:02   ` Sedat Dilek
2013-07-25 10:05     ` Sedat Dilek
2013-07-25 10:21       ` Jani Nikula
2013-07-25 10:37         ` Sedat Dilek
2013-07-25 10:37           ` Sedat Dilek
2013-07-25 13:36           ` [Intel-gfx] " Daniel Vetter
2013-07-25 14:23             ` Sedat Dilek
2013-07-25 14:27               ` Daniel Vetter
2013-07-25 15:03                 ` Sedat Dilek
2013-07-25 15:05                   ` Daniel Vetter
2013-07-25 15:34                     ` Sedat Dilek
2013-07-25 16:11                       ` Sedat Dilek
2013-07-25 16:31                         ` Chris Wilson
2013-07-25 16:35                           ` Sedat Dilek
2013-07-25 16:35                             ` Sedat Dilek
2013-07-25 17:01                             ` [Intel-gfx] " Chris Wilson
2013-07-25 17:15                               ` Sedat Dilek
2013-07-25 17:15                                 ` Sedat Dilek
2013-07-25 17:26                                 ` [Intel-gfx] " Chris Wilson
2013-07-25 17:52                                   ` Sedat Dilek
2013-07-25 17:52                                     ` Sedat Dilek
2013-07-25 17:55                                     ` [Intel-gfx] " Sedat Dilek
2013-07-25 17:55                                       ` Sedat Dilek
2013-07-25 18:03                                       ` [Intel-gfx] " Sedat Dilek
2013-07-25 18:03                                         ` Sedat Dilek
2013-07-25 18:45                                         ` [Intel-gfx] " Chris Wilson
2013-07-25 18:50                                           ` Sedat Dilek
2013-07-25 19:00                                             ` Chris Wilson
2013-07-25 19:12                                               ` Sedat Dilek
2013-07-25 19:22                                                 ` Chris Wilson
2013-07-25 19:32                                                   ` Sedat Dilek
2013-07-25 20:07                                                     ` Sedat Dilek
2013-07-25 21:52                                                       ` Chris Wilson
2013-07-25 23:21                                                         ` Sedat Dilek
2013-07-25 23:25                                                           ` Chris Wilson
2013-07-26  7:15                                                             ` Sedat Dilek
2013-07-26  7:26                                                               ` Chris Wilson
2013-07-26  8:25                                                                 ` Sedat Dilek
2013-07-26  8:25                                                                   ` Sedat Dilek
2013-07-26  8:27                                                                   ` [Intel-gfx] " Sedat Dilek
2013-07-26  8:50                                                                     ` Chris Wilson
2013-07-26  8:52                                                                       ` Daniel Vetter
2013-07-26  9:02                                                                         ` Sedat Dilek
2013-07-26  9:11                                                                           ` Sedat Dilek
2013-07-26  9:16                                                                             ` Daniel Vetter
2013-07-26  9:24                                                                               ` [PATCH] drm/gem: fix mmap vma size calculations David Herrmann
2013-07-26 10:09                                                                                 ` [PATCH v2] " David Herrmann
2013-07-26 20:15                                                                                   ` Daniel Vetter
2013-07-30  7:41                                                                                     ` Sedat Dilek
2013-07-30  7:52                                                                                       ` Sedat Dilek
2013-07-31 16:46                                                                                         ` David Herrmann
2013-07-31 17:13                                                                                           ` Sedat Dilek [this message]
2013-07-26  9:32                                                                               ` [Intel-gfx] linux-next: Tree for Jul 25 [ call-trace: drm | drm-intel related? ] Sedat Dilek
2013-07-26 10:34                                                                                 ` Sedat Dilek
2013-07-25 18:03                                     ` Chris Wilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA+icZUXr7731NMi2o74P2-E01YQqdFe0cjzCxt7G_GRZxO7-hw@mail.gmail.com \
    --to=sedat.dilek@gmail.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dh.herrmann@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.