From: Michael Walle <michael@walle.cc>
To: Jungseung Lee <js07.lee@samsung.com>
Cc: js07.lee@gmail.com, linux-mtd@lists.infradead.org,
vigneshr@ti.com, Tudor.Ambarus@microchip.com
Subject: Re: [PATCH v3 2/3] mtd: spi-nor: add 4bit block protection support
Date: Thu, 20 Feb 2020 20:09:03 +0100 [thread overview]
Message-ID: <9aaabe654603679dffdbf4c57bcfe0ff@walle.cc> (raw)
In-Reply-To: <ed9ae10ab3be4da90779cb6f8d6c6cf1e9fbc968.camel@samsung.com>
Am 2020-02-19 11:50, schrieb Jungseung Lee:
> Hi, Tudor and all
>
> 2020-02-10 (Mon), 11:26 +0000, Tudor.Ambarus@microchip.com:
>> On Monday, February 10, 2020 12:29:34 PM EET Michael Walle wrote:
>> > > It's bytes. Take a look at W25Q128JV. The sector size for this
>> > > flash is
>> > > 64KByte. The flash has 256 sectors. For this specific case:
>> > > bp_slots_available = 6;
>> > > bp_slots_needed = 8;
>> > >
>> > > The if condition is true, so
>> > > bp_slot_count = 6;
>> > > bp_min_slot_size = 64k << (8 - 6); //256k
>> >
>> > But nor->info->n_sectors is not 64k, its 256. Do you mean
>> > sector_size
>> > (like in
>> > my example below? Then we are on the same page
>>
>> Indeed, there is a typo in the pseudo code; I'm happy that the
>> example is
>> correct at least. I meant sector_size, not sectors. Now we should
>> exercise the
>> logic to all the known (corner) cases. Maybe Jungseung will tell us
>> if he
>> spots a flaw in the overall logic.
>>
>
> I didn't find any flaw in this logic. But IMHO for the pseudo code.
>
> bp_slots_available = (bp_mask >> shift) + 1 - 2;
> bp_slots_needed = ilog2(nor->info->n_sectors);
>
> if (bp_slots_needed > bp_slots_available) {
> bp_slot_count = bp_slots_available;
> bp_min_slot_size = nor->info->sector_size <<
> (bp_slots_needed - bp_slots_available);
> } else {
> bp_slot_count = bp_slots_needed;
> bp_min_slot_size = mtd->size >> bp_slot_count;
> }
>
> Probably we can use directly nor->info->sector_size for bp_min_slot_
> size.
>
> sector_size x n_sectors = mtd->size
> mtd->size / n_sectors = mtd->size >>
> ilog2(n_sectors) = sector_size
>
> bp_slot_count is equal to log2(n_sectors) now so if we can trust the
> value, we can also trust sector_size.
>
> After change it,
>
> if (bp_slots_needed > bp_slots_available)
> bp_min_slot_size = nor->info->sector_size <<
> (bp_slots_needed - bp_slots_available);
> else
> bp_min_slot_size = nor->info->sector_size
Yes, thats what I pointed out in my previous mail, too. So I guess we
agree on that.
> This is a comment from my previous mail.
>> > The exact fact is that locks operate in two different ways
>> > according to flash model.
>> >
>> > (1) the smallest protected portion is fixed.
>> > for BP0-2 : 1/64
>> > for BP0-1 : 1/4
>> > (2) the smallest protected portion is inversely propotional with
>> > number of sectors.
Again. please don't consider the ratio of the protected area to the
flash size.
This is only the result of applying the sector size and IMHO really bad
for
understanding. Use the number of protected sectors. Thus your (2) is
actually
always one sector (as you've already pointed out above).
> (1) - if the slot is insufficient.
> (2) - if the slot is sufficient.
>
> From the fact, that could be rewritten like below. I think it's more
> intuitive one.
>
> if (bp_slots_needed > bp_slots_available) // (1)
> bp_min_slot_size = mtd->size >> bp_slots_available;
Given the reasoning above, I'd prefer having the number of sectors and
thus
the sector_size. Eg. keep the following
bp_min_slot_size = nor->info->sector_size <<
(bp_slots_needed - bp_slots_available);
> else // (2)
> bp_min_slot_size = nor->info->sector_size;
>
> We could also find a few flashes that does not following the overall
> logic. For example, "en25qh256" and "en25qh16" which was manufactured
> by EON. They are always following way (2) no matter what the number of
> slot is. It seems that it could be handled like below with custom hook
> later.
>
> if (bp_slots_needed < bp_slots_available || force)
For the en25qh16 the "bp_slots_needed < bp_slots_available" is already
true, isn't it?
But good catch for the en25qh256. IMHO the rework of the BP bits should
already
add a flag (together with a reference to this flash) so this information
is not lost. what about sth like MIN_LOCK_SIZE_IS_ONE_SECTOR.
-michael
> bp_min_slot_size = nor->info->sector_size;
> else
> bp_min_slot_size = mtd->size >> bp_slots_available;
>
>> Cheers,
>> ta
>>
>
> Thanks,
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2020-02-20 19:09 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20200113055910epcas1p4f97dfeb465b00d66649d6321cffc7b5a@epcas1p4.samsung.com>
2020-01-13 5:59 ` [PATCH v3 1/3] mtd: spi-nor: introduce SR_BP_SHIFT define Jungseung Lee
2020-01-13 5:59 ` [PATCH v3 2/3] mtd: spi-nor: add 4bit block protection support Jungseung Lee
2020-01-14 10:49 ` Tudor.Ambarus
2020-01-17 15:06 ` Jungseung Lee
2020-01-22 11:42 ` Jungseung Lee
2020-01-22 14:31 ` Tudor.Ambarus
2020-01-22 17:14 ` Michael Walle
2020-01-23 3:59 ` Jungseung Lee
2020-01-23 8:15 ` Michael Walle
2020-02-11 7:52 ` chenxiang (M)
2020-03-04 5:20 ` Jungseung Lee
2020-03-04 8:36 ` chenxiang (M)
2020-03-07 7:40 ` Jungseung Lee
2020-01-22 19:36 ` Michael Walle
2020-01-23 6:22 ` Jungseung Lee
2020-01-23 8:10 ` Michael Walle
2020-01-23 8:53 ` Jungseung Lee
2020-01-23 9:31 ` Michael Walle
2020-01-28 11:01 ` Jungseung Lee
2020-01-28 12:29 ` [SPAM] " Michael Walle
2020-01-30 8:17 ` Jungseung Lee
2020-01-30 8:36 ` [SPAM] " Michael Walle
2020-01-30 10:07 ` Jungseung Lee
2020-02-03 13:56 ` Vignesh Raghavendra
2020-02-03 14:38 ` [SPAM] " Michael Walle
2020-02-03 14:58 ` Jungseung Lee
2020-02-03 17:31 ` Vignesh Raghavendra
2020-02-07 12:17 ` Tudor.Ambarus
2020-02-10 8:33 ` Michael Walle
2020-02-10 9:47 ` Tudor.Ambarus
2020-02-10 9:59 ` Tudor.Ambarus
2020-02-10 10:40 ` Michael Walle
2020-02-10 11:27 ` Tudor.Ambarus
2020-02-10 12:14 ` Michael Walle
2020-02-10 15:50 ` Tudor.Ambarus
2020-02-10 10:29 ` Michael Walle
2020-02-10 11:26 ` Tudor.Ambarus
2020-02-19 10:50 ` Jungseung Lee
2020-02-19 11:08 ` Michael Walle
2020-02-19 11:23 ` Jungseung Lee
2020-02-19 11:36 ` Michael Walle
2020-02-20 19:09 ` Michael Walle [this message]
2020-02-21 9:30 ` Tudor.Ambarus
2020-02-25 8:20 ` Tudor.Ambarus
2020-02-25 9:25 ` Jungseung Lee
2020-01-13 5:59 ` [PATCH v3 3/3] mtd: spi-nor: support lock/unlock for a few Micron chips Jungseung Lee
2020-01-13 12:30 ` John Garry
2020-01-13 12:40 ` Jungseung Lee
2020-01-13 12:45 ` Jungseung Lee
2020-01-13 13:00 ` John Garry
2020-02-17 0:18 ` [PATCH v3 1/3] mtd: spi-nor: introduce SR_BP_SHIFT define Tudor.Ambarus
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=9aaabe654603679dffdbf4c57bcfe0ff@walle.cc \
--to=michael@walle.cc \
--cc=Tudor.Ambarus@microchip.com \
--cc=js07.lee@gmail.com \
--cc=js07.lee@samsung.com \
--cc=linux-mtd@lists.infradead.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.