Skip to contentSkip to conversation

bus/fslmc: unlock spinlock in case of timeout

PATCH Superseded Alvaro Karsz 2 participants 3 messages Dec 26, 2022 – Jan 3, 2023

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 bus/fslmc: unlock spinlock in case of timeout

Bug in function mc_send_command,
A spinlock is not unlocked in case of timeouts.

Fixes 79711846f676 ("bus/fslmc: add timeout in MC send command")

--
v2:
- Fix code indentation.
- Fix "Fixes: " tag format.

---
 drivers/bus/fslmc/mc/mc_sys.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/bus/fslmc/mc/mc_sys.c +5 -1
index ab9a074835..018bd9990e 100644
@@ -77,8 +77,12 @@ int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd)
 		total_time = rte_get_timer_cycles() - start_time;
 	} while (status == MC_CMD_STATUS_READY && total_time <= time_to_wait);
 
-	if (status == MC_CMD_STATUS_READY)
+	if (status == MC_CMD_STATUS_READY) {
+		/* --- Call unlock function here in case portal is shared --- */
+		rte_spinlock_unlock(&mc_portal_lock);
+
 		return mc_status_to_error(MC_CMD_STATUS_TIMEOUT);
+	}
 
 	/* Read the response back into the command buffer */
 	mc_read_response(mc_io->regs, cmd);
Signature · 1 line
2.32.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 5 lines · Alvaro Karsz

Bug in function mc_send_command,
A spinlock is not unlocked in case of timeouts.

Fixes 79711846f676 ("bus/fslmc: add timeout in MC send command")

This is worth backporting to 22.11 LTS.
Please add:
Cc: [email protected]

Quoted 14 lines

--
v2:
- Fix code indentation.
- Fix "Fixes: " tag format.

---
 drivers/bus/fslmc/mc/mc_sys.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/bus/fslmc/mc/mc_sys.c +0 -0
index ab9a074835..018bd9990e 100644

drivers/bus/fslmc/mc/mc_sys.c int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd) · line 81

Quoted 6 lines
drivers/bus/fslmc/mc/mc_sys.c +2 -1
@@ -77,8 +77,12 @@ int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd)
                total_time = rte_get_timer_cycles() - start_time;
        } while (status == MC_CMD_STATUS_READY && total_time <= time_to_wait);
 
-       if (status == MC_CMD_STATUS_READY)
+       if (status == MC_CMD_STATUS_READY) {
+               /* --- Call unlock function here in case portal is shared --- */

This comment is useless, but otherwise the fix lgtm.

Quoted 10 lines
drivers/bus/fslmc/mc/mc_sys.c +3 -1
+               rte_spinlock_unlock(&mc_portal_lock);
+
                return mc_status_to_error(MC_CMD_STATUS_TIMEOUT);
+       }
 
        /* Read the response back into the command buffer */
        mc_read_response(mc_io->regs, cmd);
--

2.32.0

Signature · 1 line
David Marchand