Skip to content

Commit

Permalink
drm/i915/hwmon: Block waiting for GuC reset to complete
Browse files Browse the repository at this point in the history
Instead of erroring out when GuC reset is in progress, block waiting for
GuC reset to complete which is a more reasonable uapi behavior.

v2: Avoid race between wake_up_all and waiting for wakeup (Rodrigo)
v3: Remove timeout when blocked (Tvrtko)

Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230420164041.1428455-4-ashutosh.dixit@intel.com
  • Loading branch information
Ashutosh Dixit authored and Rodrigo Vivi committed Apr 26, 2023
1 parent 1b44019 commit 655bd3b
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions drivers/gpu/drm/i915/i915_hwmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct hwm_drvdata {
char name[12];
int gt_n;
bool reset_in_progress;
wait_queue_head_t waitq;
};

struct i915_hwmon {
Expand Down Expand Up @@ -397,14 +398,32 @@ hwm_power_max_write(struct hwm_drvdata *ddat, long val)
{
struct i915_hwmon *hwmon = ddat->hwmon;
intel_wakeref_t wakeref;
DEFINE_WAIT(wait);
int ret = 0;
u32 nval;

mutex_lock(&hwmon->hwmon_lock);
if (hwmon->ddat.reset_in_progress) {
ret = -EAGAIN;
goto unlock;
/* Block waiting for GuC reset to complete when needed */
for (;;) {
mutex_lock(&hwmon->hwmon_lock);

prepare_to_wait(&ddat->waitq, &wait, TASK_INTERRUPTIBLE);

if (!hwmon->ddat.reset_in_progress)
break;

if (signal_pending(current)) {
ret = -EINTR;
break;
}

mutex_unlock(&hwmon->hwmon_lock);

schedule();
}
finish_wait(&ddat->waitq, &wait);
if (ret)
goto unlock;

wakeref = intel_runtime_pm_get(ddat->uncore->rpm);

/* Disable PL1 limit and verify, because the limit cannot be disabled on all platforms */
Expand Down Expand Up @@ -508,6 +527,7 @@ void i915_hwmon_power_max_restore(struct drm_i915_private *i915, bool old)
intel_uncore_rmw(hwmon->ddat.uncore, hwmon->rg.pkg_rapl_limit,
PKG_PWR_LIM_1_EN, old ? PKG_PWR_LIM_1_EN : 0);
hwmon->ddat.reset_in_progress = false;
wake_up_all(&hwmon->ddat.waitq);

mutex_unlock(&hwmon->hwmon_lock);
}
Expand Down Expand Up @@ -784,6 +804,7 @@ void i915_hwmon_register(struct drm_i915_private *i915)
ddat->uncore = &i915->uncore;
snprintf(ddat->name, sizeof(ddat->name), "i915");
ddat->gt_n = -1;
init_waitqueue_head(&ddat->waitq);

for_each_gt(gt, i915, i) {
ddat_gt = hwmon->ddat_gt + i;
Expand Down

0 comments on commit 655bd3b

Please sign in to comment.