drm/i915: Generate the engine name based on the instance number
authorOscar Mateo <oscar.mateo@intel.com>
Mon, 10 Apr 2017 14:34:31 +0000 (07:34 -0700)
committerChris Wilson <chris@chris-wilson.co.uk>
Tue, 11 Apr 2017 11:58:10 +0000 (12:58 +0100)
Not really needed, but makes the next change a little bit more compact.

v2:
  - Use zero-based numbering for engine names: xcs0, xcs1.. xcsN (Tvrtko, Chris)
  - Make sure the mock engine name is null-terminated (Tvrtko, Chris)

v3: Because I'm stupid (Chris)

v4: Verify engine name wasn't truncated (Michal)

v5:
  - Kill the warning in mock engine (Chris)

Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1491834873-9345-4-git-send-email-oscar.mateo@intel.com
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
drivers/gpu/drm/i915/intel_engine_cs.c
drivers/gpu/drm/i915/intel_ringbuffer.h
drivers/gpu/drm/i915/selftests/mock_engine.c

index a7ffa4c66d1c2e4a25b9b3cd8316284f381ea3cd..5e5cda02ee19866a620c02f6c55fecda6eb0a40e 100644 (file)
@@ -71,7 +71,7 @@ static const struct engine_info {
                .init_legacy = intel_init_bsd_ring_buffer,
        },
        [VCS2] = {
-               .name = "vcs2",
+               .name = "vcs",
                .hw_id = VCS2_HW,
                .exec_id = I915_EXEC_BSD,
                .class = VIDEO_DECODE_CLASS,
@@ -108,7 +108,8 @@ intel_engine_setup(struct drm_i915_private *dev_priv,
 
        engine->id = id;
        engine->i915 = dev_priv;
-       engine->name = info->name;
+       WARN_ON(snprintf(engine->name, sizeof(engine->name), "%s%u",
+                        info->name, info->instance) >= sizeof(engine->name));
        engine->exec_id = info->exec_id;
        engine->hw_id = engine->guc_id = info->hw_id;
        engine->mmio_base = info->mmio_base;
index 8b53ddb190c586472d78413e5d8d2fd260422e89..fd8994b5688cf4aa794ee60e77404a318837920b 100644 (file)
@@ -187,9 +187,11 @@ enum intel_engine_id {
        VECS
 };
 
+#define INTEL_ENGINE_CS_MAX_NAME 8
+
 struct intel_engine_cs {
        struct drm_i915_private *i915;
-       const char      *name;
+       char name[INTEL_ENGINE_CS_MAX_NAME];
        enum intel_engine_id id;
        unsigned int exec_id;
        unsigned int hw_id;
index b89050e0de480bf7c20823c260209d6c0f9fdaee..b8e53bdc3cc4be8567e8f8e3d0b1e83ed290f5ae 100644 (file)
@@ -140,7 +140,7 @@ struct intel_engine_cs *mock_engine(struct drm_i915_private *i915,
 
        /* minimal engine setup for requests */
        engine->base.i915 = i915;
-       engine->base.name = name;
+       snprintf(engine->base.name, sizeof(engine->base.name), "%s", name);
        engine->base.id = id++;
        engine->base.status_page.page_addr = (void *)(engine + 1);