Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.1 spidev module complains loudly about "buggy DT" #1054

Closed
pelwell opened this issue Jul 10, 2015 · 6 comments
Closed

4.1 spidev module complains loudly about "buggy DT" #1054

pelwell opened this issue Jul 10, 2015 · 6 comments

Comments

@pelwell
Copy link
Contributor

pelwell commented Jul 10, 2015

spidev is the userspace interface to the SPI subsystem. It is (at least in some ways) analogous to i2c-dev.

The Raspberry Pi DTS files, in common with the upstream bcm2835 DTS's and those for many other platforms, use a compatible string of "spidev" to cause the spidev module to be loaded. A new commit in the upstream 4.1 branch (956b200) demonstrates the author's objection to this practice by causing the module to WARN when it detects that usage:

[   10.664420] spi spi0.1: setting up native-CS1 as GPIO 7
[   10.678260] spi spi0.0: setting up native-CS0 as GPIO 8
[   10.691016] spidev spi0.0: buggy DT: spidev listed directly in DT
[   10.705643] ------------[ cut here ]------------
[   10.717445] WARNING: CPU: 2 PID: 301 at drivers/spi/spidev.c:730 spidev_probe+0x180/0x1bc()
[   10.733972] Modules linked in: i2c_bcm2708(+) spi_bcm2835(+) w1_gpio wire cn uio_pdrv_genirq uio
[   10.750489] CPU: 2 PID: 301 Comm: modprobe Not tainted 4.1.1-v7+ #599
[   10.750507] Hardware name: BCM2709
[   10.750562] [<80018430>] (unwind_backtrace) from [<80013e0c>] (show_stack+0x20/0x24)
[   10.750588] [<80013e0c>] (show_stack) from [<805549e8>] (dump_stack+0x98/0xe0)
[   10.750619] [<805549e8>] (dump_stack) from [<80026a1c>] (warn_slowpath_common+0x8c/0xc8)
[   10.750641] [<80026a1c>] (warn_slowpath_common) from [<80026b14>] (warn_slowpath_null+0x2c/0x34)
[   10.750668] [<80026b14>] (warn_slowpath_null) from [<803bc79c>] (spidev_probe+0x180/0x1bc)
[   10.750689] [<803bc79c>] (spidev_probe) from [<803b9ea0>] (spi_drv_probe+0x48/0x4c)
[   10.750712] [<803b9ea0>] (spi_drv_probe) from [<80370394>] (really_probe+0x1b4/0x268)
[   10.750734] [<80370394>] (really_probe) from [<803704a8>] (__device_attach+0x60/0x64)
[   10.750754] [<803704a8>] (__device_attach) from [<8036e6f8>] (bus_for_each_drv+0x6c/0x9c)
[   10.750774] [<8036e6f8>] (bus_for_each_drv) from [<803701d4>] (device_attach+0x84/0x90)
[   10.750793] [<803701d4>] (device_attach) from [<8036f7d8>] (bus_probe_device+0x94/0xb8)
[   10.750812] [<8036f7d8>] (bus_probe_device) from [<8036d86c>] (device_add+0x3ac/0x53c)
[   10.750842] [<8036d86c>] (device_add) from [<803ba55c>] (spi_add_device+0x94/0x13c)
[   10.750866] [<803ba55c>] (spi_add_device) from [<803bbf6c>] (spi_register_master+0x42c/0x6e4)
[   10.750887] [<803bbf6c>] (spi_register_master) from [<803bc260>] (devm_spi_register_master+0x3c/0x78)
[   10.750923] [<803bc260>] (devm_spi_register_master) from [<7f03e3b8>] (bcm2835_spi_probe+0x174/0x220 [spi_bcm2835])
[   10.750960] [<7f03e3b8>] (bcm2835_spi_probe [spi_bcm2835]) from [<80371cd4>] (platform_drv_probe+0x3c/0x6c)
[   10.750981] [<80371cd4>] (platform_drv_probe) from [<80370394>] (really_probe+0x1b4/0x268)
[   10.751002] [<80370394>] (really_probe) from [<80370554>] (__driver_attach+0xa8/0xac)
[   10.751028] [<80370554>] (__driver_attach) from [<8036e630>] (bus_for_each_dev+0x74/0xa4)
[   10.751048] [<8036e630>] (bus_for_each_dev) from [<8036fdd0>] (driver_attach+0x28/0x30)
[   10.751072] [<8036fdd0>] (driver_attach) from [<8036fa68>] (bus_add_driver+0x154/0x1fc)
[   10.751095] [<8036fa68>] (bus_add_driver) from [<80370a1c>] (driver_register+0x88/0x108)
[   10.751114] [<80370a1c>] (driver_register) from [<80371c84>] (__platform_driver_register+0x58/0x6c)
[   10.751146] [<80371c84>] (__platform_driver_register) from [<7f041018>] (bcm2835_spi_driver_init+0x18/0x24 [spi_bcm2835])
[   10.751171] [<7f041018>] (bcm2835_spi_driver_init [spi_bcm2835]) from [<80009654>] (do_one_initcall+0x90/0x1ec)
[   10.751193] [<80009654>] (do_one_initcall) from [<80551838>] (do_init_module+0x6c/0x1bc)
[   10.751213] [<80551838>] (do_init_module) from [<80097b24>] (load_module+0x1ce8/0x1f30)
[   10.751240] [<80097b24>] (load_module) from [<80097e48>] (SyS_init_module+0xdc/0x134)
[   10.751260] [<80097e48>] (SyS_init_module) from [<8000f980>] (ret_fast_syscall+0x0/0x54)
[   10.751270] ---[ end trace 8d7e7c0750dd358b ]---

