Skip to content

i915: avoid register_fictitious_range on meteorlake#324

Open
amshafer wants to merge 2 commits into
freebsd:masterfrom
amshafer:master
Open

i915: avoid register_fictitious_range on meteorlake#324
amshafer wants to merge 2 commits into
freebsd:masterfrom
amshafer:master

Conversation

@amshafer
Copy link
Copy Markdown
Contributor

On my meteorlake system the info->aperture_base and size fields are not filled out. This seems to have something to do with my GPU having support for device local memory which doesn't get tracked in gmadr.start and mappable_end. This passes zeroes in and makes
register_fictitious_range panic.

This change works around this by simply not registering a fict range at all if the aperture tracking is invalid. This does have the not great side effect of garbling the framebuffer slightly but it prevents the panic and lets desktop usage happen. This workaround can be kept until we figure out what is going wrong with the framebuffer registering.

@wulf7
Copy link
Copy Markdown
Contributor

wulf7 commented Nov 16, 2024

What is the value of hw.intel_graphics_stolen_size and hw.intel_graphics_stolen_base sysctls on your system? If it is zero than update sys/x86/pci/pci_early_quirks.[ch] files with your IDS

@lutzbichler lutzbichler mentioned this pull request Jan 13, 2025
31 tasks
@emaste
Copy link
Copy Markdown
Member

emaste commented Jan 13, 2025

it is zero than update sys/x86/pci/pci_early_quirks.[ch] files with your IDS

On my Framework 13" Ultra 1 these are indeed zero. Maybe torvalds/linux@dbb2ffb. (Other than drm-kmod currently being in ports) is there a reason we couldn't use the upstream logic directly?

@amshafer
Copy link
Copy Markdown
Contributor Author

Yes I saw that as well. I've been waiting for the in-progress 6.7 update to complete so I can test with that commit. That commit alone did not apply cleanly on 6.6.

@dumbbell
Copy link
Copy Markdown
Member

dumbbell commented Jan 22, 2025

I made a change in #332 (the Linux 6.7 update) to use the same address and size that is used by vt(4). I don’t have the issue with my Intel 12th gen CPU/GPU, so I have no idea if it solves the issue. Could you please try it?

