All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <guenter.roeck@ericsson.com>
To: Natarajan Gurumoorthy <natg@google.com>
Cc: Jean Delvare <khali@linux-fr.org>,
	Wim Van Sebroeck <wim@iguana.be>,
	Mike Waychison <mikew@google.com>,
	"lm-sensors@lm-sensors.org" <lm-sensors@lm-sensors.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-watchdog@vger.kernel.org" <linux-watchdog@vger.kernel.org>
Subject: Re: [PATCH v7 1/2] Use "request_muxed_region" in it87 watchdog drivers
Date: Wed, 27 Apr 2011 12:49:56 -0700	[thread overview]
Message-ID: <20110427194956.GA24382@ericsson.com> (raw)
In-Reply-To: <BANLkTikGGO76ToGaRJ0foSc-Yp6Fe4C97g@mail.gmail.com>

On Wed, Apr 27, 2011 at 01:49:01PM -0400, Natarajan Gurumoorthy wrote:
> Guenter,
> 
> On Thu, Apr 21, 2011 at 9:44 PM, Guenter Roeck
> <guenter.roeck@ericsson.com> wrote:
> > >  /**
> > > @@ -303,8 +308,6 @@ static void wdt_stop(void)
> > >
> > >  static int wdt_set_timeout(int t)
> > >  {
> > > -       unsigned long flags;
> > > -
> > >         if (t < 1 || t > max_units * 60)
> > >                 return -EINVAL;
> > >
> > > @@ -313,14 +316,14 @@ static int wdt_set_timeout(int t)
> > >         else
> > >                 timeout = t;
> > >
> > > -       spin_lock_irqsave(&spinlock, flags);
> > >         if (test_bit(WDTS_TIMER_RUN, &wdt_status)) {
> > > -               superio_enter();
> > > +               if (superio_enter())
> > > +                       return -EBUSY;
> > > +
> > I don't think you can do that here. You are moving the lock,
> > meaning test_bit is no longer protected by the lock.
> >
> I am not sure I am in agreement with your here. If you look at other
> places in the original driver I see sections of code in "wdt_ioctl"
> that look as follows:
>         case WDIOC_SETOPTIONS:
>                 if (get_user(new_options, uarg.i))
>                         return -EFAULT;
> 
>                 switch (new_options) {
>                 case WDIOS_DISABLECARD:
>                         if (test_bit(WDTS_TIMER_RUN, &wdt_status))
>                                 wdt_stop();
>                         clear_bit(WDTS_TIMER_RUN, &wdt_status);
>                         return 0;
> 
>                 case WDIOS_ENABLECARD:
>                         if (!test_and_set_bit(WDTS_TIMER_RUN, &wdt_status))
>                                 wdt_start();
>                         return 0;
> 
>                 default:
>                         return -EFAULT;
>                 }
> 
> They have run through manipulating the "WDTS_TIMER_RUN" bit in
> wdt_status without touching the spinlock. "wdt_stop" does acquire the
> spinlock before touching the hardware through superio_enter. It seems
> to me that the original writers of this driver were using the spinlock
> to isolate access to the hardware and we will be achieving the same by
> the use of "request_muxed_region" call from superio_enter.
> 
Agreed. Thanks for the clarification.

Guenter

WARNING: multiple messages have this Message-ID (diff)
From: Guenter Roeck <guenter.roeck@ericsson.com>
To: Natarajan Gurumoorthy <natg@google.com>
Cc: Jean Delvare <khali@linux-fr.org>,
	Wim Van Sebroeck <wim@iguana.be>,
	Mike Waychison <mikew@google.com>,
	"lm-sensors@lm-sensors.org" <lm-sensors@lm-sensors.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-watchdog@vger.kernel.org" <linux-watchdog@vger.kernel.org>
Subject: Re: [lm-sensors] [PATCH v7 1/2] Use "request_muxed_region" in it87
Date: Wed, 27 Apr 2011 19:49:56 +0000	[thread overview]
Message-ID: <20110427194956.GA24382@ericsson.com> (raw)
In-Reply-To: <BANLkTikGGO76ToGaRJ0foSc-Yp6Fe4C97g@mail.gmail.com>

On Wed, Apr 27, 2011 at 01:49:01PM -0400, Natarajan Gurumoorthy wrote:
> Guenter,
> 
> On Thu, Apr 21, 2011 at 9:44 PM, Guenter Roeck
> <guenter.roeck@ericsson.com> wrote:
> > >  /**
> > > @@ -303,8 +308,6 @@ static void wdt_stop(void)
> > >
> > >  static int wdt_set_timeout(int t)
> > >  {
> > > -       unsigned long flags;
> > > -
> > >         if (t < 1 || t > max_units * 60)
> > >                 return -EINVAL;
> > >
> > > @@ -313,14 +316,14 @@ static int wdt_set_timeout(int t)
> > >         else
> > >                 timeout = t;
> > >
> > > -       spin_lock_irqsave(&spinlock, flags);
> > >         if (test_bit(WDTS_TIMER_RUN, &wdt_status)) {
> > > -               superio_enter();
> > > +               if (superio_enter())
> > > +                       return -EBUSY;
> > > +
> > I don't think you can do that here. You are moving the lock,
> > meaning test_bit is no longer protected by the lock.
> >
> I am not sure I am in agreement with your here. If you look at other
> places in the original driver I see sections of code in "wdt_ioctl"
> that look as follows:
>         case WDIOC_SETOPTIONS:
>                 if (get_user(new_options, uarg.i))
>                         return -EFAULT;
> 
>                 switch (new_options) {
>                 case WDIOS_DISABLECARD:
>                         if (test_bit(WDTS_TIMER_RUN, &wdt_status))
>                                 wdt_stop();
>                         clear_bit(WDTS_TIMER_RUN, &wdt_status);
>                         return 0;
> 
>                 case WDIOS_ENABLECARD:
>                         if (!test_and_set_bit(WDTS_TIMER_RUN, &wdt_status))
>                                 wdt_start();
>                         return 0;
> 
>                 default:
>                         return -EFAULT;
>                 }
> 
> They have run through manipulating the "WDTS_TIMER_RUN" bit in
> wdt_status without touching the spinlock. "wdt_stop" does acquire the
> spinlock before touching the hardware through superio_enter. It seems
> to me that the original writers of this driver were using the spinlock
> to isolate access to the hardware and we will be achieving the same by
> the use of "request_muxed_region" call from superio_enter.
> 
Agreed. Thanks for the clarification.

Guenter

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

  reply	other threads:[~2011-04-27 19:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-18 18:58 [PATCH v7 0/2] Make all it87 drivers SMP safe Nat Gurumoorthy
2011-04-18 18:58 ` [lm-sensors] " Nat Gurumoorthy
2011-04-18 19:00 ` [PATCH v7 1/2] Use "request_muxed_region" in it87 watchdog drivers Nat Gurumoorthy
2011-04-18 19:00   ` [lm-sensors] [PATCH v7 1/2] Use "request_muxed_region" in it87 Nat Gurumoorthy
2011-04-22  4:44   ` [PATCH v7 1/2] Use "request_muxed_region" in it87 watchdog drivers Guenter Roeck
2011-04-22  4:44     ` [lm-sensors] [PATCH v7 1/2] Use "request_muxed_region" in it87 Guenter Roeck
2011-04-27 17:49     ` [PATCH v7 1/2] Use "request_muxed_region" in it87 watchdog drivers Natarajan Gurumoorthy
2011-04-27 17:49       ` Natarajan Gurumoorthy
2011-04-27 17:49       ` [lm-sensors] [PATCH v7 1/2] Use "request_muxed_region" in it87 Natarajan Gurumoorthy
2011-04-27 19:49       ` Guenter Roeck [this message]
2011-04-27 19:49         ` Guenter Roeck
2011-04-18 19:00 ` [PATCH v7 2/2] Use "request_muxed_region" in it87 hwmon drivers Nat Gurumoorthy
2011-04-18 19:00   ` [lm-sensors] [PATCH v7 2/2] Use "request_muxed_region" in it87 Nat Gurumoorthy
2011-05-04  9:32 ` [PATCH v7 0/2] Make all it87 drivers SMP safe Alan Cox
2011-05-04  9:32   ` [lm-sensors] " Alan Cox

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=20110427194956.GA24382@ericsson.com \
    --to=guenter.roeck@ericsson.com \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=lm-sensors@lm-sensors.org \
    --cc=mikew@google.com \
    --cc=natg@google.com \
    --cc=wim@iguana.be \
    /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.