public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/5] mtd: rawnand: Simplify the locking
@ 2018-11-20 10:57 Boris Brezillon
  2018-11-20 10:57 ` [RFC PATCH 1/5] mtd: rawnand: mtk: Use nand_controller_init() instead of open-coding it Boris Brezillon
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Boris Brezillon @ 2018-11-20 10:57 UTC (permalink / raw)
  To: Boris Brezillon, Richard Weinberger, Miquel Raynal, linux-mtd
  Cc: David Woodhouse, Brian Norris, Marek Vasut, Xiaolei Li,
	Matthias Brugger, Maxim Levitsky

Hello,

The nand_get_device()/nand_release_device() logic looks complex for no
obvious reasons. I might be wrong, but I think the spinlock+waitqueue
approach can be replaced by regular mutexes: one to serialize accesses
to the NAND chip (and protect the suspended field), another one to
serialize accesses to the controller.

We also get rid of the ->state field which was not really useful except
for detecting when the NAND chip is suspended (some drivers were using
it to determine the timeout value, but always taking the max timeout
sounds like a good solution too, since it's a timeout, not a delay).
This ->state field is replaced by a ->suspended field which is
protected by the chip lock. So no state machine anymore, just 3 states:

1/ NAND is idle
2/ NAND is being accessed (we don't care about the access type)
3/ NAND is suspended

Patches 1 to 4 are preparing things for the chip->state, controller->wq
and controller->lock removal by patching all drivers that were
accessing those fields directly.

Patch 5 is doing the actual locking changes.

Note that even if we don't rework the locking, I think patches 1 to 4
are worth applying.

Regards,

Boris

Boris Brezillon (5):
  mtd: rawnand: mtk: Use nand_controller_init() instead of open-coding
    it
  mtd: rawnand: tmio: Do not abuse nand_controller->wq
  mtd: rawnand: omap2: Use nand_controller_init()
  mtd: rawnand: Stop using chip->state in drivers
  mtd: rawnand: Simplify the locking

 drivers/mtd/nand/raw/mtk_nand.c  |   3 +-
 drivers/mtd/nand/raw/nand_base.c | 111 +++++++++++++------------------
 drivers/mtd/nand/raw/omap2.c     |  20 +++---
 drivers/mtd/nand/raw/r852.c      |   3 +-
 drivers/mtd/nand/raw/tmio_nand.c |  21 +++---
 include/linux/mtd/rawnand.h      |  24 +++----
 6 files changed, 76 insertions(+), 106 deletions(-)

-- 
2.17.1

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

end of thread, other threads:[~2019-01-15 16:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-20 10:57 [RFC PATCH 0/5] mtd: rawnand: Simplify the locking Boris Brezillon
2018-11-20 10:57 ` [RFC PATCH 1/5] mtd: rawnand: mtk: Use nand_controller_init() instead of open-coding it Boris Brezillon
2018-11-20 10:57 ` [RFC PATCH 2/5] mtd: rawnand: tmio: Do not abuse nand_controller->wq Boris Brezillon
2018-11-20 10:57 ` [RFC PATCH 3/5] mtd: rawnand: omap2: Use nand_controller_init() Boris Brezillon
2018-11-20 10:57 ` [RFC PATCH 4/5] mtd: rawnand: Stop using chip->state in drivers Boris Brezillon
2018-11-20 10:57 ` [RFC PATCH 5/5] mtd: rawnand: Simplify the locking Boris Brezillon
2019-01-15 16:54 ` [RFC PATCH 0/5] " Miquel Raynal

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