/* * Loop over all available slices and assign each a user engine. * For example, if there are four compute slices available, the * assignment of compute slices to compute engines would be, * * With 1 engine (ccs0): * slice 0, 1, 2, 3: ccs0 * * With 2 engines (ccs0, ccs1): * slice 0, 2: ccs0 * slice 1, 3: ccs1 * * With 4 engines (ccs0, ccs1, ccs2, ccs3): * slice 0: ccs0 * slice 1: ccs1 * slice 2: ccs2 * slice 3: ccs3
*/ for (width = num_slices / num_engines; width; width--) { struct xe_hw_engine *hwe; enum xe_hw_engine_id id;
for_each_hw_engine(hwe, gt, id) { if (hwe->class != XE_ENGINE_CLASS_COMPUTE) continue;
/* * Mask bits need to be set for the register. Though only Xe2+ * platforms require setting of mask bits, it won't harm for older * platforms as these bits are unused there.
*/
mode |= CCS_MODE_CSLICE_0_3_MASK << 16;
xe_mmio_write32(>->mmio, CCS_MODE, mode);
if (IS_SRIOV(xe)) {
xe_gt_dbg(gt, "Can't change compute mode when running as %s\n",
xe_sriov_mode_to_string(xe_device_sriov_mode(xe))); return -EOPNOTSUPP;
}
ret = kstrtou32(buff, 0, &num_engines); if (ret) return ret;
/* * Ensure number of engines specified is valid and there is an * exact multiple of engines for slices.
*/
num_slices = hweight32(CCS_MASK(gt)); if (!num_engines || num_engines > num_slices || num_slices % num_engines) {
xe_gt_dbg(gt, "Invalid compute config, %d engines %d slices\n",
num_engines, num_slices); return -EINVAL;
}
/* CCS mode can only be updated when there are no drm clients */
mutex_lock(&xe->drm.filelist_mutex); if (!list_empty(&xe->drm.filelist)) {
mutex_unlock(&xe->drm.filelist_mutex);
xe_gt_dbg(gt, "Rejecting compute mode change as there are active drm clients\n"); return -EBUSY;
}
if (gt->ccs_mode != num_engines) {
xe_gt_info(gt, "Setting compute mode to %d\n", num_engines);
gt->ccs_mode = num_engines;
xe_gt_record_user_engines(gt);
xe_gt_reset(gt);
}
/** * xe_gt_ccs_mode_sysfs_init - Initialize CCS mode sysfs interfaces * @gt: GT structure * * Through a per-gt 'ccs_mode' sysfs interface, the user can enable a fixed * number of compute hardware engines to which the available compute slices * are to be allocated. This user configuration change triggers a gt reset * and it is expected that there are no open drm clients while doing so. * The number of available compute slices is exposed to user through a per-gt * 'num_cslices' sysfs interface. * * Returns: Returns error value for failure and 0 for success.
*/ int xe_gt_ccs_mode_sysfs_init(struct xe_gt *gt)
{ struct xe_device *xe = gt_to_xe(gt); int err;
if (!xe_gt_ccs_mode_enabled(gt)) return 0;
err = sysfs_create_files(gt->sysfs, gt_ccs_mode_attrs); if (err) return err;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.