CONFIG_MTD_NAND_S3C2410_CLKSTOP vs. clk_disable
werner at openmoko.org
Fri Jul 27 00:08:13 EDT 2007
Hi Ben, linux-mtd,
in 188.8.131.52 (code looks equivalent in 2.6.23-rc1) on our HXD8
S3C2440-based system, bad things happen if opening and then
closing an MTD character device when CONFIG_MTD_NAND_S3C2410_CLKSTOP
is set. Basically the driver falls over completely.
We've tracked this down to the clock's usage count getting
decremented below zero. This happens in s3c2410_nand_select_chip
when mtd_close calls mtd->sync.
The easy work-around is not to enable
CONFIG_MTD_NAND_S3C2410_CLKSTOP, but I wonder what the proper
solution should look like.
It seems to me that s3c2410_nand_select_chip mistakenly assumes
that clk_enable/clk_disable just switch the clock on or off,
instead of actually counting activations.
Either that, or there is the assumption that select/deselect
operations are always paired, e.g., that we only call
nand_release_device after a chip has been selected. This may be
true in a lot of cases, but not in nand_sync (and in some other
code paths as well).
So, should s3c2410_nand_select_chip keep track of whether it has
actually selected a chip ?
More information about the linux-mtd