Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/uc: Extract common code from GuC stop/disable comm

During normal driver unload we attempt to disable GuC communication
while it is currently stopped. This results in a nop'd call to
intel_guc_ct_disable within guc_disable_communication because
stop/disable rely on the same flag to prevent further comms with CT.

We can avoid the call to disable and still leave communication in a
satisfactory state by extracting a set of shared steps from stop/disable.
This set can include guc_disable_interrupts as we do not require the
single caller of guc_stop_communication to be atomic:
"drm/i915/selftests: Fixup atomic reset checking".

This situation (stop -> disable) only occurs during intel_uc_fini_hw,
so during fini, call guc_disable_communication only if currently enabled.
The symmetric calls to enable/disable remain unmodified for all other
scenarios.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110943
Signed-off-by: Fernando Pacheco <fernando.pacheco@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20190829174154.14675-1-fernando.pacheco@intel.com

authored by

Fernando Pacheco and committed by
Chris Wilson
9be02fde e7b6affd

+18 -12
+18 -12
drivers/gpu/drm/i915/gt/uc/intel_uc.c
··· 224 224 return 0; 225 225 } 226 226 227 - static void guc_stop_communication(struct intel_guc *guc) 228 - { 229 - intel_guc_ct_stop(&guc->ct); 230 - 231 - guc->send = intel_guc_send_nop; 232 - guc->handler = intel_guc_to_host_event_handler_nop; 233 - 234 - guc_clear_mmio_msg(guc); 235 - } 236 - 237 - static void guc_disable_communication(struct intel_guc *guc) 227 + static void __guc_stop_communication(struct intel_guc *guc) 238 228 { 239 229 /* 240 230 * Events generated during or after CT disable are logged by guc in ··· 237 247 238 248 guc->send = intel_guc_send_nop; 239 249 guc->handler = intel_guc_to_host_event_handler_nop; 250 + } 251 + 252 + static void guc_stop_communication(struct intel_guc *guc) 253 + { 254 + intel_guc_ct_stop(&guc->ct); 255 + 256 + __guc_stop_communication(guc); 257 + 258 + DRM_INFO("GuC communication stopped\n"); 259 + } 260 + 261 + static void guc_disable_communication(struct intel_guc *guc) 262 + { 263 + __guc_stop_communication(guc); 240 264 241 265 intel_guc_ct_disable(&guc->ct); 242 266 ··· 541 537 if (intel_uc_supports_guc_submission(uc)) 542 538 intel_guc_submission_disable(guc); 543 539 544 - guc_disable_communication(guc); 540 + if (guc_communication_enabled(guc)) 541 + guc_disable_communication(guc); 542 + 545 543 __uc_sanitize(uc); 546 544 } 547 545