]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
include: trace: Fix inflight count helper on failed initialization
authorCristian Marussi <cristian.marussi@arm.com>
Tue, 14 Oct 2025 11:53:45 +0000 (12:53 +0100)
committerSudeep Holla <sudeep.holla@arm.com>
Wed, 15 Oct 2025 14:26:41 +0000 (15:26 +0100)
Add a check to the scmi_inflight_count() helper to handle the case
when the SCMI debug subsystem fails to initialize.

Fixes: f8e656382b4a ("include: trace: Add tracepoint support for inflight xfer count")
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Message-Id: <20251014115346.2391418-2-cristian.marussi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
drivers/firmware/arm_scmi/common.h
drivers/firmware/arm_scmi/driver.c

index 21c0b95027c648eba037626841976b26e6118928..7c35c95fddbaf8bcccef30e47834bbd34c6660cf 100644 (file)
@@ -333,10 +333,12 @@ static inline void scmi_inc_count(struct scmi_debug_info *dbg, int stat)
        }
 }
 
-static inline void scmi_dec_count(atomic_t *arr, int stat)
+static inline void scmi_dec_count(struct scmi_debug_info *dbg, int stat)
 {
-       if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_COUNTERS))
-               atomic_dec(&arr[stat]);
+       if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_COUNTERS)) {
+               if (dbg)
+                       atomic_dec(&dbg->counters[stat]);
+       }
 }
 
 enum scmi_bad_msg {
index 56419285c0bfd3bea738425aed8af6c7e0653bca..1cd15412024cd46fab11cda9a01ab54d01504e98 100644 (file)
@@ -594,7 +594,7 @@ scmi_xfer_inflight_register_unlocked(struct scmi_xfer *xfer,
        /* Set in-flight */
        set_bit(xfer->hdr.seq, minfo->xfer_alloc_table);
        hash_add(minfo->pending_xfers, &xfer->node, xfer->hdr.seq);
-       scmi_inc_count(info->dbg->counters, XFERS_INFLIGHT);
+       scmi_inc_count(info->dbg, XFERS_INFLIGHT);
 
        xfer->pending = true;
 }
@@ -803,7 +803,7 @@ __scmi_xfer_put(struct scmi_xfers_info *minfo, struct scmi_xfer *xfer)
                        hash_del(&xfer->node);
                        xfer->pending = false;
 
-                       scmi_dec_count(info->dbg->counters, XFERS_INFLIGHT);
+                       scmi_dec_count(info->dbg, XFERS_INFLIGHT);
                }
                hlist_add_head(&xfer->node, &minfo->free_xfers);
        }
@@ -3407,6 +3407,9 @@ int scmi_inflight_count(const struct scmi_handle *handle)
        if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_COUNTERS)) {
                struct scmi_info *info = handle_to_scmi_info(handle);
 
+               if (!info->dbg)
+                       return 0;
+
                return atomic_read(&info->dbg->counters[XFERS_INFLIGHT]);
        } else {
                return 0;