* mtd0 device is missing in /sys/class/mtd @ 2023-12-28 16:38 Manojkiran Eda 2023-12-31 13:16 ` Joakim Tjernlund 0 siblings, 1 reply; 4+ messages in thread From: Manojkiran Eda @ 2023-12-28 16:38 UTC (permalink / raw) To: linux-mtd Hi All, I was as beginner in linux device driver development, and recently I was working on a device driver for espi protocol and was stuck with a problem. I have an mtd device driver through which one could access the NOR flash connected to the other end of espi bus. The driver seems to have probed successfully , I see an entry for my mtd device in /proc/mtd but , I dont see an entry for my mtd device in the /sys/class/mtd. Here are few logs of interest : root@mybox:~# cat /proc/mtd dev: size erasesize name mtd0: 04000000 00001000 "aspeed-espi-flash” <<<<<—— This is my mtd device mtd1: 04000000 00010000 "bmc" mtd2: 000e0000 00010000 "u-boot" mtd3: 00020000 00010000 "u-boot-env" mtd4: 00900000 00010000 "kernel" mtd5: 02000000 00010000 "rofs" mtd6: 01600000 00010000 "rwfs" mtd7: 04000000 00010000 "alt-bmc" mtd8: 000e0000 00010000 "alt-u-boot" mtd9: 00020000 00010000 "alt-u-boot-env" mtd10: 00900000 00010000 "alt-kernel" mtd11: 02000000 00010000 "alt-rofs" mtd12: 01600000 00010000 "alt-rwfs” root@mybox:/sys/class/mtd# ls mtd1 mtd10ro mtd11ro mtd12ro mtd2 mtd3 mtd4 mtd5 mtd6 mtd7 mtd8 mtd9 mtd10 mtd11 mtd12 mtd1ro mtd2ro mtd3ro mtd4ro mtd5ro mtd6ro mtd7ro mtd8ro mtd9ro I was expecting mtd0 to be present in the /sys/class/mtd, but its not there. Looking at dmesg: root@mybox:/sys/class/mtd# dmesg | grep -ie mtd -A5 -ie espi [ 0.685006] Entered the aspeed_espi_ctrl_probe function [ 0.690990] device matched : 1 [ 0.699225] espi alloc started [ 0.704726] espi read from device tree, flash size : 67108864 [ 0.712416] espi flash enabled [ 0.716572] espi flash channel is ready [ 0.720940] espi flash allocation completed [ 0.725259] aspeed-espi-ctrl 1e6ee000.espi-ctrl: module loaded -- [ 0.962764] 5 fixed-partitions partitions found on MTD device bmc [ 0.969675] Creating 5 MTD partitions on "bmc": [ 0.974776] 0x000000000000-0x0000000e0000 : "u-boot" [ 0.981982] 0x0000000e0000-0x000000100000 : "u-boot-env" [ 0.989557] 0x000000100000-0x000000a00000 : "kernel" [ 0.996772] 0x000000a00000-0x000002a00000 : "rofs" [ 1.003759] 0x000002a00000-0x000004000000 : "rwfs" -- [ 1.048304] 5 fixed-partitions partitions found on MTD device alt-bmc [ 1.055563] Creating 5 MTD partitions on "alt-bmc": [ 1.061096] 0x000000000000-0x0000000e0000 : "alt-u-boot" [ 1.068672] 0x0000000e0000-0x000000100000 : "alt-u-boot-env" [ 1.076607] 0x000000100000-0x000000a00000 : "alt-kernel" [ 1.084211] 0x000000a00000-0x000002a00000 : "alt-rofs" [ 1.091594] 0x000002a00000-0x000004000000 : "alt-rwfs” and the mtd devices listed in /sys/class/mtd from mtd1 through mtd12 are basically from the partitions list above. root@mybox:/sys/class/mtd# for dir in *; do cat $dir/name; done bmc alt-kernel alt-rofs alt-rwfs u-boot u-boot-env kernel rofs rwfs alt-bmc alt-u-boot alt-u-boot-env Does anyone know what could be the possible reason for the problem ? Any hints/help would be appreciated. Thanks, Manoj ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: mtd0 device is missing in /sys/class/mtd 2023-12-28 16:38 mtd0 device is missing in /sys/class/mtd Manojkiran Eda @ 2023-12-31 13:16 ` Joakim Tjernlund [not found] ` <F86A353E-FFA9-4C8A-88D4-C726029CB27B@gmail.com> 0 siblings, 1 reply; 4+ messages in thread From: Joakim Tjernlund @ 2023-12-31 13:16 UTC (permalink / raw) To: Manojkiran Eda, linux-mtd@lists.infradead.org Try adding MTD_PARTITIONED_MASTER to your kernel config ________________________________________ From: linux-mtd <linux-mtd-bounces@lists.infradead.org> on behalf of Manojkiran Eda <manojkiran.eda@gmail.com> Sent: 28 December 2023 17:38 To: linux-mtd@lists.infradead.org Subject: mtd0 device is missing in /sys/class/mtd Hi All, I was as beginner in linux device driver development, and recently I was working on a device driver for espi protocol and was stuck with a problem. I have an mtd device driver through which one could access the NOR flash connected to the other end of espi bus. The driver seems to have probed successfully , I see an entry for my mtd device in /proc/mtd but , I dont see an entry for my mtd device in the /sys/class/mtd. Here are few logs of interest : root@mybox:~# cat /proc/mtd dev: size erasesize name mtd0: 04000000 00001000 "aspeed-espi-flash” <<<<<—— This is my mtd device mtd1: 04000000 00010000 "bmc" mtd2: 000e0000 00010000 "u-boot" mtd3: 00020000 00010000 "u-boot-env" mtd4: 00900000 00010000 "kernel" mtd5: 02000000 00010000 "rofs" mtd6: 01600000 00010000 "rwfs" mtd7: 04000000 00010000 "alt-bmc" mtd8: 000e0000 00010000 "alt-u-boot" mtd9: 00020000 00010000 "alt-u-boot-env" mtd10: 00900000 00010000 "alt-kernel" mtd11: 02000000 00010000 "alt-rofs" mtd12: 01600000 00010000 "alt-rwfs” root@mybox:/sys/class/mtd# ls mtd1 mtd10ro mtd11ro mtd12ro mtd2 mtd3 mtd4 mtd5 mtd6 mtd7 mtd8 mtd9 mtd10 mtd11 mtd12 mtd1ro mtd2ro mtd3ro mtd4ro mtd5ro mtd6ro mtd7ro mtd8ro mtd9ro I was expecting mtd0 to be present in the /sys/class/mtd, but its not there. Looking at dmesg: root@mybox:/sys/class/mtd# dmesg | grep -ie mtd -A5 -ie espi [ 0.685006] Entered the aspeed_espi_ctrl_probe function [ 0.690990] device matched : 1 [ 0.699225] espi alloc started [ 0.704726] espi read from device tree, flash size : 67108864 [ 0.712416] espi flash enabled [ 0.716572] espi flash channel is ready [ 0.720940] espi flash allocation completed [ 0.725259] aspeed-espi-ctrl 1e6ee000.espi-ctrl: module loaded -- [ 0.962764] 5 fixed-partitions partitions found on MTD device bmc [ 0.969675] Creating 5 MTD partitions on "bmc": [ 0.974776] 0x000000000000-0x0000000e0000 : "u-boot" [ 0.981982] 0x0000000e0000-0x000000100000 : "u-boot-env" [ 0.989557] 0x000000100000-0x000000a00000 : "kernel" [ 0.996772] 0x000000a00000-0x000002a00000 : "rofs" [ 1.003759] 0x000002a00000-0x000004000000 : "rwfs" -- [ 1.048304] 5 fixed-partitions partitions found on MTD device alt-bmc [ 1.055563] Creating 5 MTD partitions on "alt-bmc": [ 1.061096] 0x000000000000-0x0000000e0000 : "alt-u-boot" [ 1.068672] 0x0000000e0000-0x000000100000 : "alt-u-boot-env" [ 1.076607] 0x000000100000-0x000000a00000 : "alt-kernel" [ 1.084211] 0x000000a00000-0x000002a00000 : "alt-rofs" [ 1.091594] 0x000002a00000-0x000004000000 : "alt-rwfs” and the mtd devices listed in /sys/class/mtd from mtd1 through mtd12 are basically from the partitions list above. root@mybox:/sys/class/mtd# for dir in *; do cat $dir/name; done bmc alt-kernel alt-rofs alt-rwfs u-boot u-boot-env kernel rofs rwfs alt-bmc alt-u-boot alt-u-boot-env Does anyone know what could be the possible reason for the problem ? Any hints/help would be appreciated. Thanks, Manoj ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <F86A353E-FFA9-4C8A-88D4-C726029CB27B@gmail.com>]
* Re: mtd0 device is missing in /sys/class/mtd [not found] ` <F86A353E-FFA9-4C8A-88D4-C726029CB27B@gmail.com> @ 2024-01-02 11:54 ` Manojkiran Eda 2024-01-02 17:21 ` Manojkiran Eda 1 sibling, 0 replies; 4+ messages in thread From: Manojkiran Eda @ 2024-01-02 11:54 UTC (permalink / raw) To: Joakim Tjernlund; +Cc: linux-mtd@lists.infradead.org I tried adding MTD_PARTITIONED_MASTER to my kernel config, and still facing the same issue. Debugging a little more , I figured out that my driver is being probed a lot early than the mtd class being registered. So the code is bailing out lot early since the class_to_subsys() returns null (https://elixir.bootlin.com/linux/latest/source/drivers/base/core.c#L3180) console traces: [ 9.128866] Entered the aspeed_espi_ctrl_probe function …. [ 11.581081] mtd class is registering now Looking more, I see a class_is_registered() method available at (https://elixir.bootlin.com/linux/latest/source/drivers/base/class.c#L644) . Is that something that I could check in my driver and return an EPROBE_DEFER ? Or should this logic be incorporated in the mtdcore.c ? Because the mtd_class definition is been declared in the mtdcore and is not passed down from my driver code. All I was doing is calling mtd_device_register() and expecting it to return EPROBE_DEFER if the mtd core subsystem/class is not registered/probed in the kernel. But I am not sure what’s the right direction. Can any one help me out on this ? Thanks, Manoj >> On 31-Dec-2023, at 6:46 PM, Joakim Tjernlund <Joakim.Tjernlund@infinera.com> wrote: >> >> Try adding MTD_PARTITIONED_MASTER to your kernel config >> >> ________________________________________ >> From: linux-mtd <linux-mtd-bounces@lists.infradead.org> on behalf of Manojkiran Eda <manojkiran.eda@gmail.com> >> Sent: 28 December 2023 17:38 >> To: linux-mtd@lists.infradead.org >> Subject: mtd0 device is missing in /sys/class/mtd >> >> Hi All, >> >> I was as beginner in linux device driver development, and recently I was working on a device driver for espi protocol and was stuck with a problem. >> >> I have an mtd device driver through which one could access the NOR flash connected to the other end of espi bus. The driver seems to have probed successfully , I see an entry for my mtd device in /proc/mtd but , I dont see an entry for my mtd device in the /sys/class/mtd. >> >> Here are few logs of interest : >> >> root@mybox:~# cat /proc/mtd >> dev: size erasesize name >> mtd0: 04000000 00001000 "aspeed-espi-flash” <<<<<—— This is my mtd device >> mtd1: 04000000 00010000 "bmc" >> mtd2: 000e0000 00010000 "u-boot" >> mtd3: 00020000 00010000 "u-boot-env" >> mtd4: 00900000 00010000 "kernel" >> mtd5: 02000000 00010000 "rofs" >> mtd6: 01600000 00010000 "rwfs" >> mtd7: 04000000 00010000 "alt-bmc" >> mtd8: 000e0000 00010000 "alt-u-boot" >> mtd9: 00020000 00010000 "alt-u-boot-env" >> mtd10: 00900000 00010000 "alt-kernel" >> mtd11: 02000000 00010000 "alt-rofs" >> mtd12: 01600000 00010000 "alt-rwfs” >> >> >> root@mybox:/sys/class/mtd# ls >> mtd1 mtd10ro mtd11ro mtd12ro mtd2 mtd3 mtd4 mtd5 mtd6 mtd7 mtd8 mtd9 >> mtd10 mtd11 mtd12 mtd1ro mtd2ro mtd3ro mtd4ro mtd5ro mtd6ro mtd7ro mtd8ro mtd9ro >> >> I was expecting mtd0 to be present in the /sys/class/mtd, but its not there. >> >> Looking at dmesg: >> >> root@mybox:/sys/class/mtd# dmesg | grep -ie mtd -A5 -ie espi >> [ 0.685006] Entered the aspeed_espi_ctrl_probe function >> [ 0.690990] device matched : 1 >> [ 0.699225] espi alloc started >> [ 0.704726] espi read from device tree, flash size : 67108864 >> [ 0.712416] espi flash enabled >> [ 0.716572] espi flash channel is ready >> [ 0.720940] espi flash allocation completed >> [ 0.725259] aspeed-espi-ctrl 1e6ee000.espi-ctrl: module loaded >> -- >> [ 0.962764] 5 fixed-partitions partitions found on MTD device bmc >> [ 0.969675] Creating 5 MTD partitions on "bmc": >> [ 0.974776] 0x000000000000-0x0000000e0000 : "u-boot" >> [ 0.981982] 0x0000000e0000-0x000000100000 : "u-boot-env" >> [ 0.989557] 0x000000100000-0x000000a00000 : "kernel" >> [ 0.996772] 0x000000a00000-0x000002a00000 : "rofs" >> [ 1.003759] 0x000002a00000-0x000004000000 : "rwfs" >> -- >> [ 1.048304] 5 fixed-partitions partitions found on MTD device alt-bmc >> [ 1.055563] Creating 5 MTD partitions on "alt-bmc": >> [ 1.061096] 0x000000000000-0x0000000e0000 : "alt-u-boot" >> [ 1.068672] 0x0000000e0000-0x000000100000 : "alt-u-boot-env" >> [ 1.076607] 0x000000100000-0x000000a00000 : "alt-kernel" >> [ 1.084211] 0x000000a00000-0x000002a00000 : "alt-rofs" >> [ 1.091594] 0x000002a00000-0x000004000000 : "alt-rwfs” >> >> and the mtd devices listed in /sys/class/mtd from mtd1 through mtd12 are basically from the partitions list above. >> >> root@mybox:/sys/class/mtd# for dir in *; do cat $dir/name; done >> bmc >> alt-kernel >> alt-rofs >> alt-rwfs >> u-boot >> u-boot-env >> kernel >> rofs >> rwfs >> alt-bmc >> alt-u-boot >> alt-u-boot-env >> >> Does anyone know what could be the possible reason for the problem ? Any hints/help would be appreciated. >> >> Thanks, >> Manoj >> >> >> ______________________________________________________ >> Linux MTD discussion mailing list >> http://lists.infradead.org/mailman/listinfo/linux-mtd/ > ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: mtd0 device is missing in /sys/class/mtd [not found] ` <F86A353E-FFA9-4C8A-88D4-C726029CB27B@gmail.com> 2024-01-02 11:54 ` Manojkiran Eda @ 2024-01-02 17:21 ` Manojkiran Eda 1 sibling, 0 replies; 4+ messages in thread From: Manojkiran Eda @ 2024-01-02 17:21 UTC (permalink / raw) To: Joakim Tjernlund; +Cc: linux-mtd@lists.infradead.org I was reading somewhere that , modules that are declared with subsys_initcall() are guaranteed to be executed before the modules that are declared with module_init() , so declaring the mtdcore with subsys_initcall() rather than module_init() solved the issue. But wondering if this is the right way to solve the problem ? What is the right way EPROBE_DEFER ? Or Changing the subsystem’s procedure to subsys_initcall() ? Thanks, Manoj > On 02-Jan-2024, at 5:20 PM, Manojkiran Eda <manojkiran.eda@gmail.com> wrote: > > I tried adding MTD_PARTITIONED_MASTER to my kernel config, and still facing the same issue. Debugging a little more , I figured out that my driver is being probed a lot early than the mtd class being registered. So the code is bailing out lot early since the class_to_subsys() returns null (https://elixir.bootlin.com/linux/latest/source/drivers/base/core.c#L3180) > > console traces: > > [ 9.128866] Entered the aspeed_espi_ctrl_probe function > …. > [ 11.581081] mtd class is registering now > > > Looking more, I see a class_is_registered() method available at https://elixir.bootlin.com/linux/latest/source/drivers/base/class.c#L644 . Is that something that I could check in my driver and return an EPROBE_DEFER ? Or should this logic be incorporated in the mtdcore.c ? Because the mtd_class definition is been declared in the mtdcore and is not passed down from my driver code. All I was doing is calling mtd_device_register() and expecting it to return EPROBE_DEFER if the mtd core subsystem/class is not registered/probed in the kernel. > > But I am not sure what’s the right direction. Can any one help me out on this ? > > Thanks, > Manoj > >> On 31-Dec-2023, at 6:46 PM, Joakim Tjernlund <Joakim.Tjernlund@infinera.com> wrote: >> >> Try adding MTD_PARTITIONED_MASTER to your kernel config >> >> ________________________________________ >> From: linux-mtd <linux-mtd-bounces@lists.infradead.org> on behalf of Manojkiran Eda <manojkiran.eda@gmail.com> >> Sent: 28 December 2023 17:38 >> To: linux-mtd@lists.infradead.org >> Subject: mtd0 device is missing in /sys/class/mtd >> >> Hi All, >> >> I was as beginner in linux device driver development, and recently I was working on a device driver for espi protocol and was stuck with a problem. >> >> I have an mtd device driver through which one could access the NOR flash connected to the other end of espi bus. The driver seems to have probed successfully , I see an entry for my mtd device in /proc/mtd but , I dont see an entry for my mtd device in the /sys/class/mtd. >> >> Here are few logs of interest : >> >> root@mybox:~# cat /proc/mtd >> dev: size erasesize name >> mtd0: 04000000 00001000 "aspeed-espi-flash” <<<<<—— This is my mtd device >> mtd1: 04000000 00010000 "bmc" >> mtd2: 000e0000 00010000 "u-boot" >> mtd3: 00020000 00010000 "u-boot-env" >> mtd4: 00900000 00010000 "kernel" >> mtd5: 02000000 00010000 "rofs" >> mtd6: 01600000 00010000 "rwfs" >> mtd7: 04000000 00010000 "alt-bmc" >> mtd8: 000e0000 00010000 "alt-u-boot" >> mtd9: 00020000 00010000 "alt-u-boot-env" >> mtd10: 00900000 00010000 "alt-kernel" >> mtd11: 02000000 00010000 "alt-rofs" >> mtd12: 01600000 00010000 "alt-rwfs” >> >> >> root@mybox:/sys/class/mtd# ls >> mtd1 mtd10ro mtd11ro mtd12ro mtd2 mtd3 mtd4 mtd5 mtd6 mtd7 mtd8 mtd9 >> mtd10 mtd11 mtd12 mtd1ro mtd2ro mtd3ro mtd4ro mtd5ro mtd6ro mtd7ro mtd8ro mtd9ro >> >> I was expecting mtd0 to be present in the /sys/class/mtd, but its not there. >> >> Looking at dmesg: >> >> root@mybox:/sys/class/mtd# dmesg | grep -ie mtd -A5 -ie espi >> [ 0.685006] Entered the aspeed_espi_ctrl_probe function >> [ 0.690990] device matched : 1 >> [ 0.699225] espi alloc started >> [ 0.704726] espi read from device tree, flash size : 67108864 >> [ 0.712416] espi flash enabled >> [ 0.716572] espi flash channel is ready >> [ 0.720940] espi flash allocation completed >> [ 0.725259] aspeed-espi-ctrl 1e6ee000.espi-ctrl: module loaded >> -- >> [ 0.962764] 5 fixed-partitions partitions found on MTD device bmc >> [ 0.969675] Creating 5 MTD partitions on "bmc": >> [ 0.974776] 0x000000000000-0x0000000e0000 : "u-boot" >> [ 0.981982] 0x0000000e0000-0x000000100000 : "u-boot-env" >> [ 0.989557] 0x000000100000-0x000000a00000 : "kernel" >> [ 0.996772] 0x000000a00000-0x000002a00000 : "rofs" >> [ 1.003759] 0x000002a00000-0x000004000000 : "rwfs" >> -- >> [ 1.048304] 5 fixed-partitions partitions found on MTD device alt-bmc >> [ 1.055563] Creating 5 MTD partitions on "alt-bmc": >> [ 1.061096] 0x000000000000-0x0000000e0000 : "alt-u-boot" >> [ 1.068672] 0x0000000e0000-0x000000100000 : "alt-u-boot-env" >> [ 1.076607] 0x000000100000-0x000000a00000 : "alt-kernel" >> [ 1.084211] 0x000000a00000-0x000002a00000 : "alt-rofs" >> [ 1.091594] 0x000002a00000-0x000004000000 : "alt-rwfs” >> >> and the mtd devices listed in /sys/class/mtd from mtd1 through mtd12 are basically from the partitions list above. >> >> root@mybox:/sys/class/mtd# for dir in *; do cat $dir/name; done >> bmc >> alt-kernel >> alt-rofs >> alt-rwfs >> u-boot >> u-boot-env >> kernel >> rofs >> rwfs >> alt-bmc >> alt-u-boot >> alt-u-boot-env >> >> Does anyone know what could be the possible reason for the problem ? Any hints/help would be appreciated. >> >> Thanks, >> Manoj >> >> >> ______________________________________________________ >> Linux MTD discussion mailing list >> http://lists.infradead.org/mailman/listinfo/linux-mtd/ > ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-01-02 17:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-28 16:38 mtd0 device is missing in /sys/class/mtd Manojkiran Eda
2023-12-31 13:16 ` Joakim Tjernlund
[not found] ` <F86A353E-FFA9-4C8A-88D4-C726029CB27B@gmail.com>
2024-01-02 11:54 ` Manojkiran Eda
2024-01-02 17:21 ` Manojkiran Eda
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox