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

drm/xe/pf: Add functions to configure VF scheduling priority

Add functions to configure PF or VF scheduling priority using the
VF_CFG_SCHED_PRIORITY KLV.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Lukasz Laguna <lukasz.laguna@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241106151301.2079-4-michal.wajdeczko@intel.com

+81
+76
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
··· 207 207 return pf_push_vf_cfg_u32(gt, vfid, GUC_KLV_VF_CFG_PREEMPT_TIMEOUT_KEY, *preempt_timeout); 208 208 } 209 209 210 + static int pf_push_vf_cfg_sched_priority(struct xe_gt *gt, unsigned int vfid, u32 priority) 211 + { 212 + return pf_push_vf_cfg_u32(gt, vfid, GUC_KLV_VF_CFG_SCHED_PRIORITY_KEY, priority); 213 + } 214 + 210 215 static int pf_push_vf_cfg_lmem(struct xe_gt *gt, unsigned int vfid, u64 size) 211 216 { 212 217 return pf_push_vf_cfg_u64(gt, vfid, GUC_KLV_VF_CFG_LMEM_SIZE_KEY, size); ··· 1770 1765 mutex_unlock(xe_gt_sriov_pf_master_mutex(gt)); 1771 1766 1772 1767 return preempt_timeout; 1768 + } 1769 + 1770 + static const char *sched_priority_unit(u32 priority) 1771 + { 1772 + return priority == GUC_SCHED_PRIORITY_LOW ? "(low)" : 1773 + priority == GUC_SCHED_PRIORITY_NORMAL ? "(normal)" : 1774 + priority == GUC_SCHED_PRIORITY_HIGH ? "(high)" : 1775 + "(?)"; 1776 + } 1777 + 1778 + static int pf_provision_sched_priority(struct xe_gt *gt, unsigned int vfid, u32 priority) 1779 + { 1780 + struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid); 1781 + int err; 1782 + 1783 + err = pf_push_vf_cfg_sched_priority(gt, vfid, priority); 1784 + if (unlikely(err)) 1785 + return err; 1786 + 1787 + config->sched_priority = priority; 1788 + return 0; 1789 + } 1790 + 1791 + static int pf_get_sched_priority(struct xe_gt *gt, unsigned int vfid) 1792 + { 1793 + struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid); 1794 + 1795 + return config->sched_priority; 1796 + } 1797 + 1798 + /** 1799 + * xe_gt_sriov_pf_config_set_sched_priority() - Configure scheduling priority. 1800 + * @gt: the &xe_gt 1801 + * @vfid: the VF identifier 1802 + * @priority: requested scheduling priority 1803 + * 1804 + * This function can only be called on PF. 1805 + * 1806 + * Return: 0 on success or a negative error code on failure. 1807 + */ 1808 + int xe_gt_sriov_pf_config_set_sched_priority(struct xe_gt *gt, unsigned int vfid, u32 priority) 1809 + { 1810 + int err; 1811 + 1812 + mutex_lock(xe_gt_sriov_pf_master_mutex(gt)); 1813 + err = pf_provision_sched_priority(gt, vfid, priority); 1814 + mutex_unlock(xe_gt_sriov_pf_master_mutex(gt)); 1815 + 1816 + return pf_config_set_u32_done(gt, vfid, priority, 1817 + xe_gt_sriov_pf_config_get_sched_priority(gt, vfid), 1818 + "scheduling priority", sched_priority_unit, err); 1819 + } 1820 + 1821 + /** 1822 + * xe_gt_sriov_pf_config_get_sched_priority - Get VF's scheduling priority. 1823 + * @gt: the &xe_gt 1824 + * @vfid: the VF identifier 1825 + * 1826 + * This function can only be called on PF. 1827 + * 1828 + * Return: VF's (or PF's) scheduling priority. 1829 + */ 1830 + u32 xe_gt_sriov_pf_config_get_sched_priority(struct xe_gt *gt, unsigned int vfid) 1831 + { 1832 + u32 priority; 1833 + 1834 + mutex_lock(xe_gt_sriov_pf_master_mutex(gt)); 1835 + priority = pf_get_sched_priority(gt, vfid); 1836 + mutex_unlock(xe_gt_sriov_pf_master_mutex(gt)); 1837 + 1838 + return priority; 1773 1839 } 1774 1840 1775 1841 static void pf_reset_config_sched(struct xe_gt *gt, struct xe_gt_sriov_config *config)
+3
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h
··· 44 44 int xe_gt_sriov_pf_config_set_preempt_timeout(struct xe_gt *gt, unsigned int vfid, 45 45 u32 preempt_timeout); 46 46 47 + u32 xe_gt_sriov_pf_config_get_sched_priority(struct xe_gt *gt, unsigned int vfid); 48 + int xe_gt_sriov_pf_config_set_sched_priority(struct xe_gt *gt, unsigned int vfid, u32 priority); 49 + 47 50 u32 xe_gt_sriov_pf_config_get_threshold(struct xe_gt *gt, unsigned int vfid, 48 51 enum xe_guc_klv_threshold_index index); 49 52 int xe_gt_sriov_pf_config_set_threshold(struct xe_gt *gt, unsigned int vfid,
+2
drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h
··· 33 33 u32 exec_quantum; 34 34 /** @preempt_timeout: preemption timeout in microseconds. */ 35 35 u32 preempt_timeout; 36 + /** @sched_priority: scheduling priority. */ 37 + u32 sched_priority; 36 38 /** @thresholds: GuC thresholds for adverse events notifications. */ 37 39 u32 thresholds[XE_GUC_KLV_NUM_THRESHOLDS]; 38 40 };