You will need a kernel from my freebsd-src branch (see #332 description) from tonight as well.

Edit: The change in question is independant of the 6.7 update by the way. It was just simpler for me to implement and test. If it fixes the actual problem, I will open a dedicated pull request.

@dumbbell
Copy link
Copy Markdown
Member

On my Framework 13" Ultra 1 these are indeed zero. Maybe torvalds/linux@dbb2ffb. (Other than drm-kmod currently being in ports) is there a reason we couldn't use the upstream logic directly?

This logic is already in for a few patches (though the code changed since the linked commit).

If I understand the code correctly, the computed address and size are used to reserve the memory range. If this fails, the i915 driver aborts the initialization. The amdgpu doesn’t appear to do the same reservation. Anyway, this reservation in the i915 driver is commented out on FreeBSD. linuxkpi doesn not have the called API yet. I’m not sure what it should call in FreeBSD.

On my meteorlake system the info->aperture_base and size fields are not
filled out. This seems to have something to do with my GPU having
support for device local memory which doesn't get tracked in gmadr.start
and mappable_end. This passes zeroes in and makes
register_fictitious_range panic.

This change works around this by simply not registering a fict range at
all if the aperture tracking is invalid. This does have the not great
side effect of garbling the framebuffer slightly but it prevents the
panic and lets desktop usage happen. This workaround can be kept until
we figure out what is going wrong with the framebuffer registering.
@dumbbell
Copy link
Copy Markdown
Member

I committed the workaround that resolves the color corruption issue.

As for the fictitious memory range, is this still a problem for yor?

@amshafer
Copy link
Copy Markdown
Contributor Author

I think it still is an issue as the memory range appears valid for me but doesn't work. This might be a MTL issue though. Your recent fixes did drastically simplify the workarounds I have to carry in my tree though so definitely an improvement.

amshafer added a commit to amshafer/drm-kmod that referenced this pull request Feb 25, 2026
This fixes issues with the smem_start being nonzero but invalid,
which caused panics on meteorlake.

The problem is that the GMADR was not getting initialized on mtl
which we need in order to use shmem framebuffers. We are falling
back to shmem framebuffers on freebsd because the Wa_22018444074
mtl hardware workaround disabled using stolen memory on mtl. We
end up trying to use shmem but due to Wa_22018444074 GMADR is
not valid so we end up with a value such as 0x2000 instead of a
valid pointer.

This change initializes GMADR on meteorlake. Linux has likely not
run into this as they do not actually consume the physical address
in smem_start like we do when we pass it to register_fictitious_range.

See freebsd#324
emaste pushed a commit to emaste/drm-kmod that referenced this pull request Apr 9, 2026
This fixes issues with the smem_start being nonzero but invalid,
which caused panics on meteorlake.

The problem is that the GMADR was not getting initialized on mtl
which we need in order to use shmem framebuffers. We are falling
back to shmem framebuffers on freebsd because the Wa_22018444074
mtl hardware workaround disabled using stolen memory on mtl. We
end up trying to use shmem but due to Wa_22018444074 GMADR is
not valid so we end up with a value such as 0x2000 instead of a
valid pointer.

This change initializes GMADR on meteorlake. Linux has likely not
run into this as they do not actually consume the physical address
in smem_start like we do when we pass it to register_fictitious_range.

See freebsd#324
emaste pushed a commit to emaste/drm-kmod that referenced this pull request May 4, 2026
This fixes issues with the smem_start being nonzero but invalid,
which caused panics on meteorlake.

The problem is that the GMADR was not getting initialized on mtl
which we need in order to use shmem framebuffers. We are falling
back to shmem framebuffers on freebsd because the Wa_22018444074
mtl hardware workaround disabled using stolen memory on mtl. We
end up trying to use shmem but due to Wa_22018444074 GMADR is
not valid so we end up with a value such as 0x2000 instead of a
valid pointer.

This change initializes GMADR on meteorlake. Linux has likely not
run into this as they do not actually consume the physical address
in smem_start like we do when we pass it to register_fictitious_range.

See freebsd#324
amshafer added a commit to amshafer/drm-kmod that referenced this pull request May 6, 2026
This fixes issues with the smem_start being nonzero but invalid,
which caused panics on meteorlake.

The problem is that the GMADR was not getting initialized on mtl
which we need in order to use shmem framebuffers. We are falling
back to shmem framebuffers on freebsd because the Wa_22018444074
mtl hardware workaround disabled using stolen memory on mtl. We
end up trying to use shmem but due to Wa_22018444074 GMADR is
not valid so we end up with a value such as 0x2000 instead of a
valid pointer.

This change initializes GMADR on meteorlake. Linux has likely not
run into this as they do not actually consume the physical address
in smem_start like we do when we pass it to register_fictitious_range.

See freebsd#324
amshafer added a commit to amshafer/drm-kmod that referenced this pull request May 8, 2026
This fixes issues with the smem_start being nonzero but invalid,
which caused panics on meteorlake.

The problem is that the GMADR was not getting initialized on mtl
which we need in order to use shmem framebuffers. We are falling
back to shmem framebuffers on freebsd because the Wa_22018444074
mtl hardware workaround disabled using stolen memory on mtl. We
end up trying to use shmem but due to Wa_22018444074 GMADR is
not valid so we end up with a value such as 0x2000 instead of a
valid pointer.

This change initializes GMADR on meteorlake. Linux has likely not
run into this as they do not actually consume the physical address
in smem_start like we do when we pass it to register_fictitious_range.

See freebsd#324
amshafer added a commit to amshafer/drm-kmod that referenced this pull request May 8, 2026
This fixes issues with the smem_start being nonzero but invalid,
which caused panics on meteorlake.

The problem is that the GMADR was not getting initialized on mtl
which we need in order to use shmem framebuffers. We are falling
back to shmem framebuffers on freebsd because the Wa_22018444074
mtl hardware workaround disabled using stolen memory on mtl. We
end up trying to use shmem but due to Wa_22018444074 GMADR is
not valid so we end up with a value such as 0x2000 instead of a
valid pointer.

This change initializes GMADR on meteorlake. Linux has likely not
run into this as they do not actually consume the physical address
in smem_start like we do when we pass it to register_fictitious_range.

See freebsd#324
@dumbbell dumbbell added the i915 i915 related problems label May 9, 2026
dumbbell pushed a commit that referenced this pull request May 11, 2026
This fixes issues with the smem_start being nonzero but invalid,
which caused panics on meteorlake.

The problem is that the GMADR was not getting initialized on mtl
which we need in order to use shmem framebuffers. We are falling
back to shmem framebuffers on freebsd because the Wa_22018444074
mtl hardware workaround disabled using stolen memory on mtl. We
end up trying to use shmem but due to Wa_22018444074 GMADR is
not valid so we end up with a value such as 0x2000 instead of a
valid pointer.

This change initializes GMADR on meteorlake. Linux has likely not
run into this as they do not actually consume the physical address
in smem_start like we do when we pass it to register_fictitious_range.

See #324
emaste pushed a commit to emaste/drm-kmod that referenced this pull request May 11, 2026
This fixes issues with the smem_start being nonzero but invalid,
which caused panics on meteorlake.

The problem is that the GMADR was not getting initialized on mtl
which we need in order to use shmem framebuffers. We are falling
back to shmem framebuffers on freebsd because the Wa_22018444074
mtl hardware workaround disabled using stolen memory on mtl. We
end up trying to use shmem but due to Wa_22018444074 GMADR is
not valid so we end up with a value such as 0x2000 instead of a
valid pointer.

This change initializes GMADR on meteorlake. Linux has likely not
run into this as they do not actually consume the physical address
in smem_start like we do when we pass it to register_fictitious_range.

See freebsd#324
dumbbell pushed a commit that referenced this pull request May 11, 2026
This fixes issues with the smem_start being nonzero but invalid,
which caused panics on meteorlake.

The problem is that the GMADR was not getting initialized on mtl
which we need in order to use shmem framebuffers. We are falling
back to shmem framebuffers on freebsd because the Wa_22018444074
mtl hardware workaround disabled using stolen memory on mtl. We
end up trying to use shmem but due to Wa_22018444074 GMADR is
not valid so we end up with a value such as 0x2000 instead of a
valid pointer.

This change initializes GMADR on meteorlake. Linux has likely not
run into this as they do not actually consume the physical address
in smem_start like we do when we pass it to register_fictitious_range.

See #324

(cherry picked from commit 52e96e1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

i915 i915 related problems

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants