Linux-mtd Archive on lore.kernel.org
 help / color / Atom feed
From: Vignesh Raghavendra <vigneshr@ti.com>
To: Chris Packham <Chris.Packham@alliedtelesis.co.nz>,
	"dwmw2@infradead.org" <dwmw2@infradead.org>,
	"computersforpeace@gmail.com" <computersforpeace@gmail.com>,
	"marek.vasut@gmail.com" <marek.vasut@gmail.com>,
	"miquel.raynal@bootlin.com" <miquel.raynal@bootlin.com>,
	"richard@nod.at" <richard@nod.at>
Cc: "sr@denx.de" <sr@denx.de>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mtd: cfi_cmdset_0002: dynamically determine the max sectors
Date: Fri, 14 Jun 2019 13:09:32 +0530
Message-ID: <8039faae-0ea3-fe85-ae2d-3e7853410a7d@ti.com> (raw)
In-Reply-To: <8e80d911f0dd4759b3edc72fb76530d6@svr-chch-ex1.atlnz.lc>



On 14/06/19 8:53 AM, Chris Packham wrote:
> Hi All,
> 
> I think this may have got lost in the change of maintainer for mtd.
> 

I do have this in my queue of patches for mtd/next and will forward to
Miquel once he is back.


> On 22/05/19 12:06 PM, Chris Packham wrote:
>> Because PPB unlocking unlocks the whole chip cfi_ppb_unlock() needs to
>> remember the locked status for each sector so it can re-lock the
>> unaddressed sectors. Dynamically calculate the maximum number of sectors
>> rather than using a hardcoded value that is too small for larger chips.
>>
>> Tested with Spansion S29GL01GS11TFI flash device.
>>
>> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>

Acked-by: Vignesh Raghavendra <vigneshr@ti.com>

Regards
Vignesh

>> ---
>>   drivers/mtd/chips/cfi_cmdset_0002.c | 13 ++++++++-----
>>   1 file changed, 8 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
>> index c8fa5906bdf9..a1a7d334aa82 100644
>> --- a/drivers/mtd/chips/cfi_cmdset_0002.c
>> +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
>> @@ -2533,8 +2533,6 @@ struct ppb_lock {
>>   	int locked;
>>   };
>>   
>> -#define MAX_SECTORS			512
>> -
>>   #define DO_XXLOCK_ONEBLOCK_LOCK		((void *)1)
>>   #define DO_XXLOCK_ONEBLOCK_UNLOCK	((void *)2)
>>   #define DO_XXLOCK_ONEBLOCK_GETLOCK	((void *)3)
>> @@ -2633,6 +2631,7 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs,
>>   	int i;
>>   	int sectors;
>>   	int ret;
>> +	int max_sectors;
>>   
>>   	/*
>>   	 * PPB unlocking always unlocks all sectors of the flash chip.
>> @@ -2640,7 +2639,11 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs,
>>   	 * first check the locking status of all sectors and save
>>   	 * it for future use.
>>   	 */
>> -	sect = kcalloc(MAX_SECTORS, sizeof(struct ppb_lock), GFP_KERNEL);
>> +	max_sectors = 0;
>> +	for (i = 0; i < mtd->numeraseregions; i++)
>> +		max_sectors += regions[i].numblocks;
>> +
>> +	sect = kcalloc(max_sectors, sizeof(struct ppb_lock), GFP_KERNEL);
>>   	if (!sect)
>>   		return -ENOMEM;
>>   
>> @@ -2689,9 +2692,9 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs,
>>   		}
>>   
>>   		sectors++;
>> -		if (sectors >= MAX_SECTORS) {
>> +		if (sectors >= max_sectors) {
>>   			printk(KERN_ERR "Only %d sectors for PPB locking supported!\n",
>> -			       MAX_SECTORS);
>> +			       max_sectors);
>>   			kfree(sect);
>>   			return -EINVAL;
>>   		}
>>
> 

-- 
Regards
Vignesh

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

      parent reply index

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22  0:06 Chris Packham
2019-05-22  6:01 ` Stefan Roese
2019-06-14  3:23 ` Chris Packham
2019-06-14  7:18   ` Joakim Tjernlund
2019-06-14  7:39   ` Vignesh Raghavendra [this message]

Reply instructions:

You may reply publically 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=8039faae-0ea3-fe85-ae2d-3e7853410a7d@ti.com \
    --to=vigneshr@ti.com \
    --cc=Chris.Packham@alliedtelesis.co.nz \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=sr@denx.de \
    /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

Linux-mtd Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mtd/0 linux-mtd/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mtd linux-mtd/ https://lore.kernel.org/linux-mtd \
		linux-mtd@lists.infradead.org linux-mtd@archiver.kernel.org
	public-inbox-index linux-mtd


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-mtd


AGPL code for this site: git clone https://public-inbox.org/ public-inbox