Hi All, On 8/02/19 12:58 PM, Przemyslaw Sobon wrote: > Fixes: dfeae1073583(mtd: cfi_cmdset_0002: Change write buffer to > check correct value) > > There was an endless loop in CFI Flash driver when a value was written > incorrectly. In such case chip_ready returns true but chip_good returns > false and we never get out of the loop. > > The solution was to break the loop in 2 cases, either device is ready or > device is not ready and timeout elapsed. The correctness of the write is > checked after the loop ended. That way we ensure the loop always ends. > > Signed-off-by: Przemyslaw Sobon <psobon@xxxxxxxxxx> Mark (cc'd) has done some testing here, and assuming he's happy with the forgery. Tested-by: Mark Tomlinson <Mark.Tomlinson@xxxxxxxxxxxxxxxxxxx> > --- > drivers/mtd/chips/cfi_cmdset_0002.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c > index 72428b6bfc47..6cc31d2057e9 100644 > --- a/drivers/mtd/chips/cfi_cmdset_0002.c > +++ b/drivers/mtd/chips/cfi_cmdset_0002.c > @@ -1879,15 +1879,18 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, > if (time_after(jiffies, timeo) && !chip_ready(map, adr)) > break; > > - if (chip_good(map, adr, datum)) { > - xip_enable(map, chip, adr); > - goto op_done; > - } > + if (chip_ready(map, adr)) > + break; > > /* Latency issues. Drop the lock, wait a while and retry */ > UDELAY(map, chip, adr, 1); > } > > + if (chip_good(map, adr, datum)) { > + xip_enable(map, chip, adr); > + goto op_done; > + } > + > /* > * Recovery from write-buffer programming failures requires > * the write-to-buffer-reset sequence. Since the last part > ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/