From: Scott Wood <scottwood@freescale.com>
To: Anton Vorontsov <cbouatmailru@gmail.com>
Cc: Wood Scott-B07421 <B07421@freescale.com>,
dedekind1@gmail.com, Zang Roy-R61911 <r61911@freescale.com>,
Lan Chunhe-B25806 <B25806@freescale.com>,
linuxppc-dev@ozlabs.org, linux-mtd@lists.infradead.org,
akpm@linux-foundation.org, dwmw2@infradead.org,
Gala Kumar-B11780 <B11780@freescale.com>
Subject: Re: [PATCH 2/3 v3] P4080/mtd: Only make elbc nand driver detect nand flash partitions
Date: Thu, 16 Sep 2010 11:14:48 -0500 [thread overview]
Message-ID: <20100916111448.27ef7440@schlenkerla.am.freescale.net> (raw)
In-Reply-To: <20100916112624.GA32074@oksana.dev.rtsoft.ru>
On Thu, 16 Sep 2010 15:26:24 +0400
Anton Vorontsov <cbouatmailru@gmail.com> wrote:
> On Thu, Sep 16, 2010 at 06:39:40PM +0800, Zang Roy-R61911 wrote:
> [...]
> > But my code has some assignment for "foo" instead of a simple
> > allocation, how about this way for my code:
>
> This will surely work, and all the rest is just a matter of
> taste. So, I'm fine with it. But see below, I think I found
> some new, quite serious issues.
>
> > DEFINE_MUTEX(fsl_elbc_mutex);
>
> I'd place the mutex inside the fsl_lbc_ctrl_dev,
> i.e. fsl_lbc_ctrl_dev->nand_lock. This is to avoid more
> global variables.
I wouldn't. If the lock is only meaningful to the NAND driver, it
should be declared in the NAND driver.
Besides, it's not any less of a global just because it's sitting inside
a singleton struct.
Perhaps it should be declared as a static local inside the probe
function, if it's just to guard against this one race.
> > elbc_fcm_ctrl->read_bytes = 0;
> > elbc_fcm_ctrl->index = 0;
> > elbc_fcm_ctrl->addr = NULL;
>
> I guess these variables should be per chip select, as
> otherwise there will be tons of races when somebody try
> to access two or more NAND chips simultaneously.
The NAND layer has its own per-controller mutex that prevents this.
> So, I'd suggest to redo the whole thing this way: don't allocate
> elbc_fcm_ctrl in this driver, but make an array inside the
> fsl_lbc_ctrl_dev. I.e.
> fsl_lbc_ctrl_dev->nand_ctrl[MAX_CHIP_SELECTS]
NACK.
There is not a separate controller per chip select.
> Btw, even before this patch, it seems that the driver had
> all these bugs/races, i.e. ctrl->controller.lock was not
> used at all. Ugh.
It is used, search nand_base.c for controller->lock.
-Scott
next prev parent reply other threads:[~2010-09-16 16:15 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-16 6:41 [PATCH 1/3 v3] P4080/eLBC: Make Freescale elbc interrupt common to elbc devices Roy Zang
2010-09-16 6:41 ` [PATCH 2/3 v3] P4080/mtd: Only make elbc nand driver detect nand flash partitions Roy Zang
2010-09-16 6:41 ` [PATCH 3/3 v3] P4080/mtd: Fix the freescale lbc issue with 36bit mode Roy Zang
2010-09-16 7:31 ` Anton Vorontsov
2010-09-16 7:36 ` Zang Roy-R61911
2010-09-16 8:21 ` [PATCH 2/3 v3] P4080/mtd: Only make elbc nand driver detect nand flash partitions Anton Vorontsov
2010-09-16 8:50 ` Zang Roy-R61911
2010-09-16 9:25 ` Anton Vorontsov
2010-09-16 10:08 ` Zang Roy-R61911
2010-09-16 10:14 ` Anton Vorontsov
2010-09-16 10:39 ` Zang Roy-R61911
2010-09-16 11:26 ` Anton Vorontsov
2010-09-16 16:14 ` Scott Wood [this message]
2010-09-16 16:40 ` Anton Vorontsov
2010-09-16 16:53 ` Scott Wood
2010-09-16 7:27 ` [PATCH 1/3 v3] P4080/eLBC: Make Freescale elbc interrupt common to elbc devices Anton Vorontsov
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=20100916111448.27ef7440@schlenkerla.am.freescale.net \
--to=scottwood@freescale.com \
--cc=B07421@freescale.com \
--cc=B11780@freescale.com \
--cc=B25806@freescale.com \
--cc=akpm@linux-foundation.org \
--cc=cbouatmailru@gmail.com \
--cc=dedekind1@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=r61911@freescale.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;
as well as URLs for NNTP newsgroup(s).