Lines Matching +full:cs +full:- +full:enable +full:- +full:mask
1 // SPDX-License-Identifier: MIT
28 * Configfs is a filesystem-based manager of kernel objects. XE KMD registers a
73 * -------------------
75 * Enable survivability mode on supported cards. This setting only takes
76 * effect when probing the device. Example to enable it::
83 * ----------------
97 * Note that the engine names are the per-GT hardware names. On multi-tile
109 * ----
111 * Enable extra debugging capabilities to trace engine execution. Only useful
114 * done via debugfs. Example to enable it::
121 * ------------------
134 * <engine-class> cmd <instr> [[dword0] [dword1] [...]]
138 * <engine-class> reg <address> <value>
182 u32 *cs; member
216 u64 mask; member
225 { .cls = "rcs", .mask = XE_HW_ENGINE_RCS_MASK, .engine_class = XE_ENGINE_CLASS_RENDER },
226 { .cls = "bcs", .mask = XE_HW_ENGINE_BCS_MASK, .engine_class = XE_ENGINE_CLASS_COPY },
227 { .cls = "vcs", .mask = XE_HW_ENGINE_VCS_MASK, .engine_class = XE_ENGINE_CLASS_VIDEO_DECODE },
228 { .cls = "vecs", .mask = XE_HW_ENGINE_VECS_MASK, .engine_class = XE_ENGINE_CLASS_VIDEO_ENHANCE },
229 { .cls = "ccs", .mask = XE_HW_ENGINE_CCS_MASK, .engine_class = XE_ENGINE_CLASS_COMPUTE },
230 { .cls = "gsccs", .mask = XE_HW_ENGINE_GSCCS_MASK, .engine_class = XE_ENGINE_CLASS_OTHER },
240 return &to_xe_config_group_device(item)->config; in to_xe_config_device()
250 lockdep_assert_held(&dev->lock); in is_bound()
252 name = dev->group.cg_item.ci_name; in is_bound()
273 return sprintf(page, "%d\n", dev->survivability_mode); in survivability_mode_show()
286 guard(mutex)(&dev->lock); in survivability_mode_store()
288 return -EBUSY; in survivability_mode_store()
290 dev->config.survivability_mode = survivability_mode; in survivability_mode_store()
301 u64 mask = engine_info[i].mask; in engines_allowed_show() local
303 if ((dev->engines_allowed & mask) == mask) { in engines_allowed_show()
305 } else if (mask & dev->engines_allowed) { in engines_allowed_show()
306 u16 bit0 = __ffs64(mask), bit; in engines_allowed_show()
308 mask &= dev->engines_allowed; in engines_allowed_show()
310 for_each_set_bit(bit, (const unsigned long *)&mask, 64) in engines_allowed_show()
312 bit - bit0); in engines_allowed_show()
316 return p - page; in engines_allowed_show()
320 * Lookup engine_info. If @mask is not NULL, reduce the mask according to the
324 * - lookup_engine_info("rcs0", &mask): return "rcs" entry from @engine_info and
325 * mask == BIT_ULL(XE_HW_ENGINE_RCS0)
326 * - lookup_engine_info("rcs*", &mask): return "rcs" entry from @engine_info and
327 * mask == XE_HW_ENGINE_RCS_MASK
328 * - lookup_engine_info("rcs", NULL): return "rcs" entry from @engine_info
330 static const struct engine_info *lookup_engine_info(const char *pattern, u64 *mask) in lookup_engine_info() argument
340 if (!mask) in lookup_engine_info()
344 *mask = engine_info[i].mask; in lookup_engine_info()
351 bit = __ffs64(engine_info[i].mask) + instance; in lookup_engine_info()
352 if (bit >= fls64(engine_info[i].mask)) in lookup_engine_info()
355 *mask = BIT_ULL(bit); in lookup_engine_info()
362 static int parse_engine(const char *s, const char *end_chars, u64 *mask, in parse_engine() argument
371 return -EINVAL; in parse_engine()
376 info = lookup_engine_info(buf, mask); in parse_engine()
378 return -ENOENT; in parse_engine()
391 u64 mask, val = 0; in engines_allowed_store() local
394 patternlen = parse_engine(page + p, ",\n", &mask, NULL); in engines_allowed_store()
396 return -EINVAL; in engines_allowed_store()
398 val |= mask; in engines_allowed_store()
401 guard(mutex)(&dev->lock); in engines_allowed_store()
403 return -EBUSY; in engines_allowed_store()
405 dev->config.engines_allowed = val; in engines_allowed_store()
414 return sprintf(page, "%d\n", dev->enable_psmi); in enable_psmi_show()
427 guard(mutex)(&dev->lock); in enable_psmi_store()
429 return -EBUSY; in enable_psmi_store()
431 dev->config.enable_psmi = val; in enable_psmi_store()
443 *max_size -= len; in wa_bb_read_advance()
459 guard(mutex)(&dev->lock); in wa_bb_show()
470 return -ENOBUFS; in wa_bb_show()
473 len = snprintf(p, sz, " %08x", wa_bb[ec].cs[j]); in wa_bb_show()
475 return -ENOBUFS; in wa_bb_show()
479 return -ENOBUFS; in wa_bb_show()
483 return -ENOBUFS; in wa_bb_show()
489 return p - data; in wa_bb_show()
496 return wa_bb_show(dev, dev->config.ctx_restore_mid_bb, page, SZ_4K); in ctx_restore_mid_bb_show()
503 return wa_bb_show(dev, dev->config.ctx_restore_post_bb, page, SZ_4K); in ctx_restore_post_bb_show()
508 if (wa_bb->cs) in wa_bb_append()
509 wa_bb->cs[wa_bb->len] = val; in wa_bb_append()
511 wa_bb->len++; in wa_bb_append()
525 if (!numlen || numlen >= sizeof(numstr) - 1) in parse_hex()
526 return -EINVAL; in parse_hex()
533 return -EINVAL; in parse_hex()
535 return p - line; in parse_hex()
541 * <engine-class> cmd <u32> <u32...>
542 * <engine-class> reg <u32_addr> <u32_val>
544 * and optionally save them in @wa_bb[i].cs is non-NULL.
574 return -EINVAL; in parse_wa_bb_lines()
580 wa_bb_append(&wa_bb[info->engine_class], val); in parse_wa_bb_lines()
586 return -EINVAL; in parse_wa_bb_lines()
591 return -EINVAL; in parse_wa_bb_lines()
595 wa_bb_append(&wa_bb[info->engine_class], in parse_wa_bb_lines()
597 wa_bb_append(&wa_bb[info->engine_class], val); in parse_wa_bb_lines()
598 wa_bb_append(&wa_bb[info->engine_class], val2); in parse_wa_bb_lines()
600 return -EINVAL; in parse_wa_bb_lines()
616 /* 1. Count dwords - wa_bb[i].cs is NULL for all classes */ in wa_bb_store()
621 guard(mutex)(&dev->lock); in wa_bb_store()
624 return -EBUSY; in wa_bb_store()
630 tmp = krealloc(wa_bb[0].cs, count * sizeof(u32), GFP_KERNEL); in wa_bb_store()
632 return -ENOMEM; in wa_bb_store()
640 tmp_wa_bb[class].cs = tmp + count; in wa_bb_store()
660 return wa_bb_store(dev->config.ctx_restore_mid_bb, dev, data, sz); in ctx_restore_mid_bb_store()
668 return wa_bb_store(dev->config.ctx_restore_post_bb, dev, data, sz); in ctx_restore_post_bb_store()
690 mutex_destroy(&dev->lock); in xe_config_device_release()
692 kfree(dev->config.ctx_restore_post_bb[0].cs); in xe_config_device_release()
706 if (!dev->desc->is_dgfx || dev->desc->platform < XE_BATTLEMAGE) in xe_config_device_is_visible()
728 const struct pci_device_id *ids = drv ? drv->id_table : NULL; in xe_match_desc()
731 return found ? (const void *)found->driver_data : NULL; in xe_match_desc()
756 return ERR_PTR(-EINVAL); in xe_config_make_device_group()
762 return ERR_PTR(-EINVAL); in xe_config_make_device_group()
770 return ERR_PTR(-ENODEV); in xe_config_make_device_group()
772 if (PCI_DEVFN(slot, function) != pdev->devfn) { in xe_config_make_device_group()
774 vfnumber = PCI_DEVFN(slot, function) - pdev->devfn; in xe_config_make_device_group()
775 if (!dev_is_pf(&pdev->dev) || vfnumber > pci_sriov_get_totalvfs(pdev)) { in xe_config_make_device_group()
777 return ERR_PTR(-ENODEV); in xe_config_make_device_group()
782 if (match && vfnumber && !match->has_sriov) { in xe_config_make_device_group()
792 return ERR_PTR(-ENOENT); in xe_config_make_device_group()
796 return ERR_PTR(-ENOMEM); in xe_config_make_device_group()
798 dev->desc = match; in xe_config_make_device_group()
799 set_device_defaults(&dev->config); in xe_config_make_device_group()
801 config_group_init_type_name(&dev->group, name, &xe_config_device_type); in xe_config_make_device_group()
803 mutex_init(&dev->lock); in xe_config_make_device_group()
805 return &dev->group; in xe_config_make_device_group()
844 if (dev->config.attr_ != device_defaults.attr_) \ in dump_custom_dev_config()
846 dev->config.attr_); \ in dump_custom_dev_config()
857 * xe_configfs_check_device() - Test if device was configured by configfs
870 /* memcmp here is safe as both are zero-initialized */ in xe_configfs_check_device()
871 if (memcmp(&dev->config, &device_defaults, sizeof(dev->config))) { in xe_configfs_check_device()
876 config_group_put(&dev->group); in xe_configfs_check_device()
880 * xe_configfs_get_survivability_mode - get configfs survivability mode attribute
893 mode = dev->config.survivability_mode; in xe_configfs_get_survivability_mode()
894 config_group_put(&dev->group); in xe_configfs_get_survivability_mode()
900 * xe_configfs_get_engines_allowed - get engine allowed mask from configfs
903 * Return: engine mask with allowed engines set in configfs
913 engines_allowed = dev->config.engines_allowed; in xe_configfs_get_engines_allowed()
914 config_group_put(&dev->group); in xe_configfs_get_engines_allowed()
920 * xe_configfs_get_psmi_enabled - get configfs enable_psmi setting
933 ret = dev->config.enable_psmi; in xe_configfs_get_psmi_enabled()
934 config_group_put(&dev->group); in xe_configfs_get_psmi_enabled()
940 * xe_configfs_get_ctx_restore_mid_bb - get configfs ctx_restore_mid_bb setting
943 * @cs: pointer to the bb to use - only valid during probe
949 const u32 **cs) in xe_configfs_get_ctx_restore_mid_bb() argument
957 if (cs) in xe_configfs_get_ctx_restore_mid_bb()
958 *cs = dev->config.ctx_restore_mid_bb[class].cs; in xe_configfs_get_ctx_restore_mid_bb()
960 len = dev->config.ctx_restore_mid_bb[class].len; in xe_configfs_get_ctx_restore_mid_bb()
961 config_group_put(&dev->group); in xe_configfs_get_ctx_restore_mid_bb()
967 * xe_configfs_get_ctx_restore_post_bb - get configfs ctx_restore_post_bb setting
970 * @cs: pointer to the bb to use - only valid during probe
976 const u32 **cs) in xe_configfs_get_ctx_restore_post_bb() argument
984 *cs = dev->config.ctx_restore_post_bb[class].cs; in xe_configfs_get_ctx_restore_post_bb()
985 len = dev->config.ctx_restore_post_bb[class].len; in xe_configfs_get_ctx_restore_post_bb()
986 config_group_put(&dev->group); in xe_configfs_get_ctx_restore_post_bb()