[v2] bus/fslmc: unlock spinlock in case of timeout

Message ID 20221226074709.2432165-1-alvaro.karsz@solid-run.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] bus/fslmc: unlock spinlock in case of timeout |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS

Commit Message

Alvaro Karsz Dec. 26, 2022, 7:47 a.m. UTC
  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")
Signed-off-by: Alvaro Karsz <alvaro.karsz@solid-run.com>
--
v2:
	- Fix code indentation.
	- Fix "Fixes: " tag format.
---
 drivers/bus/fslmc/mc/mc_sys.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Comments

David Marchand Jan. 3, 2023, 9:51 a.m. UTC | #1
On Mon, Dec 26, 2022 at 8:47 AM Alvaro Karsz <alvaro.karsz@solid-run.com> wrote:
>
> 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: stable@dpdk.org

> Signed-off-by: Alvaro Karsz <alvaro.karsz@solid-run.com>
> --
> v2:
>         - Fix code indentation.
>         - Fix "Fixes: " tag format.
> ---
>  drivers/bus/fslmc/mc/mc_sys.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/bus/fslmc/mc/mc_sys.c b/drivers/bus/fslmc/mc/mc_sys.c
> index ab9a074835..018bd9990e 100644
> --- a/drivers/bus/fslmc/mc/mc_sys.c
> +++ b/drivers/bus/fslmc/mc/mc_sys.c
> @@ -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.
Reviewed-by: David Marchand <david.marchand@redhat.com>


> +               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
>
  
Alvaro Karsz Jan. 3, 2023, 8:06 p.m. UTC | #2
Hi David,

Thanks for your review.

I'll create a new version without the comment, and will cc stable@dpdk.org.
  

Patch

diff --git a/drivers/bus/fslmc/mc/mc_sys.c b/drivers/bus/fslmc/mc/mc_sys.c
index ab9a074835..018bd9990e 100644
--- a/drivers/bus/fslmc/mc/mc_sys.c
+++ b/drivers/bus/fslmc/mc/mc_sys.c
@@ -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);