All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Peres <martin.peres-GANU6spQydw@public.gmane.org>
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 1/4] pm/fan: drop the fan lock in fan_update() before rescheduling
Date: Tue, 25 Mar 2014 14:08:44 +0100	[thread overview]
Message-ID: <53317FDC.9040502@free.fr> (raw)
In-Reply-To: <1395622983-2807-1-git-send-email-martin.peres-GANU6spQydw@public.gmane.org>

Le 24/03/2014 02:03, Martin Peres a écrit :
> From: Martin Peres <martin.peres@labri.fr>
>
> This should fix a deadlock that has been reported to us where fan_update()
> would hold the fan lock and try to grab the alarm_program_lock to reschedule
> an update. On an other CPU, the alarm_program_lock would have been taken
> before calling fan_update(), leading to a deadlock.
>
> We should Cc: <stable@vger.kernel.org> # 3.9+
>
> Reported-by: Marcin Slusarz <marcin.slusarz@gmail.com>
> Tested-by: Timothée Ravier <tim@siosm.fr>

Tested-by: Boris Fersing (IRC nick fersingb, email is private)

> Signed-off-by: Martin Peres <martin.peres@free.fr>
> ---
>   nvkm/subdev/therm/fan.c | 19 +++++++++++++------
>   1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/nvkm/subdev/therm/fan.c b/nvkm/subdev/therm/fan.c
> index 95f6129..29d4c41 100644
> --- a/nvkm/subdev/therm/fan.c
> +++ b/nvkm/subdev/therm/fan.c
> @@ -54,8 +54,10 @@ nouveau_fan_update(struct nouveau_fan *fan, bool immediate, int target)
>
>   	/* check that we're not already at the target duty cycle */
>   	duty = fan->get(therm);
> -	if (duty == target)
> -		goto done;
> +	if (duty == target) {
> +		spin_unlock_irqrestore(&fan->lock, flags);
> +		return 0;
> +	}
>
>   	/* smooth out the fanspeed increase/decrease */
>   	if (!immediate && duty >= 0) {
> @@ -73,8 +75,15 @@ nouveau_fan_update(struct nouveau_fan *fan, bool immediate, int target)
>
>   	nv_debug(therm, "FAN update: %d\n", duty);
>   	ret = fan->set(therm, duty);
> -	if (ret)
> -		goto done;
> +	if (ret) {
> +		spin_unlock_irqrestore(&fan->lock, flags);
> +		return ret;
> +	}
> +
> +	/* fan speed updated, drop the fan lock before grabbing the
> +	 * alarm-scheduling lock and risking a deadlock
> +	 */
> +	spin_unlock_irqrestore(&fan->lock, flags);
>
>   	/* schedule next fan update, if not at target speed already */
>   	if (list_empty(&fan->alarm.head) && target != duty) {
> @@ -92,8 +101,6 @@ nouveau_fan_update(struct nouveau_fan *fan, bool immediate, int target)
>   		ptimer->alarm(ptimer, delay * 1000 * 1000, &fan->alarm);
>   	}
>
> -done:
> -	spin_unlock_irqrestore(&fan->lock, flags);
>   	return ret;
>   }
>
>

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau

      parent reply	other threads:[~2014-03-25 13:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-24  1:03 [PATCH 1/4] pm/fan: drop the fan lock in fan_update() before rescheduling Martin Peres
     [not found] ` <1395622983-2807-1-git-send-email-martin.peres-GANU6spQydw@public.gmane.org>
2014-03-24  1:03   ` [PATCH 2/4] drm/nvd7/fan: handle another kind of PWM fans Martin Peres
2014-03-24  1:03   ` [PATCH 3/4] drm/therm/fan: let the vbios decide on the automatic fan management mode Martin Peres
2014-03-24  1:03   ` [PATCH 4/4] bios/hack: try 16 times when reading the vbios from PROM Martin Peres
2014-03-25 13:08   ` Martin Peres [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53317FDC.9040502@free.fr \
    --to=martin.peres-ganu6spqydw@public.gmane.org \
    --cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.