public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Manojkiran Eda <manojkiran.eda@gmail.com>
To: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>
Cc: "linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>
Subject: Re: mtd0 device is missing in /sys/class/mtd
Date: Tue, 2 Jan 2024 17:24:06 +0530	[thread overview]
Message-ID: <E8FDBC63-F364-44EB-8B90-925A4EC2F501@gmail.com> (raw)
In-Reply-To: <F86A353E-FFA9-4C8A-88D4-C726029CB27B@gmail.com>

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/

  parent reply	other threads:[~2024-01-02 11:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2024-01-02 17:21     ` Manojkiran Eda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E8FDBC63-F364-44EB-8B90-925A4EC2F501@gmail.com \
    --to=manojkiran.eda@gmail.com \
    --cc=Joakim.Tjernlund@infinera.com \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox