All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Metcalf <cmetcalf@tilera.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Greg KH <gregkh@suse.de>, <linux-kernel@vger.kernel.org>,
	Eric Biederman <ebiederm@aristanetworks.com>,
	Chris Wright <chrisw@sous-sol.org>,
	Benjamin Thery <benjamin.thery@bull.net>,
	Phil Carmody <ext-phil.2.carmody@nokia.com>
Subject: Re: [PATCH v2] arch/tile: add hypervisor-based character driver for SPI flash ROM
Date: Sun, 29 May 2011 14:23:59 -0400	[thread overview]
Message-ID: <4DE28F3F.2010709@tilera.com> (raw)
In-Reply-To: <201105291745.26468.arnd@arndb.de>

On 5/29/2011 11:45 AM, Arnd Bergmann wrote:
> On Sunday 29 May 2011 14:18:36 Chris Metcalf wrote:
>> On 5/29/2011 7:45 AM, Greg KH wrote:
>>> On Sat, May 28, 2011 at 08:32:07PM -0400, Chris Metcalf wrote:
>>>>> As you are only using 1 minor device, why not just use a misc device
>>>>> instead?  It's simpler, and you get the sysfs code for free, which you
>>>>> forgot to do, so your device node will never show up in userspace :(
>>>> Interesting; this appears to be a bug.  We use 4 minors (see "srom_devs =
>>>> 4" higher up).  I'll fix this.  We may have some other devices that would
>>>> benefit from being recast as misc devices, so I'll look at our set of
>>>> internal devices.
>>> This kind of implies that you didn't test this code, right?  You might
>>> want to do that next time :)
>> No, this bug has been in the code since day one (I just double-checked our
>> SCM), and it has always worked fine.  I'm looking into how this is possible
>> now, but trust me, we've tested this aspect of the driver the whole time. :-)
>>
> AFAICT, the driver just calls cdev_add in a loop, adding one device
> add a time. This is actually a correct way to register multiple
> character devices, but simply passing the number of devices you
> want to add as the third argument would be simpler.

Good catch!  Amusingly, I audited our other drivers that we haven't tried
to push back yet, and did find one that actually did have this bug: it was
doing cdev_add() without the surrounding loop, but without passing the
right minor count from alloc_chrdev_region() (although in that case the
default value was "1" in any case).

I restructured the tile-srom init code to call cdev_add() once, using a
single global "struct cdev".  The "open" routine now uses "iminor()"
instead of "container_of()" to get the proper srom_dev structure with the
driver's per-partition info.

> On a related note, the number of devices you add is a module parameter,
> which seems a bit backwards, since the hypervisor should actually
> know how many devices there are. Can't you just ask the hypervisor?

Fair point.  I restructured the init so we loop calling hv_dev_open() until
the hypervisor says we've hit a bad partition number, and that's the number
of partitions the Linux driver then supports.

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com



  reply	other threads:[~2011-05-29 18:24 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-04 19:10 [PATCH] arch/tile: add arch/tile/drivers/ directory with SROM driver Chris Metcalf
2011-05-05  6:41 ` Arnd Bergmann
2011-05-06 19:37   ` Chris Metcalf
2011-05-20 18:05   ` Chris Metcalf
2011-05-20 18:46     ` Arnd Bergmann
2011-05-20 22:40       ` Eric Biederman
2011-05-20 23:39         ` Chris Metcalf
2011-05-21  3:21           ` Greg KH
2011-05-21  9:33             ` Arnd Bergmann
2011-05-21 13:52               ` Chris Metcalf
2011-05-21 15:02                 ` Arnd Bergmann
2011-05-21 15:31                   ` Chris Metcalf
2011-05-21 15:50                 ` Eric Biederman
2011-05-23 20:10                   ` Chris Metcalf
2011-05-21  7:46           ` Eric Biederman
2011-05-21  8:32             ` Arnd Bergmann
2011-05-22  0:54               ` Mike Frysinger
2011-05-28 15:13 ` [PATCH v2] arch/tile: add hypervisor-based character driver for SPI flash ROM Chris Metcalf
2011-05-28 21:23   ` Greg KH
2011-05-29  0:32     ` Chris Metcalf
2011-05-29 11:45       ` Greg KH
2011-05-29 12:18         ` Chris Metcalf
2011-05-29 13:47           ` Greg KH
2011-05-29 15:45           ` Arnd Bergmann
2011-05-29 18:23             ` Chris Metcalf [this message]
2011-06-02 15:04   ` [PATCH v3] " Chris Metcalf
2011-06-10 16:41     ` Arnd Bergmann

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=4DE28F3F.2010709@tilera.com \
    --to=cmetcalf@tilera.com \
    --cc=arnd@arndb.de \
    --cc=benjamin.thery@bull.net \
    --cc=chrisw@sous-sol.org \
    --cc=ebiederm@aristanetworks.com \
    --cc=ext-phil.2.carmody@nokia.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 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.