linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Re: Questions about MTD subpartitioning
       [not found] <AM7P189MB07258ABAA4DA1823DDDE78579BBC2@AM7P189MB0725.EURP189.PROD.OUTLOOK.COM>
@ 2025-04-18  7:16 ` Miquel Raynal
       [not found]   ` <DB8P189MB073217A985B7E4D574C972829B852@DB8P189MB0732.EURP189.PROD.OUTLOOK.COM>
  0 siblings, 1 reply; 2+ messages in thread
From: Miquel Raynal @ 2025-04-18  7:16 UTC (permalink / raw)
  To: Roland Kovács; +Cc: linux-mtd@lists.infradead.org, Malin Jonsson

Hi Roland,

On 17/04/2025 at 12:08:42 GMT, Roland Kovács <roland.kovacs@est.tech> wrote:

> Hi, 
>
> I'd like to ask some questions regarding mtdchar device driver.
> We'd like to add subpartitions to the PDR region of a NOR-flash device from userspace, but we hit a check in the BLKPG
> ioctl call which prevents subpartitioning.
> As far as I can tell, this check predates the support for subpartitions in mtdpart.c and I couldn't find information on
> why this is the case.
>
> Is there a particular reason why subpartitions through BLKPG is not allowed? 
> Or do you have any other recommended way of doing subpartitions from
> userspace?

In general I do not use subpartitioning from userspace, so I must admit
this is going to be a blind advise.

Looking at the code I see that partitioning is only allowed on master
devices, not partitions. But if you have partitions in you DT, the
master device is not kept (for historical reasons). But if you need it
you may select CONFIG_MTD_PARTITIONED_MASTER.

If that does not help, please give more details about the command
attempted, the device identification and geometry as well as the errors
you get.

Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Questions about MTD subpartitioning
       [not found]   ` <DB8P189MB073217A985B7E4D574C972829B852@DB8P189MB0732.EURP189.PROD.OUTLOOK.COM>
@ 2025-04-29  8:51     ` Miquel Raynal
  0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2025-04-29  8:51 UTC (permalink / raw)
  To: Roland Kovács; +Cc: linux-mtd@lists.infradead.org, Malin Jonsson

Hi Roland,

On 24/04/2025 at 14:21:49 GMT, Roland Kovács <roland.kovacs@est.tech> wrote:

> Many thanks for your response Miquel,
>
>> But if you have partitions in you DT, the
>> master device is not kept (for historical reasons).
>
> In our case, we don't have DT as the platform is x86.

To be very transparent, I am not familiar enough with x86 to be helpful
here.

> We are using the bog-standard spi-nor flash driver, the only extra we have is
> an additional driver that reads the predefined regions from the SPI controller,
> and registers them under the MTD master as partitions, some of them with write
> protection.
>
>> But if you need it you may select CONFIG_MTD_PARTITIONED_MASTER.
>
> Enabling the above *does* allow adding more partitions, however one issue I
> see with that is any new partition created will take its flags (including
> MTD_WRITEABLE) from the master device. So if we were to create partitions that
> overlap a predefined partition to emulate subpartitions that way we will have
> writable access over an otherwise read-only marked area.

AFAIU MTD_WRITEABLE is not a protection mechanism. It just tells
userspace if the type of underlying device is writeable, it does not
indicate anything about any type of write protection on top.

> Some partitions do have hardware write protection, but on some we enforce it
> in software, but I can't seem to find a way to do this in userspace.
>
> Is there a way to change write protection that I perhaps missed?

There is a MEMLOCK ioctl, but only a single spi nor manufacturer driver
implements it.

> Unless there's already an option for it would adding support for BLKROSET and
> BLKROGET make sense?

This would be at the block level, I have no objection myself but my
opinion would not be super relevant there, as you would have to involve
block folks in the discussion :)

Cheers,
Miquèl

> Regards,
> Roland
> -------------------------------------------------------------------------------------------------------------------------
> From: Miquel Raynal <miquel.raynal@bootlin.com>
> Sent: 18 April 2025 09:16
> To: Roland Kovács <roland.kovacs@est.tech>
> Cc: linux-mtd@lists.infradead.org <linux-mtd@lists.infradead.org>; Malin Jonsson <malin.jonsson@est.tech>
> Subject: Re: Questions about MTD subpartitioning 
>  
> Hi Roland,
>
> On 17/04/2025 at 12:08:42 GMT, Roland Kovács <roland.kovacs@est.tech> wrote:
>
>> Hi, 
>>
>> I'd like to ask some questions regarding mtdchar device driver.
>> We'd like to add subpartitions to the PDR region of a NOR-flash device from userspace, but we hit a check in the BLKPG
>> ioctl call which prevents subpartitioning.
>> As far as I can tell, this check predates the support for subpartitions in mtdpart.c and I couldn't find information on
>> why this is the case.
>>
>> Is there a particular reason why subpartitions through BLKPG is not allowed? 
>> Or do you have any other recommended way of doing subpartitions from
>> userspace?
>
> In general I do not use subpartitioning from userspace, so I must admit
> this is going to be a blind advise.
>
> Looking at the code I see that partitioning is only allowed on master
> devices, not partitions. But if you have partitions in you DT, the
> master device is not kept (for historical reasons). But if you need it
> you may select CONFIG_MTD_PARTITIONED_MASTER.
>
> If that does not help, please give more details about the command
> attempted, the device identification and geometry as well as the errors
> you get.
>
> Thanks,
> Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-04-29  8:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <AM7P189MB07258ABAA4DA1823DDDE78579BBC2@AM7P189MB0725.EURP189.PROD.OUTLOOK.COM>
2025-04-18  7:16 ` Questions about MTD subpartitioning Miquel Raynal
     [not found]   ` <DB8P189MB073217A985B7E4D574C972829B852@DB8P189MB0732.EURP189.PROD.OUTLOOK.COM>
2025-04-29  8:51     ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).