public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* Reduce the size of a probed flash for broken HW
@ 2006-04-24 14:40 Franck Bui-Huu
  2006-04-24 15:07 ` Nicolas Pitre
  2006-04-25  9:19 ` Franck Bui-Huu
  0 siblings, 2 replies; 3+ messages in thread
From: Franck Bui-Huu @ 2006-04-24 14:40 UTC (permalink / raw)
  To: linux-mtd; +Cc: Franck, Nicolas Pitre

[discussed with Vitaly Wool on IRC]

My hardware has some problem to access my onboard flashes specially
the last 64Ko of them. So I need a way to restrict access to these areas.

Several solutions comes in mind:

  - In the mapping driver, try to modify the mtd_info and cfi_info
    setup by the MTD probing functions to reduce the detected
    size. This solution is really hackish since it modifies internal
    structures of the MTD layer that the mapping driver is not
    supposed to be aware of. I just did this in my driver:

	*mtd = do_map_probe("xxx_probe", map);
	while ((*mtd)->size > 32Mo - 64Ko)
		(*mtd)->size -= (*mtd)->erasesize;

    and it seems to work fine...

  - Use a partition that exclude the last 64Ko of the flash. This
    solution was suggested by Nicolas Pitre, but I think it imposes
    some restrictions on flash concatenation for example.

  - Modify the common MTD layer to take into account the value of the
    mapping size given by the hardware: if the driver setup a mapping
    size of the flash lesser than the real flash size then the MTD
    layer should use the map size instead of simply ignoring it. Thus
    the MTD layer gives the opportunity to the driver to reduce the
    size of the flash.

Can anybody gives some feedback or others solutions ?

Thanks
--
               Franck

[Please CC me, I'm not subscribed to this list]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Reduce the size of a probed flash for broken HW
  2006-04-24 14:40 Reduce the size of a probed flash for broken HW Franck Bui-Huu
@ 2006-04-24 15:07 ` Nicolas Pitre
  2006-04-25  9:19 ` Franck Bui-Huu
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Pitre @ 2006-04-24 15:07 UTC (permalink / raw)
  To: Franck Bui-Huu; +Cc: linux-mtd

On Mon, 24 Apr 2006, Franck Bui-Huu wrote:

> [discussed with Vitaly Wool on IRC]
> 
> My hardware has some problem to access my onboard flashes specially
> the last 64Ko of them. So I need a way to restrict access to these areas.
> 
> Several solutions comes in mind:
> 
>   - In the mapping driver, try to modify the mtd_info and cfi_info
>     setup by the MTD probing functions to reduce the detected
>     size. This solution is really hackish since it modifies internal
>     structures of the MTD layer that the mapping driver is not
>     supposed to be aware of. I just did this in my driver:
> 
> 	*mtd = do_map_probe("xxx_probe", map);
> 	while ((*mtd)->size > 32Mo - 64Ko)
> 		(*mtd)->size -= (*mtd)->erasesize;
> 
>     and it seems to work fine...

I think that is indeed the easiest solution.  Just keep it to your map 
driver and clearly label it with a big comment explaining why you do so.

I don't think you need to modify the cfi_info at all.


Nicolas

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Reduce the size of a probed flash for broken HW
  2006-04-24 14:40 Reduce the size of a probed flash for broken HW Franck Bui-Huu
  2006-04-24 15:07 ` Nicolas Pitre
@ 2006-04-25  9:19 ` Franck Bui-Huu
  1 sibling, 0 replies; 3+ messages in thread
From: Franck Bui-Huu @ 2006-04-25  9:19 UTC (permalink / raw)
  To: linux-mtd; +Cc: Franck, Nicolas Pitre

2006/4/24, Franck Bui-Huu <vagabon.xyz@gmail.com>:
> [discussed with Vitaly Wool on IRC]
>
> My hardware has some problem to access my onboard flashes specially
> the last 64Ko of them. So I need a way to restrict access to these areas.
>
> Several solutions comes in mind:
>
>   - In the mapping driver, try to modify the mtd_info and cfi_info
>     setup by the MTD probing functions to reduce the detected
>     size. This solution is really hackish since it modifies internal
>     structures of the MTD layer that the mapping driver is not
>     supposed to be aware of. I just did this in my driver:
>
>         *mtd = do_map_probe("xxx_probe", map);
>         while ((*mtd)->size > 32Mo - 64Ko)
>                 (*mtd)->size -= (*mtd)->erasesize;
>
>     and it seems to work fine...
>
>   - Use a partition that exclude the last 64Ko of the flash. This
>     solution was suggested by Nicolas Pitre, but I think it imposes
>     some restrictions on flash concatenation for example.
>

in case someone is interested, here is the implementation of the first
and second solutions:

static struct mtd_info * __init fix_mtd_size(struct mtd_info *mtd)
{
#if 0
	while (mtd->size > MAX_BANK_SIZE)
		mtd->size -= mtd->erasesize;

	return mtd;
#else
	struct mtd_partition fixed_part;
	struct mtd_info *fixed_mtd = NULL;

	memset(&fixed_part, 0, sizeof (struct mtd_partition));
	fixed_part.name = mtd->name;
	fixed_part.size = mtd->size;
	while (fixed_part.size > MAX_BANK_SIZE)
		fixed_part.size -= mtd->erasesize;
	fixed_part.mtdp = &fixed_mtd;

	add_mtd_partitions(mtd, &fixed_part, 1);

	return fixed_mtd;
#endif
}

--
               Franck

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-04-25  9:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-24 14:40 Reduce the size of a probed flash for broken HW Franck Bui-Huu
2006-04-24 15:07 ` Nicolas Pitre
2006-04-25  9:19 ` Franck Bui-Huu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox