Message ID | 567E14D9F917DD43923114D48B1586363D569F2F@NTXBOIMBX01.micron.com |
---|---|
State | New, archived |
Headers | show |
On Wed, 2012-06-27 at 05:23 +0000, Youxin He (youxinhe) wrote: > Hi Artem, > How about just change HZ/1000 stuff to msecs_to_jiffies()? Schedule_timeout() is a good idea but I don't see it is necessary to use schedule_timeout() to replace schedule(). The code you add below is just for suspend case, normal case will not go to schedule(), but normal case you should check for timeout otherwise infinite loop in case a program failure occur. > > + #define WRITE_TIEMEOUT 4 > ....... > - unsigned long uWriteTimeout = ( HZ / 1000 ) + 1; > + unsigned long uWriteTimeout = msecs_to_jiffies(WRITE_TIEMEOUT); I think that the current code simply buggy and needs to be re-wised. E.g., what is this: timeo = jiffies + (HZ / 2); /* FIXME */ mutex_lock(&chip->mutex); ... if (time_after(jiffies, timeo) && !chip_ready(map, adr)){ What if we are not able to grab the mutex for longer than "HZ/2". So I suggest you to try to come-up with the general clean-up of the timeouts in this driver. AFAICS, but not sure because did not think hard enough, schedule_tiemout() could be use in most places in this driver.
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index 22d0493..8ce3b44 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -48,6 +48,9 @@ #define SST49LF008A 0x005a #define AT49BV6416 0x00d6 +/* Write operation timeout, ms */ +#define WRITE_TIEMEOUT 2 + static int cfi_amdstd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *); static int cfi_amdstd_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); static int cfi_amdstd_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); @@ -1143,17 +1146,6 @@ static int cfi_amdstd_secsi_read (struct mtd_info *mtd, loff_t from, size_t len, static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, unsigned long adr, map_word datum) { struct cfi_private *cfi = map->fldrv_priv; - unsigned long timeo = jiffies + HZ; - /* - * We use a 1ms + 1 jiffies generic timeout for writes (most devices - * have a max write time of a few hundreds usec). However, we should - * use the maximum timeout value given by the chip at probe time - * instead. Unfortunately, struct flchip does have a field for - * maximum timeout, only for typical which can be far too short - * depending of the conditions. The ' + 1' is to avoid having a - * timeout of 0 jiffies if HZ is smaller than 1000. - */ - unsigned long uWriteTimeout = ( HZ / 1000 ) + 1; int ret = 0;