Skip to content

Commit 289ce7e

Browse files
cris-masudeep-holla
authored andcommitted
include: trace: Fix inflight count helper on failed initialization
Add a check to the scmi_inflight_count() helper to handle the case when the SCMI debug subsystem fails to initialize. Fixes: f8e6563 ("include: trace: Add tracepoint support for inflight xfer count") Signed-off-by: Cristian Marussi <[email protected]> Message-Id: <[email protected]> Signed-off-by: Sudeep Holla <[email protected]>
1 parent 2290ab4 commit 289ce7e

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

drivers/firmware/arm_scmi/common.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,12 @@ static inline void scmi_inc_count(struct scmi_debug_info *dbg, int stat)
333333
}
334334
}
335335

336-
static inline void scmi_dec_count(atomic_t *arr, int stat)
336+
static inline void scmi_dec_count(struct scmi_debug_info *dbg, int stat)
337337
{
338-
if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_COUNTERS))
339-
atomic_dec(&arr[stat]);
338+
if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_COUNTERS)) {
339+
if (dbg)
340+
atomic_dec(&dbg->counters[stat]);
341+
}
340342
}
341343

342344
enum scmi_bad_msg {

drivers/firmware/arm_scmi/driver.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ scmi_xfer_inflight_register_unlocked(struct scmi_xfer *xfer,
594594
/* Set in-flight */
595595
set_bit(xfer->hdr.seq, minfo->xfer_alloc_table);
596596
hash_add(minfo->pending_xfers, &xfer->node, xfer->hdr.seq);
597-
scmi_inc_count(info->dbg->counters, XFERS_INFLIGHT);
597+
scmi_inc_count(info->dbg, XFERS_INFLIGHT);
598598

599599
xfer->pending = true;
600600
}
@@ -803,7 +803,7 @@ __scmi_xfer_put(struct scmi_xfers_info *minfo, struct scmi_xfer *xfer)
803803
hash_del(&xfer->node);
804804
xfer->pending = false;
805805

806-
scmi_dec_count(info->dbg->counters, XFERS_INFLIGHT);
806+
scmi_dec_count(info->dbg, XFERS_INFLIGHT);
807807
}
808808
hlist_add_head(&xfer->node, &minfo->free_xfers);
809809
}
@@ -3407,6 +3407,9 @@ int scmi_inflight_count(const struct scmi_handle *handle)
34073407
if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_COUNTERS)) {
34083408
struct scmi_info *info = handle_to_scmi_info(handle);
34093409

3410+
if (!info->dbg)
3411+
return 0;
3412+
34103413
return atomic_read(&info->dbg->counters[XFERS_INFLIGHT]);
34113414
} else {
34123415
return 0;

0 commit comments

Comments
 (0)