NetBSD-Bugs archive

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

AW: kern/61012: spi(4): add ca_rescan so children attach on runtime modload / drvctl -r



The following reply was made to PR kern/61012; it has been noted by GNATS.

From: "Grassmann, Thorsten" <Thorsten.Grassmann%zae-bayern.de@localhost>
To: "kern-bug-people%netbsd.org@localhost" <kern-bug-people%netbsd.org@localhost>,
	"netbsd-bugs%netbsd.org@localhost" <netbsd-bugs%netbsd.org@localhost>, "gnats-bugs%netbsd.org@localhost"
	<gnats-bugs%netbsd.org@localhost>
Cc: 
Subject: AW: kern/61012: spi(4): add ca_rescan so children attach on runtime
 modload / drvctl -r
Date: Mon, 16 Nov 2026 18:07:35 +0000

 --_000_2b96a108026d446a99c90d07a80bd894zaebayernde_
 Content-Type: text/plain; charset="iso-8859-1"
 Content-Transfer-Encoding: quoted-printable
 
 > [snip]
 >
 > [I am neither encouraging for discouraging this PRs desire mostly just
 > pointing out a couple of things]
 >
 > Ya, modules with the SPI drivers have never really been a thing.  In
 > particular, the main reason, I think, is that indirect config / probe of
 > the device really doesn't work very well for them.  You mostly need to
 > pin down the slave that the device is attached to in a kernel config.
 >
 > You should provide the ioconf fragment you used for your module.
 > Usually that specifies all possible addresses that a device could be at.
 > For SPI you would have no way to know how many you are dealing with.
 > (Yes, for the RPI it would be up to 2, but any platform with USB can use
 > umcpmio(4) to get SPI and then you have up to 8 possible SPI slaves.
 > Think of a AMD64 Virtualbox VM that has a ucmcpmio(4) device attached to
 > it.  The virtual VM gets a real SPI port.).
 >
 > For platforms with FDT this probably all works or seems to because the
 > FDT would lock down the slave address along with the kernel config, but
 > non-FDT platforms with SPI would have trouble with ghost devices on
 > rescan.
 >
 > You can also get ghost devices with I2C and 1-Wire (onewire(4)) on
 > indirect probes, unless a particular device driver has taken steps in
 > its match function to see if there really is something present at a
 > particular address.  For I2C that is quite possible (probably), for
 > 1-Wire, not so much.
 >
 > --
 > Brad Spencer - brad%anduin.eldar.org@localhost
 
 
 Thanks for the review!
 The ioconf I used pins the slaves explicitly (matching the number of plugs,=
  but not necessarily of controllers plugged into them):
 
     pseudo-root spi*
     snespad0    at spi? slave 0
     snespad1    at spi? slave 1
 
 (This specific driver works with a single snes controller, and nothing else=
 , directly wired to an SPI bus and more than one controller on one bus usin=
 g a small adaptor board with a tristate output buffer IC, like this one: ht=
 tps://github.com/thgrass/SNES-Gamepads-to-SPI-Adaptor )
 
 
 If just for the sake of it, I'll try and give arguments FOR the proposed pa=
 tch:
 
 You're right about ghost devices, but it already exists at boot: spi_attach=
 () runs the same config_search, and some current spi children (tmp121temp, =
 mcp3kadc, bmx280) just return 1 from match(). This patch doesn't make it wo=
 rse, it just makes runtime rescan behave like boot. New spi drivers should =
 probe in match() like they already must/should at boot.
 
 Also, no existing driver seems to need changes: CFATTACH_DECL_NEW is litera=
 lly CFATTACH_DECL2_NEW with NULL,NULL, so the patch only changes ca_rescan =
 NULL -> spi_rescan. Boot is unchanged anyhow; and runtime rescan previously=
  just failed ENODEV, so nothing working today can break.
 
 Best regards,
 Thorsten
 
 
 
 ________________________________
 Von: Brad Spencer via gnats <gnats-admin%NetBSD.org@localhost>
 Gesendet: Sonntag, 15. November 2026 20:50:02
 An: kern-bug-people%netbsd.org@localhost; gnats-admin%netbsd.org@localhost; netbsd-bugs@netbsd.=
 org; Grassmann, Thorsten
 Betreff: Re: kern/61012: spi(4): add ca_rescan so children attach on runtim=
 e modload / drvctl -r
 
 The following reply was made to PR kern/61012; it has been noted by GNATS.
 
 From: Brad Spencer <brad%anduin.eldar.org@localhost>
 To: gnats-bugs%netbsd.org@localhost
 Cc: kern-bug-people%netbsd.org@localhost, gnats-admin%netbsd.org@localhost, netbsd-bugs@netbsd.=
 org
 Subject: Re: kern/61012: spi(4): add ca_rescan so children attach on runtim=
 e
  modload / drvctl -r
 Date: Sun, 15 Nov 2026 14:24:19 -0500
 
  "thorsten.grassmann%zae-bayern.de@localhost via gnats" <gnats-admin%NetBSD.org@localhost>
  writes:
 
  >>Number:         61012
  >>Category:       kern
  >>Synopsis:       spi(4): add ca_rescan so children attach on runtime modl=
 oad / drvctl -r
  >>Confidential:   no
  >>Severity:       non-critical
  >>Priority:       low
  >>Responsible:    kern-bug-people
  >>State:          open
  >>Class:          change-request
  >>Submitter-Id:   net
  >>Arrival-Date:   Sun Nov 15 17:40:00 +0000 2026
  >>Originator:     Thorsten Grassmann
  >>Release:        11.1, NetBSD-current
  >>Organization:
  > ZAE Bayern
  >>Environment:
  > NetBSD netbsdrpi 11.1 NetBSD 11.1 (GENERIC64) #4: Sun Nov 15 02:19:15 CE=
 T 2026  grass@mirrorbox:/tmp/nbsd/obj/sys/arch/evbarm/compile/GENERIC64 evb=
 arm
  >>Description:
  > I wrote a small SNES-gamepad driver as an LKM that attaches with "snespa=
 d* at spi? slave N" (for a Raspberry Pi 3 via the SPI0 header; the driver i=
 s pure spi(4) and machine-independent; https://github.com/thgrass/NetBSD_sn=
 espad_spi ).
  > On NetBSD 11.1 evbarm GENERIC64 with bcmspi(4)/spi(4):
  >
  >     # modload snespad
  >     modload: rc=3D0            // module loads fine
  >     // dmesg: nothing. no snespad0 at spi0, no /dev/snespad*.
  >     # drvctl -r -a spi spi0   -> also nothing.
  >
  > Tracing config_cfdata_attach() -> rescan_with_cfdata() showed the rescan=
  is dispatched to ca_rescan of each attached bus. But spi's cfattach is ca_=
 rescan =3D NULL (CFATTACH_DECL_NEW).
  > The same driver works when built into the kernel directly.
  >
  > Is this by design? As SPI devices usually are "built-in" and there is ra=
 rely the need for loadable modules in production.
  > Adding proposed patch (see below) would at least make SPI driver develop=
 ment more convenient...
  >>How-To-Repeat:
  > On any system with an spi(4) bus attached:
  >
  >     # drvctl -l                  // shows spi0
  >     # drvctl -r -a spi spi0
  >     drvctl: DRVRESCANBUS: No such device or address
  >>Fix:
  > Patch spi-rescan-trunk.patch:
  > adds spi_rescan() to spi(4) and registers it as ca_rescan via CFATTACH_D=
 ECL2_NEW. (Boot-time attach is unchanged).
 
  [snip]
 
  [I am neither encouraging for discouraging this PRs desire mostly just
  pointing out a couple of things]
 
  Ya, modules with the SPI drivers have never really been a thing.  In
  particular, the main reason, I think, is that indirect config / probe of
  the device really doesn't work very well for them.  You mostly need to
  pin down the slave that the device is attached to in a kernel config.
 
  You should provide the ioconf fragment you used for your module.
  Usually that specifies all possible addresses that a device could be at.
  For SPI you would have no way to know how many you are dealing with.
  (Yes, for the RPI it would be up to 2, but any platform with USB can use
  umcpmio(4) to get SPI and then you have up to 8 possible SPI slaves.
  Think of a AMD64 Virtualbox VM that has a ucmcpmio(4) device attached to
  it.  The virtual VM gets a real SPI port.).
 
  For platforms with FDT this probably all works or seems to because the
  FDT would lock down the slave address along with the kernel config, but
  non-FDT platforms with SPI would have trouble with ghost devices on
  rescan.
 
  You can also get ghost devices with I2C and 1-Wire (onewire(4)) on
  indirect probes, unless a particular device driver has taken steps in
  its match function to see if there really is something present at a
  particular address.  For I2C that is quite possible (probably), for
  1-Wire, not so much.
 
 
 
 
 
 
  --
  Brad Spencer - brad%anduin.eldar.org@localhost
 
 
 --_000_2b96a108026d446a99c90d07a80bd894zaebayernde_
 Content-Type: text/html; charset="iso-8859-1"
 Content-Transfer-Encoding: quoted-printable
 
 <html>
 <head>
 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
 1">
 <meta name=3D"Generator" content=3D"Microsoft Exchange Server">
 <!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
 ding-left: 4pt; border-left: #800000 2px solid; } --></style>
 </head>
 <body>
 <meta content=3D"text/html; charset=3DUTF-8">
 <style type=3D"text/css" style=3D"">
 <!--
 p
 	{margin-top:0;
 	margin-bottom:0}
 -->
 </style>
 <div dir=3D"ltr">
 <div id=3D"x_divtagdefaultwrapper" dir=3D"ltr" style=3D"font-size:12pt; col=
 or:#000000; font-family:Calibri,Helvetica,sans-serif">
 <div id=3D"x_Signature">
 <div id=3D"x_divtagdefaultwrapper" dir=3D"ltr" style=3D"font-size:12pt; col=
 or:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,Apple Col=
 or Emoji,Segoe UI Emoji,NotoColorEmoji,Segoe UI Symbol,Android Emoji,EmojiS=
 ymbols">
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">
 <div>
 <div><span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Ar=
 ial&quot;,sans-serif">&gt;</span>&nbsp;[snip]<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;[I am neither encouraging for discouragin=
 g this PRs desire mostly just<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;pointing out a couple of things]<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;Ya, modules with the SPI drivers have nev=
 er really been a thing.&nbsp; In<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;particular, the main reason, I think, is =
 that indirect config / probe of<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;the device really doesn't work very well =
 for them.&nbsp; You mostly need to<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;pin down the slave that the device is att=
 ached to in a kernel config.<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;You should provide the ioconf fragment yo=
 u used for your module.<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;Usually that specifies all possible addre=
 sses that a device could be at.<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;For SPI you would have no way to know how=
  many you are dealing with.<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;(Yes, for the RPI it would be up to 2, bu=
 t any platform with USB can use<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;umcpmio(4) to get SPI and then you have u=
 p to 8 possible SPI slaves.<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;Think of a AMD64 Virtualbox VM that has a=
  ucmcpmio(4) device attached to<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;it.&nbsp; The virtual VM gets a real SPI =
 port.).<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;For platforms with FDT this probably all =
 works or seems to because the<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;FDT would lock down the slave address alo=
 ng with the kernel config, but<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;non-FDT platforms with SPI would have tro=
 uble with ghost devices on<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;rescan.<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;You can also get ghost devices with I2C a=
 nd 1-Wire (onewire(4)) on<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;indirect probes, unless a particular devi=
 ce driver has taken steps in<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;its match function to see if there really=
  is something present at a<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;particular address.&nbsp; For I2C that is=
  quite possible (probably), for<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;1-Wire, not so much.<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;&nbsp;<br>
 <span style=3D"font-size:8.0pt; line-height:107%; font-family:&quot;Arial&q=
 uot;,sans-serif">&gt;</span>&nbsp;--
 <br>
 &gt; Brad Spencer - brad%anduin.eldar.org@localhost</div>
 <br>
 </div>
 <div><br>
 </div>
 <div>Thanks for the review!</div>
 <div>The ioconf I used pins the slaves explicitly (matching the number of p=
 lugs, but not necessarily of controllers plugged into them):<br>
 <br>
 &nbsp; &nbsp; pseudo-root spi*<br>
 &nbsp; &nbsp; snespad0&nbsp; &nbsp; at spi? slave 0<br>
 &nbsp; &nbsp; snespad1&nbsp; &nbsp; at spi? slave 1</div>
 <div><br>
 </div>
 <div>(This specific driver works with a single snes controller, and nothing=
  else, directly wired to an SPI bus and more than one controller on one bus=
  using a small adaptor board with a tristate output buffer IC, like this on=
 e:&nbsp;<a href=3D"https://github.com/thgrass/SNES-Gamepads-to-SPI-Adaptor"=
  class=3D"x_OWAAutoLink" id=3D"LPlnk336557">https://github.com/thgrass/SNES=
 -Gamepads-to-SPI-Adaptor</a>&nbsp;)</div>
 <div><br>
 </div>
 <div><br>
 </div>
 <div>If just for the sake of it, I'll try and give arguments FOR the propos=
 ed patch:&nbsp;<br>
 <br>
 You're right about ghost devices, but it already exists at boot: spi_attach=
 () runs the same config_search, and some current spi children (tmp121temp, =
 mcp3kadc, bmx280) just return 1 from match(). This patch doesn't make it wo=
 rse, it just makes runtime rescan
  behave like boot.&nbsp;New spi drivers should probe in match() like they a=
 lready must/should at boot.<br>
 <br>
 Also, no existing driver seems to need changes: CFATTACH_DECL_NEW is litera=
 lly CFATTACH_DECL2_NEW with NULL,NULL, so the patch only changes&nbsp;ca_re=
 scan NULL -&gt; spi_rescan. Boot is unchanged anyhow; and runtime rescan pr=
 eviously just failed ENODEV, so nothing
  working today can break.<br>
 <br>
 Best regards,</div>
 Thorsten</span>
 <p class=3D"x_MsoNormal"><span style=3D"font-size:8.0pt; line-height:107%; =
 font-family:&quot;Arial&quot;,sans-serif">&nbsp;</span></p>
 <p></p>
 </div>
 </div>
 </div>
 <hr tabindex=3D"-1" style=3D"display:inline-block; width:98%">
 <div id=3D"x_divRplyFwdMsg" dir=3D"ltr"><font face=3D"Calibri, sans-serif" =
 color=3D"#000000" style=3D"font-size:11pt"><b>Von:</b> Brad Spencer via gna=
 ts &lt;gnats-admin%NetBSD.org@localhost&gt;<br>
 <b>Gesendet:</b> Sonntag, 15. November 2026 20:50:02<br>
 <b>An:</b> kern-bug-people%netbsd.org@localhost; gnats-admin%netbsd.org@localhost; netbsd-bugs@=
 netbsd.org; Grassmann, Thorsten<br>
 <b>Betreff:</b> Re: kern/61012: spi(4): add ca_rescan so children attach on=
  runtime modload / drvctl -r</font>
 <div>&nbsp;</div>
 </div>
 </div>
 <font size=3D"2"><span style=3D"font-size:10pt;">
 <div class=3D"PlainText">The following reply was made to PR kern/61012; it =
 has been noted by GNATS.<br>
 <br>
 From: Brad Spencer &lt;brad%anduin.eldar.org@localhost&gt;<br>
 To: gnats-bugs%netbsd.org@localhost<br>
 Cc: kern-bug-people%netbsd.org@localhost, gnats-admin%netbsd.org@localhost, netbsd-bugs@netbsd.=
 org<br>
 Subject: Re: kern/61012: spi(4): add ca_rescan so children attach on runtim=
 e<br>
 &nbsp;modload / drvctl -r<br>
 Date: Sun, 15 Nov 2026 14:24:19 -0500<br>
 <br>
 &nbsp;&quot;thorsten.grassmann%zae-bayern.de@localhost via gnats&quot; &lt;gnats-admi=
 n%NetBSD.org@localhost&gt;<br>
 &nbsp;writes:<br>
 &nbsp;<br>
 &nbsp;&gt;&gt;Number:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 61012=
 <br>
 &nbsp;&gt;&gt;Category:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; kern<br>
 &nbsp;&gt;&gt;Synopsis:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; spi(4): add ca_=
 rescan so children attach on runtime modload / drvctl -r<br>
 &nbsp;&gt;&gt;Confidential:&nbsp;&nbsp; no<br>
 &nbsp;&gt;&gt;Severity:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; non-critical<br=
 >
 &nbsp;&gt;&gt;Priority:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; low<br>
 &nbsp;&gt;&gt;Responsible:&nbsp;&nbsp;&nbsp; kern-bug-people<br>
 &nbsp;&gt;&gt;State:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
 open<br>
 &nbsp;&gt;&gt;Class:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
 change-request<br>
 &nbsp;&gt;&gt;Submitter-Id:&nbsp;&nbsp; net<br>
 &nbsp;&gt;&gt;Arrival-Date:&nbsp;&nbsp; Sun Nov 15 17:40:00 &#43;0000 2026<=
 br>
 &nbsp;&gt;&gt;Originator:&nbsp;&nbsp;&nbsp;&nbsp; Thorsten Grassmann<br>
 &nbsp;&gt;&gt;Release:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 11.1, NetB=
 SD-current<br>
 &nbsp;&gt;&gt;Organization:<br>
 &nbsp;&gt; ZAE Bayern<br>
 &nbsp;&gt;&gt;Environment:<br>
 &nbsp;&gt; NetBSD netbsdrpi 11.1 NetBSD 11.1 (GENERIC64) #4: Sun Nov 15 02:=
 19:15 CET 2026&nbsp; grass@mirrorbox:/tmp/nbsd/obj/sys/arch/evbarm/compile/=
 GENERIC64 evbarm<br>
 &nbsp;&gt;&gt;Description:<br>
 &nbsp;&gt; I wrote a small SNES-gamepad driver as an LKM that attaches with=
  &quot;snespad* at spi? slave N&quot; (for a Raspberry Pi 3 via the SPI0 he=
 ader; the driver is pure spi(4) and machine-independent;
 <a href=3D"https://github.com/thgrass/NetBSD_snespad_spi";>https://github.co=
 m/thgrass/NetBSD_snespad_spi</a> ).<br>
 &nbsp;&gt; On NetBSD 11.1 evbarm GENERIC64 with bcmspi(4)/spi(4):<br>
 &nbsp;&gt;<br>
 &nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp; # modload snespad<br>
 &nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp; modload: rc=3D0&nbsp;&nbsp;&nbsp;&nbsp;&=
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // module loads fine<br>
 &nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp; // dmesg: nothing. no snespad0 at spi0, =
 no /dev/snespad*.<br>
 &nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp; # drvctl -r -a spi spi0&nbsp;&nbsp; -&gt=
 ; also nothing.<br>
 &nbsp;&gt;<br>
 &nbsp;&gt; Tracing config_cfdata_attach() -&gt; rescan_with_cfdata() showed=
  the rescan is dispatched to ca_rescan of each attached bus. But spi's cfat=
 tach is ca_rescan =3D NULL (CFATTACH_DECL_NEW).<br>
 &nbsp;&gt; The same driver works when built into the kernel directly.<br>
 &nbsp;&gt;<br>
 &nbsp;&gt; Is this by design? As SPI devices usually are &quot;built-in&quo=
 t; and there is rarely the need for loadable modules in production.<br>
 &nbsp;&gt; Adding proposed patch (see below) would at least make SPI driver=
  development more convenient...<br>
 &nbsp;&gt;&gt;How-To-Repeat:<br>
 &nbsp;&gt; On any system with an spi(4) bus attached:<br>
 &nbsp;&gt;<br>
 &nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp; # drvctl -l&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
 ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /=
 / shows spi0<br>
 &nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp; # drvctl -r -a spi spi0<br>
 &nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp; drvctl: DRVRESCANBUS: No such device or =
 address<br>
 &nbsp;&gt;&gt;Fix:<br>
 &nbsp;&gt; Patch spi-rescan-trunk.patch:<br>
 &nbsp;&gt; adds spi_rescan() to spi(4) and registers it as ca_rescan via CF=
 ATTACH_DECL2_NEW. (Boot-time attach is unchanged).<br>
 &nbsp;<br>
 &nbsp;[snip]<br>
 &nbsp;<br>
 &nbsp;[I am neither encouraging for discouraging this PRs desire mostly jus=
 t<br>
 &nbsp;pointing out a couple of things]<br>
 &nbsp;<br>
 &nbsp;Ya, modules with the SPI drivers have never really been a thing.&nbsp=
 ; In<br>
 &nbsp;particular, the main reason, I think, is that indirect config / probe=
  of<br>
 &nbsp;the device really doesn't work very well for them.&nbsp; You mostly n=
 eed to<br>
 &nbsp;pin down the slave that the device is attached to in a kernel config.=
 <br>
 &nbsp;<br>
 &nbsp;You should provide the ioconf fragment you used for your module.<br>
 &nbsp;Usually that specifies all possible addresses that a device could be =
 at.<br>
 &nbsp;For SPI you would have no way to know how many you are dealing with.<=
 br>
 &nbsp;(Yes, for the RPI it would be up to 2, but any platform with USB can =
 use<br>
 &nbsp;umcpmio(4) to get SPI and then you have up to 8 possible SPI slaves.<=
 br>
 &nbsp;Think of a AMD64 Virtualbox VM that has a ucmcpmio(4) device attached=
  to<br>
 &nbsp;it.&nbsp; The virtual VM gets a real SPI port.).<br>
 &nbsp;<br>
 &nbsp;For platforms with FDT this probably all works or seems to because th=
 e<br>
 &nbsp;FDT would lock down the slave address along with the kernel config, b=
 ut<br>
 &nbsp;non-FDT platforms with SPI would have trouble with ghost devices on<b=
 r>
 &nbsp;rescan.<br>
 &nbsp;<br>
 &nbsp;You can also get ghost devices with I2C and 1-Wire (onewire(4)) on<br=
 >
 &nbsp;indirect probes, unless a particular device driver has taken steps in=
 <br>
 &nbsp;its match function to see if there really is something present at a<b=
 r>
 &nbsp;particular address.&nbsp; For I2C that is quite possible (probably), =
 for<br>
 &nbsp;1-Wire, not so much.<br>
 &nbsp;<br>
 &nbsp;<br>
 &nbsp;<br>
 &nbsp;<br>
 &nbsp;<br>
 &nbsp;<br>
 &nbsp;-- <br>
 &nbsp;Brad Spencer - brad%anduin.eldar.org@localhost<br>
 &nbsp;<br>
 </div>
 </span></font>
 </body>
 </html>
 
 --_000_2b96a108026d446a99c90d07a80bd894zaebayernde_--
 




Home | Main Index | Thread Index | Old Index