Re: [PATCH 3/7] mtd: spi-nor: add restriction for nmaps in smpt parser
From: Boris Brezillon
Date: Thu Nov 08 2018 - 08:08:40 EST
On Thu, 8 Nov 2018 13:54:47 +0100
Boris Brezillon <boris.brezillon@xxxxxxxxxxx> wrote:
> > - while (i < smpt_len) {
> > + for (nmaps = 0; i < smpt_len; nmaps++) {
> > + /*
> > + * The map selector is limited to a maximum of 8 bits, allowing
> > + * for a maximum of 256 possible map configurations. The total
> > + * number of map configurations should be addressable by the
> > + * total number of bits described by the detection commands.
> > + */
> > + if (ncmds && nmaps >= (1 << (ncmds + 1)))
> > + break;
> > +
>
> Maybe I missed something but it sounds like this change is just
> optimizing the SPMT parsing a bit, and to be honest, I'm not sure this
> is really needed. Most of the time, smpt_len will be rather small, so
> trying to bail out earlier is not bringing much perf improvements.
To make it clearer, I don't think the extra complexity is worth the tiny
perf improvement.