Nova and its uAPI are under active upstream development. Require users
to acknowledge that the uAPI is not yet stable and may change
incompatibly before enabling the driver.

Refuse to load unless acknowledge_unstable_uapi=1 is set, and taint the
kernel when enabled. This keeps use of the unstable interfaces an
explicit opt-in while they are developed upstream.

Signed-off-by: Danilo Krummrich <[email protected]>
---
 drivers/gpu/drm/nova/Kconfig | 11 +++++++-
 drivers/gpu/drm/nova/nova.rs | 55 ++++++++++++++++++++++++++++++++++--
 2 files changed, 63 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/nova/Kconfig b/drivers/gpu/drm/nova/Kconfig
index ba16c74401f8..2cb62517b2f9 100644
--- a/drivers/gpu/drm/nova/Kconfig
+++ b/drivers/gpu/drm/nova/Kconfig
@@ -12,6 +12,15 @@ config DRM_NOVA
          Choose this if you want to build the Nova DRM driver for Nvidia
          GSP-based GPUs.
 
-         This driver is work in progress and may not be functional.
+         This driver is under active upstream development and may not be
+         functional. Its uAPI is intended to be developed upstream alongside
+         the driver and is not yet stable. It may change incompatibly during
+         development.
+
+         Loading requires the acknowledge_unstable_uapi=1 module parameter, or
+         nova-drm.acknowledge_unstable_uapi=1 on the kernel command line when
+         built in.
+
+         Enabling the driver taints the kernel.
 
          If M is selected, the module will be called nova-drm.
diff --git a/drivers/gpu/drm/nova/nova.rs b/drivers/gpu/drm/nova/nova.rs
index 1fd454c7e0df..ad68f6e1a613 100644
--- a/drivers/gpu/drm/nova/nova.rs
+++ b/drivers/gpu/drm/nova/nova.rs
@@ -2,16 +2,67 @@
 
 //! Nova DRM Driver
 
+use kernel::{
+    auxiliary,
+    driver::Registration,
+    panic::{
+        self,
+        Lockdep,
+        Taint, //
+    },
+    prelude::*,
+    InPlaceModule, //
+};
+
 mod driver;
 mod file;
 mod gem;
 
 use crate::driver::NovaDriver;
 
-kernel::module_auxiliary_driver! {
-    type: NovaDriver,
+module! {
+    type: NovaModule,
     name: "nova-drm",
     authors: ["Danilo Krummrich"],
     description: "Nova GPU driver",
     license: "GPL v2",
+    params: {
+        acknowledge_unstable_uapi: bool {
+            default: false,
+            description: "Acknowledge that Nova and its uAPI are under active 
upstream development \
+                          and the uAPI may change incompatibly; enable the 
driver (taints kernel)",
+        },
+    },
+}
+
+#[pin_data]
+struct NovaModule {
+    #[pin]
+    _driver: Registration<auxiliary::Adapter<NovaDriver>>,
+}
+
+impl NovaModule {
+    fn check_unstable_uapi() -> Result {
+        pr_warn!("Nova and its uAPI are under active upstream development\n");
+
+        if !module_parameters::acknowledge_unstable_uapi.value() {
+            pr_err!("Driver disabled: Nova's uAPI is unstable and may change 
incompatibly\n");
+            pr_info!("Set nova-drm.acknowledge_unstable_uapi=1 to enable 
(taints kernel)\n");
+            return Err(EPERM);
+        }
+
+        pr_warn!("Unstable uAPI enabled; userspace compatibility is not 
guaranteed\n");
+        panic::add_taint(Taint::User, Lockdep::StillOk);
+
+        Ok(())
+    }
+}
+
+impl InPlaceModule for NovaModule {
+    fn init(module: &'static kernel::ThisModule) -> impl PinInit<Self, Error> {
+        try_pin_init!(Self {
+            _: { Self::check_unstable_uapi()? },
+            _driver <- Registration::new(<Self as 
kernel::ModuleMetadata>::NAME, module),
+        })
+    }
 }
-- 
2.56.0

Reply via email to