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

drm/i915/runtime_pm: Prefer drm_WARN* over WARN*

struct drm_device specific drm_WARN* macros include device information
in the backtrace, so we know what device the warnings originate from.

Prefer drm_WARN* over WARN*.

Conversion is done with below semantic patch:

@@
identifier func, T;
@@
func(struct intel_runtime_pm *T,...) {
+ struct drm_i915_private *i915 = container_of(T, struct drm_i915_private, runtime_pm);
<+...
(
-WARN(
+drm_WARN(&i915->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>

}

Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200504181600.18503-10-pankaj.laxminarayan.bharadiya@intel.com

authored by

Pankaj Bharadiya and committed by
Jani Nikula
649c10ff 19edeb38

+28 -11
+28 -11
drivers/gpu/drm/i915/intel_runtime_pm.c
··· 116 116 static void untrack_intel_runtime_pm_wakeref(struct intel_runtime_pm *rpm, 117 117 depot_stack_handle_t stack) 118 118 { 119 + struct drm_i915_private *i915 = container_of(rpm, 120 + struct drm_i915_private, 121 + runtime_pm); 119 122 unsigned long flags, n; 120 123 bool found = false; 121 124 ··· 137 134 } 138 135 spin_unlock_irqrestore(&rpm->debug.lock, flags); 139 136 140 - if (WARN(!found, 141 - "Unmatched wakeref (tracking %lu), count %u\n", 142 - rpm->debug.count, atomic_read(&rpm->wakeref_count))) { 137 + if (drm_WARN(&i915->drm, !found, 138 + "Unmatched wakeref (tracking %lu), count %u\n", 139 + rpm->debug.count, atomic_read(&rpm->wakeref_count))) { 143 140 char *buf; 144 141 145 142 buf = kmalloc(PAGE_SIZE, GFP_NOWAIT | __GFP_NOWARN); ··· 358 355 static intel_wakeref_t __intel_runtime_pm_get(struct intel_runtime_pm *rpm, 359 356 bool wakelock) 360 357 { 358 + struct drm_i915_private *i915 = container_of(rpm, 359 + struct drm_i915_private, 360 + runtime_pm); 361 361 int ret; 362 362 363 363 ret = pm_runtime_get_sync(rpm->kdev); 364 - WARN_ONCE(ret < 0, "pm_runtime_get_sync() failed: %d\n", ret); 364 + drm_WARN_ONCE(&i915->drm, ret < 0, 365 + "pm_runtime_get_sync() failed: %d\n", ret); 365 366 366 367 intel_runtime_pm_acquire(rpm, wakelock); 367 368 ··· 546 539 */ 547 540 void intel_runtime_pm_enable(struct intel_runtime_pm *rpm) 548 541 { 542 + struct drm_i915_private *i915 = container_of(rpm, 543 + struct drm_i915_private, 544 + runtime_pm); 549 545 struct device *kdev = rpm->kdev; 550 546 551 547 /* ··· 575 565 576 566 pm_runtime_dont_use_autosuspend(kdev); 577 567 ret = pm_runtime_get_sync(kdev); 578 - WARN(ret < 0, "pm_runtime_get_sync() failed: %d\n", ret); 568 + drm_WARN(&i915->drm, ret < 0, 569 + "pm_runtime_get_sync() failed: %d\n", ret); 579 570 } else { 580 571 pm_runtime_use_autosuspend(kdev); 581 572 } ··· 591 580 592 581 void intel_runtime_pm_disable(struct intel_runtime_pm *rpm) 593 582 { 583 + struct drm_i915_private *i915 = container_of(rpm, 584 + struct drm_i915_private, 585 + runtime_pm); 594 586 struct device *kdev = rpm->kdev; 595 587 596 588 /* Transfer rpm ownership back to core */ 597 - WARN(pm_runtime_get_sync(kdev) < 0, 598 - "Failed to pass rpm ownership back to core\n"); 589 + drm_WARN(&i915->drm, pm_runtime_get_sync(kdev) < 0, 590 + "Failed to pass rpm ownership back to core\n"); 599 591 600 592 pm_runtime_dont_use_autosuspend(kdev); 601 593 ··· 608 594 609 595 void intel_runtime_pm_driver_release(struct intel_runtime_pm *rpm) 610 596 { 597 + struct drm_i915_private *i915 = container_of(rpm, 598 + struct drm_i915_private, 599 + runtime_pm); 611 600 int count = atomic_read(&rpm->wakeref_count); 612 601 613 - WARN(count, 614 - "i915 raw-wakerefs=%d wakelocks=%d on cleanup\n", 615 - intel_rpm_raw_wakeref_count(count), 616 - intel_rpm_wakelock_count(count)); 602 + drm_WARN(&i915->drm, count, 603 + "i915 raw-wakerefs=%d wakelocks=%d on cleanup\n", 604 + intel_rpm_raw_wakeref_count(count), 605 + intel_rpm_wakelock_count(count)); 617 606 618 607 untrack_all_intel_runtime_pm_wakerefs(rpm); 619 608 }