Re: [PATCH v3] platform/x86: Add support for improved performance mode

From: Breno Leitao
Date: Wed Nov 22 2023 - 14:44:59 EST


On Mon, Nov 13, 2023 at 11:54:33AM -0500, Mark Pearson wrote:
> @@ -10355,6 +10361,17 @@ static int dytc_profile_set(struct platform_profile_handler *pprof,
> if (err)
> goto unlock;
>
> + /* Set TMS mode appropriately (enable for performance), if available */
> + if (dytc_ultraperf_cap) {
> + int cmd;
> +
> + cmd = DYTC_SET_COMMAND(DYTC_FUNCTION_TMS, DYTC_NOMODE,
> + profile == PLATFORM_PROFILE_PERFORMANCE);
> + err = dytc_command(cmd, &output);
> + if (err)
> + return err;

Aren't you returning holding the 'dytc_mutex' mutex?

>From what I understand, in the first line of this function you get the lock,
and release later, at the exit, so, returning without releasing the lock might
be dangerous. Here is a summary of how I read this function with your change:


mutex_lock_interruptible(&dytc_mutex);
...
err = dytc_command(cmd, &output);
if (err)
return err;

unlock:
mutex_unlock(&dytc_mutex);
return err;


I think "goto unlock" might solve it.