From: Matthew Auld <matthew.auld@intel.com>
To: "Levi, Ilia" <ilia.levi@intel.com>, intel-xe@lists.freedesktop.org
Cc: koby.elbaz@intel.com, meny.yossefi@intel.com,
shuicheng.lin@intel.com, thomas.hellstrom@intel.com,
matthew.brost@intel.com, Sashiko <sashiko-bot@kernel.org>
Subject: Re: [PATCH v3 2/7] drm/xe/mmio_gem: use write-back mapping for dummy page
Date: Tue, 28 Jul 2026 17:37:58 +0100 [thread overview]
Message-ID: <aacb6ef7-6d09-4ad7-a7f2-e202a3867dfc@intel.com> (raw)
In-Reply-To: <95514f1d-2cee-4c3e-b228-2a43dddd5269@intel.com>
On 24/07/2026 10:49, Levi, Ilia wrote:
>
> On 23-Jul-26 20:16, Matthew Auld wrote:
>> On 23/07/2026 17:18, Ilia Levi wrote:
>>> Currently vmf_insert_pfn() maps the dummy page as UC, inheriting the
>>> VMA's page protection which was set for the real MMIO region. This
>>> conflicts with the direct map's WB mapping of the same page, creating a
>>> cache type alias which is architecturally undefined on x86.
>>
>> Is this claim correct? AFAICT on x86 it pulls the caching type from the pfn, so if the page is allocated as WB, it should just use WB, no? I'm looking at pfnmap_setup_cachemode() on x86.
>>
>> Perhaps this is instead needed for non-x86?
>
> Right, or on x86 if PAT is disabled. Good catch!
With that perhaps tweaked to make it clearer,
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
>
>>
>>>
>>> Use vmf_insert_pfn_prot() with a WB pgprot instead. Also simplify to
>>> fault in the requested page instead of the whole VMA.
>>>
>>> Fixes: 1ffcf8b8ae8a ("drm/xe: Support for mmap-ing mmio regions")
>>> Reported-by: Sashiko <sashiko-bot@kernel.org>
>>> Closes: https://sashiko.dev/#/patchset/20260525125801.975038-6-ilia.levi%40intel.com
>>> Assisted-by: GitHub-Copilot:claude-opus-4.6
>>> Signed-off-by: Ilia Levi <ilia.levi@intel.com>
>>> ---
>>> drivers/gpu/drm/xe/xe_mmio_gem.c | 19 +++++--------------
>>> 1 file changed, 5 insertions(+), 14 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/xe/xe_mmio_gem.c b/drivers/gpu/drm/xe/xe_mmio_gem.c
>>> index f15a6a84af15..418a24bdfa4e 100644
>>> --- a/drivers/gpu/drm/xe/xe_mmio_gem.c
>>> +++ b/drivers/gpu/drm/xe/xe_mmio_gem.c
>>> @@ -172,14 +172,13 @@ static void xe_mmio_gem_release_dummy_page(struct drm_device *dev, void *res)
>>> __free_page((struct page *)res);
>>> }
>>> -static vm_fault_t xe_mmio_gem_vm_fault_dummy_page(struct vm_area_struct *vma)
>>> +static vm_fault_t xe_mmio_gem_vm_fault_dummy_page(struct vm_fault *vmf)
>>> {
>>> + struct vm_area_struct *vma = vmf->vma;
>>> struct drm_gem_object *base = vma->vm_private_data;
>>> struct drm_device *dev = base->dev;
>>> - vm_fault_t ret = VM_FAULT_NOPAGE;
>>> struct page *page;
>>> unsigned long pfn;
>>> - unsigned long i;
>>> page = alloc_page(GFP_KERNEL | __GFP_ZERO);
>>> if (!page)
>>> @@ -190,16 +189,8 @@ static vm_fault_t xe_mmio_gem_vm_fault_dummy_page(struct vm_area_struct *vma)
>>> pfn = page_to_pfn(page);
>>> - /* Map the entire VMA to the same dummy page */
>>> - for (i = 0; i < base->size; i += PAGE_SIZE) {
>>> - unsigned long addr = vma->vm_start + i;
>>> -
>>> - ret = vmf_insert_pfn(vma, addr, pfn);
>>> - if (ret & VM_FAULT_ERROR)
>>> - break;
>>> - }
>>> -
>>> - return ret;
>>> + return vmf_insert_pfn_prot(vma, vmf->address, pfn,
>>> + vm_get_page_prot(vma->vm_flags));
>>> }
>>> static vm_fault_t xe_mmio_gem_vm_fault(struct vm_fault *vmf)
>>> @@ -219,7 +210,7 @@ static vm_fault_t xe_mmio_gem_vm_fault(struct vm_fault *vmf)
>>> * It is assumed the userspace will receive the notification via some
>>> * other channel (e.g. drm uevent).
>>> */
>>> - return xe_mmio_gem_vm_fault_dummy_page(vma);
>>> + return xe_mmio_gem_vm_fault_dummy_page(vmf);
>>> }
>>> for (i = 0; i < base->size; i += PAGE_SIZE) {
>>
next prev parent reply other threads:[~2026-07-28 16:38 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 16:18 [PATCH v3 0/7] drm/xe/mmio_gem: fix fault handler and destroy path Ilia Levi
2026-07-23 16:18 ` [PATCH v3 1/7] drm/xe/mmio_gem: forbid VMA split Ilia Levi
2026-07-23 16:25 ` Matthew Auld
2026-07-23 16:18 ` [PATCH v3 2/7] drm/xe/mmio_gem: use write-back mapping for dummy page Ilia Levi
2026-07-23 17:16 ` Matthew Auld
2026-07-24 9:49 ` Levi, Ilia
2026-07-28 16:37 ` Matthew Auld [this message]
2026-07-23 16:18 ` [PATCH v3 3/7] drm/xe/mmio_gem: simplify fault handler loop Ilia Levi
2026-07-23 17:22 ` Matthew Auld
2026-07-23 16:18 ` [PATCH v3 4/7] drm/xe/mmio_gem: Revoke drm_vma_node on xe_mmio_gem destroy Ilia Levi
2026-07-23 16:18 ` [PATCH v3 5/7] drm/xe/mmio_gem: cache the dummy page per object Ilia Levi
2026-07-28 16:33 ` Matthew Auld
2026-07-23 16:18 ` [PATCH v3 6/7] drm/xe/mmio_gem: fix destroy flow Ilia Levi
2026-07-24 12:50 ` Matthew Auld
2026-07-23 16:18 ` [PATCH v3 7/7] drm/xe: convert PCI barrier mmap to use xe_mmio_gem Ilia Levi
2026-07-23 16:59 ` ✓ CI.KUnit: success for drm/xe/mmio_gem: fix fault handler and destroy path (rev3) Patchwork
2026-07-23 17:34 ` ✓ Xe.CI.BAT: " Patchwork
2026-07-24 17:14 ` ✓ Xe.CI.FULL: " Patchwork
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=aacb6ef7-6d09-4ad7-a7f2-e202a3867dfc@intel.com \
--to=matthew.auld@intel.com \
--cc=ilia.levi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=koby.elbaz@intel.com \
--cc=matthew.brost@intel.com \
--cc=meny.yossefi@intel.com \
--cc=sashiko-bot@kernel.org \
--cc=shuicheng.lin@intel.com \
--cc=thomas.hellstrom@intel.com \
/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.