All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@collabora.com>
To: Thomas Zimmermann <tzimmermann@suse.de>
Cc: loic.molinari@collabora.com, willy@infradead.org,
	frank.binns@imgtec.com, matt.coster@imgtec.com,
	maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	airlied@gmail.com, simona@ffwll.ch,
	dri-devel@lists.freedesktop.org, linux-mm@kvack.org
Subject: Re: [PATCH v3 4/6] drm/gem-shmem: Refactor drm_gem_shmem_try_map_pmd()
Date: Mon, 9 Feb 2026 15:25:56 +0100	[thread overview]
Message-ID: <20260209152556.636825c6@fedora> (raw)
In-Reply-To: <20260209133241.238813-5-tzimmermann@suse.de>

On Mon,  9 Feb 2026 14:27:13 +0100
Thomas Zimmermann <tzimmermann@suse.de> wrote:

> The current mmap page-fault handler requires some changes before it
> can track folio access.
> 
> Call to folio_test_pmd_mappable() into the mmap page-fault handler
> before calling drm_gem_shmem_try_map_pmd(). The folio will become
> useful for tracking the access status.
> 
> Also rename drm_gem_shmem_try_map_pmd() to _try_insert_pfn_pmd()
> and only pass the page fault and page-frame number. The new name and
> parameters make it similar to vmf_insert_pfn_pmd().
> 
> No functional changes. If PMD mapping fails or is not supported,
> insert a regular PFN as before.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

> ---
>  drivers/gpu/drm/drm_gem_shmem_helper.c | 25 ++++++++++++-------------
>  1 file changed, 12 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
> index ab8e331005f9..c3a054899ba3 100644
> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c
> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
> @@ -550,17 +550,14 @@ int drm_gem_shmem_dumb_create(struct drm_file *file, struct drm_device *dev,
>  }
>  EXPORT_SYMBOL_GPL(drm_gem_shmem_dumb_create);
>  
> -static vm_fault_t drm_gem_shmem_try_map_pmd(struct vm_fault *vmf, unsigned long addr,
> -					    struct page *page)
> +static vm_fault_t drm_gem_shmem_try_insert_pfn_pmd(struct vm_fault *vmf, unsigned long pfn)
>  {
>  #ifdef CONFIG_ARCH_SUPPORTS_PMD_PFNMAP
> -	unsigned long pfn = page_to_pfn(page);
>  	unsigned long paddr = pfn << PAGE_SHIFT;
> -	bool aligned = (addr & ~PMD_MASK) == (paddr & ~PMD_MASK);
> +	bool aligned = (vmf->address & ~PMD_MASK) == (paddr & ~PMD_MASK);
>  
> -	if (aligned &&
> -	    pmd_none(*vmf->pmd) &&
> -	    folio_test_pmd_mappable(page_folio(page))) {
> +	if (aligned && pmd_none(*vmf->pmd)) {
> +		/* Read-only mapping; split upon write fault */
>  		pfn &= PMD_MASK >> PAGE_SHIFT;
>  		return vmf_insert_pfn_pmd(vmf, pfn, false);
>  	}
> @@ -580,6 +577,7 @@ static vm_fault_t drm_gem_shmem_fault(struct vm_fault *vmf)
>  	struct page **pages = shmem->pages;
>  	pgoff_t page_offset = vmf->pgoff - vma->vm_pgoff; /* page offset within VMA */
>  	struct page *page;
> +	struct folio *folio;
>  	unsigned long pfn;
>  
>  	dma_resv_lock(obj->resv, NULL);
> @@ -591,15 +589,16 @@ static vm_fault_t drm_gem_shmem_fault(struct vm_fault *vmf)
>  	page = pages[page_offset];
>  	if (drm_WARN_ON_ONCE(dev, !page))
>  		goto out;
> -
> -	ret = drm_gem_shmem_try_map_pmd(vmf, vmf->address, page);
> -	if (ret == VM_FAULT_NOPAGE)
> -		goto out;
> +	folio = page_folio(page);
>  
>  	pfn = page_to_pfn(page);
> -	ret = vmf_insert_pfn(vma, vmf->address, pfn);
>  
> - out:
> +	if (folio_test_pmd_mappable(folio))
> +		ret = drm_gem_shmem_try_insert_pfn_pmd(vmf, pfn);
> +	if (ret != VM_FAULT_NOPAGE)
> +		ret = vmf_insert_pfn(vma, vmf->address, pfn);
> +
> +out:
>  	dma_resv_unlock(obj->resv);
>  
>  	return ret;



  reply	other threads:[~2026-02-09 14:26 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-09 13:27 [PATCH v3 0/6] drm/gem-shmem: Track page accessed/dirty status Thomas Zimmermann
2026-02-09 13:27 ` [PATCH v3 1/6] drm/gem-shmem: Use obj directly where appropriate in fault handler Thomas Zimmermann
2026-02-09 14:10   ` Boris Brezillon
2026-02-09 13:27 ` [PATCH v3 2/6] drm/gem-shmem: Test for existence of page in mmap " Thomas Zimmermann
2026-02-09 14:10   ` Boris Brezillon
2026-02-09 13:27 ` [PATCH v3 3/6] drm/gem-shmem: Return vm_fault_t from drm_gem_shmem_try_map_pmd() Thomas Zimmermann
2026-02-09 13:27 ` [PATCH v3 4/6] drm/gem-shmem: Refactor drm_gem_shmem_try_map_pmd() Thomas Zimmermann
2026-02-09 14:25   ` Boris Brezillon [this message]
2026-02-09 13:27 ` [PATCH v3 5/6] drm/gem-shmem: Track folio accessed/dirty status in mmap Thomas Zimmermann
2026-02-09 14:23   ` Boris Brezillon
2026-02-09 14:46     ` Thomas Zimmermann
2026-02-09 15:01       ` Boris Brezillon
2026-02-25 11:35         ` Thomas Zimmermann
2026-05-20 13:11   ` Igor Torrente
2026-05-20 14:44     ` Boris Brezillon
2026-05-22  8:31       ` Thomas Zimmermann
2026-05-26 14:44     ` Thomas Zimmermann
2026-05-26 14:56       ` Igor Torrente
2026-05-27  6:56         ` Thomas Zimmermann
2026-05-27 10:18           ` Boris Brezillon
2026-05-27 10:32             ` Thomas Zimmermann
2026-05-27 15:02               ` Igor Torrente
2026-05-27 15:19                 ` Thomas Zimmermann
2026-05-28  7:20             ` Thomas Zimmermann
2026-05-28  9:11               ` Boris Brezillon
2026-05-28  9:22                 ` Thomas Zimmermann
2026-05-28  9:38                   ` Boris Brezillon
2026-02-09 13:27 ` [PATCH v3 6/6] drm/gem-shmem: Track folio accessed/dirty status in vmap Thomas Zimmermann
2026-02-25 10:57   ` Frank Binns
2026-02-25 11:34     ` Thomas Zimmermann

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=20260209152556.636825c6@fedora \
    --to=boris.brezillon@collabora.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=frank.binns@imgtec.com \
    --cc=linux-mm@kvack.org \
    --cc=loic.molinari@collabora.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=matt.coster@imgtec.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    --cc=willy@infradead.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.