From mboxrd@z Thu Jan 1 00:00:00 1970 From: Miquel Raynal Date: Tue, 30 Oct 2018 23:43:40 +0100 Subject: [U-Boot] [PATCH] cmd: mtdparts: Probe MTD devices in mtdparts_init() In-Reply-To: <20181030230250.736979d0@bbrezillon> References: <20181030095151.12442-1-sr@denx.de> <20181030110354.48e1736d@bbrezillon> <20181030114138.12ce4a8e@bbrezillon> <20181030230250.736979d0@bbrezillon> Message-ID: <20181030234340.5c277762@xps13> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de Hi Boris, Boris Brezillon wrote on Tue, 30 Oct 2018 23:02:50 +0100: > On Tue, 30 Oct 2018 11:59:13 +0100 > Stefan Roese wrote: >=20 > > On 30.10.18 11:41, Boris Brezillon wrote: =20 > > > On Tue, 30 Oct 2018 11:13:37 +0100 > > > Stefan Roese wrote: > > > =20 > > >> Hi Boris, > > >> > > >> On 30.10.18 11:03, Boris Brezillon wrote: =20 > > >>> On Tue, 30 Oct 2018 10:51:51 +0100 > > >>> Stefan Roese wrote: > > >>> =20 > > >>>> Calling "mtdparts" currently fails when its called before any othe= r mtd > > >>>> command (or ubi command) has been called. The MTD devices are not > > >>>> probed at this point and therefore it fails e.g. with this message: > > >>>> =20 > > >>>> =3D> mtdparts =20 > > >>>> Device spi-nand0 not found! =20 > > >>> > > >>> IIRC, we decided that mtdparts should not call mtd_probe_devices() = to > > >>> encourage people to stop using it. =20 > > >> > > >> I see. But I don't quite get how this missing call (and reslting > > >> error message) would encourage people to stop using it. =20 > > >=20 > > > You're right, this message does not encourage people to stop using > > > mtdparts on existing setups (mtdparts should work just fine on any MTD > > > devices except SPI NANDs) but it does discourage them from using it on > > > spi-nand devices since it returns an error. =20 > >=20 > > IMHO, that's more confusing than discouraging. > > =20 > > >>>> > > >>>> This patch adds a call to mtd_probe_devices() to mtdparts_init() to > > >>>> solve this issue. This also fixes a problem when calling "ubi part" > > >>>> as first flash storage related command. =20 > > >>> > > >>> Hm, this one is unexpected. Miquel, any idea why this happens. Do we > > >>> need to enable a specific option if we want mtd_probe_devices() to = be > > >>> called in the ubi part path? =20 > > >> > > >> Please note that "ubi part part-foo" does still work. It only > > >> prints this error message before attaching the MTD partition. > > >> The error is printed because of this call-chain: > > >> > > >> ubi_part() =20 > > >> -> ubi_detach() > > >> -> mtdparts_init() =20 > > >> > > >> So again, mtdparts_init() is called without the MTD devices > > >> being probed. =20 > > >=20 > > > I guess we forgot to remove this mtdparts_init() call from the detach > > > path. I think it's no longer needed since we now call > > > mtd_probe_devices() in ubi_part(), and mtd_probe_devices() will take > > > care of creating MTD partitions based on the mtdparts=3D and mtdids=3D > > > variables. =20 > >=20 > > A quick test reveals that this removal does not remove the > > error message. Instead the command does not work anymore at > > all: > > =20 > > =3D> ubi part nand =20 > > Partition nand not found! > >=20 > > Before (and without my patch) its this: > > =20 > > =3D> ubi part nand =20 > > Device spi-nand0 not found! > > Error initializing mtdparts! > > ubi0: attaching mtd2 > > ubi0: scanning is finished > > ubi0: attached mtd2 (name "nand", size 128 MiB) =20 >=20 > I think I found what's missing in mtd_probe_devices(): we don't use the > default mtdparts and mtdids when those env vars are NULL (see what's > done in mtdparts_init() to handle this case [1]). >=20 > [1]https://elixir.bootlin.com/u-boot/v2018.11-rc3/source/cmd/mtdparts.c#L= 1763 Isn't the right solution to always define these env variables when they are needed? Defining such default behavior with a Kconfig entry is, from my opinion, a lot of noise for such an useless feature... Thanks, Miqu=C3=A8l