Hi Miquel, > > Hi Alexander, > > alexander.usyskin@xxxxxxxxx wrote on Mon, 24 Jul 2023 11:43:59 +0000: > > > > > > > With this patch applied, when I load up the module, I get the same 3 > > > > > > devices: > > > > > > /dev/mtd0 > > > > > > /dev/mtd0ro > > > > > > /dev/mtdblock0 > > > > > > > > > > > > Upon removal, the below 2 devices still hang around: > > > > > > /dev/mtd0 > > > > > > /dev/mtd0ro > > > > > > > > > Our use-case do not produce mtdblock, maybe there are some > imbalances > > > of get/put? > > > > I have somewhere version with pr_debug after every kref_get/put. That > may > > > help to catch where > > > > it missed, I hope. > > > > > > I believe mtdblock is the good citizen here. Just disable > > > CONFIG_MTD_BLOCK from your configuration and you will likely observe > > > the same issue, just a bit narrowed, perhaps. Indeed, if you manage to > > > follow all the get/put calls it can help to find an imbalance. > > > > > > Thanks, > > > Miquèl > > > > Miquel, do you have CONFIG_MTD_PARTITIONED_MASTER set in your > config? > > Not sure I get your question. You can enable or disable it, it should > work in both cases (yet, the handling is of course a bit different as > the top level device will be retained/not retained). > > Thanks, > Miquèl I'm trying to understand why I can't reproduce the problem in my scenario. I found an important difference in upstreamed patch and internal version: The IS_ENABLED(CONFIG_MTD_PARTITIONED_MASTER) check around kref_get/put does not exists in the internal tree. The code before my patch do not have such check, so I tend to assume that this check should be removed. If you reproduce happens with CONFIG_MTD_PARTITIONED_MASTER disabled that may explain problems that you see. -- Thanks, Sasha