drm/xe/gsc: Trigger a driver flr to cleanup the GSC on unload
authorDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Fri, 17 Nov 2023 22:51:49 +0000 (14:51 -0800)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Thu, 21 Dec 2023 16:45:06 +0000 (11:45 -0500)
GSC is only killed by an FLR, so we need to trigger one on unload to
make sure we stop it. This is because we assign a chunk of memory to
the GSC as part of the FW load, so we need to make sure it stops
using it when we release it to the system on driver unload. Note that
this is not a problem of the unload per-se, because the GSC will not
touch that memory unless there are requests for it coming from the
driver; therefore, no accesses will happen while Xe is not loaded,
but if we re-load the driver then the GSC might wake up and try to
access that old memory location again.

Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Alan Previn <alan.previn.teres.alexis@intel.com>
Reviewed-by: John Harrison <John.C.Harrison@Intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_gsc.c

index 5731c026a77a1701cfc523c37db7b1acb7f4c93e..907585846a8945e2ebeeabb8dbd4d6d722e6c5c1 100644 (file)
@@ -130,6 +130,23 @@ static int gsc_upload(struct xe_gsc *gsc)
                return err;
        }
 
+       /*
+        * GSC is only killed by an FLR, so we need to trigger one on unload to
+        * make sure we stop it. This is because we assign a chunk of memory to
+        * the GSC as part of the FW load, so we need to make sure it stops
+        * using it when we release it to the system on driver unload. Note that
+        * this is not a problem of the unload per-se, because the GSC will not
+        * touch that memory unless there are requests for it coming from the
+        * driver; therefore, no accesses will happen while Xe is not loaded,
+        * but if we re-load the driver then the GSC might wake up and try to
+        * access that old memory location again.
+        * Given that an FLR is a very disruptive action (see the FLR function
+        * for details), we want to do it as the last action before releasing
+        * the access to the MMIO bar, which means we need to do it as part of
+        * mmio cleanup.
+        */
+       xe->needs_flr_on_fini = true;
+
        err = emit_gsc_upload(gsc);
        if (err) {
                xe_gt_err(gt, "Failed to emit GSC FW upload (%pe)\n", ERR_PTR(err));