drm/amdgpu/swsmu: add interrupt work function
authorAlex Deucher <alexander.deucher@amd.com>
Thu, 1 Oct 2020 13:03:37 +0000 (09:03 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 1 Oct 2020 14:43:10 +0000 (10:43 -0400)
So we can schedule work from interrupts.  This might include
long tasks or things that could sleep.

Fixes: e1188aacad1730 ("drm/amdgpu/smu11: add support for SMU AC/DC interrupts")
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c

index 85c5e8627e3bedb905cfac35d6f17f6981ea3e5d..44fd0cd069de679fbb9c4f74bcfb082c4dec7272 100644 (file)
@@ -453,6 +453,7 @@ struct smu_context
 
        struct work_struct throttling_logging_work;
        atomic64_t throttle_int_counter;
+       struct work_struct interrupt_work;
 
        unsigned fan_max_rpm;
        unsigned manual_fan_speed_rpm;
@@ -601,6 +602,7 @@ struct pptable_funcs {
        int (*deep_sleep_control)(struct smu_context *smu, bool enablement);
        int (*get_fan_parameters)(struct smu_context *smu);
        int (*post_init)(struct smu_context *smu);
+       void (*interrupt_work)(struct smu_context *smu);
 };
 
 typedef enum {
index 3010cb31324ab392608cd5a4e59d88b987d40e1f..d20a657ee081d541f7c85c6305afbd9085cc4446 100644 (file)
@@ -780,6 +780,19 @@ static void smu_throttling_logging_work_fn(struct work_struct *work)
        smu_log_thermal_throttling(smu);
 }
 
+static void smu_interrupt_work_fn(struct work_struct *work)
+{
+       struct smu_context *smu = container_of(work, struct smu_context,
+                                              interrupt_work);
+
+       mutex_lock(&smu->mutex);
+
+       if (smu->ppt_funcs && smu->ppt_funcs->interrupt_work)
+               smu->ppt_funcs->interrupt_work(smu);
+
+       mutex_unlock(&smu->mutex);
+}
+
 static int smu_sw_init(void *handle)
 {
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -802,6 +815,7 @@ static int smu_sw_init(void *handle)
        mutex_init(&smu->message_lock);
 
        INIT_WORK(&smu->throttling_logging_work, smu_throttling_logging_work_fn);
+       INIT_WORK(&smu->interrupt_work, smu_interrupt_work_fn);
        atomic64_set(&smu->throttle_int_counter, 0);
        smu->watermarks_bitmap = 0;
        smu->power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
@@ -1197,6 +1211,7 @@ static int smu_smc_hw_cleanup(struct smu_context *smu)
        int ret = 0;
 
        cancel_work_sync(&smu->throttling_logging_work);
+       cancel_work_sync(&smu->interrupt_work);
 
        ret = smu_disable_thermal_alert(smu);
        if (ret) {