]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/i915: remove IS_ACTIVE
authorLucas De Marchi <lucas.demarchi@intel.com>
Tue, 5 Oct 2021 17:17:28 +0000 (10:17 -0700)
committerLucas De Marchi <lucas.demarchi@intel.com>
Thu, 7 Oct 2021 18:04:05 +0000 (11:04 -0700)
When trying to bring IS_ACTIVE to linux/kconfig.h I thought it wouldn't
provide much value just encapsulating it in a boolean context. So I also
added the support for handling undefined macros as the IS_ENABLED()
counterpart. However the feedback received from Masahiro Yamada was that
it is too ugly, not providing much value. And just wrapping in a boolean
context is too dumb - we could simply open code it.

As detailed in commit babaab2f4738 ("drm/i915: Encapsulate kconfig
constant values inside boolean predicates"), the IS_ACTIVE macro was
added to workaround a compilation warning. However after checking again
our current uses of IS_ACTIVE it turned out there is only
1 case in which it triggers a warning in clang (due
-Wconstant-logical-operand) and 2 in smatch. All the others
can simply use the shorter version, without wrapping it in any macro.

So here I'm dialing all the way back to simply removing the macro. That
single case hit by clang can be changed to make the constant come first,
so it doesn't think it's mask:

-       if (context && CONFIG_DRM_I915_FENCE_TIMEOUT)
+       if (CONFIG_DRM_I915_FENCE_TIMEOUT && context)

As talked with Dan Carpenter, that logic will be added in smatch as
well, so it will also stop warning about it.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20211005171728.3147094-1-lucas.demarchi@intel.com
drivers/gpu/drm/i915/gem/i915_gem_context.c
drivers/gpu/drm/i915/gem/i915_gem_mman.c
drivers/gpu/drm/i915/gt/intel_engine.h
drivers/gpu/drm/i915/gt/intel_engine_heartbeat.c
drivers/gpu/drm/i915/gt/intel_engine_types.h
drivers/gpu/drm/i915/gt/intel_execlists_submission.c
drivers/gpu/drm/i915/gt/selftest_engine_heartbeat.c
drivers/gpu/drm/i915/gt/selftest_execlists.c
drivers/gpu/drm/i915/i915_config.c
drivers/gpu/drm/i915/i915_request.c
drivers/gpu/drm/i915/i915_utils.h

index 74e33a4cdfe8c5fe68a645b45c66867d39d0f228..d225d3dd0b40e0730bcb5f7a9d92eaee0a068fe3 100644 (file)
@@ -804,7 +804,7 @@ static int intel_context_set_gem(struct intel_context *ce,
            intel_engine_has_semaphores(ce->engine))
                __set_bit(CONTEXT_USE_SEMAPHORES, &ce->flags);
 
-       if (IS_ACTIVE(CONFIG_DRM_I915_REQUEST_TIMEOUT) &&
+       if (CONFIG_DRM_I915_REQUEST_TIMEOUT &&
            ctx->i915->params.request_timeout_ms) {
                unsigned int timeout_ms = ctx->i915->params.request_timeout_ms;
 
index 5130e8ed9564745488d1893bcb6151ba19273f88..65fc6ff5f59dabd26976f1e159dbb9ff53ce7005 100644 (file)
@@ -395,7 +395,7 @@ retry:
        /* Track the mmo associated with the fenced vma */
        vma->mmo = mmo;
 
-       if (IS_ACTIVE(CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND))
+       if (CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND)
                intel_wakeref_auto(&i915->ggtt.userfault_wakeref,
                                   msecs_to_jiffies_timeout(CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND));
 
index eed4634c08cd9f1918b113b5c5cc9c7fcea6fc8a..452248884ef18d48bc69a5e6762a161699c2c272 100644 (file)
@@ -275,7 +275,7 @@ static inline bool intel_engine_uses_guc(const struct intel_engine_cs *engine)
 static inline bool
 intel_engine_has_preempt_reset(const struct intel_engine_cs *engine)
 {
-       if (!IS_ACTIVE(CONFIG_DRM_I915_PREEMPT_TIMEOUT))
+       if (!CONFIG_DRM_I915_PREEMPT_TIMEOUT)
                return false;
 
        return intel_engine_has_preemption(engine);
@@ -302,7 +302,7 @@ intel_virtual_engine_has_heartbeat(const struct intel_engine_cs *engine)
 static inline bool
 intel_engine_has_heartbeat(const struct intel_engine_cs *engine)
 {
-       if (!IS_ACTIVE(CONFIG_DRM_I915_HEARTBEAT_INTERVAL))
+       if (!CONFIG_DRM_I915_HEARTBEAT_INTERVAL)
                return false;
 
        if (intel_engine_is_virtual(engine))
index 74775ae961b2baf4ffcb10cb3961b60813c806be..a3698f611f4577032ceab0dc2876a818018bd045 100644 (file)
@@ -207,7 +207,7 @@ out:
 
 void intel_engine_unpark_heartbeat(struct intel_engine_cs *engine)
 {
-       if (!IS_ACTIVE(CONFIG_DRM_I915_HEARTBEAT_INTERVAL))
+       if (!CONFIG_DRM_I915_HEARTBEAT_INTERVAL)
                return;
 
        next_heartbeat(engine);
index 5ae1207c363b320c7b25a8fa4b14888bed093ec5..9167ce52487c2dccbbb9fe0582049f618a371862 100644 (file)
@@ -556,7 +556,7 @@ intel_engine_has_semaphores(const struct intel_engine_cs *engine)
 static inline bool
 intel_engine_has_timeslices(const struct intel_engine_cs *engine)
 {
-       if (!IS_ACTIVE(CONFIG_DRM_I915_TIMESLICE_DURATION))
+       if (!CONFIG_DRM_I915_TIMESLICE_DURATION)
                return false;
 
        return engine->flags & I915_ENGINE_HAS_TIMESLICES;
index 7147fe80919edcbe1daabb28bb69da3e84a48b1b..73a79c2acd3ad2b09895088a5d4c9747440a1fbe 100644 (file)
@@ -3339,7 +3339,7 @@ logical_ring_default_vfuncs(struct intel_engine_cs *engine)
                engine->flags |= I915_ENGINE_HAS_SEMAPHORES;
                if (can_preempt(engine)) {
                        engine->flags |= I915_ENGINE_HAS_PREEMPTION;
-                       if (IS_ACTIVE(CONFIG_DRM_I915_TIMESLICE_DURATION))
+                       if (CONFIG_DRM_I915_TIMESLICE_DURATION)
                                engine->flags |= I915_ENGINE_HAS_TIMESLICES;
                }
        }
index 317eebf086c3f848cf37f1cd7ee86ae5bed11c5d..6e6e4d747ccaf9d185e7b3d2f216b2abb9f9f905 100644 (file)
@@ -290,7 +290,7 @@ static int live_heartbeat_fast(void *arg)
        int err = 0;
 
        /* Check that the heartbeat ticks at the desired rate. */
-       if (!IS_ACTIVE(CONFIG_DRM_I915_HEARTBEAT_INTERVAL))
+       if (!CONFIG_DRM_I915_HEARTBEAT_INTERVAL)
                return 0;
 
        for_each_engine(engine, gt, id) {
@@ -352,7 +352,7 @@ static int live_heartbeat_off(void *arg)
        int err = 0;
 
        /* Check that we can turn off heartbeat and not interrupt VIP */
-       if (!IS_ACTIVE(CONFIG_DRM_I915_HEARTBEAT_INTERVAL))
+       if (!CONFIG_DRM_I915_HEARTBEAT_INTERVAL)
                return 0;
 
        for_each_engine(engine, gt, id) {
index b3863abc51f5fe60434235f1da83a0ab7eb03d85..25a8c4f62b0d1fabf6ca215900a1c7628dcad05d 100644 (file)
@@ -992,7 +992,7 @@ static int live_timeslice_preempt(void *arg)
         * need to preempt the current task and replace it with another
         * ready task.
         */
-       if (!IS_ACTIVE(CONFIG_DRM_I915_TIMESLICE_DURATION))
+       if (!CONFIG_DRM_I915_TIMESLICE_DURATION)
                return 0;
 
        obj = i915_gem_object_create_internal(gt->i915, PAGE_SIZE);
@@ -1122,7 +1122,7 @@ static int live_timeslice_rewind(void *arg)
         * but only a few of those requests, forcing us to rewind the
         * RING_TAIL of the original request.
         */
-       if (!IS_ACTIVE(CONFIG_DRM_I915_TIMESLICE_DURATION))
+       if (!CONFIG_DRM_I915_TIMESLICE_DURATION)
                return 0;
 
        for_each_engine(engine, gt, id) {
@@ -1299,7 +1299,7 @@ static int live_timeslice_queue(void *arg)
         * ELSP[1] is already occupied, so must rely on timeslicing to
         * eject ELSP[0] in favour of the queue.)
         */
-       if (!IS_ACTIVE(CONFIG_DRM_I915_TIMESLICE_DURATION))
+       if (!CONFIG_DRM_I915_TIMESLICE_DURATION)
                return 0;
 
        obj = i915_gem_object_create_internal(gt->i915, PAGE_SIZE);
@@ -1420,7 +1420,7 @@ static int live_timeslice_nopreempt(void *arg)
         * We should not timeslice into a request that is marked with
         * I915_REQUEST_NOPREEMPT.
         */
-       if (!IS_ACTIVE(CONFIG_DRM_I915_TIMESLICE_DURATION))
+       if (!CONFIG_DRM_I915_TIMESLICE_DURATION)
                return 0;
 
        if (igt_spinner_init(&spin, gt))
@@ -2260,7 +2260,7 @@ static int __cancel_hostile(struct live_preempt_cancel *arg)
        int err;
 
        /* Preempt cancel non-preemptible spinner in ELSP0 */
-       if (!IS_ACTIVE(CONFIG_DRM_I915_PREEMPT_TIMEOUT))
+       if (!CONFIG_DRM_I915_PREEMPT_TIMEOUT)
                return 0;
 
        if (!intel_has_reset_engine(arg->engine->gt))
@@ -2316,7 +2316,7 @@ static int __cancel_fail(struct live_preempt_cancel *arg)
        struct i915_request *rq;
        int err;
 
-       if (!IS_ACTIVE(CONFIG_DRM_I915_PREEMPT_TIMEOUT))
+       if (!CONFIG_DRM_I915_PREEMPT_TIMEOUT)
                return 0;
 
        if (!intel_has_reset_engine(engine->gt))
@@ -3375,7 +3375,7 @@ static int live_preempt_timeout(void *arg)
         * Check that we force preemption to occur by cancelling the previous
         * context if it refuses to yield the GPU.
         */
-       if (!IS_ACTIVE(CONFIG_DRM_I915_PREEMPT_TIMEOUT))
+       if (!CONFIG_DRM_I915_PREEMPT_TIMEOUT)
                return 0;
 
        if (!intel_has_reset_engine(gt))
index b79b5f6d2cfa3b1d44bb23465b3155600551409e..afb828dab53b34267e1e1b45df769dcb32b5141c 100644 (file)
@@ -8,7 +8,7 @@
 unsigned long
 i915_fence_context_timeout(const struct drm_i915_private *i915, u64 context)
 {
-       if (context && IS_ACTIVE(CONFIG_DRM_I915_FENCE_TIMEOUT))
+       if (CONFIG_DRM_I915_FENCE_TIMEOUT && context)
                return msecs_to_jiffies_timeout(CONFIG_DRM_I915_FENCE_TIMEOUT);
 
        return 0;
index 4f189982f67e3b02771bb9943894596b46a04c02..ed64fa9defdf1ec88024995e7fe5534c926ec6ba 100644 (file)
@@ -1862,7 +1862,7 @@ long i915_request_wait(struct i915_request *rq,
         * completion. That requires having a good predictor for the request
         * duration, which we currently lack.
         */
-       if (IS_ACTIVE(CONFIG_DRM_I915_MAX_REQUEST_BUSYWAIT) &&
+       if (CONFIG_DRM_I915_MAX_REQUEST_BUSYWAIT &&
            __i915_spin_request(rq, state))
                goto out;
 
index 5259edacde380c10b32bc204cb38a084979ad514..62f189e064a9bc82881e3907749ff4a6dae053ab 100644 (file)
@@ -458,17 +458,4 @@ static inline bool timer_expired(const struct timer_list *t)
        return timer_active(t) && !timer_pending(t);
 }
 
-/*
- * This is a lookalike for IS_ENABLED() that takes a kconfig value,
- * e.g. CONFIG_DRM_I915_SPIN_REQUEST, and evaluates whether it is non-zero
- * i.e. whether the configuration is active. Wrapping up the config inside
- * a boolean context prevents clang and smatch from complaining about potential
- * issues in confusing logical-&& with bitwise-& for constants.
- *
- * Sadly IS_ENABLED() itself does not work with kconfig values.
- *
- * Returns 0 if @config is 0, 1 if set to any value.
- */
-#define IS_ACTIVE(config) ((config) != 0)
-
 #endif /* !__I915_UTILS_H */