Re: [PATCH] Merge the Sonics Silicon Backplane subsystem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux