drm/i915: Flush buffer pools on driver remove
authorJanusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Fri, 24 Sep 2021 16:38:25 +0000 (18:38 +0200)
committerMatt Roper <matthew.d.roper@intel.com>
Sat, 25 Sep 2021 02:56:30 +0000 (19:56 -0700)
We currently do an explicit flush of the buffer pools within the call path
of drm_driver.release(); this removes all buffers, regardless of their age,
freeing the buffers' associated resources (objects, address space areas).
However there is other code that runs within the drm_driver.release() call
chain that expects objects and their associated address space areas have
already been flushed.

Since buffer pools auto-flush old buffers once per second in a worker
thread, there's a small window where if we remove the driver while there
are still objects in buffers with an age of less than one second, the
assumptions of the other release code may be violated.

By moving the flush to driver remove (which executes earlier via the
pci_driver.remove() flow) we're ensuring that all buffers are flushed and
their associated objects freed before some other code in
pci_driver.remove() flushes those objects so they are released before
_any_ code in drm_driver.release() that check completness of those
flushes executes.

v2: Reword commit description as suggested by Matt.

Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210924163825.634606-1-janusz.krzysztofik@linux.intel.com
drivers/gpu/drm/i915/gt/intel_gt.c
drivers/gpu/drm/i915/gt/intel_gt_buffer_pool.c

index 4037c37782253c952e2a411f7a312f1ca6b60f64..5b3acf2b064e3cbc043afa38f43cab972f74ed60 100644 (file)
@@ -741,6 +741,8 @@ void intel_gt_driver_remove(struct intel_gt *gt)
        intel_uc_driver_remove(&gt->uc);
 
        intel_engines_release(gt);
+
+       intel_gt_flush_buffer_pool(gt);
 }
 
 void intel_gt_driver_unregister(struct intel_gt *gt)
index aa0a59c5b614707cef04e8fcea924f40e9cf9ce8..acc49c56a9f30bd8cfe19273e111ba06a0ae27a6 100644 (file)
@@ -245,8 +245,6 @@ void intel_gt_fini_buffer_pool(struct intel_gt *gt)
        struct intel_gt_buffer_pool *pool = &gt->buffer_pool;
        int n;
 
-       intel_gt_flush_buffer_pool(gt);
-
        for (n = 0; n < ARRAY_SIZE(pool->cache_list); n++)
                GEM_BUG_ON(!list_empty(&pool->cache_list[n]));
 }