From: Brian Norris <computersforpeace@gmail.com>
To: Javier Martinez Canillas <javier@osg.samsung.com>
Cc: Mark Brown <broonie@kernel.org>,
Heiner Kallweit <hkallweit1@gmail.com>,
linux-mtd@lists.infradead.org,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org
Subject: Re: spi: OF module autoloading is still broken
Date: Mon, 16 Nov 2015 11:24:34 -0800 [thread overview]
Message-ID: <20151116192434.GO8456@google.com> (raw)
In-Reply-To: <564A101F.9090807@osg.samsung.com>
Hi Javier,
On Mon, Nov 16, 2015 at 02:19:27PM -0300, Javier Martinez Canillas wrote:
> On 11/13/2015 08:48 PM, Brian Norris wrote:
> > On Fri, Nov 13, 2015 at 11:14:10PM +0000, Mark Brown wrote:
> >> On Fri, Nov 13, 2015 at 02:51:13PM -0800, Brian Norris wrote:
> Documentation/devicetree/bindings/mtd/jedec,spi-nor.txt
>
> And doesn't have a list of compatible strings. It points to a file in
> the Linux kernel source tree (drivers/mtd/devices/m25p80.c) which IMHO
> is wrong since the bindings should be OS agnostic. So instead, a list
> of the valid compatible strings (with both manufacturer and model)
> should be documented there.
Yep, that's a sore spot that I'm aware of. We had enough trouble sorting
out what "jedec,spi-nor" would be, and I never moved on to the point of
fixing up that comment. Will do that this week.
> The fact that having compatible = "garbage,valid-model" or "valid-model"
> worked was just a fortunate event due how the SPI core currently works.
I'd call that "unfortunate", and I agree with Mark. Implementation
matters more than documentation when talking about ABI.
> > No "nor-jedec" -- that was an intermediate name that got replaced
> > mid-release-cycle due to some late DT review comments.
> >
>
> I think the comments in the m25p80 driver should be updated then since I
> had the same confusion when reading the spi_device_id table.
Oops, thanks for pointing that out. That's old garbage that should be
cleaned up. Will patch that soon.
> > But yes, I suppose adding "spi-nor" back to the spi_device_id table
> > fixes *one* of the immediate problems (i.e., 'compatible =
> > "jedec,spi-nor"'). That would cover Heiner's report. But it doesn't
> > solve:
> >
> > compatible = "vendor,shiny-new-device", "jedec,spi-nor"
> >
> > I believe that the latter is sometimes the Right Way (TM) to do things
> > for device tree, so you have a fallback if auto-probing "jedec,spi-nor"
> > ever doesn't suffice.
> >
> > (This came up in Heiner's original post: "In case of m25p80 this means
> > that "jedec,spi-nor" has to be the first "compatible" value. This
> > constraint might be too strict ..")
> >
>
> I don't believe Heiner's statement is correct or maybe I misunderstood how
> module alias is reported for OF based platforms. But IIRC what happens is
> that the of_device_get_modalias() concatenates all the compatible strings
> that are present in the OF node.
Heiner was only talking about the existing SPI core code, which doesn't
use of_device_get_modalias().
> So in this particular example the reported modalias would be:
>
> of:Nshiny-new-deviceT<NULL>Cvendor,shiny-new-deviceCjedec,spi-nor
>
> and since the modaliases that will be stored in the module would be:
>
> alias: of:N*T*Cjedec,spi-nor*
>
> the latter will match the former since all compatible strings are in the
> reported modalias and the of_device_id .name was not set so is a wilcard.
>
> If there is also a "vendor,shiny-new-device", then the aliases would be:
>
> alias: of:N*T*Cvendor,shiny-new-device*
> alias: of:N*T*Cjedec,spi-nor*
>
> so of:N*T*Cvendor,shiny-new-device* will also match
> of:Nshiny-new-deviceT<NULL>Cvendor,shiny-new-deviceCjedec,spi-nor
>
> That covers the two use cases for valid compatible strings AFAICT and DT
> using invalid compatible strings should not be tried to be supported IMHO.
But it doesn't cover cases like this:
compatible = "vendor,m25p80";
which today yield uevent/modalias:
spi:m25p80
and will match with m25p80.c's spi_device_id table (and therefore will
autoload). Your patch will change this to:
of:N*T*vendor,m25p80*
and unless I go and add "vendor,m25p80" to m25p80's of_match_table as
well, then this will NOT autoload. But, see how this can't be extended
to wildcard matches? So I think your patch requires a bit more thought
and care, or else you will break a lot more than you think.
> I will of course add a comment to my patch explaining what could break when
> the SPI core is modified to report a proper OF modalias
> but I don't think we
> should try to maintain FDTs that were not doing the right thing with regard
> to using wrong and undocumented compatible strings.
I don't think you have problems only with bad FDTs. I think you have a
problem with perfectly valid DTs.
Brian
next prev parent reply other threads:[~2015-11-16 19:24 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <56104E88.3040807@gmail.com>
2015-11-12 18:59 ` m25p80: Commit "allow arbitrary OF matching for "jedec,spi-nor"" breaks module autoloading Brian Norris
2015-11-13 19:40 ` spi: OF module autoloading is still broken (was: Re: m25p80: Commit "allow arbitrary OF matching for "jedec,spi-nor"" breaks module autoloading) Brian Norris
2015-11-13 22:12 ` Mark Brown
2015-11-13 22:51 ` Brian Norris
2015-11-13 23:14 ` Mark Brown
2015-11-13 23:48 ` Brian Norris
2015-11-16 13:53 ` Mark Brown
2015-11-16 17:26 ` spi: OF module autoloading is still broken Javier Martinez Canillas
2015-11-16 17:51 ` Mark Brown
2015-11-16 18:00 ` Javier Martinez Canillas
2015-11-16 17:19 ` Javier Martinez Canillas
2015-11-16 17:49 ` Mark Brown
2015-11-16 17:57 ` Javier Martinez Canillas
2015-11-16 19:24 ` Brian Norris [this message]
2015-11-16 20:00 ` Javier Martinez Canillas
2015-11-16 20:47 ` Brian Norris
2015-11-16 21:32 ` Javier Martinez Canillas
2015-11-16 21:51 ` Brian Norris
2015-11-17 13:14 ` Javier Martinez Canillas
2015-11-17 13:19 ` Mark Brown
2015-11-17 13:36 ` Javier Martinez Canillas
2015-11-18 20:07 ` Javier Martinez Canillas
2015-11-19 12:47 ` Javier Martinez Canillas
2015-11-17 13:34 ` Mark Brown
2015-11-17 13:38 ` Javier Martinez Canillas
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=20151116192434.GO8456@google.com \
--to=computersforpeace@gmail.com \
--cc=broonie@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=javier@osg.samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-spi@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;
as well as URLs for NNTP newsgroup(s).