]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/xe/sriov: Use scope-based runtime PM
authorMatt Roper <matthew.d.roper@intel.com>
Tue, 18 Nov 2025 16:44:03 +0000 (08:44 -0800)
committerMatt Roper <matthew.d.roper@intel.com>
Wed, 19 Nov 2025 19:58:58 +0000 (11:58 -0800)
Use scope-based runtime power management in the SRIOV code for
consistency with other parts of the driver.

v2:
 - Drop unnecessary 'ret' variables.  (Gustavo)

Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com>
Link: https://patch.msgid.link/20251118164338.3572146-53-matthew.d.roper@intel.com
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
drivers/gpu/drm/xe/xe_pci_sriov.c
drivers/gpu/drm/xe/xe_sriov_pf_debugfs.c
drivers/gpu/drm/xe/xe_sriov_pf_sysfs.c
drivers/gpu/drm/xe/xe_sriov_vf_ccs.c
drivers/gpu/drm/xe/xe_tile_sriov_pf_debugfs.c

index 9ff69c4843b0ae47eff935a47273c9ee8b78515a..3fd22034f03e24d1cfe12216d00fa8bb270344d7 100644 (file)
@@ -219,7 +219,6 @@ static int pf_disable_vfs(struct xe_device *xe)
 int xe_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)
 {
        struct xe_device *xe = pdev_to_xe_device(pdev);
-       int ret;
 
        if (!IS_SRIOV_PF(xe))
                return -ENODEV;
@@ -233,14 +232,11 @@ int xe_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)
        if (num_vfs && pci_num_vf(pdev))
                return -EBUSY;
 
-       xe_pm_runtime_get(xe);
+       guard(xe_pm_runtime)(xe);
        if (num_vfs > 0)
-               ret = pf_enable_vfs(xe, num_vfs);
+               return pf_enable_vfs(xe, num_vfs);
        else
-               ret = pf_disable_vfs(xe);
-       xe_pm_runtime_put(xe);
-
-       return ret;
+               return pf_disable_vfs(xe);
 }
 
 /**
index bad751217e1e529d15478a62da23cb58d1dd9c42..e84bdde9bc80140f46caabedd9112d0f8fd7eebb 100644 (file)
@@ -70,9 +70,8 @@ static ssize_t from_file_write_to_xe_call(struct file *file, const char __user *
        if (ret < 0)
                return ret;
        if (yes) {
-               xe_pm_runtime_get(xe);
+               guard(xe_pm_runtime)(xe);
                ret = call(xe);
-               xe_pm_runtime_put(xe);
        }
        if (ret < 0)
                return ret;
@@ -209,9 +208,8 @@ static ssize_t from_file_write_to_vf_call(struct file *file, const char __user *
        if (ret < 0)
                return ret;
        if (yes) {
-               xe_pm_runtime_get(xe);
+               guard(xe_pm_runtime)(xe);
                ret = call(xe, vfid);
-               xe_pm_runtime_put(xe);
        }
        if (ret < 0)
                return ret;
index c0b767ac735cf2611f230c6a399c8f9985fdecd1..3d140506ba36bad3711cf3a326c7569c2d19e935 100644 (file)
@@ -389,16 +389,12 @@ static ssize_t xe_sriov_dev_attr_store(struct kobject *kobj, struct attribute *a
        struct xe_sriov_dev_attr *vattr = to_xe_sriov_dev_attr(attr);
        struct xe_sriov_kobj *vkobj = to_xe_sriov_kobj(kobj);
        struct xe_device *xe = vkobj->xe;
-       ssize_t ret;
 
        if (!vattr->store)
                return -EPERM;
 
-       xe_pm_runtime_get(xe);
-       ret = xe_sriov_pf_wait_ready(xe) ?: vattr->store(xe, buf, count);
-       xe_pm_runtime_put(xe);
-
-       return ret;
+       guard(xe_pm_runtime)(xe);
+       return xe_sriov_pf_wait_ready(xe) ?: vattr->store(xe, buf, count);
 }
 
 static ssize_t xe_sriov_vf_attr_show(struct kobject *kobj, struct attribute *attr, char *buf)
@@ -423,18 +419,14 @@ static ssize_t xe_sriov_vf_attr_store(struct kobject *kobj, struct attribute *at
        struct xe_sriov_kobj *vkobj = to_xe_sriov_kobj(kobj);
        struct xe_device *xe = vkobj->xe;
        unsigned int vfid = vkobj->vfid;
-       ssize_t ret;
 
        xe_sriov_pf_assert_vfid(xe, vfid);
 
        if (!vattr->store)
                return -EPERM;
 
-       xe_pm_runtime_get(xe);
-       ret = xe_sriov_pf_wait_ready(xe) ?: vattr->store(xe, vfid, buf, count);
-       xe_pm_runtime_get(xe);
-
-       return ret;
+       guard(xe_pm_runtime)(xe);
+       return xe_sriov_pf_wait_ready(xe) ?: vattr->store(xe, vfid, buf, count);
 }
 
 static const struct sysfs_ops xe_sriov_dev_sysfs_ops = {
index 33f4238604e11a0c2359cb41f3cc4c168e3bb3e7..052a5071e69ff4c0df94e0071a71dbdb9490ca1f 100644 (file)
@@ -477,8 +477,7 @@ void xe_sriov_vf_ccs_print(struct xe_device *xe, struct drm_printer *p)
        if (!IS_VF_CCS_READY(xe))
                return;
 
-       xe_pm_runtime_get(xe);
-
+       guard(xe_pm_runtime)(xe);
        for_each_ccs_rw_ctx(ctx_id) {
                bb_pool = xe->sriov.vf.ccs.contexts[ctx_id].mem.ccs_bb_pool;
                if (!bb_pool)
@@ -489,6 +488,4 @@ void xe_sriov_vf_ccs_print(struct xe_device *xe, struct drm_printer *p)
                drm_suballoc_dump_debug_info(&bb_pool->base, p, xe_sa_manager_gpu_addr(bb_pool));
                drm_puts(p, "\n");
        }
-
-       xe_pm_runtime_put(xe);
 }
index f3f478f14ff590c64b0d048b76a546256dae4f57..7f97db2f89bbc96c592f5ba21bb8390dd76ec765 100644 (file)
@@ -141,12 +141,11 @@ static int NAME##_set(void *data, u64 val)                                        \
        if (val > (TYPE)~0ull)                                                  \
                return -EOVERFLOW;                                              \
                                                                                \
-       xe_pm_runtime_get(xe);                                                  \
+       guard(xe_pm_runtime)(xe);                                               \
        err = xe_sriov_pf_wait_ready(xe) ?:                                     \
              xe_gt_sriov_pf_config_set_##CONFIG(gt, vfid, val);                \
        if (!err)                                                               \
                xe_sriov_pf_provision_set_custom_mode(xe);                      \
-       xe_pm_runtime_put(xe);                                                  \
                                                                                \
        return err;                                                             \
 }                                                                              \