[PATCH] mtd: Add locking to cfi_cmdset_001:do_getlockstatus_oneblock
Joakim Tjernlund
Joakim.Tjernlund at infinera.com
Sat Nov 7 02:11:39 PST 2015
On Fri, 2015-11-06 at 14:49 +0100, Mark Marshall wrote:
> The function (do_getlockstatus_oneblock) switches the flash out of
> array-read mode and into query mode. It should not run in parallel to
> another function that uses array-read mode. We therefore need to
> acquire the chip mutex and call get_chip(..., FL_JEDEC_QUERY).
>
Hmm, this mail has NL breaks in it for long lines and won't apply.
Is it on my end or yours?
> drivers/mtd/chips/cfi_cmdset_0001.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c
> b/drivers/mtd/chips/cfi_cmdset_0001.c
> index 286b97a..d675efb 100644
> --- a/drivers/mtd/chips/cfi_cmdset_0001.c
> +++ b/drivers/mtd/chips/cfi_cmdset_0001.c
> @@ -2051,13 +2051,32 @@ static int __xipram
> do_getlockstatus_oneblock(struct map_info *map,
> {
> > > struct cfi_private *cfi = map->fldrv_priv;
> > > int status, ofs_factor = cfi->interleave * cfi->device_type;
> +> > int ret;
>
> > > adr += chip->start;
> +
> +> > mutex_lock(&chip->mutex);
> +> > ret = get_chip(map, chip, adr, FL_JEDEC_QUERY);
> +> > if (ret) {
> +> > > mutex_unlock(&chip->mutex);
> +> > > return ret;
> +> > }
> +
> +> > /* let's ensure we're not reading back cached data from array mode */
> +> > INVALIDATE_CACHED_RANGE(map, adr+(2*ofs_factor), 1);
> +
> > > xip_disable(map, chip, adr+(2*ofs_factor));
> > > map_write(map, CMD(0x90), adr+(2*ofs_factor));
> > > chip->state = FL_JEDEC_QUERY;
> > > status = cfi_read_query(map, adr+(2*ofs_factor));
> > > xip_enable(map, chip, 0);
> +
> +> > /* then ensure we don't keep query data in the cache */
> +> > INVALIDATE_CACHED_RANGE(map, adr+(2*ofs_factor), 1);
> +
> +> > put_chip(map, chip, adr);
> +> > mutex_unlock(&chip->mutex);
> +
> > > return status;
> }
>
More information about the linux-mtd
mailing list