From: Rostislav Lisovy <lisovy@gmail.com>
To: David Woodhouse <dwmw2@infradead.org>,
Brian Norris <computersforpeace@gmail.com>,
pekon gupta <pekon@ti.com>, Tony Lindgren <tony@atomide.com>,
Roger Quadros <rogerq@ti.com>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Cc: lisovy@gmail.com, michal.vokac@comap.cz, sojkam1@fel.cvut.cz,
Rostislav Lisovy <lisovy@merica.cz>
Subject: [PATCH 2/2] mtd: nand: omap: Synchronize access to the ECC engine
Date: Wed, 1 Oct 2014 16:59:14 +0200 [thread overview]
Message-ID: <1412175554-19391-2-git-send-email-lisovy@merica.cz> (raw)
In-Reply-To: <1412175554-19391-1-git-send-email-lisovy@merica.cz>
The AM335x Technical Reference Manual (spruh73j.pdf) says
"Because the ECC engine includes only one accumulation context,
it can be allocated to only one chip-select at a time ... "
(7.1.3.3.12.3). Since the commit 97a288ba2cfa ("ARM: omap2+:
gpmc-nand: Use dynamic platform_device_alloc()") gpmc-nand
driver supports multiple NAND flash devices connected to
the single controller. Use spinlocks to restrict access
to the ECC engine for single read/write operation at a time.
Tested with custom AM335x board using 2x NAND flash chips.
Signed-off-by: Rostislav Lisovy <lisovy@merica.cz>
---
drivers/mtd/nand/omap2.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 24d5c6a..8761a5b 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -24,6 +24,7 @@
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/of_device.h>
+#include <linux/spinlock.h>
#include <linux/mtd/nand_bch.h>
#include <linux/platform_data/elm.h>
@@ -146,6 +147,7 @@ static u_char bch8_vector[] = {0xf3, 0xdb, 0x14, 0x16, 0x8b, 0xd2, 0xbe, 0xcc,
static u_char bch4_vector[] = {0x00, 0x6b, 0x31, 0xdd, 0x41, 0xbc, 0x10};
#endif
+static DEFINE_SPINLOCK(omap_eccengine_lock);
struct omap_nand_info {
struct nand_hw_control controller;
@@ -1518,6 +1520,7 @@ static int omap_write_page_bch(struct mtd_info *mtd, struct nand_chip *chip,
uint8_t *ecc_calc = chip->buffers->ecccalc;
uint32_t *eccpos = chip->ecc.layout->eccpos;
+ spin_lock(&omap_eccengine_lock);
/* Enable GPMC ecc engine */
chip->ecc.hwctl(mtd, NAND_ECC_WRITE);
@@ -1526,6 +1529,7 @@ static int omap_write_page_bch(struct mtd_info *mtd, struct nand_chip *chip,
/* Update ecc vector from GPMC result registers */
chip->ecc.calculate(mtd, buf, &ecc_calc[0]);
+ spin_unlock(&omap_eccengine_lock);
for (i = 0; i < chip->ecc.total; i++)
chip->oob_poi[eccpos[i]] = ecc_calc[i];
@@ -1561,6 +1565,7 @@ static int omap_read_page_bch(struct mtd_info *mtd, struct nand_chip *chip,
int stat;
unsigned int max_bitflips = 0;
+ spin_lock(&omap_eccengine_lock);
/* Enable GPMC ecc engine */
chip->ecc.hwctl(mtd, NAND_ECC_READ);
@@ -1573,6 +1578,7 @@ static int omap_read_page_bch(struct mtd_info *mtd, struct nand_chip *chip,
/* Calculate ecc bytes */
chip->ecc.calculate(mtd, buf, ecc_calc);
+ spin_unlock(&omap_eccengine_lock);
memcpy(ecc_code, &chip->oob_poi[eccpos[0]], chip->ecc.total);
--
1.9.1
next prev parent reply other threads:[~2014-10-01 14:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-01 14:59 [PATCH 1/2] mtd: nand: omap: Do not use global variables Rostislav Lisovy
2014-10-01 14:59 ` Rostislav Lisovy [this message]
2014-10-02 7:12 ` [PATCH 2/2] mtd: nand: omap: Synchronize access to the ECC engine Roger Quadros
2014-10-02 6:44 ` [PATCH 1/2] mtd: nand: omap: Do not use global variables Roger Quadros
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1412175554-19391-2-git-send-email-lisovy@merica.cz \
--to=lisovy@gmail.com \
--cc=computersforpeace@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=lisovy@merica.cz \
--cc=michal.vokac@comap.cz \
--cc=pekon@ti.com \
--cc=rogerq@ti.com \
--cc=sojkam1@fel.cvut.cz \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®