Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

slimbus: messaging: check for valid transaction id

In some usecases transaction ids are dynamically allocated inside
the controller driver after sending the messages which have generic
acknowledge responses. So check for this before refcounting pm_runtime.

Without this we would end up imbalancing runtime pm count by
doing pm_runtime_put() in both slim_do_transfer() and slim_msg_response()
for a single pm_runtime_get() in slim_do_transfer()

Fixes: d3062a210930 ("slimbus: messaging: add slim_alloc/free_txn_tid()")
Cc: <stable@vger.kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20210809082428.11236-3-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Srinivas Kandagatla and committed by
Greg Kroah-Hartman
a263c1ff 9659281c

+3 -2
+3 -2
drivers/slimbus/messaging.c
··· 131 131 goto slim_xfer_err; 132 132 } 133 133 } 134 - 134 + /* Initialize tid to invalid value */ 135 + txn->tid = 0; 135 136 need_tid = slim_tid_txn(txn->mt, txn->mc); 136 137 137 138 if (need_tid) { ··· 164 163 txn->mt, txn->mc, txn->la, ret); 165 164 166 165 slim_xfer_err: 167 - if (!clk_pause_msg && (!need_tid || ret == -ETIMEDOUT)) { 166 + if (!clk_pause_msg && (txn->tid == 0 || ret == -ETIMEDOUT)) { 168 167 /* 169 168 * remove runtime-pm vote if this was TX only, or 170 169 * if there was error during this transaction