From: Pratyush Yadav <pratyush@kernel.org>
To: Tudor Ambarus <tudor.ambarus@linaro.org>
Cc: "Andrew Lunn" <andrew@lunn.ch>,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
"Geert Uytterhoeven" <geert+renesas@glider.be>,
imx@lists.linux.dev, "Tony Lindgren" <tony@atomide.com>,
"Marco Felsch" <m.felsch@pengutronix.de>,
"Nicolas Ferre" <nicolas.ferre@microchip.com>,
"Thierry Reding" <thierry.reding@gmail.com>,
linux-mtd@lists.infradead.org, linux-i2c@vger.kernel.org,
"Miquel Raynal" <miquel.raynal@bootlin.com>,
"WANG Xuerui" <kernel@xen0n.name>,
"Fabio Estevam" <festevam@gmail.com>,
linux-aspeed@lists.ozlabs.org,
"Richard Weinberger" <richard@nod.at>,
"Gregory Clement" <gregory.clement@bootlin.com>,
"Huacai Chen" <chenhuacai@kernel.org>,
"Russell King" <linux@armlinux.org.uk>,
"Christophe Leroy" <christophe.leroy@csgroup.eu>,
"Jonathan Hunter" <jonathanh@nvidia.com>,
"Joel Stanley" <joel@jms.id.au>,
"Naveen N. Rao" <naveen.n.rao@linux.ibm.com>,
"Andrew Jeffery" <andrew@codeconstruct.com.au>,
"Sebastian Hesselbarth" <sebastian.hesselbarth@gmail.com>,
"Arnd Bergmann" <arnd@arndb.de>,
openbmc@lists.ozlabs.org, "Sascha Hauer" <s.hauer@pengutronix.de>,
"Jonathan Neuschäfer" <j.neuschaefer@gmx.net>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Vladimir Zapolskiy" <vz@mleia.com>,
"Maxime Ripard" <mripard@kernel.org>,
loongarch@lists.linux.dev, linux-tegra@vger.kernel.org,
linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
"Thomas Bogendoerfer" <tsbogend@alpha.franken.de>,
linux-mips@vger.kernel.org,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
linuxppc-dev@lists.ozlabs.org,
"Claudiu Beznea" <claudiu.beznea@tuxon.dev>,
linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
"Dinh Nguyen" <dinguyen@kernel.org>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Shawn Guo" <shawnguo@kernel.org>,
"Bartosz Golaszewski" <brgl@bgdev.pl>
Subject: Re: [PATCH 4/9] mtd: devices: add AT24 eeprom support
Date: Tue, 02 Jul 2024 15:41:52 +0200 [thread overview]
Message-ID: <mafs0ikxnykpr.fsf@kernel.org> (raw)
In-Reply-To: <07b701a9-7b52-45b7-8dba-1c25d77cbf15@linaro.org> (Tudor Ambarus's message of "Mon, 1 Jul 2024 17:14:14 +0100")
On Mon, Jul 01 2024, Tudor Ambarus wrote:
> On 7/1/24 2:53 PM, Marco Felsch wrote:
>> EEPROMs can become quite large nowadays (>=64K). Exposing such devices
>> as single device isn't always sufficient. There may be partitions which
>> require different access permissions. Also write access always need to
>> to verify the offset.
>>
>> Port the current misc/eeprom/at24.c driver to the MTD framework since
>> EEPROMs are memory-technology devices and the framework already supports
>
> I was under the impression that MTD devices are tightly coupled by erase
> blocks. But then we see MTD_NO_ERASE, so what are MTD devices after all?
I was curious as well so I did some digging.
The Kconfig help says:
Memory Technology Devices are flash, RAM and similar chips, often
used for solid state file systems on embedded devices [...]
The FAQ on the MTD documentation [0] says:
Unix traditionally only knew block devices and character devices.
Character devices were things like keyboards or mice, that you could
read current data from, but couldn't be seek-ed and didn't have a size.
Block devices had a fixed size and could be seek-ed. They also happened
to be organized in blocks of multiple bytes, usually 512.
Flash doesn't match the description of either block or character
devices. They behave similar to block device, but have differences. For
example, block devices don't distinguish between write and erase
operations. Therefore, a special device type to match flash
characteristics was created: MTD.
So MTD is neither a block nor a char device. There are translations to
use them, as if they were. But those translations are nowhere near the
original, just like translated Chinese poems.
And in the section below, it lists some properties of an MTD device:
- Consists of eraseblocks.
- Eraseblocks are larger (typically 128KiB).
- Maintains 3 main operations: read from eraseblock, write to
eraseblock, and erase eraseblock.
- Bad eraseblocks are not hidden and should be dealt with in
software.
- Eraseblocks wear-out and become bad and unusable after about 10^3
(for MLC NAND) - 10^5 (NOR, SLC NAND) erase cycles.
This does support the assumption you had about MTD devices being tightly
coupled with erase block. It also makes it quite clear that an EEPROM is
not MTD -- since EEPROMs are byte-erasable.
Of course, the existence of MTD_NO_ERASE nullifies a lot of
these points. So it seems the subsystem has evolved. MTD_NO_ERASE was
added by 92cbfdcc3661d ("[MTD] replace MTD_RAM with MTD_GENERIC_TYPE")
in 2006, but this commit only adds the flag. The functionality of "not
requiring an explicit erase" for RAM devices has existed since the start
of the git history at least.
I also found a thread from 2013 by Maxime Ripard (+Cc) suggesting adding
EEPROMs to MTD [1]. The main purpose would have been unifying the EEPROM
drivers under a single interface. I am not sure what came of it though,
since I can't find any patches that followed up with the proposal.
Overall, I'd say that while originally MTD was written with flash
devices with erase blocks in mind, the subsystem seems to have evolved
with time to include other types of devices.
I don't see anything obviously wrong with adding EEPROMs to the type of
devices in MTD as well. It doesn't seem to be too invasive to the
subsystem (I do see some dubious code when skimming through the patches,
but nothing unfixable). And the EEPROM drivers can get a common
interface. The other option would be to create a separate subsystem for
EEPROMs, but perhaps that would just lead to a bunch of code being
duplicated.
I'd like to hear if somebody thinks otherwise, and sees reasons to _not_
do this.
[0] http://www.linux-mtd.infradead.org/faq/general.html
[1] https://lore.kernel.org/linux-mtd/20130705201118.GM2959@lukather/
--
Regards,
Pratyush Yadav
next prev parent reply other threads:[~2024-07-02 17:50 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-01 13:53 [PATCH 0/9] AT24 EEPROM MTD Support Marco Felsch
2024-07-01 13:53 ` [PATCH 1/9] mtd: core: add nvmem_write support Marco Felsch
2024-07-01 13:53 ` [PATCH 2/9] mtd: add mtd_is_master helper Marco Felsch
2024-07-01 16:14 ` Sergei Shtylyov
2024-07-02 8:22 ` Marco Felsch
2024-07-01 13:53 ` [PATCH 3/9] mtd: add support to handle EEPROM devices Marco Felsch
2024-07-01 13:53 ` [PATCH 4/9] mtd: devices: add AT24 eeprom support Marco Felsch
2024-07-01 16:14 ` Tudor Ambarus
2024-07-02 13:41 ` Pratyush Yadav [this message]
2024-07-02 13:56 ` Maxime Ripard
2024-07-02 14:15 ` Pratyush Yadav
2024-07-02 14:34 ` Maxime Ripard
2024-07-08 6:44 ` Miquel Raynal
2024-07-09 9:22 ` Marco Felsch
2024-07-09 9:43 ` Miquel Raynal
2024-07-09 10:38 ` Marco Felsch
2024-07-17 8:19 ` Miquel Raynal
2024-07-18 9:17 ` Marco Felsch
2024-08-23 15:37 ` Miquel Raynal
2024-07-01 13:53 ` [PATCH 5/9] ARM: defconfig: convert to MTD_EEPROM_AT24 Marco Felsch
2024-07-10 12:48 ` Arnd Bergmann
2024-07-10 12:59 ` Bartosz Golaszewski
2024-07-10 14:06 ` Arnd Bergmann
2024-07-01 13:53 ` [PATCH 6/9] powerpc: " Marco Felsch
2024-07-01 13:53 ` [PATCH 7/9] MIPS: configs: " Marco Felsch
2024-07-01 13:53 ` [PATCH 8/9] LoongArch: " Marco Felsch
2024-07-01 13:53 ` [PATCH 9/9] eeprom: at24: remove deprecated Kconfig symbol Marco Felsch
2024-07-02 8:57 ` Bartosz Golaszewski
2024-07-02 9:15 ` Marco Felsch
2024-08-23 16:24 ` [PATCH 0/9] AT24 EEPROM MTD Support Andy Shevchenko
2024-08-26 7:51 ` Marco Felsch
2024-08-26 10:32 ` Andy Shevchenko
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=mafs0ikxnykpr.fsf@kernel.org \
--to=pratyush@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=andrew@codeconstruct.com.au \
--cc=andrew@lunn.ch \
--cc=arnd@arndb.de \
--cc=brgl@bgdev.pl \
--cc=chenhuacai@kernel.org \
--cc=christophe.leroy@csgroup.eu \
--cc=claudiu.beznea@tuxon.dev \
--cc=dinguyen@kernel.org \
--cc=festevam@gmail.com \
--cc=geert+renesas@glider.be \
--cc=gregkh@linuxfoundation.org \
--cc=gregory.clement@bootlin.com \
--cc=imx@lists.linux.dev \
--cc=j.neuschaefer@gmx.net \
--cc=joel@jms.id.au \
--cc=jonathanh@nvidia.com \
--cc=kernel@pengutronix.de \
--cc=kernel@xen0n.name \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=loongarch@lists.linux.dev \
--cc=m.felsch@pengutronix.de \
--cc=miquel.raynal@bootlin.com \
--cc=mripard@kernel.org \
--cc=naveen.n.rao@linux.ibm.com \
--cc=nicolas.ferre@microchip.com \
--cc=npiggin@gmail.com \
--cc=openbmc@lists.ozlabs.org \
--cc=richard@nod.at \
--cc=s.hauer@pengutronix.de \
--cc=sebastian.hesselbarth@gmail.com \
--cc=shawnguo@kernel.org \
--cc=thierry.reding@gmail.com \
--cc=tony@atomide.com \
--cc=tsbogend@alpha.franken.de \
--cc=tudor.ambarus@linaro.org \
--cc=vigneshr@ti.com \
--cc=vz@mleia.com \
/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;
as well as URLs for NNTP newsgroup(s).