From: Michael Buesch <mb@bu3sch.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "linux-kernel" <linux-kernel@vger.kernel.org>,
bcm43xx-dev@lists.berlios.de, netdev@vger.kernel.org,
linux-wireless@vger.kernel.org,
Gary Zambrano <zambrano@broadcom.com>
Subject: Re: [PATCH] Merge the Sonics Silicon Backplane subsystem
Date: Fri, 27 Jul 2007 21:43:59 +0200 [thread overview]
Message-ID: <200707272143.59551.mb@bu3sch.de> (raw)
In-Reply-To: <20070727123853.d16e875c.akpm@linux-foundation.org>
On Friday 27 July 2007 21:38:53 Andrew Morton wrote:
> > > > +static ssize_t ssb_pci_attr_sprom_show(struct device *pcidev,
> > > > + struct device_attribute *attr,
> > > > + char *buf)
> > > > +{
> > > > + struct pci_dev *pdev = container_of(pcidev, struct pci_dev, dev);
> > > > + struct ssb_bus *bus;
> > > > + u16 *sprom;
> > > > + int err = -ENODEV;
> > > > + ssize_t count = 0;
> > > > +
> > > > + bus = ssb_pci_dev_to_bus(pdev);
> > > > + if (!bus)
> > > > + goto out;
> > > > + err = -ENOMEM;
> > > > + sprom = kcalloc(SSB_SPROMSIZE_WORDS, sizeof(u16), GFP_KERNEL);
> > > > + if (!sprom)
> > > > + goto out;
> > > > +
> > > > + err = -ERESTARTSYS;
> > > > + if (mutex_lock_interruptible(&bus->pci_sprom_mutex))
> > > > + goto out_kfree;
> > > > + sprom_do_read(bus, sprom);
> > > > + mutex_unlock(&bus->pci_sprom_mutex);
> > > > +
> > > > + count = sprom2hex(sprom, buf, PAGE_SIZE);
> > > > + err = 0;
> > > > +
> > > > +out_kfree:
> > > > + kfree(sprom);
> > > > +out:
> > > > + return err ? err : count;
> > > > +}
> > >
> > > The mutex_lock_interruptible() looks fishy. Some commented explanation of
> > > what it's doing would be good here. It's quite unobvious to this reader.
> > > Cheesy deadlock avoidance? Hope not.
> >
> > No, it's simply to avoid writing the SPROM concurrently.
> > SPROM writing is hairy and we must make sure here that
> > we are the only one accessing the whole bus. We do that
> > by suspending all devices and taking a lock to protect
> > the SPROM from write concurrency.
>
> Sure, but why is the locking interruptible rather than plain old
> mutex_lock()?
Hm, well. We hold this mutex for several seconds, as writing takes
this long. So I simply thought it was worth allowing the waiter
to interrupt here. If you say that's not an issue, I'll be happy
to use mutex_lock() and reduce code complexity in this area.
--
Greetings Michael.
WARNING: multiple messages have this Message-ID (diff)
From: Michael Buesch <mb-fseUSCV1ubazQB+pC5nmwQ@public.gmane.org>
To: Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
Cc: "linux-kernel"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
bcm43xx-dev-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Gary Zambrano <zambrano-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Subject: Re: [PATCH] Merge the Sonics Silicon Backplane subsystem
Date: Fri, 27 Jul 2007 21:43:59 +0200 [thread overview]
Message-ID: <200707272143.59551.mb@bu3sch.de> (raw)
In-Reply-To: <20070727123853.d16e875c.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
On Friday 27 July 2007 21:38:53 Andrew Morton wrote:
> > > > +static ssize_t ssb_pci_attr_sprom_show(struct device *pcidev,
> > > > + struct device_attribute *attr,
> > > > + char *buf)
> > > > +{
> > > > + struct pci_dev *pdev = container_of(pcidev, struct pci_dev, dev);
> > > > + struct ssb_bus *bus;
> > > > + u16 *sprom;
> > > > + int err = -ENODEV;
> > > > + ssize_t count = 0;
> > > > +
> > > > + bus = ssb_pci_dev_to_bus(pdev);
> > > > + if (!bus)
> > > > + goto out;
> > > > + err = -ENOMEM;
> > > > + sprom = kcalloc(SSB_SPROMSIZE_WORDS, sizeof(u16), GFP_KERNEL);
> > > > + if (!sprom)
> > > > + goto out;
> > > > +
> > > > + err = -ERESTARTSYS;
> > > > + if (mutex_lock_interruptible(&bus->pci_sprom_mutex))
> > > > + goto out_kfree;
> > > > + sprom_do_read(bus, sprom);
> > > > + mutex_unlock(&bus->pci_sprom_mutex);
> > > > +
> > > > + count = sprom2hex(sprom, buf, PAGE_SIZE);
> > > > + err = 0;
> > > > +
> > > > +out_kfree:
> > > > + kfree(sprom);
> > > > +out:
> > > > + return err ? err : count;
> > > > +}
> > >
> > > The mutex_lock_interruptible() looks fishy. Some commented explanation of
> > > what it's doing would be good here. It's quite unobvious to this reader.
> > > Cheesy deadlock avoidance? Hope not.
> >
> > No, it's simply to avoid writing the SPROM concurrently.
> > SPROM writing is hairy and we must make sure here that
> > we are the only one accessing the whole bus. We do that
> > by suspending all devices and taking a lock to protect
> > the SPROM from write concurrency.
>
> Sure, but why is the locking interruptible rather than plain old
> mutex_lock()?
Hm, well. We hold this mutex for several seconds, as writing takes
this long. So I simply thought it was worth allowing the waiter
to interrupt here. If you say that's not an issue, I'll be happy
to use mutex_lock() and reduce code complexity in this area.
--
Greetings Michael.
next prev parent reply other threads:[~2007-07-27 19:45 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-27 16:57 [PATCH] Merge the Sonics Silicon Backplane subsystem Michael Buesch
2007-07-27 16:57 ` Michael Buesch
2007-07-27 19:03 ` Andrew Morton
2007-07-27 19:03 ` Andrew Morton
2007-07-27 19:30 ` Michael Buesch
2007-07-27 19:30 ` Michael Buesch
2007-07-27 19:38 ` Andrew Morton
2007-07-27 19:38 ` Andrew Morton
2007-07-27 19:43 ` Michael Buesch [this message]
2007-07-27 19:43 ` Michael Buesch
2007-07-27 20:12 ` Andrew Morton
2007-07-27 20:12 ` Andrew Morton
2007-07-27 20:28 ` Michael Buesch
2007-07-27 20:28 ` Michael Buesch
2007-07-29 4:45 ` Dmitry Torokhov
2007-07-27 19:21 ` John W. Linville
2007-07-27 19:21 ` John W. Linville
2007-07-27 19:39 ` Michael Buesch
2007-08-02 13:58 ` Geert Uytterhoeven
2007-08-02 14:24 ` Michael Buesch
2007-08-02 14:24 ` Michael Buesch
2007-08-02 16:12 ` Geert Uytterhoeven
2007-08-02 16:18 ` Michael Buesch
2007-08-02 16:18 ` Michael Buesch
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=200707272143.59551.mb@bu3sch.de \
--to=mb@bu3sch.de \
--cc=akpm@linux-foundation.org \
--cc=bcm43xx-dev@lists.berlios.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=zambrano@broadcom.com \
/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.