The commit message reads:

    spi: spidev: Warn loudly if instantiated from DT as "spidev"

    Since spidev is a detail of how Linux controls a device rather than a
    description of the hardware in the system we should never have a node
    described as "spidev" in DT, any SPI device could be a spidev so this
    is just not a useful description.

    In order to help prevent users from writing such device trees generate a
    warning if spidev is instantiated as a DT node without an ID in the match
    table.

    Signed-off-by: Mark Brown <broonie@kernel.org>

Following the analogy with i2c-dev, I can understand why this is frowned upon. Like i2c-dev, spidev does not talk directly to any hardware, but it is undoubtedly convenient to be able to load the module (with control over the maximum frequency) from the DT blob. And encouraging people to work around this by adding their specific devices to the list of compatible strings (i.e. making a generic module specific to a group of devices) seems bizarre.

There is currently only one device with a compatible string in the match table:

static const struct of_device_id spidev_dt_ids[] = {
       { .compatible = "rohm,dh2228fv" },
       {},
};

In other words, the only way to make an "approved" DT is currently to claim to be a DAC. This would probably break if that DAC ever got a dedicated driver module.

There are a few options that I can think of:

  1. Rely on everybody who wants to use the user-space interface to control a device (which musn't have a driver) to add the name of that device to the list.
  2. Create a Raspberry Pi-specific name for the spidev module ("rpi,spidev"), and add that to the list of compatible strings.
  3. Add "spidev" to the list of compatible strings, which is enough to satisfy the letter of the test, but definitely not the spirit.
  4. Revert the patch that adds the test.
  5. Pretend that the Pi has one of those DACs on each SPI channel.

None of them are very palatable, but 3) seems the least disruptive.

@msperl: You've tried to raise this with the author - what are your thoughts?

@notro
Copy link
Contributor

notro commented Jul 10, 2015

Even though I understand the rationale, I find it strange that this change was accepted. The mantra is to not break userpace, which I would argue that this change leads to. And doesn't it break the DT ABI also? There are in-kernel DT's that use spidev.
At least additional functionality should have been added so spi(dev) devices could be added from userspace like with i2c-dev.

I agree that 3) would be the best choice for now.

@msperl
Copy link
Contributor

msperl commented Jul 10, 2015

There have been a long 2 threads on the spi mailing list about that.
The only thing that came up was:

  • add a different compatibility to spidev
  • add a solution to load the module as a backup when no other compatible module is loaded
  • make it work similar to i2c to change compatibility (via /sys)

Unfortunately no solution has materialized besides the recommendation of patching spidev -
I can not find that email by Mark now...

@msperl
Copy link
Contributor

msperl commented Jul 10, 2015

here one of those threads:
http://www.spinics.net/lists/linux-spi/msg03641.html

@pelwell
Copy link
Contributor Author

