[PATCH] drm/xe/xe_gt_idle: Drop redundant newline in name

Dixit, Ashutosh ashutosh.dixit at intel.com
Sat Feb 3 06:37:55 UTC 2024


On Fri, 02 Feb 2024 21:36:58 -0800, Lucas De Marchi wrote:
>

Hi Lucas,

> On Fri, Feb 02, 2024 at 02:56:23PM -0800, Ashutosh Dixit wrote:
> > Newline in name is redunant and produces an unnecessary empty line during
> > 'cat name'. Newline is added during sysfs_emit. See '27a1a1e2e47d ("drm/xe:
> > stringify the argument to avoid potential vulnerability")'.
>
> $ git grep sprintf -- drivers/gpu/drm/xe
> drivers/gpu/drm/xe/xe_debugfs.c:                        sprintf(name, "vram%d_mm", mem_type - XE_PL_VRAM0);
> drivers/gpu/drm/xe/xe_exec_queue.c:             sprintf(q->name, "rcs%d", instance);
> drivers/gpu/drm/xe/xe_exec_queue.c:             sprintf(q->name, "vcs%d", instance);
> drivers/gpu/drm/xe/xe_exec_queue.c:             sprintf(q->name, "vecs%d", instance);
> drivers/gpu/drm/xe/xe_exec_queue.c:             sprintf(q->name, "bcs%d", instance);
> drivers/gpu/drm/xe/xe_exec_queue.c:             sprintf(q->name, "ccs%d", instance);
> drivers/gpu/drm/xe/xe_exec_queue.c:             sprintf(q->name, "gsccs%d", instance);
> drivers/gpu/drm/xe/xe_gt_debugfs.c:     sprintf(name, "gt%d", gt->info.id);
> drivers/gpu/drm/xe/xe_gt_idle.c:                sprintf(gtidle->name, "gt%d-mc\n", gt->info.id);
> drivers/gpu/drm/xe/xe_gt_idle.c:                sprintf(gtidle->name, "gt%d-rc\n", gt->info.id);
> drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c:  return sprintf(buf, "%u\n", eclass->sched_props.job_timeout_max);
> drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c:  return sprintf(buf, "%u\n", eclass->sched_props.job_timeout_min);
> drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c:  return sprintf(buf, "%u\n", eclass->sched_props.job_timeout_ms);
> drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c:  return sprintf(buf, "%u\n", eclass->defaults.job_timeout_ms);
> drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c:  return sprintf(buf, "%u\n", eclass->defaults.job_timeout_min);
> drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c:  return sprintf(buf, "%u\n", eclass->defaults.job_timeout_max);
> drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c:  return sprintf(buf, "%u\n", eclass->sched_props.timeslice_max);
> drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c:  return sprintf(buf, "%u\n", eclass->sched_props.timeslice_min);
> drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c:  return sprintf(buf, "%u\n", eclass->sched_props.timeslice_us);
> drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c:  return sprintf(buf, "%u\n", eclass->defaults.timeslice_us);
> drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c:  return sprintf(buf, "%u\n", eclass->defaults.timeslice_min);
> drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c:  return sprintf(buf, "%u\n", eclass->defaults.timeslice_max);
> drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c:  return sprintf(buf, "%u\n", eclass->sched_props.preempt_timeout_us);
> drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c:  return sprintf(buf, "%u\n", eclass->defaults.preempt_timeout_us);
> drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c:  return sprintf(buf, "%u\n", eclass->defaults.preempt_timeout_min);
> drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c:  return sprintf(buf, "%u\n", eclass->defaults.preempt_timeout_max);
> drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c:  return sprintf(buf, "%u\n", eclass->sched_props.preempt_timeout_max);
> drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c:  return sprintf(buf, "%u\n", eclass->sched_props.preempt_timeout_min);
> drivers/gpu/drm/xe/xe_hw_fence.c:       sprintf(ctx->name, "%s", name);
>
>
> it looks like all these in xe_hw_engine_class_sysfs.c have the same
> problem. Can you fix them all together?

No, these are actually ok, they don't add 2 newlines like the ones I fixed.

It would probably have been better to use sysfs_emit to emit these values,
instead of sprintf, but they don't add an additional newline. So if you
want I can add a patch which changes these to sysfs_emit, but maybe not
needed, and that would be a second patch.

Thanks.
--
Ashutosh


More information about the Intel-xe mailing list