* RE: erasesize
@ 2001-06-05 13:03 Frederic Giasson
2001-06-05 13:12 ` erasesize David Woodhouse
0 siblings, 1 reply; 6+ messages in thread
From: Frederic Giasson @ 2001-06-05 13:03 UTC (permalink / raw)
To: Frederic Giasson, 'David Woodhouse', Abraham vd Merwe
Cc: MTD for Linux
... Maybe it should be passed through the arg pointer in the
ioctl(), in a 2 u_long sized structure?
Frédéric Giasson
-----Original Message-----
From: Frederic Giasson [mailto:fgiasson@mediatrix.com]
Sent: Tuesday, June 05, 2001 8:49 AM
To: 'David Woodhouse'; Abraham vd Merwe
Cc: MTD for Linux
Subject: RE: erasesize
I have a question too about the erase->len ( erasesize ). I have a
flash chip with variable block sizes, and I am using cfi_cmdset_0002. Where
should that ->len be set? When I printk the value held by erase->len just
before calling do_erase_oneblock() in cfi_amdstd_erase_varsize(), I get a
dummy value. I suspect that it should be set according to the
mtd_erase_region_info structure, but it is not done.
Does anyone has a clue about it?
Thanks!
Frédéric Giasson
-----Original Message-----
From: David Woodhouse [mailto:dwmw2@infradead.org]
Sent: Tuesday, June 05, 2001 8:30 AM
To: Abraham vd Merwe
Cc: MTD for Linux
Subject: Re: erasesize
abraham@2d3d.co.za said:
> What should I set erasesize to when the flash chips have multiple
> erase sizes (and therefor I use eraseregions to get erasesize info)?
> Is 0 acceptable or should I set it to something else - it doesn't
> really make sense to put any value in this after all...
See the other Intel driver. Set the erase size to the 'major' erase size
for the device, then fill in the appropriate structure to represent the
other regions.
--
dwmw2
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: erasesize
2001-06-05 13:03 erasesize Frederic Giasson
@ 2001-06-05 13:12 ` David Woodhouse
0 siblings, 0 replies; 6+ messages in thread
From: David Woodhouse @ 2001-06-05 13:12 UTC (permalink / raw)
To: Frederic Giasson; +Cc: Abraham vd Merwe, MTD for Linux
fgiasson@mediatrix.com said:
> ... Maybe it should be passed through the arg pointer in the ioctl(),
> in a 2 u_long sized structure?
I don't fully understand the question. The 'len' member of the struct
erase_info contains the total length of the erase requested by the user of
the MTD device. The only connexion with the device's erase size(s) is that
obviously the range to be erase must start and end on an eraseblock
boundary.
cfi_amdstd_erase_varsize() is an internal function intended to issue the
magic erase commands only to a certain address on the chip - it doesn't
know anything about the erase size at that address, or care about the
length field, does it?
--
dwmw2
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: erasesize
@ 2001-06-05 17:40 Frederic Giasson
0 siblings, 0 replies; 6+ messages in thread
From: Frederic Giasson @ 2001-06-05 17:40 UTC (permalink / raw)
To: 'David Woodhouse'; +Cc: linux-mtd
fgiasson@mediatrix.com said:
> Therefore, this is why I think that the length of the block to erase
> whould be passed by the user. At least, this is what the code suggest.
That's correct. The user should pass the length of the region to erase.
For example, if you have a chip which has 8 * 8K regions, then 15 * 64K,
the user may request that you erase 72K starting at offset 56K. That would
require the magic incantation to be issued once at offset 56K to erase that
8K block, and once at offset 64K to erase that 64K block.
--
dwmw2
We agree on that. Now I am questionning on the portabilty of the piece of
code below
( which belongs to cfi_amdstd_erase_varsize() ) between different CFI ( and
maybe even non-cfi ) flashes.
There is the reasons of my concern:
if( instr->addr > mtd->size )
{
printk( "cfi_amdstd_erase_varsize: Requested erase region begining
out of range!\n" );
printk( "instr->addr: %X, mtd->size: %d\n", instr->addr, mtd->size
);
return -EINVAL;
}
if( ( instr->len + instr->addr ) > mtd->size )
{
printk( "cfi_amdstd_erase_varsize: Requested erase region end out of
range!\n" );
printk( "instr->len: %X instr->addr: %X, mtd->size: %d\n",
instr->len, instr->addr, mtd->size );
return -EINVAL;
}
/* Check that both start and end of the requested erase are
* aligned with the erasesize at the appropriate addresses.
*/
/* Skip all erase regions which are ended before the start of
the requested erase. Actually, to save on the calculations,
we skip to the first erase region which starts after the
start of the requested erase, and then go back one.
*/
i = 0;
while( ( i < mtd->numeraseregions ) && ( instr->addr >=
regions[i].offset ) )
{
i++;
}
i--;
/* OK, now i is pointing at the erase region in which this
erase request starts. Check the start of the requested
erase range is aligned with the erase size which is in
effect here.
*/
if( instr->addr & ( regions[i].erasesize - 1 ) )
{
printk( "cfi_amdstd_erase_varsize: Erase region begin address as to
be aligned with physical sector.\n" );
return -EINVAL;
}
/* Remember the erase region we start on */
first = i;
/* Next, check that the end of the requested erase is aligned
* with the erase region at that address.
*/
while( ( i < mtd->numeraseregions ) && ( (instr->addr + instr->len)
>= regions[i].offset ) )
{
i++;
}
/* As before, drop back one to point at the region in which
the address actually falls
*/
i--;
if( (instr->addr + instr->len) & (regions[i].erasesize-1) )
{
printk( "cfi_amdstd_erase_varsize: End address is not aligned with
the region requested to be erased.\n" );
return -EINVAL;
}
Those 2 instructions ( from the code above)
if( instr->addr & ( regions[i].erasesize - 1 ) )
{
[return error]
}
and
if( (instr->addr + instr->len) & (regions[i].erasesize-1) )
{
[return error]
}
, which job are to ensure respectively that the start address of the block
to be erased is aligned
with the start of a physical sector, and that the instr->len is in a way so
that the block ends at
the very end of a physical sector, not a byte more or less.
With my flash ( Atmel, which is not CFI ) and probably most of the
existing flash memories on the market,
it does the job. However, it assumes 2 things:
- sectors must have power-2 sizes
- sectors must be aligned on a multiple of their own size.
For example, a 32KB sector beggining at address 24KB wouldn't be OK.
I never seen a flash physically mapped in
such a way, but maybe it is not always the case ( someone has the answer??
).
Whatever that answer would be, it would be safer to do as the code below
does:
// Searching for a sector that begins at the starting address of the
block
// requested to be erased
while( ( i < mtd->numeraseregions ) && ( instr->addr !=
regions[i].offset ) )
{
i++;
}
/* Remember the erase region we start on */
first = i;
// Searching for a sector that ends exactly at the last address of the
block
// requested to be erased
while(
( i < mtd->numeraseregions ) &&
(
( instr->addr + instr->len ) !=
( regions[i].offset + regions[i].erasesize )
)
)
{
i++;
}
This would be safer, without taking longer to execute.
Anyone disagree?
Frédéric Giasson
^ permalink raw reply [flat|nested] 6+ messages in thread* RE: erasesize
@ 2001-06-05 12:49 Frederic Giasson
0 siblings, 0 replies; 6+ messages in thread
From: Frederic Giasson @ 2001-06-05 12:49 UTC (permalink / raw)
To: 'David Woodhouse', Abraham vd Merwe; +Cc: MTD for Linux
I have a question too about the erase->len ( erasesize ). I have a
flash chip with variable block sizes, and I am using cfi_cmdset_0002. Where
should that ->len be set? When I printk the value held by erase->len just
before calling do_erase_oneblock() in cfi_amdstd_erase_varsize(), I get a
dummy value. I suspect that it should be set according to the
mtd_erase_region_info structure, but it is not done.
Does anyone has a clue about it?
Thanks!
Frédéric Giasson
-----Original Message-----
From: David Woodhouse [mailto:dwmw2@infradead.org]
Sent: Tuesday, June 05, 2001 8:30 AM
To: Abraham vd Merwe
Cc: MTD for Linux
Subject: Re: erasesize
abraham@2d3d.co.za said:
> What should I set erasesize to when the flash chips have multiple
> erase sizes (and therefor I use eraseregions to get erasesize info)?
> Is 0 acceptable or should I set it to something else - it doesn't
> really make sense to put any value in this after all...
See the other Intel driver. Set the erase size to the 'major' erase size
for the device, then fill in the appropriate structure to represent the
other regions.
--
dwmw2
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 6+ messages in thread
* erasesize
@ 2001-06-05 10:52 Abraham vd Merwe
2001-06-05 12:30 ` erasesize David Woodhouse
0 siblings, 1 reply; 6+ messages in thread
From: Abraham vd Merwe @ 2001-06-05 10:52 UTC (permalink / raw)
To: MTD for Linux
[-- Attachment #1: Type: text/plain, Size: 739 bytes --]
Hi!
What should I set erasesize to when the flash chips have multiple erase
sizes (and therefor I use eraseregions to get erasesize info)? Is 0
acceptable or should I set it to something else - it doesn't really make
sense to put any value in this after all...
--
Regards
Abraham
Will Rogers never met you.
__________________________________________________________
Abraham vd Merwe - 2d3D, Inc.
Device Driver Development, Outsourcing, Embedded Systems
Cell: +27 82 565 4451 Snailmail:
Tel: +27 21 761 7549 Block C, Antree Park
Fax: +27 21 761 7648 Doncaster Road
Email: abraham@2d3d.co.za Kenilworth, 7700
Http: http://www.2d3d.com South Africa
[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: erasesize
2001-06-05 10:52 erasesize Abraham vd Merwe
@ 2001-06-05 12:30 ` David Woodhouse
0 siblings, 0 replies; 6+ messages in thread
From: David Woodhouse @ 2001-06-05 12:30 UTC (permalink / raw)
To: Abraham vd Merwe; +Cc: MTD for Linux
abraham@2d3d.co.za said:
> What should I set erasesize to when the flash chips have multiple
> erase sizes (and therefor I use eraseregions to get erasesize info)?
> Is 0 acceptable or should I set it to something else - it doesn't
> really make sense to put any value in this after all...
See the other Intel driver. Set the erase size to the 'major' erase size
for the device, then fill in the appropriate structure to represent the
other regions.
--
dwmw2
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2001-06-05 17:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-06-05 13:03 erasesize Frederic Giasson
2001-06-05 13:12 ` erasesize David Woodhouse
-- strict thread matches above, loose matches on Subject: below --
2001-06-05 17:40 erasesize Frederic Giasson
2001-06-05 12:49 erasesize Frederic Giasson
2001-06-05 10:52 erasesize Abraham vd Merwe
2001-06-05 12:30 ` erasesize David Woodhouse
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox