* [PATCH v5 0/5] Enable atomic modesetting by default
@ 2026-07-30 20:45 Lyude Paul
2026-07-30 20:45 ` [PATCH v5 1/5] drm/nouveau: Fix cleanup bug in nouveau_drm_device_new() Lyude Paul
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Lyude Paul @ 2026-07-30 20:45 UTC (permalink / raw)
To: dri-devel, nouveau, linux-kernel
Cc: Maarten Lankhorst, Simona Vetter, David Airlie,
Thomas Zimmermann, Maxime Ripard, Danilo Krummrich, Lyude Paul
Nouveau is one of the very few modern hardware drivers in the kernel that
doesn't have atomic modesetting enabled by default, in part because when it
was originally written by Ben there wasn't much in the way of good atomic
modesetting clients to actually test things out with.
Nowadays however, atomic modesetting is very much the norm - and support in
userspace for non-atomic drivers is starting to bitrot a bit - leading to
its own set of issues. At the same time, many of those issues are fixed by
just turning on atomic in nouveau. Plus, I've been running nouveau with
atomic modesetting on by default for most of the machines I work on, and
I've already fixed quite a number of issues to the point where things seem
quite stable (excluding a single screen flashing bug on my desktop, which I
am not particularly convinced has anything to do with atomic modesetting).
This patch series enables atomic modesetting by default, at least for
NV50 and newer. NV04 is left unchanged, as atomic modesetting was never
implemented for it. This series also enforces leaving atomic modesetting
disabled on <NV50, and adds the value of nouveau.atomic to our kernel
debug output.
Previous version of this patch series:
https://patchwork.freedesktop.org/series/171310/
Lyude Paul (5):
drm/nouveau: Fix cleanup bug in nouveau_drm_device_new()
drm/nouveau: Print the nouveau.atomic parameter in
nouveau_display_options()
drm/nouveau: Fix drm_driver struct/nouveau.atomic parameter handling
drm/nouveau/kms: Only allow enabling atomic modesetting on nv50+
drm/nouveau/kms/nv50-: Enable atomic modesetting by default
drivers/gpu/drm/nouveau/nouveau_drm.c | 40 ++++++++++++++-------------
drivers/gpu/drm/nouveau/nouveau_drv.h | 1 +
2 files changed, 22 insertions(+), 19 deletions(-)
base-commit: 35b6cf07851a2b430b0eefbcb7b5a856f9030264
--
2.55.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v5 1/5] drm/nouveau: Fix cleanup bug in nouveau_drm_device_new()
2026-07-30 20:45 [PATCH v5 0/5] Enable atomic modesetting by default Lyude Paul
@ 2026-07-30 20:45 ` Lyude Paul
2026-07-30 20:45 ` [PATCH v5 2/5] drm/nouveau: Print the nouveau.atomic parameter in nouveau_display_options() Lyude Paul
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Lyude Paul @ 2026-07-30 20:45 UTC (permalink / raw)
To: dri-devel, nouveau, linux-kernel
Cc: Maarten Lankhorst, Simona Vetter, David Airlie,
Thomas Zimmermann, Maxime Ripard, Danilo Krummrich, Lyude Paul
Sashiko caught this while reviewing the patches for enabling atomic by
default - if we fail to allocate the DRM device pointer, we'll attempt to
free the error pointer that it returns rather than the actual struct.
Let's fix this while we're at it.
Signed-off-by: Lyude Paul <lyude@redhat.com>
---
V3:
* Don't use devm, that will just break during unbind (Sashiko).
V5:
* Fix silly rebasing error
* Go back to the old style of error handling since we're not using a second
allocation for drm_driver anymore.
drivers/gpu/drm/nouveau/nouveau_drm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 4d1ad718e09b7..a348115518ec4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -749,7 +749,8 @@ nouveau_drm_device_new(const struct drm_driver *drm_driver, struct device *paren
drm->dev = drm_dev_alloc(drm_driver, parent);
if (IS_ERR(drm->dev)) {
ret = PTR_ERR(drm->dev);
- goto done;
+ kfree(drm);
+ return ERR_PTR(ret);
}
drm->dev->dev_private = drm;
--
2.55.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v5 2/5] drm/nouveau: Print the nouveau.atomic parameter in nouveau_display_options()
2026-07-30 20:45 [PATCH v5 0/5] Enable atomic modesetting by default Lyude Paul
2026-07-30 20:45 ` [PATCH v5 1/5] drm/nouveau: Fix cleanup bug in nouveau_drm_device_new() Lyude Paul
@ 2026-07-30 20:45 ` Lyude Paul
2026-07-30 20:45 ` [PATCH v5 3/5] drm/nouveau: Fix drm_driver struct/nouveau.atomic parameter handling Lyude Paul
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Lyude Paul @ 2026-07-30 20:45 UTC (permalink / raw)
To: dri-devel, nouveau, linux-kernel
Cc: Maarten Lankhorst, Simona Vetter, David Airlie,
Thomas Zimmermann, Maxime Ripard, Danilo Krummrich, Lyude Paul
Seems like we never remembered to start printing the value for this, so
let's start to aid in troubleshooting in case we run into any issues with
atomic.
Signed-off-by: Lyude Paul <lyude@redhat.com>
---
drivers/gpu/drm/nouveau/nouveau_drm.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index a348115518ec4..451009adee0de 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -1417,6 +1417,7 @@ static void nouveau_display_options(void)
DRM_DEBUG_DRIVER("... debug : %s\n", nouveau_debug);
DRM_DEBUG_DRIVER("... noaccel : %d\n", nouveau_noaccel);
DRM_DEBUG_DRIVER("... modeset : %d\n", nouveau_modeset);
+ DRM_DEBUG_DRIVER("... atomic : %d\n", nouveau_atomic);
DRM_DEBUG_DRIVER("... runpm : %d\n", nouveau_runtime_pm);
DRM_DEBUG_DRIVER("... vram_pushbuf : %d\n", nouveau_vram_pushbuf);
DRM_DEBUG_DRIVER("... hdmimhz : %d\n", nouveau_hdmimhz);
--
2.55.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v5 3/5] drm/nouveau: Fix drm_driver struct/nouveau.atomic parameter handling
2026-07-30 20:45 [PATCH v5 0/5] Enable atomic modesetting by default Lyude Paul
2026-07-30 20:45 ` [PATCH v5 1/5] drm/nouveau: Fix cleanup bug in nouveau_drm_device_new() Lyude Paul
2026-07-30 20:45 ` [PATCH v5 2/5] drm/nouveau: Print the nouveau.atomic parameter in nouveau_display_options() Lyude Paul
@ 2026-07-30 20:45 ` Lyude Paul
2026-07-30 20:45 ` [PATCH v5 4/5] drm/nouveau/kms: Only allow enabling atomic modesetting on nv50+ Lyude Paul
2026-07-30 20:45 ` [PATCH v5 5/5] drm/nouveau/kms/nv50-: Enable atomic modesetting by default Lyude Paul
4 siblings, 0 replies; 6+ messages in thread
From: Lyude Paul @ 2026-07-30 20:45 UTC (permalink / raw)
To: dri-devel, nouveau, linux-kernel
Cc: Maarten Lankhorst, Simona Vetter, David Airlie,
Thomas Zimmermann, Maxime Ripard, Danilo Krummrich, Lyude Paul
The way we handled the nouveau.atomic module parameter before was fairly
broken, and had a number of issues:
- It was only ever actually parsed in the case of PCI devices.
- When nouveau.atomic was enabled, it would add the cap for atomic
modesetting to the global driver_pci structure. This meant that if one
GPU on a system supported atomic and another didn't, it would still get
enabled for both.
Looking into this exposed further silliness in the way that we actually
handle the drm_driver struct. We have one global structure for platform
devices, and another for PCI devices - both of which are literally
identical.
So before we start preparing to enable atomic modesetting by default, let's
fix this. Instead of sharing driver_pci and driver_platform, we move the
drm_driver struct we use over to the nouveau_drm struct, and then copy the
contents of driver_stub over to it. We then convert driver_stub to a const,
and move the handling of the nouveau.atomic module parameter into
nouveau_drm_device_new(), and conditionally add the atomic modesetting
capability to the embedded drm_driver struct.
Doing this is also preferable, as the next step for enabling atomic
modesetting by default will be ensuring that we don't enable it for legacy
devices that still don't support it. This requires only checking the atomic
modesetting module parameter after the NVIF device is ready, as this allows
us to check the GPU family that nouveau is running on.
Signed-off-by: Lyude Paul <lyude@redhat.com>
---
V2:
* s/driver_pci/drm_driver/
* Dynamically allocate drm_driver struct, get rid of duplicate global
driver structs to fix another Sashiko issue.
V3:
* Don't use devm (sashiko)
V4:
* Don't return 0 by mistake (thanks C)
drivers/gpu/drm/nouveau/nouveau_drm.c | 27 +++++++++++----------------
drivers/gpu/drm/nouveau/nouveau_drv.h | 1 +
2 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 451009adee0de..9cd12ebc7e449 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -111,9 +111,7 @@ MODULE_PARM_DESC(runpm, "disable (0), force enable (1), optimus only default (-1
static int nouveau_runtime_pm = -1;
module_param_named(runpm, nouveau_runtime_pm, int, 0400);
-static struct drm_driver driver_stub;
-static struct drm_driver driver_pci;
-static struct drm_driver driver_platform;
+static const struct drm_driver driver_stub;
#ifdef CONFIG_DEBUG_FS
struct dentry *nouveau_debugfs_root;
@@ -727,8 +725,7 @@ nouveau_drm_device_del(struct nouveau_drm *drm)
}
static struct nouveau_drm *
-nouveau_drm_device_new(const struct drm_driver *drm_driver, struct device *parent,
- struct nvkm_device *device)
+nouveau_drm_device_new(struct device *parent, struct nvkm_device *device)
{
static const struct nvif_mclass
mmus[] = {
@@ -744,9 +741,10 @@ nouveau_drm_device_new(const struct drm_driver *drm_driver, struct device *paren
if (!drm)
return ERR_PTR(-ENOMEM);
+ drm->drm_driver = driver_stub;
drm->nvkm = device;
- drm->dev = drm_dev_alloc(drm_driver, parent);
+ drm->dev = drm_dev_alloc(&drm->drm_driver, parent);
if (IS_ERR(drm->dev)) {
ret = PTR_ERR(drm->dev);
kfree(drm);
@@ -771,6 +769,9 @@ nouveau_drm_device_new(const struct drm_driver *drm_driver, struct device *paren
goto done;
}
+ if (nouveau_atomic)
+ drm->drm_driver.driver_features |= DRIVER_ATOMIC;
+
ret = nvif_device_map(&drm->device);
if (ret) {
NV_ERROR(drm, "Failed to map PRI: %d\n", ret);
@@ -874,16 +875,13 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
return ret;
/* Remove conflicting drivers (vesafb, efifb etc). */
- ret = aperture_remove_conflicting_pci_devices(pdev, driver_pci.name);
+ ret = aperture_remove_conflicting_pci_devices(pdev, driver_stub.name);
if (ret)
goto fail_nvkm;
pci_set_master(pdev);
- if (nouveau_atomic)
- driver_pci.driver_features |= DRIVER_ATOMIC;
-
- drm = nouveau_drm_device_new(&driver_pci, &pdev->dev, device);
+ drm = nouveau_drm_device_new(&pdev->dev, device);
if (IS_ERR(drm)) {
ret = PTR_ERR(drm);
goto fail_nvkm;
@@ -1360,7 +1358,7 @@ nouveau_driver_fops = {
.fop_flags = FOP_UNSIGNED_OFFSET,
};
-static struct drm_driver
+static const struct drm_driver
driver_stub = {
.driver_features = DRIVER_GEM |
DRIVER_SYNCOBJ | DRIVER_SYNCOBJ_TIMELINE |
@@ -1457,7 +1455,7 @@ nouveau_platform_device_create(const struct nvkm_device_tegra_func *func,
if (err)
goto err_free;
- drm = nouveau_drm_device_new(&driver_platform, &pdev->dev, *pdevice);
+ drm = nouveau_drm_device_new(&pdev->dev, *pdevice);
if (IS_ERR(drm)) {
err = PTR_ERR(drm);
goto err_free;
@@ -1482,9 +1480,6 @@ nouveau_drm_init(void)
{
int ret;
- driver_pci = driver_stub;
- driver_platform = driver_stub;
-
nouveau_display_options();
if (nouveau_modeset == -1) {
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 5fc75dc750ed0..5cc0001134e74 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -216,6 +216,7 @@ struct nouveau_drm {
struct nouveau_cli client;
struct drm_device *dev;
+ struct drm_driver drm_driver;
struct list_head clients;
--
2.55.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v5 4/5] drm/nouveau/kms: Only allow enabling atomic modesetting on nv50+
2026-07-30 20:45 [PATCH v5 0/5] Enable atomic modesetting by default Lyude Paul
` (2 preceding siblings ...)
2026-07-30 20:45 ` [PATCH v5 3/5] drm/nouveau: Fix drm_driver struct/nouveau.atomic parameter handling Lyude Paul
@ 2026-07-30 20:45 ` Lyude Paul
2026-07-30 20:45 ` [PATCH v5 5/5] drm/nouveau/kms/nv50-: Enable atomic modesetting by default Lyude Paul
4 siblings, 0 replies; 6+ messages in thread
From: Lyude Paul @ 2026-07-30 20:45 UTC (permalink / raw)
To: dri-devel, nouveau, linux-kernel
Cc: Maarten Lankhorst, Simona Vetter, David Airlie,
Thomas Zimmermann, Maxime Ripard, Danilo Krummrich, Lyude Paul
Atomic modesetting support was never added for pre-nv50 chipsets, so make
sure we don't allow it to be forced on. Additionally, print a small warning
when it's not supported.
Signed-off-by: Lyude Paul <lyude@redhat.com>
---
V2:
* Check against info.family, not info.chipset
drivers/gpu/drm/nouveau/nouveau_drm.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 9cd12ebc7e449..bfe9d6fe450a5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -769,8 +769,12 @@ nouveau_drm_device_new(struct device *parent, struct nvkm_device *device)
goto done;
}
- if (nouveau_atomic)
- drm->drm_driver.driver_features |= DRIVER_ATOMIC;
+ if (nouveau_atomic) {
+ if (drm->device.info.family >= NV_DEVICE_INFO_V0_TESLA)
+ drm->drm_driver.driver_features |= DRIVER_ATOMIC;
+ else
+ NV_WARN(drm, "Atomic modesetting not supported (needs nv50+)\n");
+ }
ret = nvif_device_map(&drm->device);
if (ret) {
--
2.55.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v5 5/5] drm/nouveau/kms/nv50-: Enable atomic modesetting by default
2026-07-30 20:45 [PATCH v5 0/5] Enable atomic modesetting by default Lyude Paul
` (3 preceding siblings ...)
2026-07-30 20:45 ` [PATCH v5 4/5] drm/nouveau/kms: Only allow enabling atomic modesetting on nv50+ Lyude Paul
@ 2026-07-30 20:45 ` Lyude Paul
4 siblings, 0 replies; 6+ messages in thread
From: Lyude Paul @ 2026-07-30 20:45 UTC (permalink / raw)
To: dri-devel, nouveau, linux-kernel
Cc: Maarten Lankhorst, Simona Vetter, David Airlie,
Thomas Zimmermann, Maxime Ripard, Danilo Krummrich, Lyude Paul
Nouveau is one of the very few modern hardware drivers in the kernel that
doesn't have atomic modesetting enabled by default, in part because when it
was originally written by Ben there wasn't much in the way of good atomic
modesetting clients to actually test things out with.
Nowadays however, atomic modesetting is very much the norm - and support in
userspace for non-atomic drivers is starting to bitrot a bit - leading to
its own set of issues. At the same time, many of those issues are fixed by
just turning on atomic in nouveau. Plus, I've been running nouveau with
atomic modesetting on by default for most of the machines I work on, and
I've already fixed quite a number of issues to the point where things seem
quite stable (excluding a single screen flashing bug on my desktop, which I
am not particularly convinced has anything to do with atomic modesetting).
Now that we've protected against breaking things for chipsets where atomic
isn't supported (<nv50) - let's enable it by default on generations of
hardware that support it. We'll leave the module parameter around for the
time being, as turning it off may be helpful in the possibility that we hit
regressions.
Signed-off-by: Lyude Paul <lyude@redhat.com>
---
drivers/gpu/drm/nouveau/nouveau_drm.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index bfe9d6fe450a5..228760215a97b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -103,8 +103,9 @@ MODULE_PARM_DESC(modeset, "enable driver (default: auto, "
int nouveau_modeset = -1;
module_param_named(modeset, nouveau_modeset, int, 0400);
-MODULE_PARM_DESC(atomic, "Expose atomic ioctl (default: disabled)");
-static int nouveau_atomic = 0;
+MODULE_PARM_DESC(atomic, "Expose atomic ioctl (default: auto, "
+ "0 = disabled, 1 = enabled)");
+static int nouveau_atomic = -1;
module_param_named(atomic, nouveau_atomic, int, 0400);
MODULE_PARM_DESC(runpm, "disable (0), force enable (1), optimus only default (-1)");
@@ -769,10 +770,10 @@ nouveau_drm_device_new(struct device *parent, struct nvkm_device *device)
goto done;
}
- if (nouveau_atomic) {
+ if (nouveau_atomic != 0) {
if (drm->device.info.family >= NV_DEVICE_INFO_V0_TESLA)
drm->drm_driver.driver_features |= DRIVER_ATOMIC;
- else
+ else if (nouveau_atomic == 1)
NV_WARN(drm, "Atomic modesetting not supported (needs nv50+)\n");
}
--
2.55.0
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-07-30 20:46 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-30 20:45 [PATCH v5 0/5] Enable atomic modesetting by default Lyude Paul
2026-07-30 20:45 ` [PATCH v5 1/5] drm/nouveau: Fix cleanup bug in nouveau_drm_device_new() Lyude Paul
2026-07-30 20:45 ` [PATCH v5 2/5] drm/nouveau: Print the nouveau.atomic parameter in nouveau_display_options() Lyude Paul
2026-07-30 20:45 ` [PATCH v5 3/5] drm/nouveau: Fix drm_driver struct/nouveau.atomic parameter handling Lyude Paul
2026-07-30 20:45 ` [PATCH v5 4/5] drm/nouveau/kms: Only allow enabling atomic modesetting on nv50+ Lyude Paul
2026-07-30 20:45 ` [PATCH v5 5/5] drm/nouveau/kms/nv50-: Enable atomic modesetting by default Lyude Paul
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®