* [PATCH RFC] drm/nouveau: Use write-combined maps for coherent on Tegra
@ 2026-07-25 23:28 Aaron Kling via B4 Relay
2026-07-28 8:38 ` Lucas Stach
0 siblings, 1 reply; 4+ messages in thread
From: Aaron Kling via B4 Relay @ 2026-07-25 23:28 UTC (permalink / raw)
To: Lyude Paul, Danilo Krummrich, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter
Cc: dri-devel, nouveau, linux-kernel, Faith Ekstrand, Aaron Kling
From: Faith Ekstrand <faith.ekstrand@collabora.com>
On Tegra devices, uncached maps traslate to device memory, causing
unaligned accesses by userspace resulting in a SIGBUS. Instead, use
write-combined maps to ensure proper access.
Signed-off-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Co-developed-by: Aaron Kling <webgeek1234@gmail.com>
Signed-off-by: Aaron Kling <webgeek1234@gmail.com>
---
This patch is marked RFC because there is not complete confidence that
the change is correct. Without this change, nouveau can easily hit
sigbus errors in Android UI rendering via nvk or running vulkan deqp
tests on Tegra. Changing coherent maps to use write-combined stops the
crashing, but it is unknown what the performance impact is, if any.
---
drivers/gpu/drm/nouveau/nouveau_sgdma.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
index fa3b4ebf38a83..10f6ef1c541bd 100644
--- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
+++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
@@ -72,9 +72,12 @@ nouveau_sgdma_create_ttm(struct ttm_buffer_object *bo, uint32_t page_flags)
struct nouveau_sgdma_be *nvbe;
enum ttm_caching caching;
- if (nvbo->force_coherent)
- caching = ttm_uncached;
- else if (drm->agp.bridge)
+ if (nvbo->force_coherent) {
+ if (drm->client.device.info.platform == NV_DEVICE_INFO_V0_SOC)
+ caching = ttm_write_combined;
+ else
+ caching = ttm_uncached;
+ } else if (drm->agp.bridge)
caching = ttm_write_combined;
else
caching = ttm_cached;
---
base-commit: 1a1757b76427f6201bfe0bf1bea9f7574f332a93
change-id: 20260725-tegra-coherent-wc-19941d1a5a60
Best regards,
--
Aaron Kling <webgeek1234@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RFC] drm/nouveau: Use write-combined maps for coherent on Tegra
2026-07-25 23:28 [PATCH RFC] drm/nouveau: Use write-combined maps for coherent on Tegra Aaron Kling via B4 Relay
@ 2026-07-28 8:38 ` Lucas Stach
2026-08-09 6:06 ` Aaron Kling
0 siblings, 1 reply; 4+ messages in thread
From: Lucas Stach @ 2026-07-28 8:38 UTC (permalink / raw)
To: webgeek1234, Lyude Paul, Danilo Krummrich, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter
Cc: dri-devel, nouveau, linux-kernel, Faith Ekstrand
Am Samstag, dem 25.07.2026 um 18:28 -0500 schrieb Aaron Kling via B4
Relay:
> From: Faith Ekstrand <faith.ekstrand@collabora.com>
>
> On Tegra devices, uncached maps traslate to device memory, causing
> unaligned accesses by userspace resulting in a SIGBUS. Instead, use
> write-combined maps to ensure proper access.
>
This is not only an issue on Tegra. All ARM64 platforms translate
uncached to device memory, which does not support unaligned access. So
the issue could happen in the same way when connecting a discrete GPU
to a ARM64 platform with PCIe support.
I would argue that there is no downside to always using write combined
memory for coherent buffers. You gain potentially faster writes while
the only issue is that writes may get delayed visibility at the device
side. However, I don't think anyone uses coherent buffers to modify the
content from the CPU side while the device is operating on the buffer.
For all regular use-case the memory barrier in FIRE_RING() will make
sure that the buffered writes are visible to the device before the
commands using the buffer are made visible to the device.
Regards,
Lucas
> Signed-off-by: Faith Ekstrand <faith.ekstrand@collabora.com>
> Co-developed-by: Aaron Kling <webgeek1234@gmail.com>
> Signed-off-by: Aaron Kling <webgeek1234@gmail.com>
> ---
> This patch is marked RFC because there is not complete confidence that
> the change is correct. Without this change, nouveau can easily hit
> sigbus errors in Android UI rendering via nvk or running vulkan deqp
> tests on Tegra. Changing coherent maps to use write-combined stops the
> crashing, but it is unknown what the performance impact is, if any.
> ---
> drivers/gpu/drm/nouveau/nouveau_sgdma.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
> index fa3b4ebf38a83..10f6ef1c541bd 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
> @@ -72,9 +72,12 @@ nouveau_sgdma_create_ttm(struct ttm_buffer_object *bo, uint32_t page_flags)
> struct nouveau_sgdma_be *nvbe;
> enum ttm_caching caching;
>
> - if (nvbo->force_coherent)
> - caching = ttm_uncached;
> - else if (drm->agp.bridge)
> + if (nvbo->force_coherent) {
> + if (drm->client.device.info.platform == NV_DEVICE_INFO_V0_SOC)
> + caching = ttm_write_combined;
> + else
> + caching = ttm_uncached;
> + } else if (drm->agp.bridge)
> caching = ttm_write_combined;
> else
> caching = ttm_cached;
>
> ---
> base-commit: 1a1757b76427f6201bfe0bf1bea9f7574f332a93
> change-id: 20260725-tegra-coherent-wc-19941d1a5a60
>
> Best regards,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RFC] drm/nouveau: Use write-combined maps for coherent on Tegra
2026-07-28 8:38 ` Lucas Stach
@ 2026-08-09 6:06 ` Aaron Kling
2026-08-11 1:01 ` Faith Ekstrand
0 siblings, 1 reply; 4+ messages in thread
From: Aaron Kling @ 2026-08-09 6:06 UTC (permalink / raw)
To: dev
Cc: Lyude Paul, Danilo Krummrich, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, dri-devel,
nouveau, linux-kernel, Faith Ekstrand
On Tue, Jul 28, 2026 at 3:38 AM Lucas Stach <dev@lynxeye.de> wrote:
>
> Am Samstag, dem 25.07.2026 um 18:28 -0500 schrieb Aaron Kling via B4
> Relay:
> > From: Faith Ekstrand <faith.ekstrand@collabora.com>
> >
> > On Tegra devices, uncached maps traslate to device memory, causing
> > unaligned accesses by userspace resulting in a SIGBUS. Instead, use
> > write-combined maps to ensure proper access.
> >
> This is not only an issue on Tegra. All ARM64 platforms translate
> uncached to device memory, which does not support unaligned access. So
> the issue could happen in the same way when connecting a discrete GPU
> to a ARM64 platform with PCIe support.
>
> I would argue that there is no downside to always using write combined
> memory for coherent buffers. You gain potentially faster writes while
> the only issue is that writes may get delayed visibility at the device
> side. However, I don't think anyone uses coherent buffers to modify the
> content from the CPU side while the device is operating on the buffer.
> For all regular use-case the memory barrier in FIRE_RING() will make
> sure that the buffered writes are visible to the device before the
> commands using the buffer are made visible to the device.
Should I send a new revision that sets write combined for all coherent
then? I only have Tegra devices to verify this on, so I can't attest
to how this affects discrete cards.
Aaron
> Regards,
> Lucas
>
> > Signed-off-by: Faith Ekstrand <faith.ekstrand@collabora.com>
> > Co-developed-by: Aaron Kling <webgeek1234@gmail.com>
> > Signed-off-by: Aaron Kling <webgeek1234@gmail.com>
> > ---
> > This patch is marked RFC because there is not complete confidence that
> > the change is correct. Without this change, nouveau can easily hit
> > sigbus errors in Android UI rendering via nvk or running vulkan deqp
> > tests on Tegra. Changing coherent maps to use write-combined stops the
> > crashing, but it is unknown what the performance impact is, if any.
> > ---
> > drivers/gpu/drm/nouveau/nouveau_sgdma.c | 9 ++++++---
> > 1 file changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
> > index fa3b4ebf38a83..10f6ef1c541bd 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
> > +++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
> > @@ -72,9 +72,12 @@ nouveau_sgdma_create_ttm(struct ttm_buffer_object *bo, uint32_t page_flags)
> > struct nouveau_sgdma_be *nvbe;
> > enum ttm_caching caching;
> >
> > - if (nvbo->force_coherent)
> > - caching = ttm_uncached;
> > - else if (drm->agp.bridge)
> > + if (nvbo->force_coherent) {
> > + if (drm->client.device.info.platform == NV_DEVICE_INFO_V0_SOC)
> > + caching = ttm_write_combined;
> > + else
> > + caching = ttm_uncached;
> > + } else if (drm->agp.bridge)
> > caching = ttm_write_combined;
> > else
> > caching = ttm_cached;
> >
> > ---
> > base-commit: 1a1757b76427f6201bfe0bf1bea9f7574f332a93
> > change-id: 20260725-tegra-coherent-wc-19941d1a5a60
> >
> > Best regards,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RFC] drm/nouveau: Use write-combined maps for coherent on Tegra
2026-08-09 6:06 ` Aaron Kling
@ 2026-08-11 1:01 ` Faith Ekstrand
0 siblings, 0 replies; 4+ messages in thread
From: Faith Ekstrand @ 2026-08-11 1:01 UTC (permalink / raw)
To: Aaron Kling
Cc: dev, Lyude Paul, Danilo Krummrich, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
dri-devel, nouveau, linux-kernel, Karol Herbst
~Faith Ekstrand
From: Aaron Kling <webgeek1234@gmail.com>
To: <dev@lynxeye.de>
Cc: "Lyude Paul"<lyude@redhat.com>, "Danilo Krummrich"<dakr@kernel.org>, "Maarten Lankhorst"<maarten.lankhorst@linux.intel.com>, "Maxime Ripard"<mripard@kernel.org>, "Thomas Zimmermann"<tzimmermann@suse.de>, "David Airlie"<airlied@gmail.com>, "Simona Vetter"<simona@ffwll.ch>, <dri-devel@lists.freedesktop.org>, <nouveau@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>, "Faith Ekstrand"<faith.ekstrand@collabora.com>
Date: Sun, 09 Aug 2026 02:06:51 -0400
Subject: Re: [PATCH RFC] drm/nouveau: Use write-combined maps for coherent on Tegra
> On Tue, Jul 28, 2026 at 3:38 AM Lucas Stach <dev@lynxeye.de> wrote:
> >
> > Am Samstag, dem 25.07.2026 um 18:28 -0500 schrieb Aaron Kling via B4
> > Relay:
> > > From: Faith Ekstrand <faith.ekstrand@collabora.com>
> > >
> > > On Tegra devices, uncached maps traslate to device memory, causing
> > > unaligned accesses by userspace resulting in a SIGBUS. Instead, use
> > > write-combined maps to ensure proper access.
> > >
> > This is not only an issue on Tegra. All ARM64 platforms translate
> > uncached to device memory, which does not support unaligned access. So
> > the issue could happen in the same way when connecting a discrete GPU
> > to a ARM64 platform with PCIe support.
> >
> > I would argue that there is no downside to always using write combined
> > memory for coherent buffers. You gain potentially faster writes while
> > the only issue is that writes may get delayed visibility at the device
> > side. However, I don't think anyone uses coherent buffers to modify the
> > content from the CPU side while the device is operating on the buffer.
> > For all regular use-case the memory barrier in FIRE_RING() will make
> > sure that the buffered writes are visible to the device before the
> > commands using the buffer are made visible to the device.
>
> Should I send a new revision that sets write combined for all coherent
> then? I only have Tegra devices to verify this on, so I can't attest
> to how this affects discrete cards.
Yeah, generally we should be using WC on discrete cards, too. The big question is if nouveau is doing some shenanigans behind the scnenes with cache types. I'm pretty sure I've had this discussion with nouveau people and we came to the conclusion that uncached mapped to WC on discrete for some reason. If we're getting actual uncached maps instead of WC on discrete GPUs, that's a serious performance problem but I don't think we are. I've CC'd Karol in case he remembers what's going on here.
~Faith
> Aaron
>
> > Regards,
> > Lucas
> >
> > > Signed-off-by: Faith Ekstrand <faith.ekstrand@collabora.com>
> > > Co-developed-by: Aaron Kling <webgeek1234@gmail.com>
> > > Signed-off-by: Aaron Kling <webgeek1234@gmail.com>
> > > ---
> > > This patch is marked RFC because there is not complete confidence that
> > > the change is correct. Without this change, nouveau can easily hit
> > > sigbus errors in Android UI rendering via nvk or running vulkan deqp
> > > tests on Tegra. Changing coherent maps to use write-combined stops the
> > > crashing, but it is unknown what the performance impact is, if any.
> > > ---
> > > drivers/gpu/drm/nouveau/nouveau_sgdma.c | 9 ++++++---
> > > 1 file changed, 6 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
> > > index fa3b4ebf38a83..10f6ef1c541bd 100644
> > > --- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
> > > +++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
> > > @@ -72,9 +72,12 @@ nouveau_sgdma_create_ttm(struct ttm_buffer_object *bo, uint32_t page_flags)
> > > struct nouveau_sgdma_be *nvbe;
> > > enum ttm_caching caching;
> > >
> > > - if (nvbo->force_coherent)
> > > - caching = ttm_uncached;
> > > - else if (drm->agp.bridge)
> > > + if (nvbo->force_coherent) {
> > > + if (drm->client.device.info.platform == NV_DEVICE_INFO_V0_SOC)
> > > + caching = ttm_write_combined;
> > > + else
> > > + caching = ttm_uncached;
> > > + } else if (drm->agp.bridge)
> > > caching = ttm_write_combined;
> > > else
> > > caching = ttm_cached;
> > >
> > > ---
> > > base-commit: 1a1757b76427f6201bfe0bf1bea9f7574f332a93
> > > change-id: 20260725-tegra-coherent-wc-19941d1a5a60
> > >
> > > Best regards,
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-11 1:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-25 23:28 [PATCH RFC] drm/nouveau: Use write-combined maps for coherent on Tegra Aaron Kling via B4 Relay
2026-07-28 8:38 ` Lucas Stach
2026-08-09 6:06 ` Aaron Kling
2026-08-11 1:01 ` Faith Ekstrand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®