Re: Re-entrancy of flash erase/write

Robert Kaiser
2002-02-25T16:45:03Z

[-- Attachment #1: Type: TEXT/PLAIN, Size: 779 bytes --]

On Mon, 25 Feb 2002, Adam Wozniak wrote:

> ENABLE/DISABLE_VPP call the map_info set_vpp function
> For the physmap_map map_info, there is no set_vpp, it is NULL
>
> So for people who use physmap_map anyway, they won't see the behavior
> you are describing. I suspect it is the same for other maps.

Hmm, so you are suggesting that this problem has not been noticed
because so few people have set_vpp() functions these days ?

If that is the case, may I suggest the attached patch. It solved the
problem for me.

[David, OK to apply this ?]

Rob

----------------------------------------------------------------
Robert Kaiser email: rkaiser@sysgo.de
SYSGO RTS GmbH
Am Pfaffenstein 14
D-55270 Klein-Winternheim / Germany fax: (49) 6136 9948-10

[-- Attachment #2: Type: TEXT/PLAIN, Size: 1174 bytes --]

Index: map.h
===================================================================
RCS file: /home/cvs/mtd/include/linux/mtd/map.h,v
retrieving revision 1.27
diff -u -p -r1.27 map.h
--- map.h 2002/02/21 08:26:59 1.27
+++ map.h 2002/02/25 16:51:36
@@ -47,6 +47,7 @@ struct map_info {
void (*copy_to)(struct map_info *, unsigned long, const void *, ssize_t);

void (*set_vpp)(struct map_info *, int);
+ int vpp_counter;
/* We put these two here rather than a single void *map_priv,
because we want mappers to be able to have quickly-accessible
cache for the 'currently-mapped page' without the _extra_
@@ -90,7 +91,7 @@ static inline void map_destroy(struct mt
kfree(mtd);
}

-#define ENABLE_VPP(map) do { if(map->set_vpp) map->set_vpp(map, 1); } while(0)
-#define DISABLE_VPP(map) do { if(map->set_vpp) map->set_vpp(map, 0); } while(0)
+#define ENABLE_VPP(map) do { if(map->set_vpp) if(++map->vpp_counter == 1) map->set_vpp(map, 1); } while(0)
+#define DISABLE_VPP(map) do { if(map->set_vpp) { if(--map->vpp_counter == 0) map->set_vpp(map, 0); else if(map->vpp_counter < 0) BUG();} } while(0)

#endif /* __LINUX_MTD_MAP_H__ */