linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Richard Weinberger <richard@nod.at>
Cc: Vignesh Raghavendra <vigneshr@ti.com>,
	Tudor Ambarus <Tudor.Ambarus@microchip.com>,
	Boris Brezillon <boris.brezillon@bootlin.com>,
	Boris Brezillon <boris.brezillon@collabora.com>,
	linux-mtd <linux-mtd@lists.infradead.org>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH 4/8] mtd: Add support for emulated SLC mode on MLC NANDs
Date: Tue, 14 Jan 2020 11:04:13 +0100	[thread overview]
Message-ID: <20200114110413.63e089ae@xps13> (raw)
In-Reply-To: <1518112485.16967.1578527342428.JavaMail.zimbra@nod.at>

Hi Richard,

A very simple question below.

> 
> > +	 * is an MLC NAND and has a proper pairing scheme defined.
> > +	 * We also reject masters that implement ->_writev() for now, because
> > +	 * NAND controller drivers don't implement this hook, and adding the
> > +	 * SLC -> MLC address/length conversion to this path is useless if we
> > +	 * don't have a user.
> > +	 */
> > +	if (mtd->flags & MTD_MLC_IN_SLC_MODE &&
> > +	    (!mtd_is_partition(mtd) || master->type != MTD_MLCNANDFLASH ||
> > +	     !master->pairing || master->_writev))
> > +		return -EINVAL;
> > +
> > 	mutex_lock(&mtd_table_mutex);
> > 
> > 	i = idr_alloc(&mtd_idr, mtd, 0, 0, GFP_KERNEL);
> > @@ -632,6 +645,14 @@ int add_mtd_device(struct mtd_info *mtd)
> > 	if (mtd->bitflip_threshold == 0)
> > 		mtd->bitflip_threshold = mtd->ecc_strength;
> > 
> > +	if (mtd->flags & MTD_MLC_IN_SLC_MODE) {
> > +		int ngroups = mtd_pairing_groups(master);
> > +
> > +		mtd->erasesize /= ngroups;
> > +		mtd->size = (u64)mtd_div_by_eb(mtd->size, master) *
> > +			    mtd->erasesize;  
> 
> Can we please have a helper for this? You use this formula many times.

I thought you were talking about the mtd->size calculation but this
line appears only once as-is. the whole 'if' block is never exactly the
same so it cannot be factored out. The only line that is actually
repeating is the if condition. Do you mean you would like something
like this?

	static bool mtd_emulates_slc(struct mtd_info *mtd)
	{
		return mtd->flags & MTD_EMULATE_SLC_ON_MLC;
	}


Thanks,
Miquèl

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

  parent reply	other threads:[~2020-01-14 10:04 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-30 16:51 [PATCH 0/8] MLC in SLC mode Miquel Raynal
2019-12-30 16:51 ` [PATCH 1/8] mtd: rawnand: toshiba: Add a specific init for TC58TEG5DCLTA00 Miquel Raynal
2019-12-30 16:51 ` [PATCH 2/8] mtd: rawnand: Define the "distance 3" MLC pairing scheme Miquel Raynal
2019-12-30 16:51 ` [PATCH 3/8] mtd: rawnand: toshiba: Set the pairing scheme for TC58TEG5DCLTA00 Miquel Raynal
2019-12-30 16:51 ` [PATCH 4/8] mtd: Add support for emulated SLC mode on MLC NANDs Miquel Raynal
2020-01-08 23:49   ` Richard Weinberger
2020-01-09 18:16     ` Miquel Raynal
2020-01-09 18:39       ` Richard Weinberger
2020-01-09 19:19         ` Boris Brezillon
2020-01-09 19:22           ` Miquel Raynal
2020-01-14 10:04     ` Miquel Raynal [this message]
2019-12-30 16:51 ` [PATCH 5/8] dt-bindings: mtd: partition: Document the slc-mode property Miquel Raynal
2019-12-31  3:53   ` Florian Fainelli
2020-01-14  9:33     ` Miquel Raynal
2019-12-30 16:51 ` [PATCH 6/8] mtd: partitions: ofpart: Parse " Miquel Raynal
2019-12-30 16:51 ` [PATCH 7/8] mtd: cmdlinepart: Add an slc option to use SLC mode on a part Miquel Raynal
2019-12-30 16:51 ` [PATCH 8/8] ubi: Relax the 'no MLC' rule and allow MLCs operating in SLC mode Miquel Raynal
2020-01-08 23:50   ` Richard Weinberger

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=20200114110413.63e089ae@xps13 \
    --to=miquel.raynal@bootlin.com \
    --cc=Tudor.Ambarus@microchip.com \
    --cc=boris.brezillon@bootlin.com \
    --cc=boris.brezillon@collabora.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=vigneshr@ti.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).