Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1406282 > unrolled thread
| Started by | Christer Weinigel <christer@weinigel.se> |
|---|---|
| First post | 2016-05-24 18:50 +0200 |
| Last post | 2016-05-26 10:30 +0200 |
| Articles | 20 on this page of 44 — 6 participants |
Back to article view | Back to linux.kernel
[PATCH] devicetree - document using aliases to set spi bus number. Christer Weinigel <christer@weinigel.se> - 2016-05-24 18:50 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Brown <broonie@kernel.org> - 2016-05-24 19:30 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Christer Weinigel <christer@weinigel.se> - 2016-05-24 20:20 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Brown <broonie@kernel.org> - 2016-05-24 20:40 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Christer Weinigel <christer@weinigel.se> - 2016-05-24 21:00 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Rutland <mark.rutland@arm.com> - 2016-05-25 14:20 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Brown <broonie@kernel.org> - 2016-05-25 15:00 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Brown <broonie@kernel.org> - 2016-05-25 14:40 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Frank Rowand <frowand.list@gmail.com> - 2016-05-25 01:40 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Frank Rowand <frowand.list@gmail.com> - 2016-05-25 02:20 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Rob Herring <robh@kernel.org> - 2016-05-25 19:50 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Brown <broonie@kernel.org> - 2016-05-25 20:10 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Frank Rowand <frowand.list@gmail.com> - 2016-05-25 20:10 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Brown <broonie@kernel.org> - 2016-05-25 20:50 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Christer Weinigel <christer@weinigel.se> - 2016-05-26 03:20 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Rob Herring <robh@kernel.org> - 2016-05-26 03:50 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Christer Weinigel <christer@weinigel.se> - 2016-05-26 04:00 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Brown <broonie@kernel.org> - 2016-05-26 12:20 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Christer Weinigel <christer@weinigel.se> - 2016-05-26 13:00 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Brown <broonie@kernel.org> - 2016-05-26 20:50 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Christer Weinigel <christer@weinigel.se> - 2016-05-26 23:10 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Brown <broonie@kernel.org> - 2016-05-27 18:50 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Rutland <mark.rutland@arm.com> - 2016-05-24 19:50 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Frank Rowand <frowand.list@gmail.com> - 2016-05-24 22:50 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Rutland <mark.rutland@arm.com> - 2016-05-25 11:30 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Brown <broonie@kernel.org> - 2016-05-25 12:40 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Christer Weinigel <christer@weinigel.se> - 2016-05-25 13:30 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Rutland <mark.rutland@arm.com> - 2016-05-25 14:40 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Brown <broonie@kernel.org> - 2016-05-25 15:10 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Frank Rowand <frowand.list@gmail.com> - 2016-05-25 17:40 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Rutland <mark.rutland@arm.com> - 2016-05-25 18:10 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Frank Rowand <frowand.list@gmail.com> - 2016-05-25 18:30 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Brown <broonie@kernel.org> - 2016-05-25 20:10 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Brown <broonie@kernel.org> - 2016-05-25 20:00 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Frank Rowand <frowand.list@gmail.com> - 2016-05-25 20:50 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Brown <broonie@kernel.org> - 2016-05-27 20:40 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Christer Weinigel <christer@weinigel.se> - 2016-05-28 23:00 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Brown <broonie@kernel.org> - 2016-05-30 18:20 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Frank Rowand <frowand.list@gmail.com> - 2016-05-25 17:30 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Rutland <mark.rutland@arm.com> - 2016-05-25 18:10 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Frank Rowand <frowand.list@gmail.com> - 2016-05-25 18:40 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Mark Brown <broonie@kernel.org> - 2016-05-25 20:50 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Rob Herring <robh@kernel.org> - 2016-05-25 20:50 +0200
Re: [PATCH] devicetree - document using aliases to set spi bus number. Geert Uytterhoeven <geert@linux-m68k.org> - 2016-05-26 10:30 +0200
Page 2 of 3 — ← Prev page 1 [2] 3 Next page →
| From | Christer Weinigel <christer@weinigel.se> |
|---|---|
| Date | 2016-05-26 23:10 +0200 |
| Subject | Re: [PATCH] devicetree - document using aliases to set spi bus number. |
| Message-ID | <rDaHw-2Xq-29@gated-at.bofh.it> |
| In reply to | #1407670 |
On 05/26/2016 08:47 PM, Mark Brown wrote: > On Thu, May 26, 2016 at 12:58:22PM +0200, Christer Weinigel wrote: > >> One of the main drivers behind devicetree was that Linus got fed >> up with the churn for all platform device changes in arch/arm. >> I faintly recall him writing that he would be rather unhappy if >> that just got replaced with churn for devicetree dts files. > > Since device trees are hardware descriptions they really shouldn't > be churning at all - if they are that's an indication that we're > failing at device tree. I meant churn from the sheer number of platforms. According to gsmarena.com there were over 600 new Android devices released last year. Each and every one of them is a Linux platform. I've personally worked on *counts on fingers* 8 different custom Linux platforms during the last year. That's a lot of new device tree files if all of them were to end up in the mainline kernel. My point is that I don't think it would be doable to get every devicetree file out there into the mainline kernel; it's not even desirable. devicetree files for custom platforms are a lot like userspace applications, the devicetree implementation is an ABI, and devicetrees for a lot of different platforms are built for that ABI. Using "the dts file is not in mainline" or "there is no user of that devicetree feature in mainline" as an argument for breaking existing dts files is in my opinion not a good argument. That will be a change that is visible to userspace (because device names will change). >> For platforms based on a FPGA such as the Xilinx Zync it's even >> more pointless to submit dts files to mainline. When you have >> "hardware" that can be reconfigured the device tree files can't >> be set in stone. If I use Xilinx tools [1] to add one more UART >> I have just added new hardware this needs to be reflected in the >> devicetree for the devices to be usable in Linux. And something >> like aliases which provides a stable device name can be very >> useful here. > > Right, but it doesn't follow that aliases are what we should be > doing here - both Rob and myself have mentioned providing a way to > label the actual SPI devices themselves, this seems like a more > robust way of doing things. That would be good. It would probably be clearer to have "i2c-sensors" than "i2c3". But it won't solve all of the issues that were flagged as bad with aliases. For example, someone mentioned that even if aliases worked with devicetree fragments there could be collisions in the numbering f aliases. As long as user assigned names are used there are going to be mistakes and collisions are going to happen. Some nut like me will come along and build lots of temperature sensors and have multiple buses to talk to them, and then you end up with half a dozen "i2c-sensors" busses :-) http://zoo.weinigel.se/misc/temp-chain.jpg These are actually dallas one-wire sensors, but you get the point. The only way to guarantee uniqueness would be to use uuids or something inherently unique like bus addresses (where collisions would break other things anyway) , but then we're back to things not being that user friendly again. > Just numbering the buses provides a partial solution for some > systems with usability drawbacks (you need to know the number to > name mapping somehow), naming devices is both more direct and more > general. Except that being able to assign static bus numbers devicetree is something that works _now_ and at least for me it is good enough. Being able to assign bus numbers makes life for me and the colleagues I have to support a lot easier. The whole reason I started looking at assigning bus numbers to spi ports was a very frustrated colleague complaining about the seemingly random bus number assignment. To be able to put stickers on the pin headers on a board saying "spi1", "spi2" and "spi3" and being able to refer to those numbers in in an email makes things a lot easier. It would probably be better if some future devicetree extension would allow abitrary user-friendly naming of devices, but in the absence of that I'd take numbers every time. If I'd have to wait for a perfect solution before doing something I'd never get anything done. A dumb and ok solution is often "better" than a complex one. /Christer
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2016-05-27 18:50 +0200 |
| Subject | Re: [PATCH] devicetree - document using aliases to set spi bus number. |
| Message-ID | <rDt7s-5Rp-23@gated-at.bofh.it> |
| In reply to | #1407716 |
[Multipart message — attachments visible in raw view] — view raw
On Thu, May 26, 2016 at 11:04:18PM +0200, Christer Weinigel wrote: > My point is that I don't think it would be doable to get every > devicetree file out there into the mainline kernel; it's not even > desirable. devicetree files for custom platforms are a lot like > userspace applications, the devicetree implementation is an ABI, and > devicetrees for a lot of different platforms are built for that ABI. Right, but we're nowhere near at the point where it's a very firm ABI - the overwhelming majority of the devices that ship aren't anywhere near shipping mainline usefully and where people are there are generally at least a representative subset of boards that are supported upstream and some visible community. > Using "the dts file is not in mainline" or "there is no user of that > devicetree feature in mainline" as an argument for breaking existing > dts files is in my opinion not a good argument. That will be a change > that is visible to userspace (because device names will change). It's not just that one thing - there's also things like the fact that instantiating these devices is going to be producing enormous warnings in the kernel logs and just the general use cases I'm aware of for spidev being very much out of tree custom systems with lots of other assumptions ones and things like "I need to wiggle the pins on this EVB for test". The picture is very different to the installing a standard distro on your desktop one that's most crticial here. The systems that are upstream are doing something completely different and setting symbolic names which it might be useful to pay attention to. Like I say I don't actually particularly want to remove the code, I just don't want to tell people that it's a thing they should be doing or make it more discoverable since it's a bad interface and is going to be a problem long term for anyone who is trying to use it as an ABI. > > Right, but it doesn't follow that aliases are what we should be > > doing here - both Rob and myself have mentioned providing a way to > > label the actual SPI devices themselves, this seems like a more > > robust way of doing things. > That would be good. It would probably be clearer to have > "i2c-sensors" than "i2c3". But it won't solve all of the issues that > were flagged as bad with aliases. For example, someone mentioned that > even if aliases worked with devicetree fragments there could be > collisions in the numbering f aliases. As long as user assigned names > are used there are going to be mistakes and collisions are going to > happen. Some nut like me will come along and build lots of > temperature sensors and have multiple buses to talk to them, and then > you end up with half a dozen "i2c-sensors" busses :-) Right, this is one of the reasons why this sort of in kernel stuff is not a great solution and something like udev really is much more robust - it can assign names based on the totality of information it has including the full path to the device, record the choices it made and remember devices that aren't currently in the system. In the event of collisions the kernel can try a bunch of things to attempt to provide a useful default but ultimately it's limited. > > Just numbering the buses provides a partial solution for some > > systems with usability drawbacks (you need to know the number to > > name mapping somehow), naming devices is both more direct and more > > general. > Except that being able to assign static bus numbers devicetree is > something that works _now_ and at least for me it is good enough. ... > It would probably be better if some future devicetree extension would > allow abitrary user-friendly naming of devices, but in the absence of > that I'd take numbers every time. If I'd have to wait for a perfect > solution before doing something I'd never get anything done. A dumb > and ok solution is often "better" than a complex one. A better solution is not rocket science, a better solution is reading a more suitable string from the DT. That's pretty trivial. But people mostly only seem interested in documenting and hence promoting the existing poorly considered stuff.
[toc] | [prev] | [next] | [standalone]
| From | Mark Rutland <mark.rutland@arm.com> |
|---|---|
| Date | 2016-05-24 19:50 +0200 |
| Subject | Re: [PATCH] devicetree - document using aliases to set spi bus number. |
| Message-ID | <rCoCR-6jw-1@gated-at.bofh.it> |
| In reply to | #1406282 |
On Tue, May 24, 2016 at 06:39:20PM +0200, Christer Weinigel wrote: > Document how to use devicetree aliases to assign a stable > bus number to a spi bus. > > Signed-off-by: Christer Weinigel <christer@weinigel.se> > > --- > > Trivial documentation change. > > Not having used devicetree that much it was surprisingly hard to > figure out how to assign a stable bus number to a spi bus. Add a > simple example that shows how to do that. > > Mark Cced as the SPI maintainer. Or should trivial documentation > fixes like this be addressed to someone else? > > /Christer > > Documentation/devicetree/bindings/spi/spi-bus.txt | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/Documentation/devicetree/bindings/spi/spi-bus.txt b/Documentation/devicetree/bindings/spi/spi-bus.txt > index 42d5954..c35c4c2 100644 > --- a/Documentation/devicetree/bindings/spi/spi-bus.txt > +++ b/Documentation/devicetree/bindings/spi/spi-bus.txt > @@ -94,3 +94,13 @@ SPI example for an MPC5200 SPI bus: > reg = <1>; > }; > }; > + > +Normally SPI buses are assigned dynamic bus numbers starting at 32766 > +and counting downwards. It is possible to assign the bus number > +statically using devicetee aliases. For example, on the MPC5200 the > +"spi@f00" device above is connected to the "soc" bus. To set its > +bus_num to 1 add an aliases entry like this: As Mark Brown pointed out, this is very Linux-specific (at least in the wording of the above). Generally, aliases are there to match _physical_ identifiers (e.g. to match physical labels for UART0, UART1, and on). I'm not sure whether that applies here. Thanks, Mark.
[toc] | [prev] | [next] | [standalone]
| From | Frank Rowand <frowand.list@gmail.com> |
|---|---|
| Date | 2016-05-24 22:50 +0200 |
| Message-ID | <rCrr4-8eY-7@gated-at.bofh.it> |
| In reply to | #1406306 |
On 5/24/2016 10:41 AM, Mark Rutland wrote: > On Tue, May 24, 2016 at 06:39:20PM +0200, Christer Weinigel wrote: >> Document how to use devicetree aliases to assign a stable >> bus number to a spi bus. >> >> Signed-off-by: Christer Weinigel <christer@weinigel.se> >> >> --- >> >> Trivial documentation change. >> >> Not having used devicetree that much it was surprisingly hard to >> figure out how to assign a stable bus number to a spi bus. Add a >> simple example that shows how to do that. >> >> Mark Cced as the SPI maintainer. Or should trivial documentation >> fixes like this be addressed to someone else? >> >> /Christer >> >> Documentation/devicetree/bindings/spi/spi-bus.txt | 10 ++++++++++ >> 1 file changed, 10 insertions(+) >> >> diff --git a/Documentation/devicetree/bindings/spi/spi-bus.txt b/Documentation/devicetree/bindings/spi/spi-bus.txt >> index 42d5954..c35c4c2 100644 >> --- a/Documentation/devicetree/bindings/spi/spi-bus.txt >> +++ b/Documentation/devicetree/bindings/spi/spi-bus.txt >> @@ -94,3 +94,13 @@ SPI example for an MPC5200 SPI bus: >> reg = <1>; >> }; >> }; >> + >> +Normally SPI buses are assigned dynamic bus numbers starting at 32766 >> +and counting downwards. It is possible to assign the bus number >> +statically using devicetee aliases. For example, on the MPC5200 the >> +"spi@f00" device above is connected to the "soc" bus. To set its >> +bus_num to 1 add an aliases entry like this: > > As Mark Brown pointed out, this is very Linux-specific (at least in the > wording of the above). Yes, Linux-specific. So the Linux documentation of bindings is the correct place for it. > > Generally, aliases are there to match _physical_ identifiers (e.g. to > match physical labels for UART0, UART1, and on). > > I'm not sure whether that applies here. The code and behavior is in the Linux kernel. It should be visible in the documentation instead of being a big mystery of how it works. > > Thanks, > Mark. > -- > To unsubscribe from this list: send the line "unsubscribe devicetree" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >
[toc] | [prev] | [next] | [standalone]
| From | Mark Rutland <mark.rutland@arm.com> |
|---|---|
| Date | 2016-05-25 11:30 +0200 |
| Subject | Re: [PATCH] devicetree - document using aliases to set spi bus number. |
| Message-ID | <rCDix-7HT-7@gated-at.bofh.it> |
| In reply to | #1406444 |
On Tue, May 24, 2016 at 01:41:26PM -0700, Frank Rowand wrote: > On 5/24/2016 10:41 AM, Mark Rutland wrote: > > On Tue, May 24, 2016 at 06:39:20PM +0200, Christer Weinigel wrote: > >> Document how to use devicetree aliases to assign a stable > >> bus number to a spi bus. > >> > >> Signed-off-by: Christer Weinigel <christer@weinigel.se> > >> > >> --- > >> > >> Trivial documentation change. > >> > >> Not having used devicetree that much it was surprisingly hard to > >> figure out how to assign a stable bus number to a spi bus. Add a > >> simple example that shows how to do that. > >> > >> Mark Cced as the SPI maintainer. Or should trivial documentation > >> fixes like this be addressed to someone else? > >> > >> /Christer > >> > >> Documentation/devicetree/bindings/spi/spi-bus.txt | 10 ++++++++++ > >> 1 file changed, 10 insertions(+) > >> > >> diff --git a/Documentation/devicetree/bindings/spi/spi-bus.txt b/Documentation/devicetree/bindings/spi/spi-bus.txt > >> index 42d5954..c35c4c2 100644 > >> --- a/Documentation/devicetree/bindings/spi/spi-bus.txt > >> +++ b/Documentation/devicetree/bindings/spi/spi-bus.txt > >> @@ -94,3 +94,13 @@ SPI example for an MPC5200 SPI bus: > >> reg = <1>; > >> }; > >> }; > >> + > >> +Normally SPI buses are assigned dynamic bus numbers starting at 32766 > >> +and counting downwards. It is possible to assign the bus number > >> +statically using devicetee aliases. For example, on the MPC5200 the > >> +"spi@f00" device above is connected to the "soc" bus. To set its > >> +bus_num to 1 add an aliases entry like this: > > > > As Mark Brown pointed out, this is very Linux-specific (at least in the > > wording of the above). > > Yes, Linux-specific. So the Linux documentation of bindings is the > correct place for it. I don't entirely agree. Which is not to say that I disagree as such, but rather that this is not a black-and-white affair. While bindings do happen to live in the kernel tree, we try to keep them separate from Linux internals or Linux API details that are outside of the scope of the HW/kernel interface. There are certainly reasons to describe Linux-specific bindings (e.g. things under /chosen). Mark Brown's comments imply that there is a better mechanism which does not rely on this binding, so even if we must retain support for it in Linux for legacy reasons, documenting it as a binding is not necessarily in anyone's best interest. If we want to document it, we may want to mark it as deprecated, with a pointer to better alternatives. > > Generally, aliases are there to match _physical_ identifiers (e.g. to > > match physical labels for UART0, UART1, and on). > > > > I'm not sure whether that applies here. > > The code and behavior is in the Linux kernel. It should be visible in > the documentation instead of being a big mystery of how it works. As above, I don't entirely agree. Mindlessly documenting existing Linux behaviour can have the unfortuante effect of moving people towards the wrong tool for the job. Thanks, Mark.
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2016-05-25 12:40 +0200 |
| Subject | Re: [PATCH] devicetree - document using aliases to set spi bus number. |
| Message-ID | <rCEoi-8jG-15@gated-at.bofh.it> |
| In reply to | #1406770 |
[Multipart message — attachments visible in raw view] — view raw
On Wed, May 25, 2016 at 10:20:34AM +0100, Mark Rutland wrote: > On Tue, May 24, 2016 at 01:41:26PM -0700, Frank Rowand wrote: > > The code and behavior is in the Linux kernel. It should be visible in > > the documentation instead of being a big mystery of how it works. > As above, I don't entirely agree. Mindlessly documenting existing Linux > behaviour can have the unfortuante effect of moving people towards the > wrong tool for the job. Yes, this is exactly my concern - the articulated use case (which didn't suprise me at all) is for using spidev which is itself not just Linux specific but this particular version of Linux right now specific. There are lots of things that happen to work but are in fact terrible ideas that leave messes for our future selves. We need to distinguish between things that are real, meaningful system descriptions and things that are implementation details resulting from the rush to force everyone on to DT.
[toc] | [prev] | [next] | [standalone]
| From | Christer Weinigel <christer@weinigel.se> |
|---|---|
| Date | 2016-05-25 13:30 +0200 |
| Subject | Re: [PATCH] devicetree - document using aliases to set spi bus number. |
| Message-ID | <rCFaG-nq-11@gated-at.bofh.it> |
| In reply to | #1406825 |
On 05/25/2016 12:38 PM, Mark Brown wrote:
> On Wed, May 25, 2016 at 10:20:34AM +0100, Mark Rutland wrote:
>> On Tue, May 24, 2016 at 01:41:26PM -0700, Frank Rowand wrote:
>
>>> The code and behavior is in the Linux kernel. It should be
>>> visible in the documentation instead of being a big mystery of
>>> how it works.
>
>> As above, I don't entirely agree. Mindlessly documenting existing
>> Linux behaviour can have the unfortuante effect of moving people
>> towards the wrong tool for the job.
>
> Yes, this is exactly my concern - the articulated use case (which
> didn't suprise me at all) is for using spidev which is itself not
> just Linux specific but this particular version of Linux right now
> specific. There are lots of things that happen to work but are in
> fact terrible ideas that leave messes for our future selves. We
> need to distinguish between things that are real, meaningful system
> descriptions and things that are implementation details resulting
> from the rush to force everyone on to DT.
Oh, for *beep* *beep* sake.
It used to be very easy to use SPI devices on Linux with stable device
names. Add a platform device entry and set bus_num. Add spidev
entries specifying the chip select, mode, speed and other specifics
for the devices on the bus. Then just use
/dev/spi$bus_num.$chip_select to talk to them. Very simple to use and
understand.
Doing the same with devicetree ought to be just as simple, and since
Grant added that patch it actually is. The behaviour is already in
the Linux kernel. Nobody is going to rip out the of_alias_get_id
usage from the spi driver sice that will break existing userspace.
Nobody is going to rip out the spidev framework from the Linux kernel.
The aliases mechanism which is specifically intended to provide
easy-to use names for userspace. From "A Symphony of Flavours: Using
the device tree to describe embedded hardware" by Grant Likely and
Josh Boyer:
In order to ease device lookup in client operating systems, it is
often desirable to define an aliases node. This allows one to
provide a shorthand method for identifying a device without having
to specify the full path on lookup.
What is so horrible about documenting the actual behaviour of the
Linux kernel? How is documenting that serial0 = /amba@0/blah@blah"
which is ok, so markedly different from documenting spi0 =
"/amba@0/blah/blah"?
Does everything have to be so damn difficult?
Ignore the patch if you want to, I give up. I just hope that someone
else that needs to do the same thing will find my patch with this
(ought to be) trivial documentation.
/Christer (tired of bikeshedding)
[toc] | [prev] | [next] | [standalone]
| From | Mark Rutland <mark.rutland@arm.com> |
|---|---|
| Date | 2016-05-25 14:40 +0200 |
| Subject | Re: [PATCH] devicetree - document using aliases to set spi bus number. |
| Message-ID | <rCGgq-Yf-25@gated-at.bofh.it> |
| In reply to | #1406849 |
On Wed, May 25, 2016 at 01:20:04PM +0200, Christer Weinigel wrote: > On 05/25/2016 12:38 PM, Mark Brown wrote: > > On Wed, May 25, 2016 at 10:20:34AM +0100, Mark Rutland wrote: > >> On Tue, May 24, 2016 at 01:41:26PM -0700, Frank Rowand wrote: > > > >>> The code and behavior is in the Linux kernel. It should be > >>> visible in the documentation instead of being a big mystery of > >>> how it works. > > > >> As above, I don't entirely agree. Mindlessly documenting existing > >> Linux behaviour can have the unfortuante effect of moving people > >> towards the wrong tool for the job. > > > > Yes, this is exactly my concern - the articulated use case (which > > didn't suprise me at all) is for using spidev which is itself not > > just Linux specific but this particular version of Linux right now > > specific. There are lots of things that happen to work but are in > > fact terrible ideas that leave messes for our future selves. We > > need to distinguish between things that are real, meaningful system > > descriptions and things that are implementation details resulting > > from the rush to force everyone on to DT. > > Oh, for *beep* *beep* sake. > > It used to be very easy to use SPI devices on Linux with stable device > names. Add a platform device entry and set bus_num. Add spidev > entries specifying the chip select, mode, speed and other specifics > for the devices on the bus. Then just use > /dev/spi$bus_num.$chip_select to talk to them. Very simple to use and > understand. > > Doing the same with devicetree ought to be just as simple, and since > Grant added that patch it actually is. The behaviour is already in > the Linux kernel. Nobody is going to rip out the of_alias_get_id > usage from the spi driver sice that will break existing userspace. > Nobody is going to rip out the spidev framework from the Linux kernel. > The aliases mechanism which is specifically intended to provide > easy-to use names for userspace. From "A Symphony of Flavours: Using > the device tree to describe embedded hardware" by Grant Likely and > Josh Boyer: > > In order to ease device lookup in client operating systems, it is > often desirable to define an aliases node. This allows one to > provide a shorthand method for identifying a device without having > to specify the full path on lookup. > > What is so horrible about documenting the actual behaviour of the > Linux kernel? We have described a set of problems that generally exist (e.g. mis-use of interfaces, and the fallout that can result). To avoid those, we must figure out the caveats that apply in this case. Many of us are immediately aware of mis-use rather than sensible use, as the former is painful for us while the latter goes by unnoticed. We asked about your use-case, hoping the it fell in the latter camp and could be used to drive the specification and perhaps function as an example. > How is documenting that serial0 = /amba@0/blah@blah" > which is ok, so markedly different from documenting spi0 = > "/amba@0/blah/blah"? I alluded to this a little bit in a reply to another sub-thread. Typically, serial ports are much more user-accessible (physically), and much more directly useful to a user in a generic fashion. They're often labelled (physically or in a manual) with a number, and we use aliases to describe those labels to the kernel. The fact that the kernel may use that to drive its own internal numbering is immaterial to the binding. > Does everything have to be so damn difficult? With the varied hardware that exists, and the constant expansion of the set of things which exist, there is very little that is simple any more. Things which are simple today can become alarming non-simple tomorrow, with only minor changes. So unfortunately, yes. I appreciate that it can feel like all the feedback has been negative, and that can be especially annoying given that you did not write the code in question. Please be aware that we are trying to work in your best interests, along with the best interests of many others who are using this code and binding today, or may in future. Specification work is a difficult, tiring process for all involved, for anything meaningful. Thanks, Mark.
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2016-05-25 15:10 +0200 |
| Subject | Re: [PATCH] devicetree - document using aliases to set spi bus number. |
| Message-ID | <rCGJs-1mV-5@gated-at.bofh.it> |
| In reply to | #1406871 |
[Multipart message — attachments visible in raw view] — view raw
On Wed, May 25, 2016 at 01:34:24PM +0100, Mark Rutland wrote: > On Wed, May 25, 2016 at 01:20:04PM +0200, Christer Weinigel wrote: > > Does everything have to be so damn difficult? > With the varied hardware that exists, and the constant expansion of the > set of things which exist, there is very little that is simple any more. > Things which are simple today can become alarming non-simple tomorrow, > with only minor changes. So unfortunately, yes. > I appreciate that it can feel like all the feedback has been negative, > and that can be especially annoying given that you did not write the > code in question. Please be aware that we are trying to work in your > best interests, along with the best interests of many others who are > using this code and binding today, or may in future. > Specification work is a difficult, tiring process for all involved, for > anything meaningful. Right, this is one of the costs that the community decided to take on when it decided to move away from platform devices to push everything into DT as an ABI. Things that are fine as platform data internal to the kernel aren't so good as OS neutral ABIs.
[toc] | [prev] | [next] | [standalone]
| From | Frank Rowand <frowand.list@gmail.com> |
|---|---|
| Date | 2016-05-25 17:40 +0200 |
| Message-ID | <rCJ4B-2Dy-1@gated-at.bofh.it> |
| In reply to | #1406770 |
On 5/25/2016 2:20 AM, Mark Rutland wrote: > On Tue, May 24, 2016 at 01:41:26PM -0700, Frank Rowand wrote: >> On 5/24/2016 10:41 AM, Mark Rutland wrote: >>> On Tue, May 24, 2016 at 06:39:20PM +0200, Christer Weinigel wrote: >>>> Document how to use devicetree aliases to assign a stable >>>> bus number to a spi bus. >>>> >>>> Signed-off-by: Christer Weinigel <christer@weinigel.se> >>>> >>>> --- >>>> >>>> Trivial documentation change. >>>> >>>> Not having used devicetree that much it was surprisingly hard to >>>> figure out how to assign a stable bus number to a spi bus. Add a >>>> simple example that shows how to do that. >>>> >>>> Mark Cced as the SPI maintainer. Or should trivial documentation >>>> fixes like this be addressed to someone else? >>>> >>>> /Christer >>>> >>>> Documentation/devicetree/bindings/spi/spi-bus.txt | 10 ++++++++++ >>>> 1 file changed, 10 insertions(+) >>>> >>>> diff --git a/Documentation/devicetree/bindings/spi/spi-bus.txt b/Documentation/devicetree/bindings/spi/spi-bus.txt >>>> index 42d5954..c35c4c2 100644 >>>> --- a/Documentation/devicetree/bindings/spi/spi-bus.txt >>>> +++ b/Documentation/devicetree/bindings/spi/spi-bus.txt >>>> @@ -94,3 +94,13 @@ SPI example for an MPC5200 SPI bus: >>>> reg = <1>; >>>> }; >>>> }; >>>> + >>>> +Normally SPI buses are assigned dynamic bus numbers starting at 32766 >>>> +and counting downwards. It is possible to assign the bus number >>>> +statically using devicetee aliases. For example, on the MPC5200 the >>>> +"spi@f00" device above is connected to the "soc" bus. To set its >>>> +bus_num to 1 add an aliases entry like this: >>> >>> As Mark Brown pointed out, this is very Linux-specific (at least in the >>> wording of the above). >> >> Yes, Linux-specific. So the Linux documentation of bindings is the >> correct place for it. > > I don't entirely agree. Which is not to say that I disagree as such, but > rather that this is not a black-and-white affair. > > While bindings do happen to live in the kernel tree, we try to keep them > separate from Linux internals or Linux API details that are outside of > the scope of the HW/kernel interface. There are certainly reasons to > describe Linux-specific bindings (e.g. things under /chosen). Where should this be documented? > Mark Brown's comments imply that there is a better mechanism which does > not rely on this binding, so even if we must retain support for it in > Linux for legacy reasons, documenting it as a binding is not necessarily > in anyone's best interest. If we want to document it, we may want to > mark it as deprecated, with a pointer to better alternatives. Lack of documentation and bad documentation are a MAJOR problem for devicetree. Refusing to accept documentation of existing behavior makes no sense to me. >>> Generally, aliases are there to match _physical_ identifiers (e.g. to >>> match physical labels for UART0, UART1, and on). >>> >>> I'm not sure whether that applies here. >> >> The code and behavior is in the Linux kernel. It should be visible in >> the documentation instead of being a big mystery of how it works. > > As above, I don't entirely agree. Mindlessly documenting existing Linux > behaviour can have the unfortuante effect of moving people towards the > wrong tool for the job. > > Thanks, > Mark. >
[toc] | [prev] | [next] | [standalone]
| From | Mark Rutland <mark.rutland@arm.com> |
|---|---|
| Date | 2016-05-25 18:10 +0200 |
| Subject | Re: [PATCH] devicetree - document using aliases to set spi bus number. |
| Message-ID | <rCJxE-32M-41@gated-at.bofh.it> |
| In reply to | #1407008 |
On Wed, May 25, 2016 at 08:32:51AM -0700, Frank Rowand wrote: > On 5/25/2016 2:20 AM, Mark Rutland wrote: > > On Tue, May 24, 2016 at 01:41:26PM -0700, Frank Rowand wrote: > >> On 5/24/2016 10:41 AM, Mark Rutland wrote: > >>> On Tue, May 24, 2016 at 06:39:20PM +0200, Christer Weinigel wrote: > >>>> Document how to use devicetree aliases to assign a stable > >>>> bus number to a spi bus. > >>>> > >>>> Signed-off-by: Christer Weinigel <christer@weinigel.se> > >>>> > >>>> --- > >>>> > >>>> Trivial documentation change. > >>>> > >>>> Not having used devicetree that much it was surprisingly hard to > >>>> figure out how to assign a stable bus number to a spi bus. Add a > >>>> simple example that shows how to do that. > >>>> > >>>> Mark Cced as the SPI maintainer. Or should trivial documentation > >>>> fixes like this be addressed to someone else? > >>>> > >>>> /Christer > >>>> > >>>> Documentation/devicetree/bindings/spi/spi-bus.txt | 10 ++++++++++ > >>>> 1 file changed, 10 insertions(+) > >>>> > >>>> diff --git a/Documentation/devicetree/bindings/spi/spi-bus.txt b/Documentation/devicetree/bindings/spi/spi-bus.txt > >>>> index 42d5954..c35c4c2 100644 > >>>> --- a/Documentation/devicetree/bindings/spi/spi-bus.txt > >>>> +++ b/Documentation/devicetree/bindings/spi/spi-bus.txt > >>>> @@ -94,3 +94,13 @@ SPI example for an MPC5200 SPI bus: > >>>> reg = <1>; > >>>> }; > >>>> }; > >>>> + > >>>> +Normally SPI buses are assigned dynamic bus numbers starting at 32766 > >>>> +and counting downwards. It is possible to assign the bus number > >>>> +statically using devicetee aliases. For example, on the MPC5200 the > >>>> +"spi@f00" device above is connected to the "soc" bus. To set its > >>>> +bus_num to 1 add an aliases entry like this: > >>> > >>> As Mark Brown pointed out, this is very Linux-specific (at least in the > >>> wording of the above). > >> > >> Yes, Linux-specific. So the Linux documentation of bindings is the > >> correct place for it. > > > > I don't entirely agree. Which is not to say that I disagree as such, but > > rather that this is not a black-and-white affair. > > > > While bindings do happen to live in the kernel tree, we try to keep them > > separate from Linux internals or Linux API details that are outside of > > the scope of the HW/kernel interface. There are certainly reasons to > > describe Linux-specific bindings (e.g. things under /chosen). > > Where should this be documented? That is a very good question, and one with no good or general answer. There are distinct answers for new and existing bindings. New bindings should not rely on Linux internals, and should be framed in terms of hardware or system design properties (there's some wiggle room for intent and configuration, in the case of things like watchdog timeouts). Existing cases should (almost always) be documented in the usual places, but caveats apply: (a) If they only exist as a workaround for legacy erroneous DT usage, then documenting them does not make sense. They are Linux-specific kludges. (b) If they exist, but are discouraged, we must mark them deprecated, and point at the encouraged way of doing things. I expect that many Linux-specific bindings fall in this case. (c) If they exist, and there is no other mechanism to provide equivalent functionality, then we must document them extremely carefully, with rationale and caveats. These cases highlight a hole in our ability to describe and/or abstract hardware, and we'd like to move these into category b. Regardless, if we can frame them as hardware properties and get rid of any reliance on Linux internal details, that is preferable. > > Mark Brown's comments imply that there is a better mechanism which does > > not rely on this binding, so even if we must retain support for it in > > Linux for legacy reasons, documenting it as a binding is not necessarily > > in anyone's best interest. If we want to document it, we may want to > > mark it as deprecated, with a pointer to better alternatives. > > Lack of documentation and bad documentation are a MAJOR problem for > devicetree. I certainly agree. > Refusing to accept documentation of existing behavior makes no > sense to me. To be clear: I am not refusing to document this. I am trying to ensure that we document this _appropriately_, with any caveats that apply, and (as far as possible) framed so as to not describe Linux internals. e.g. stating that this describes a well-defined system-specific bus number as documented in a manual, with a note regarding Linux behaviour is better simply describing the Linux behaviour. Thanks, Mark.
[toc] | [prev] | [next] | [standalone]
| From | Frank Rowand <frowand.list@gmail.com> |
|---|---|
| Date | 2016-05-25 18:30 +0200 |
| Message-ID | <rCJQZ-39l-1@gated-at.bofh.it> |
| In reply to | #1407035 |
On 5/25/2016 8:59 AM, Mark Rutland wrote: > On Wed, May 25, 2016 at 08:32:51AM -0700, Frank Rowand wrote: >> On 5/25/2016 2:20 AM, Mark Rutland wrote: >>> On Tue, May 24, 2016 at 01:41:26PM -0700, Frank Rowand wrote: >>>> On 5/24/2016 10:41 AM, Mark Rutland wrote: >>>>> On Tue, May 24, 2016 at 06:39:20PM +0200, Christer Weinigel wrote: >>>>>> Document how to use devicetree aliases to assign a stable >>>>>> bus number to a spi bus. >>>>>> >>>>>> Signed-off-by: Christer Weinigel <christer@weinigel.se> >>>>>> >>>>>> --- >>>>>> >>>>>> Trivial documentation change. >>>>>> >>>>>> Not having used devicetree that much it was surprisingly hard to >>>>>> figure out how to assign a stable bus number to a spi bus. Add a >>>>>> simple example that shows how to do that. >>>>>> >>>>>> Mark Cced as the SPI maintainer. Or should trivial documentation >>>>>> fixes like this be addressed to someone else? >>>>>> >>>>>> /Christer >>>>>> >>>>>> Documentation/devicetree/bindings/spi/spi-bus.txt | 10 ++++++++++ >>>>>> 1 file changed, 10 insertions(+) >>>>>> >>>>>> diff --git a/Documentation/devicetree/bindings/spi/spi-bus.txt b/Documentation/devicetree/bindings/spi/spi-bus.txt >>>>>> index 42d5954..c35c4c2 100644 >>>>>> --- a/Documentation/devicetree/bindings/spi/spi-bus.txt >>>>>> +++ b/Documentation/devicetree/bindings/spi/spi-bus.txt >>>>>> @@ -94,3 +94,13 @@ SPI example for an MPC5200 SPI bus: >>>>>> reg = <1>; >>>>>> }; >>>>>> }; >>>>>> + >>>>>> +Normally SPI buses are assigned dynamic bus numbers starting at 32766 >>>>>> +and counting downwards. It is possible to assign the bus number >>>>>> +statically using devicetee aliases. For example, on the MPC5200 the >>>>>> +"spi@f00" device above is connected to the "soc" bus. To set its >>>>>> +bus_num to 1 add an aliases entry like this: >>>>> >>>>> As Mark Brown pointed out, this is very Linux-specific (at least in the >>>>> wording of the above). >>>> >>>> Yes, Linux-specific. So the Linux documentation of bindings is the >>>> correct place for it. >>> >>> I don't entirely agree. Which is not to say that I disagree as such, but >>> rather that this is not a black-and-white affair. >>> >>> While bindings do happen to live in the kernel tree, we try to keep them >>> separate from Linux internals or Linux API details that are outside of >>> the scope of the HW/kernel interface. There are certainly reasons to >>> describe Linux-specific bindings (e.g. things under /chosen). >> >> Where should this be documented? > > That is a very good question, and one with no good or general answer. > There are distinct answers for new and existing bindings. > > New bindings should not rely on Linux internals, and should be framed in > terms of hardware or system design properties (there's some wiggle room > for intent and configuration, in the case of things like watchdog > timeouts). > > Existing cases should (almost always) be documented in the usual places, > but caveats apply: > > (a) If they only exist as a workaround for legacy erroneous DT usage, > then documenting them does not make sense. They are Linux-specific > kludges. When there is no other documentation, the kernel source is the documentation. If there is no mention that a case is for legacy use only then someone will attempt to use it. So I prefer that the case be documented and noted to be legacy. > (b) If they exist, but are discouraged, we must mark them deprecated, > and point at the encouraged way of doing things. I expect that many > Linux-specific bindings fall in this case. > > (c) If they exist, and there is no other mechanism to provide equivalent > functionality, then we must document them extremely carefully, with > rationale and caveats. These cases highlight a hole in our ability to > describe and/or abstract hardware, and we'd like to move these into > category b. > > Regardless, if we can frame them as hardware properties and get rid of > any reliance on Linux internal details, that is preferable. > >>> Mark Brown's comments imply that there is a better mechanism which does >>> not rely on this binding, so even if we must retain support for it in >>> Linux for legacy reasons, documenting it as a binding is not necessarily >>> in anyone's best interest. If we want to document it, we may want to >>> mark it as deprecated, with a pointer to better alternatives. >> >> Lack of documentation and bad documentation are a MAJOR problem for >> devicetree. > > I certainly agree. > >> Refusing to accept documentation of existing behavior makes no >> sense to me. > > To be clear: I am not refusing to document this. > > I am trying to ensure that we document this _appropriately_, with any > caveats that apply, and (as far as possible) framed so as to not > describe Linux internals. I am glad to hear that. But I have not seen any attempt by anyone in this thread to provide any help to Christer with how to change his documentation patch so that it is appropriately documenting the existing code and will be accepted. (The following "e.g." is maybe such an attempt.) > e.g. stating that this describes a well-defined system-specific bus > number as documented in a manual, with a note regarding Linux behaviour > is better simply describing the Linux behaviour. > > Thanks, > Mark. >
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2016-05-25 20:10 +0200 |
| Subject | Re: [PATCH] devicetree - document using aliases to set spi bus number. |
| Message-ID | <rCLpM-4a7-11@gated-at.bofh.it> |
| In reply to | #1407035 |
[Multipart message — attachments visible in raw view] — view raw
On Wed, May 25, 2016 at 04:59:50PM +0100, Mark Rutland wrote: > e.g. stating that this describes a well-defined system-specific bus > number as documented in a manual, with a note regarding Linux behaviour > is better simply describing the Linux behaviour. If it means anything it's really a system specific controller number but even there it's at least as likely that the system will provide a textual description as a number (eg, SPI_FLASH) and if it's supposed to map onto something that can be abstracted between systems there's no guarantee that if there's more than one SPI device to consider they'll be provided by the same arrangement of controllers and chip selects on different boards (which seems to be a use case here) so the spidev names would still vary.
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2016-05-25 20:00 +0200 |
| Subject | Re: [PATCH] devicetree - document using aliases to set spi bus number. |
| Message-ID | <rCLg5-3S1-11@gated-at.bofh.it> |
| In reply to | #1407008 |
[Multipart message — attachments visible in raw view] — view raw
On Wed, May 25, 2016 at 08:32:51AM -0700, Frank Rowand wrote: > On 5/25/2016 2:20 AM, Mark Rutland wrote: > > Linux for legacy reasons, documenting it as a binding is not necessarily > > in anyone's best interest. If we want to document it, we may want to > > mark it as deprecated, with a pointer to better alternatives. > Lack of documentation and bad documentation are a MAJOR problem for > devicetree. > Refusing to accept documentation of existing behavior makes no > sense to me. Sometimes the best thing to do is remove the behaviour, some of these things are just bugs. That's not quite the case here but it's in the spectrum of things that happen so clearly just blindly documenting everything people find happens to work is not great - if something isn't being used because it wasn't discoverable sometimes we should be thankful for that. Adding documentation for every last implementation that happens to work in a given situation through layers of indirection isn't going to help with the usability issues DT has, one of the things that the documentation does is tell both users and other OS vendors (and now I guess also people writing ACPI machine descriptions) what they should be doing when they implement or use the bindings. This is especially true if the documentation doesn't even cover the intended effects of the implementation detail, that's just checkbox documentation. One of the big problems we have with getting people to write high quality bindings is getting them to understand that they're supposed to be describing the hardware, not just dumping the current Linux implementation into an external data structure. If that's all we're doing then device tree isn't buying us a huge amount, we're just putting the same things in another format with worse tooling. This is like the issues we've got with all the historic bindings that just dumped raw numeric constants in the DT - people see those and just write a binding which dumps whatever internal constants Linux has into DTs. Consider this case, the proposal is: | +Normally SPI buses are assigned dynamic bus numbers starting at 32766 | +and counting downwards. It is possible to assign the bus number | +statically using devicetee aliases. For example, on the MPC5200 the This has no practical meaning as a spec since it doesn't say what a bus number either is or means so an implementation can happily ignore it with no effect. The details on how Linux currently does dynamic IDs are unhelpful and possibly misleading if the bus gets reinstantiated but that's somewhat secondary. The actual effect Christer is intending to generate is that his systems end up with stable names for spidev devices which are a very obvious implementation detail of Linux on current systems - using raw spidev directly in a binding rather than a compatible string for the attached device is something that generates loud warnings since that's not something that meets the DT goal of describing the hardware. With the compatible string it's fine since we have a description of the hardware and the OS can bind whatever the most suitable support is to the device, without we have literally no idea what we're supposed to be controlling. Just documenting bus numbers is not going to say anything about how Linux supports the particular devices, how spidev works and how userspace names devices, nor is it going to help anyone who wants stable naming over a class of boards with multiple sockets (eg, board A has two SPI sockets on one SPI controller, board B has one controller per socket) - the whole using one ramdisk over multiple boards use case that Christer mentioned. What would seem to be a lot more sensible here would be to define a binding for whatever device is being described with some support for providing a descriptive name which we can then bring out to userspace for it to match on (and perhaps use for the device name so you get spidev-socket1, spidev-gpschip or something which would be a lot more useful for this type of application since it's easier to map onto the physical system). That directly addresses the need is a more robust and general fashion. I do wonder if such naming support should be at a more general level, possibly even DT wide, since it seems like something that will apply elsewhere. If it's just some raw signals on an expansion connector then this seems to be something that should be handled as part of the support for things like BeagleBone capes, if no overlay is loaded perhaps that should default to raw userspace access to devices.
[toc] | [prev] | [next] | [standalone]
| From | Frank Rowand <frowand.list@gmail.com> |
|---|---|
| Date | 2016-05-25 20:50 +0200 |
| Message-ID | <rCM2t-4mV-9@gated-at.bofh.it> |
| In reply to | #1407147 |
On 5/25/2016 10:48 AM, Mark Brown wrote:
> On Wed, May 25, 2016 at 08:32:51AM -0700, Frank Rowand wrote:
>> On 5/25/2016 2:20 AM, Mark Rutland wrote:
>
>>> Linux for legacy reasons, documenting it as a binding is not necessarily
>>> in anyone's best interest. If we want to document it, we may want to
>>> mark it as deprecated, with a pointer to better alternatives.
>
>> Lack of documentation and bad documentation are a MAJOR problem for
>> devicetree.
>
>> Refusing to accept documentation of existing behavior makes no
>> sense to me.
>
> Sometimes the best thing to do is remove the behaviour, some of these
Yes. And I have not formed an opinion on whether the existing
behavior should be kept, deprecated, or removed. I have avoided
commenting on that.
> things are just bugs. That's not quite the case here but it's in the
> spectrum of things that happen so clearly just blindly documenting
> everything people find happens to work is not great - if something isn't
> being used because it wasn't discoverable sometimes we should be
> thankful for that.
>
> Adding documentation for every last implementation that happens to work
> in a given situation through layers of indirection isn't going to help
> with the usability issues DT has, one of the things that the
That is not a reasonable description of this case.
What the kernel does with the spi aliases is not a random unintended
side effect. It was a deliberate choice. Read the commit message for
bb29785e0d6d150181704be2efcc3141044625e2
> documentation does is tell both users and other OS vendors (and now I
> guess also people writing ACPI machine descriptions) what they should be
> doing when they implement or use the bindings. This is especially true
> if the documentation doesn't even cover the intended effects of the
> implementation detail, that's just checkbox documentation.
Yes, it would be great if intended effects were included in the
documentation.
> One of the big problems we have with getting people to write high
> quality bindings is getting them to understand that they're supposed to
> be describing the hardware, not just dumping the current Linux
> implementation into an external data structure. If that's all we're
> doing then device tree isn't buying us a huge amount, we're just putting
> the same things in another format with worse tooling. This is like the
Yes, that topic is on my todo list for this year, as I have been sharing
in various venues. We claim that the devicetree is supposed to be only
describing hardware (with the exception of the chosen node, which is
specified as "describes parameters chosen or specified by the system
firmware at run time") and the status property that the ePAPR defines
as state, but the Linux kernel mostly uses as a flag of whether a
node exists or should be ignored.
In reality, current devicetrees contain information about
- devicetree specific stuff (eg DT version: /dts-v1/, /include/
directives, etc)
- hardware description
- parameters (the chosen node)
- state information (the status property)
- policy
- configuration
I'm not sure whether I can cram the spi aliases into one of the above
categories. Maybe there is yet one more category I need to add to
describe the current implementation of devicetree.
I expect the discussion of whether devicetree should contain all of the
above listed categories of information to be long and thoughtful throughout
the rest of the year.
> issues we've got with all the historic bindings that just dumped raw
> numeric constants in the DT - people see those and just write a binding
> which dumps whatever internal constants Linux has into DTs.
>
> Consider this case, the proposal is:
>
> | +Normally SPI buses are assigned dynamic bus numbers starting at 32766
> | +and counting downwards. It is possible to assign the bus number
> | +statically using devicetee aliases. For example, on the MPC5200 the
>
> This has no practical meaning as a spec since it doesn't say what a bus
> number either is or means so an implementation can happily ignore it
> with no effect. The details on how Linux currently does dynamic IDs are
> unhelpful and possibly misleading if the bus gets reinstantiated but
> that's somewhat secondary.
I'm thinking out loud here, let me take a stab at a thought. We are
doing two things with the bindings in Documentations/devicetree/bindings/.
We are providing a specification, which tells people writing kernel code
what to expect the devicetree to look like. We are also providing
documentation, telling people writing devicetrees how to describe
their system so that the kernel can use it.
I think that thinking of the bindings as either just a specification or
as just documentation confuses the issue.
I'm not sure where that leads me, but it is worth thinking about.
In this specific case I see the proposed patch as trying to provide
documentation.
> The actual effect Christer is intending to generate is that his systems
> end up with stable names for spidev devices which are a very obvious
> implementation detail of Linux on current systems - using raw spidev
> directly in a binding rather than a compatible string for the attached
> device is something that generates loud warnings since that's not
> something that meets the DT goal of describing the hardware. With the
> compatible string it's fine since we have a description of the hardware
> and the OS can bind whatever the most suitable support is to the device,
> without we have literally no idea what we're supposed to be controlling.
>
> Just documenting bus numbers is not going to say anything about how
> Linux supports the particular devices, how spidev works and how
> userspace names devices, nor is it going to help anyone who wants stable
> naming over a class of boards with multiple sockets (eg, board A has two
> SPI sockets on one SPI controller, board B has one controller per
> socket) - the whole using one ramdisk over multiple boards use case that
> Christer mentioned.
>
> What would seem to be a lot more sensible here would be to define a
> binding for whatever device is being described with some support for
> providing a descriptive name which we can then bring out to userspace
> for it to match on (and perhaps use for the device name so you get
> spidev-socket1, spidev-gpschip or something which would be a lot more
> useful for this type of application since it's easier to map onto the
> physical system). That directly addresses the need is a more robust and
> general fashion. I do wonder if such naming support should be at a more
> general level, possibly even DT wide, since it seems like something that
> will apply elsewhere.
>
> If it's just some raw signals on an expansion connector then this seems
> to be something that should be handled as part of the support for things
> like BeagleBone capes, if no overlay is loaded perhaps that should
> default to raw userspace access to devices.
>
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2016-05-27 20:40 +0200 |
| Subject | Re: [PATCH] devicetree - document using aliases to set spi bus number. |
| Message-ID | <rDuPT-6Xt-17@gated-at.bofh.it> |
| In reply to | #1407161 |
[Multipart message — attachments visible in raw view] — view raw
On Wed, May 25, 2016 at 11:46:35AM -0700, Frank Rowand wrote: > On 5/25/2016 10:48 AM, Mark Brown wrote: > > Sometimes the best thing to do is remove the behaviour, some of these > Yes. And I have not formed an opinion on whether the existing > behavior should be kept, deprecated, or removed. I have avoided > commenting on that. That's not been clear... > > Adding documentation for every last implementation that happens to work > > in a given situation through layers of indirection isn't going to help > > with the usability issues DT has, one of the things that the > That is not a reasonable description of this case. > What the kernel does with the spi aliases is not a random unintended > side effect. It was a deliberate choice. Read the commit message for > bb29785e0d6d150181704be2efcc3141044625e2 I've read that (for the benefit of those playing at home that's "spi/of: Use DT aliases for assigning bus number"). What that reads like to me is that it's a quick hack which may or may not be intended to be used in the specific way it's being used now - it's still at a remove from the obviously not DT idiomatic spidev which isn't mentioned at all, it could be for that but it could also be for people trying to read log messages or distinguish between other devices. If it were for spidev I'd have expected labelling at the spidev level as it's both more direct and useful (we can easily get a string out rather than just a number). It does also mention a previous effort based on cell-index which is now being ignored as far as I can tell but presumably you feel must also be documented as a thing that might've done a thing in some older software release, I'm not sure that's useful though. Personally the way I parse this situation is that the kernel is taking a look at what's in the DT and making an effort to present it usefully in the running systems. Fixing our current interpretation in stone as a supported thing when we don't have to makes it more cumbersome to improve and discourages any efforts to do similar things in the future. It is reasonable to provide and document something here but when there's some fairly simple and obvious better things we could be doing it should be those rather than the legacy stuff.
[toc] | [prev] | [next] | [standalone]
| From | Christer Weinigel <christer@weinigel.se> |
|---|---|
| Date | 2016-05-28 23:00 +0200 |
| Subject | Re: [PATCH] devicetree - document using aliases to set spi bus number. |
| Message-ID | <rDTuW-5dM-33@gated-at.bofh.it> |
| In reply to | #1408240 |
On 05/27/2016 08:36 PM, Mark Brown wrote: > Personally the way I parse this situation is that the kernel is taking > a look at what's in the DT and making an effort to present it usefully > in the running systems. Fixing our current interpretation in stone as > a supported thing when we don't have to makes it more cumbersome to > improve and discourages any efforts to do similar things in the > future. It is reasonable to provide and document something here but > when there's some fairly simple and obvious better things we could be > doing it should be those rather than the legacy stuff. So what are the "simple and obvious better things" that one can use instead? /Christer -- Have laptop, will travel. I'm a consultant looking for interesting jobs anywhere in the world. I'm an experienced software engineer with a solid understanding of hardware. Specialities: Linux, device drivers and embedded systems in general. Find me at www.weinigel.se.
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2016-05-30 18:20 +0200 |
| Subject | Re: [PATCH] devicetree - document using aliases to set spi bus number. |
| Message-ID | <rEy55-6xL-29@gated-at.bofh.it> |
| In reply to | #1408523 |
[Multipart message — attachments visible in raw view] — view raw
On Sat, May 28, 2016 at 10:57:33PM +0200, Christer Weinigel wrote: > On 05/27/2016 08:36 PM, Mark Brown wrote: > > It is reasonable to provide and document something here but when there's > > some fairly simple and obvious better things we could be doing it should > > be those rather than the legacy stuff. > So what are the "simple and obvious better things" that one can use instead? To repeat what Rob said adding a label property on the leaf device nodes seems like a more sensible option.
[toc] | [prev] | [next] | [standalone]
| From | Frank Rowand <frowand.list@gmail.com> |
|---|---|
| Date | 2016-05-25 17:30 +0200 |
| Message-ID | <rCIUV-2Ao-7@gated-at.bofh.it> |
| In reply to | #1406306 |
On 5/24/2016 10:41 AM, Mark Rutland wrote: > On Tue, May 24, 2016 at 06:39:20PM +0200, Christer Weinigel wrote: >> Document how to use devicetree aliases to assign a stable >> bus number to a spi bus. >> >> Signed-off-by: Christer Weinigel <christer@weinigel.se> >> >> --- >> >> Trivial documentation change. >> >> Not having used devicetree that much it was surprisingly hard to >> figure out how to assign a stable bus number to a spi bus. Add a >> simple example that shows how to do that. >> >> Mark Cced as the SPI maintainer. Or should trivial documentation >> fixes like this be addressed to someone else? >> >> /Christer >> >> Documentation/devicetree/bindings/spi/spi-bus.txt | 10 ++++++++++ >> 1 file changed, 10 insertions(+) >> >> diff --git a/Documentation/devicetree/bindings/spi/spi-bus.txt b/Documentation/devicetree/bindings/spi/spi-bus.txt >> index 42d5954..c35c4c2 100644 >> --- a/Documentation/devicetree/bindings/spi/spi-bus.txt >> +++ b/Documentation/devicetree/bindings/spi/spi-bus.txt >> @@ -94,3 +94,13 @@ SPI example for an MPC5200 SPI bus: >> reg = <1>; >> }; >> }; >> + >> +Normally SPI buses are assigned dynamic bus numbers starting at 32766 >> +and counting downwards. It is possible to assign the bus number >> +statically using devicetee aliases. For example, on the MPC5200 the >> +"spi@f00" device above is connected to the "soc" bus. To set its >> +bus_num to 1 add an aliases entry like this: > > As Mark Brown pointed out, this is very Linux-specific (at least in the > wording of the above). > > Generally, aliases are there to match _physical_ identifiers (e.g. to > match physical labels for UART0, UART1, and on). Can you point to anything in the specification or any other place that states that aliases are for matching physical identifiers? Can you point to anything in the specification or any other place that states that aliases are not to be used for anything else? > > I'm not sure whether that applies here. > > Thanks, > Mark. > -- > To unsubscribe from this list: send the line "unsubscribe devicetree" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >
[toc] | [prev] | [next] | [standalone]
| From | Mark Rutland <mark.rutland@arm.com> |
|---|---|
| Date | 2016-05-25 18:10 +0200 |
| Subject | Re: [PATCH] devicetree - document using aliases to set spi bus number. |
| Message-ID | <rCJxE-32M-17@gated-at.bofh.it> |
| In reply to | #1407001 |
On Wed, May 25, 2016 at 08:25:44AM -0700, Frank Rowand wrote: > On 5/24/2016 10:41 AM, Mark Rutland wrote: > > On Tue, May 24, 2016 at 06:39:20PM +0200, Christer Weinigel wrote: > >> +Normally SPI buses are assigned dynamic bus numbers starting at 32766 > >> +and counting downwards. It is possible to assign the bus number > >> +statically using devicetee aliases. For example, on the MPC5200 the > >> +"spi@f00" device above is connected to the "soc" bus. To set its > >> +bus_num to 1 add an aliases entry like this: > > > > As Mark Brown pointed out, this is very Linux-specific (at least in the > > wording of the above). > > > > Generally, aliases are there to match _physical_ identifiers (e.g. to > > match physical labels for UART0, UART1, and on). > > Can you point to anything in the specification or any other place that > states that aliases are for matching physical identifiers? > > Can you point to anything in the specification or any other place that > states that aliases are not to be used for anything else? You have me there; I cannot find any wording to that effect, and I am evidently going by my understanding alone. IEEE 1275 simply states that there may be predefined aliases for a machine, or that users can create and use them dynamically. ePAPR (and the devicetree specification) only states that aliases exist, and that a client program might use them (through some means which is never described). Thanks, Mark.
[toc] | [prev] | [next] | [standalone]
Page 2 of 3 — ← Prev page 1 [2] 3 Next page →
Back to top | Article view | linux.kernel
csiph-web