From: Paul Cercueil <paul@crapouillou.net>
To: Christoph Hellwig <hch@infradead.org>
Cc: David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
od@zcrc.me, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/5] drm: Add and export function\r
drm_gem_cma_mmap_noncoherent
Date: Tue, 08 Dec 2020 14:00:22 +0000 [thread overview]
Message-ID: <MKX0LQ.WS1HU920R7ZP2@crapouillou.net> (raw)
In-Reply-To: <FQI8JQ.KNVZ9XZ67ZV41@crapouillou.net>
Hi Christoph,
Le mar. 3 nov. 2020 à 19:13, Paul Cercueil <paul@crapouillou.net> a
écrit :
> Hi Christoph,
>
> Le mar. 3 nov. 2020 à 18:50, Christoph Hellwig <hch@infradead.org> a
> écrit :
>> On Mon, Nov 02, 2020 at 10:06:49PM +0000, Paul Cercueil wrote:
>>> This function can be used by drivers that need to mmap dumb buffers
>>> created with non-coherent backing memory.
>>>
>>> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
>>> ---
>>> drivers/gpu/drm/drm_gem_cma_helper.c | 39
>>> \x7f\x7f++++++++++++++++++++++++++++
>>> include/drm/drm_gem_cma_helper.h | 2 ++
>>> 2 files changed, 41 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c
>>> \x7f\x7fb/drivers/gpu/drm/drm_gem_cma_helper.c
>>> index 3bdd67795e20..4ed63f4896bd 100644
>>> --- a/drivers/gpu/drm/drm_gem_cma_helper.c
>>> +++ b/drivers/gpu/drm/drm_gem_cma_helper.c
>>> @@ -387,6 +387,45 @@ int drm_gem_cma_mmap(struct file *filp,
>>> struct \x7f\x7fvm_area_struct *vma)
>>> }
>>> EXPORT_SYMBOL_GPL(drm_gem_cma_mmap);
>>>
>>> +/**
>>> + * drm_gem_cma_mmap_noncoherent - memory-map a CMA GEM object with
>>> + * non-coherent cache attribute
>>> + * @filp: file object
>>> + * @vma: VMA for the area to be mapped
>>> + *
>>> + * Just like drm_gem_cma_mmap, but for a GEM object backed by
>>> \x7f\x7fnon-coherent
>>> + * memory.
>>> + *
>>> + * Returns:
>>> + * 0 on success or a negative error code on failure.
>>> + */
>>> +int drm_gem_cma_mmap_noncoherent(struct file *filp, struct
>>> \x7f\x7fvm_area_struct *vma)
>>> +{
>>> + struct drm_gem_cma_object *cma_obj;
>>> + int ret;
>>> +
>>> + ret = drm_gem_mmap(filp, vma);
>>> + if (ret)
>>> + return ret;
>>> +
>>> + cma_obj = to_drm_gem_cma_obj(vma->vm_private_data);
>>> +
>>> + /*
>>> + * Clear the VM_PFNMAP flag that was set by drm_gem_mmap(), and
>>> \x7f\x7fset the
>>> + * vm_pgoff (used as a fake buffer offset by DRM) to 0 as we
>>> want \x7f\x7fto map
>>> + * the whole buffer.
>>> + */
>>> + vma->vm_flags &= ~VM_PFNMAP;
>>> + vma->vm_pgoff = 0;
>>> + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
>>> +
>>> + return remap_pfn_range(vma, vma->vm_start,
>>> + cma_obj->paddr >> PAGE_SHIFT,
>>> + vma->vm_end - vma->vm_start,
>>> + vma->vm_page_prot);
>>
>> Per patch 1 cma_obj->paddr is the dma address, while remap_pfn_range
>> expects a physical address. This does not work.
>
> Ok, what would be the correct way to mmap_noncoherent?
Waiting for your input here :)
Cheers,
-Paul
next prev parent reply other threads:[~2020-12-08 14:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-02 22:06 [PATCH 0/5] Add option to mmap GEM buffers cached, try 2 Paul Cercueil
2020-11-02 22:06 ` [PATCH 1/5] drm: Add and export function drm_gem_cma_create_noncoherent Paul Cercueil
2020-11-02 22:06 ` [PATCH 2/5] drm: Add and export function drm_gem_cma_dumb_create_noncoherent Paul Cercueil
2020-11-02 22:06 ` [PATCH 3/5] drm: Add and export function drm_gem_cma_mmap_noncoherent Paul Cercueil
2020-11-03 18:50 ` Christoph Hellwig
2020-11-03 19:13 ` Paul Cercueil
2020-12-08 14:00 ` Paul Cercueil [this message]
2020-11-02 22:06 ` [PATCH 4/5] drm: Add and export function drm_gem_cma_sync_data Paul Cercueil
2020-11-02 22:06 ` [PATCH 5/5] drm/ingenic: Add option to alloc cached GEM buffers Paul Cercueil
2020-11-03 10:17 ` Daniel Vetter
2020-11-03 11:56 ` Paul Cercueil
2020-11-03 12:52 ` Daniel Vetter
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=MKX0LQ.WS1HU920R7ZP2@crapouillou.net \
--to=paul@crapouillou.net \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=od@zcrc.me \
--cc=tzimmermann@suse.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox