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:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-27 16:57 [PATCH] Merge the Sonics Silicon Backplane subsystem Michael Buesch
[not found] ` <200707271857.24162.mb-fseUSCV1ubazQB+pC5nmwQ@public.gmane.org>
2007-07-27 19:03 ` Andrew Morton
[not found] ` <20070727120318.54d18cfc.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2007-07-27 19:30 ` Michael Buesch
[not found] ` <200707272130.48973.mb-fseUSCV1ubazQB+pC5nmwQ@public.gmane.org>
2007-07-27 19:38 ` Andrew Morton
[not found] ` <20070727123853.d16e875c.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2007-07-27 19:43 ` Michael Buesch [this message]
[not found] ` <200707272143.59551.mb-fseUSCV1ubazQB+pC5nmwQ@public.gmane.org>
2007-07-27 20:12 ` Andrew Morton
[not found] ` <20070727131249.74330a3d.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
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:39 ` Michael Buesch
2007-08-02 13:58 ` Geert Uytterhoeven
2007-08-02 14:24 ` Michael Buesch
2007-08-02 16:12 ` Geert Uytterhoeven
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-fseuscv1ubazqb+pc5nmwq@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=bcm43xx-dev-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=zambrano-dY08KVG/lbpWk0Htik3J/w@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).