mtd: rawnand: fsmc: Change to non-atomic bit operations
Subsystems (2)
PATCH 1/1 mtd: rawnand: fsmc: Change to non-atomic bit operations
No need to use expensive atomic change_bit() on dat[] and err_idx[]:
1. fsmc_bch8_correct_data() is called while mutex chip->lock is held
2. err_idx[] is a local variable.
To avoid big endian concern due to type cast to unsigned long, directly change the bit in the specified byte instead of using non-atomic __change_bit().
---
This driver only works on ARM. We find unaligned access in change_bit() is quite expensive on x86. Although this driver is not configured and compiled on x86, I send this patch to you in case it's useful. I haven't compiled or tested this patch yet.
drivers/mtd/nand/raw/fsmc_nand.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/fsmc_nand.c +4 -3
@@ -809,11 +809,12 @@ static int fsmc_bch8_correct_data(struct nand_chip *chip, u8 *dat, i =0 ;while (num_err--) { -change_bit (0 , (unsigned long *)&err_idx[i]); -change_bit (1 , (unsigned long *)&err_idx[i]); + err_idx[i] ^=3 ;if (err_idx[i] < chip->ecc.size *8 ) { -change_bit (err_idx[i], (unsigned long *)dat); +int err = err_idx[i]; + + dat[err >>3 ] ^=BIT (err &7 ); i++; } }
Signature · 6 lines
2.19.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 11 lines · Fenghua Yu
No need to use expensive atomic
change_bit()on dat[] and err_idx[]:
1.fsmc_bch8_correct_data()is called while mutexchip->lockis held
2. err_idx[] is a local variable.To avoid big endian concern due to type cast to unsigned long, directly change the bit in the specified byte instead of using non-atomic
__change_bit().Suggested-by Peter Zijlstra <[email protected]>Signed-off-by Fenghua Yu <[email protected]>Reviewed-by Tony Luck <[email protected]>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.
Miquel
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/