Commit fcee6854 authored by Matt Roper's avatar Matt Roper
Browse files

drm/xe/sriov: Use scope-based runtime PM



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: default avatarGustavo Sousa <gustavo.sousa@intel.com>
Link: https://patch.msgid.link/20251118164338.3572146-53-matthew.d.roper@intel.com


Signed-off-by: default avatarMatt Roper <matthew.d.roper@intel.com>
parent 008f3fcf
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -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);
}

/**
+2 −4
Original line number Diff line number Diff line
@@ -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;
+4 −12
Original line number Diff line number Diff line
@@ -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 = {
+1 −4
Original line number Diff line number Diff line
@@ -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);
}
+1 −2
Original line number Diff line number Diff line
@@ -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;								\
}										\