pelwell commented Jul 14, 2015

@popcornmix Are you happy with option 3, at least as an interim measure? It's a one-line addition to the spidev driver:

diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index 92c909e..0535375 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -706,6 +706,7 @@ static struct class *spidev_class;
 #ifdef CONFIG_OF
 static const struct of_device_id spidev_dt_ids[] = {
        { .compatible = "rohm,dh2228fv" },
+       { .compatible = "spidev" },
        {},
 };
 MODULE_DEVICE_TABLE(of, spidev_dt_ids);

@popcornmix
Copy link
Collaborator

Okay by me.

@pelwell
Copy link
Contributor Author

pelwell commented Jul 14, 2015

Pushed.

@pelwell pelwell closed this as completed Jul 14, 2015
felixradensky pushed a commit to varigit/linux-imx that referenced this issue Jan 13, 2020
See: raspberrypi/linux#1054

Signed-off-by: Eran Matityahu <eran.m@variscite.com>
margro pushed a commit to margro/linux that referenced this issue Jan 18, 2020
The upstream SPI and DT maintainers are completely opposed to declaring
in Device Tree that an SPI CS line is to be managed by the spidev
driver, even though the facility is useful on a hobbyist device like a
Raspberry Pi where arbitrary devices can be attached, and the
alternative to DT declaration (spi_board_info) has been almost entirely
rendered obsolete by DT.

Continue to override their objections by disabling the warning.

See: raspberrypi#3361
     raspberrypi#1054

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
big-henry pushed a commit to big-henry/mirror_ubuntu-bionic-kernel that referenced this issue Feb 17, 2020
YadongQi pushed a commit to YadongQi/ubuntu-bionic that referenced this issue Mar 10, 2020
m-p-s pushed a commit to m-p-s/linux-imx that referenced this issue Mar 24, 2020
See: raspberrypi/linux#1054

Signed-off-by: Eran Matityahu <eran.m@variscite.com>
varphone pushed a commit to varphone/linux-stable that referenced this issue Apr 1, 2020
Avoid warning

    [    2.991522] spidev spi2.2: buggy DT: spidev listed directly in DT

when using spidev in device tree. See

    raspberrypi/linux#1054

Signed-off-by: Stefan Christ <s.christ@phytec.de>
Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
Signed-off-by: Jan Remmet <j.remmet@phytec.de>
varphone pushed a commit to varphone/linux-stable that referenced this issue Apr 1, 2020
Avoid warning

    [    2.991522] spidev spi2.2: buggy DT: spidev listed directly in DT

when using spidev in device tree. See

    raspberrypi/linux#1054

Signed-off-by: Stefan Christ <s.christ@phytec.de>
Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
varigigi pushed a commit to varigit/linux-imx that referenced this issue Apr 2, 2020
See: raspberrypi/linux#1054

Signed-off-by: Eran Matityahu <eran.m@variscite.com>
zandrey pushed a commit to zandrey/linux-fslc that referenced this issue Apr 23, 2020
See: raspberrypi/linux#1054

Signed-off-by: Eran Matityahu <eran.m@variscite.com>
Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>
m-p-s pushed a commit to m-p-s/linux-imx that referenced this issue May 5, 2020
See: raspberrypi/linux#1054

Signed-off-by: Eran Matityahu <eran.m@variscite.com>
popcornmix pushed a commit that referenced this issue Jun 17, 2020
[ Upstream commit e2abfc0 ]

