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

drm/xe/pf: Skip fair VFs provisioning if already provisioned

Our debugfs allows to view and change VFs' provisioning configs.

If we attempt to experiment with VFs provisioning before enabling
them, this early config will affect fair provisioning calculations,
and will also be overwritten, which is undesirable behavior.

To improve this, check if the VFs configs are empty (unprovisioned)
before starting the fair provisioning procedure.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240701102738.934-2-michal.wajdeczko@intel.com

+63
+48
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
··· 1922 1922 return err; 1923 1923 } 1924 1924 1925 + static int pf_validate_vf_config(struct xe_gt *gt, unsigned int vfid) 1926 + { 1927 + struct xe_gt *primary_gt = gt_to_tile(gt)->primary_gt; 1928 + struct xe_device *xe = gt_to_xe(gt); 1929 + bool valid_ggtt, valid_ctxs, valid_dbs; 1930 + bool valid_any, valid_all; 1931 + 1932 + valid_ggtt = pf_get_vf_config_ggtt(primary_gt, vfid); 1933 + valid_ctxs = pf_get_vf_config_ctxs(gt, vfid); 1934 + valid_dbs = pf_get_vf_config_dbs(gt, vfid); 1935 + 1936 + /* note that GuC doorbells are optional */ 1937 + valid_any = valid_ggtt || valid_ctxs || valid_dbs; 1938 + valid_all = valid_ggtt && valid_ctxs; 1939 + 1940 + if (IS_DGFX(xe)) { 1941 + bool valid_lmem = pf_get_vf_config_ggtt(primary_gt, vfid); 1942 + 1943 + valid_any = valid_any || valid_lmem; 1944 + valid_all = valid_all && valid_lmem; 1945 + } 1946 + 1947 + return valid_all ? 1 : valid_any ? -ENOKEY : -ENODATA; 1948 + } 1949 + 1950 + /** 1951 + * xe_gt_sriov_pf_config_is_empty - Check VF's configuration. 1952 + * @gt: the &xe_gt 1953 + * @vfid: the VF identifier (can't be PF) 1954 + * 1955 + * This function can only be called on PF. 1956 + * 1957 + * Return: true if VF mandatory configuration (GGTT, LMEM, ...) is empty. 1958 + */ 1959 + bool xe_gt_sriov_pf_config_is_empty(struct xe_gt *gt, unsigned int vfid) 1960 + { 1961 + bool empty; 1962 + 1963 + xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt))); 1964 + xe_gt_assert(gt, vfid); 1965 + 1966 + mutex_lock(xe_gt_sriov_pf_master_mutex(gt)); 1967 + empty = pf_validate_vf_config(gt, vfid) == -ENODATA; 1968 + mutex_unlock(xe_gt_sriov_pf_master_mutex(gt)); 1969 + 1970 + return empty; 1971 + } 1972 + 1925 1973 /** 1926 1974 * xe_gt_sriov_pf_config_print_ggtt - Print GGTT configurations. 1927 1975 * @gt: the &xe_gt
+2
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h
··· 53 53 int xe_gt_sriov_pf_config_release(struct xe_gt *gt, unsigned int vfid, bool force); 54 54 int xe_gt_sriov_pf_config_push(struct xe_gt *gt, unsigned int vfid, bool refresh); 55 55 56 + bool xe_gt_sriov_pf_config_is_empty(struct xe_gt *gt, unsigned int vfid); 57 + 56 58 int xe_gt_sriov_pf_config_print_ggtt(struct xe_gt *gt, struct drm_printer *p); 57 59 int xe_gt_sriov_pf_config_print_ctxs(struct xe_gt *gt, struct drm_printer *p); 58 60 int xe_gt_sriov_pf_config_print_dbs(struct xe_gt *gt, struct drm_printer *p);
+13
drivers/gpu/drm/xe/xe_pci_sriov.c
··· 13 13 #include "xe_sriov_pf_helpers.h" 14 14 #include "xe_sriov_printk.h" 15 15 16 + static int pf_needs_provisioning(struct xe_gt *gt, unsigned int num_vfs) 17 + { 18 + unsigned int n; 19 + 20 + for (n = 1; n <= num_vfs; n++) 21 + if (!xe_gt_sriov_pf_config_is_empty(gt, n)) 22 + return false; 23 + 24 + return true; 25 + } 26 + 16 27 static int pf_provision_vfs(struct xe_device *xe, unsigned int num_vfs) 17 28 { 18 29 struct xe_gt *gt; ··· 31 20 int result = 0, err; 32 21 33 22 for_each_gt(gt, xe, id) { 23 + if (!pf_needs_provisioning(gt, num_vfs)) 24 + continue; 34 25 err = xe_gt_sriov_pf_config_set_fair(gt, VFID(1), num_vfs); 35 26 result = result ?: err; 36 27 }