drm/i915/pmu: Fix CPU hotplug with multiple GPUs
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>
Tue, 20 Oct 2020 16:11:44 +0000 (17:11 +0100)
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>
Thu, 22 Oct 2020 09:06:34 +0000 (10:06 +0100)
commit537f9c84a42754f89977bc2d19f2f69503a3a02a
treefb6e1879ec7756739dddfe66f716182cbac890a7
parentb00bccb3f0bb7e99052791eeffb3e2cfcfa1ae8e
drm/i915/pmu: Fix CPU hotplug with multiple GPUs

Since we keep a driver global mask of online CPUs and base the decision
whether PMU needs to be migrated upon it, we need to make sure the
migration is done for all registered PMUs (so GPUs).

To do this we need to track the current CPU for each PMU and base the
decision on whether to migrate on a comparison between global and local
state.

At the same time, since dynamic CPU hotplug notification slots are a
scarce resource and given how we already register the multi instance type
state, we can and should add multiple instance of the i915 PMU to this
same state and not allocate a new one for every GPU.

v2:
 * Use pr_notice. (Chris)

v3:
 * Handle a nasty interaction where unregistration which triggers a false
   CPU offline event. (Chris)

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Suggested-by: Daniel Vetter <daniel.vetter@intel.com> # dynamic slot optimisation
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20201020161144.678668-1-tvrtko.ursulin@linux.intel.com
drivers/gpu/drm/i915/i915_pci.c
drivers/gpu/drm/i915/i915_pmu.c
drivers/gpu/drm/i915/i915_pmu.h