Commit

  21b5ee5 ("x86/cpu/amd: Enable the fixed Instructions Retired
		 counter IRPERF")

mistakenly added erratum #1054 as an OS Visible Workaround (OSVW) ID 0.
Erratum #1054 is not OSVW ID 0 [1], so make it a legacy erratum.

There would never have been a false positive on older hardware that
has OSVW bit 0 set, since the IRPERF feature was not available.

However, save a couple of RDMSR executions per thread, on modern
system configurations that correctly set non-zero values in their
OSVW_ID_Length MSRs.

[1] Revision Guide for AMD Family 17h Models 00h-0Fh Processors. The
revision guide is available from the bugzilla link below.

Fixes: 21b5ee5 ("x86/cpu/amd: Enable the fixed Instructions Retired counter IRPERF")
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Kim Phillips <kim.phillips@amd.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20200417143356.26054-1-kim.phillips@amd.com
Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537
Signed-off-by: Sasha Levin <sashal@kernel.org>
popcornmix pushed a commit that referenced this issue Jun 17, 2020
[ Upstream commit e2abfc0 ]

Commit

  21b5ee5 ("x86/cpu/amd: Enable the fixed Instructions Retired
		 counter IRPERF")

mistakenly added erratum #1054 as an OS Visible Workaround (OSVW) ID 0.
Erratum #1054 is not OSVW ID 0 [1], so make it a legacy erratum.

There would never have been a false positive on older hardware that
has OSVW bit 0 set, since the IRPERF feature was not available.

However, save a couple of RDMSR executions per thread, on modern
system configurations that correctly set non-zero values in their
OSVW_ID_Length MSRs.

[1] Revision Guide for AMD Family 17h Models 00h-0Fh Processors. The
revision guide is available from the bugzilla link below.

Fixes: 21b5ee5 ("x86/cpu/amd: Enable the fixed Instructions Retired counter IRPERF")
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Kim Phillips <kim.phillips@amd.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20200417143356.26054-1-kim.phillips@amd.com
Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537
Signed-off-by: Sasha Levin <sashal@kernel.org>
popcornmix pushed a commit that referenced this issue Jun 17, 2020
[ Upstream commit e2abfc0 ]

Commit

  21b5ee5 ("x86/cpu/amd: Enable the fixed Instructions Retired
		 counter IRPERF")

mistakenly added erratum #1054 as an OS Visible Workaround (OSVW) ID 0.
Erratum #1054 is not OSVW ID 0 [1], so make it a legacy erratum.

There would never have been a false positive on older hardware that
has OSVW bit 0 set, since the IRPERF feature was not available.

However, save a couple of RDMSR executions per thread, on modern
system configurations that correctly set non-zero values in their
OSVW_ID_Length MSRs.

[1] Revision Guide for AMD Family 17h Models 00h-0Fh Processors. The
revision guide is available from the bugzilla link below.

Fixes: 21b5ee5 ("x86/cpu/amd: Enable the fixed Instructions Retired counter IRPERF")
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Kim Phillips <kim.phillips@amd.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20200417143356.26054-1-kim.phillips@amd.com
Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537
Signed-off-by: Sasha Levin <sashal@kernel.org>
l1k pushed a commit to RevolutionPi/linux that referenced this issue Jul 15, 2020
MTrensch-hilscher pushed a commit to HilscherAutomation/netx4000-linux that referenced this issue Mar 3, 2021
hisenyiu2015 pushed a commit to hisenyiu2015/msm-4.14 that referenced this issue May 20, 2021
smk-embedded pushed a commit to phytec/linux-phytec that referenced this issue Jul 12, 2021
Avoid warning

    [    2.991522] spidev spi2.2: buggy DT: spidev listed directly in DT

when using spidev in device tree. See

    raspberrypi/linux#1054

Signed-off-by: Stefan Christ <s.christ@phytec.de>
Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
Signed-off-by: Jan Remmet <j.remmet@phytec.de>
Signed-off-by: Yunus Bas <y.bas@phytec.de>
smk-embedded pushed a commit to phytec/linux-phytec that referenced this issue Nov 2, 2021
Avoid warning

    [    2.991522] spidev spi2.2: buggy DT: spidev listed directly in DT

when using spidev in device tree. See

    raspberrypi/linux#1054

Signed-off-by: Stefan Christ <s.christ@phytec.de>
Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
Signed-off-by: Jan Remmet <j.remmet@phytec.de>
Signed-off-by: Yunus Bas <y.bas@phytec.de>
smk-embedded pushed a commit to phytec/linux-phytec that referenced this issue Mar 18, 2022
Avoid warning

    [    2.991522] spidev spi2.2: buggy DT: spidev listed directly in DT

when using spidev in device tree. See

    raspberrypi/linux#1054

Signed-off-by: Stefan Christ <s.christ@phytec.de>
Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
Signed-off-by: Jan Remmet <j.remmet@phytec.de>
Signed-off-by: Yunus Bas <y.bas@phytec.de>
Signed-off-by: Andrej Picej <andrej.picej@norik.com>
Reviewed-by: Yunus Bas <y.bas@phytec.de>
smk-embedded pushed a commit to phytec/linux-phytec that referenced this issue May 6, 2022
Avoid warning

    [    2.991522] spidev spi2.2: buggy DT: spidev listed directly in DT

when using spidev in device tree. See

    raspberrypi/linux#1054

Signed-off-by: Stefan Christ <s.christ@phytec.de>
Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
Signed-off-by: Jan Remmet <j.remmet@phytec.de>
Signed-off-by: Yunus Bas <y.bas@phytec.de>
Signed-off-by: Andrej Picej <andrej.picej@norik.com>
Reviewed-by: Yunus Bas <y.bas@phytec.de>
smk-embedded pushed a commit to phytec/linux-phytec that referenced this issue Sep 1, 2022
Avoid warning

    [    2.991522] spidev spi2.2: buggy DT: spidev listed directly in DT

when using spidev in device tree. See

    raspberrypi/linux#1054

Signed-off-by: Stefan Christ <s.christ@phytec.de>
Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
Signed-off-by: Jan Remmet <j.remmet@phytec.de>
Signed-off-by: Yunus Bas <y.bas@phytec.de>
Signed-off-by: Andrej Picej <andrej.picej@norik.com>
Reviewed-by: Yunus Bas <y.bas@phytec.de>
smk-embedded pushed a commit to phytec/linux-phytec that referenced this issue Dec 16, 2022
Avoid warning

    [    2.991522] spidev spi2.2: buggy DT: spidev listed directly in DT

when using spidev in device tree. See

    raspberrypi/linux#1054

Signed-off-by: Stefan Christ <s.christ@phytec.de>
Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
Signed-off-by: Jan Remmet <j.remmet@phytec.de>
Signed-off-by: Yunus Bas <y.bas@phytec.de>
Signed-off-by: Andrej Picej <andrej.picej@norik.com>
Reviewed-by: Yunus Bas <y.bas@phytec.de>
smk-embedded pushed a commit to phytec/linux-phytec that referenced this issue Apr 25, 2023
Avoid warning

    [    2.991522] spidev spi2.2: buggy DT: spidev listed directly in DT

when using spidev in device tree. See

    raspberrypi/linux#1054

Signed-off-by: Stefan Christ <s.christ@phytec.de>
Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
Signed-off-by: Jan Remmet <j.remmet@phytec.de>
Signed-off-by: Yunus Bas <y.bas@phytec.de>
Signed-off-by: Andrej Picej <andrej.picej@norik.com>
Reviewed-by: Yunus Bas <y.bas@phytec.de>
jai-raptee pushed a commit to jai-raptee/iliteck1 that referenced this issue Apr 30, 2024
jai-raptee pushed a commit to jai-raptee/iliteck1 that referenced this issue Apr 30, 2024
jai-raptee pushed a commit to jai-raptee/iliteck1 that referenced this issue Apr 30, 2024
machine-user-automatix pushed a commit to phytec/linux-phytec that referenced this issue May 22, 2024
Avoid warning

    [    2.991522] spidev spi2.2: buggy DT: spidev listed directly in DT

when using spidev in device tree. See

    raspberrypi/linux#1054

Signed-off-by: Stefan Christ <s.christ@phytec.de>
Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
Signed-off-by: Jan Remmet <j.remmet@phytec.de>
Signed-off-by: Yunus Bas <y.bas@phytec.de>
Signed-off-by: Andrej Picej <andrej.picej@norik.com>
machine-user-automatix pushed a commit to phytec/linux-phytec that referenced this issue Jun 12, 2024
Avoid warning

    [    2.991522] spidev spi2.2: buggy DT: spidev listed directly in DT

when using spidev in device tree. See

    raspberrypi/linux#1054

Signed-off-by: Stefan Christ <s.christ@phytec.de>
Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
Signed-off-by: Jan Remmet <j.remmet@phytec.de>
Signed-off-by: Yunus Bas <y.bas@phytec.de>
Signed-off-by: Andrej Picej <andrej.picej@norik.com>
Reviewed-by: Yunus Bas <y.bas@phytec.de>
Clome pushed a commit to Clome/ubuntu-kernel that referenced this issue Jul 2, 2024
See: raspberrypi/linux#1054
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants