From: Andrew Morton <akpm@linux-foundation.org>
To: David Altobelli <david.altobelli@hp.com>
Cc: david.altobelli@hp.com, linux-kernel@vger.kernel.org, gregkh@suse.de
Subject: Re: [PATCH 2/3] hpilo: add interrupt handler
Date: Tue, 18 Aug 2009 14:30:03 -0700 [thread overview]
Message-ID: <20090818143003.4924d26a.akpm@linux-foundation.org> (raw)
In-Reply-To: <20090810200005.GB29404@ldl.fc.hp.com>
On Mon, 10 Aug 2009 14:00:05 -0600
David Altobelli <david.altobelli@hp.com> wrote:
> Add interrupt handler to hpilo. This is enablement for poll handler, and
> it also simplifies the logic for handling an iLO reset, because now
> only the interrupt handler needs to look for reset, the file system interfaces
> only need to return failure when a reset has happened.
>
> Please CC me on any replies.
It would be very helpful if there were comments in hpilo.h which fully
describe the roles of each lock.
>
> ...
>
> @@ -496,27 +491,28 @@ static int ilo_close(struct inode *ip, s
> int slot;
> struct ccb_data *data;
> struct ilo_hwinfo *hw;
> + unsigned long flags;
>
> slot = iminor(ip) % MAX_CCB;
> hw = container_of(ip->i_cdev, struct ilo_hwinfo, cdev);
>
> - spin_lock(&hw->alloc_lock);
> -
> - if (is_device_reset(hw))
> - ilo_locked_reset(hw);
> + spin_lock(&hw->open_lock);
>
> if (hw->ccb_alloc[slot]->ccb_cnt == 1) {
>
> data = fp->private_data;
>
> + spin_lock_irqsave(&hw->alloc_lock, flags);
> + hw->ccb_alloc[slot] = NULL;
> + spin_unlock_irqrestore(&hw->alloc_lock, flags);
> +
> ilo_ccb_close(hw->ilo_dev, data);
>
> kfree(data);
> - hw->ccb_alloc[slot] = NULL;
> } else
> hw->ccb_alloc[slot]->ccb_cnt--;
>
> - spin_unlock(&hw->alloc_lock);
> + spin_unlock(&hw->open_lock);
>
> return 0;
> }
Here I'd have expected that alloc_lock would provide the protection for
->ccb_cnt. But the code doesn't do that - it instead appears to use
->open_lock.
The code doesn't tell us what open_lock's role is intended to be so
this reviewer can't really tell whether or not this was a mistake.
>
> ...
>
> @@ -549,22 +543,31 @@ static int ilo_open(struct inode *ip, st
> goto out;
> }
>
> + data->ccb_cnt = 1;
> + data->ccb_excl = fp->f_flags & O_EXCL;
> + data->ilo_hw = hw;
> + init_waitqueue_head(&data->ccb_waitq);
> +
> /* write the ccb to hw */
> + spin_lock_irqsave(&hw->alloc_lock, flags);
> ilo_ccb_open(hw, data, slot);
> + hw->ccb_alloc[slot] = data;
> + spin_unlock_irqrestore(&hw->alloc_lock, flags);
>
> /* make sure the channel is functional */
> error = ilo_ccb_verify(hw, data);
> if (error) {
> +
> + spin_lock_irqsave(&hw->alloc_lock, flags);
> + hw->ccb_alloc[slot] = NULL;
> + spin_unlock_irqrestore(&hw->alloc_lock, flags);
> +
> ilo_ccb_close(hw->ilo_dev, data);
> +
> kfree(data);
> goto out;
> }
>
> - data->ccb_cnt = 1;
> - data->ccb_excl = fp->f_flags & O_EXCL;
> - data->ilo_hw = hw;
> - hw->ccb_alloc[slot] = data;
> -
> } else {
> kfree(data);
> if (fp->f_flags & O_EXCL || hw->ccb_alloc[slot]->ccb_excl) {
> @@ -580,7 +583,7 @@ static int ilo_open(struct inode *ip, st
> }
> }
> out:
> - spin_unlock(&hw->alloc_lock);
> + spin_unlock(&hw->open_lock);
>
> if (!error)
> fp->private_data = hw->ccb_alloc[slot];
> @@ -596,6 +599,41 @@ static const struct file_operations ilo_
> .release = ilo_close,
> };
>From this function I infer that the designed lock nesting is
open_lock
->alloc_lock
->fifo_lock
yes? It would be useful to document that also.
Have these changes been runtime tested with lockdep enabled?
>
> ...
>
next prev parent reply other threads:[~2009-08-18 21:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-10 19:57 [PATCH 0/3] Enable poll handler in hpilo David Altobelli
2009-08-10 19:58 ` [PATCH 1/3] hpilo: staging for interrupt handling David Altobelli
2009-08-10 20:00 ` [PATCH 2/3] hpilo: add interrupt handler David Altobelli
2009-08-18 21:30 ` Andrew Morton [this message]
2009-08-18 22:25 ` Altobelli, David
2009-08-10 20:00 ` [PATCH 3/3] hpilo: add poll f_op David Altobelli
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=20090818143003.4924d26a.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=david.altobelli@hp.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox