Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1742048 > unrolled thread
| Started by | Masahiro Yamada <yamada.masahiro@socionext.com> |
|---|---|
| First post | 2017-09-29 12:50 +0200 |
| Last post | 2017-09-29 16:40 +0200 |
| Articles | 6 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v2 0/2] mtd: nand: wait for tWHR, and fix the setup_data_interface of Denali Masahiro Yamada <yamada.masahiro@socionext.com> - 2017-09-29 12:50 +0200
[PATCH v2 1/2] mtd: nand: wait for tWHR after NAND_CMD_STATUS / NAND_CMD_READID Masahiro Yamada <yamada.masahiro@socionext.com> - 2017-09-29 12:50 +0200
Re: [PATCH v2 0/2] mtd: nand: wait for tWHR, and fix the setup_data_interface of Denali Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-09-29 14:30 +0200
Re: [PATCH v2 0/2] mtd: nand: wait for tWHR, and fix the setup_data_interface of Denali Masahiro Yamada <yamada.masahiro@socionext.com> - 2017-09-29 16:10 +0200
Re: [PATCH v2 0/2] mtd: nand: wait for tWHR, and fix the setup_data_interface of Denali Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-09-29 16:30 +0200
Re: [PATCH v2 0/2] mtd: nand: wait for tWHR, and fix the setup_data_interface of Denali Masahiro Yamada <yamada.masahiro@socionext.com> - 2017-09-29 16:40 +0200
| From | Masahiro Yamada <yamada.masahiro@socionext.com> |
|---|---|
| Date | 2017-09-29 12:50 +0200 |
| Subject | [PATCH v2 0/2] mtd: nand: wait for tWHR, and fix the setup_data_interface of Denali |
| Message-ID | <uv11L-51L-3@gated-at.bofh.it> |
1/2 : add NAND_WAIT_TWHR and nand_whr_delay().
You can set this new flag if you want nand_command(_lp)
to insert tWHR delay where needed.
2/2 : Fix Denali setup_data_interface.
Boris' suggestion in v1 was a good reminder that
made me realize tCCS was missing in the driver. Fix it now.
Changes in v2:
- Add nand_whr_delay() helper
Wait for tWHR only for drivers that explicitly set NAND_WAIT_TWHR flag
- newly added
Masahiro Yamada (2):
mtd: nand: wait for tWHR after NAND_CMD_STATUS / NAND_CMD_READID
mtd: nand: denali: fix setup_data_interface to meet tCCS delay
drivers/mtd/nand/denali.c | 10 ++++++++--
drivers/mtd/nand/nand_base.c | 21 +++++++++++++++++++--
include/linux/mtd/rawnand.h | 13 ++++++++-----
3 files changed, 35 insertions(+), 9 deletions(-)
--
2.7.4
[toc] | [next] | [standalone]
| From | Masahiro Yamada <yamada.masahiro@socionext.com> |
|---|---|
| Date | 2017-09-29 12:50 +0200 |
| Subject | [PATCH v2 1/2] mtd: nand: wait for tWHR after NAND_CMD_STATUS / NAND_CMD_READID |
| Message-ID | <uv11M-51L-7@gated-at.bofh.it> |
| In reply to | #1742048 |
For commands such as Read Status, Read ID, etc. the controller needs
to wait for tWHR before it reads out the first data. If the controller
does not take care of it, the driver has to wait explicitly to make
sure to meet the spec.
Introduce NAND_WAIT_TWHR, which works like NAND_WAIT_TCCS. The
driver can set this flag to let the core to handle the tWHR delay.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
Changes in v2:
- Add nand_whr_delay() helper
Wait for tWHR only for drivers that explicitly set NAND_WAIT_TWHR flag
drivers/mtd/nand/nand_base.c | 21 +++++++++++++++++++--
include/linux/mtd/rawnand.h | 13 ++++++++-----
2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index b1cf32c..455085d 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -676,6 +676,17 @@ static void nand_wait_status_ready(struct mtd_info *mtd, unsigned long timeo)
} while (time_before(jiffies, timeo));
};
+static void nand_whr_delay(struct nand_chip *chip)
+{
+ if (!(chip->options & NAND_WAIT_TWHR))
+ return;
+
+ if (chip->data_interface && chip->data_interface->timings.sdr.tWHR_min)
+ ndelay(chip->data_interface->timings.sdr.tWHR_min / 1000);
+ else
+ ndelay(200);
+}
+
/**
* nand_command - [DEFAULT] Send command to NAND device
* @mtd: MTD device structure
@@ -742,9 +753,12 @@ static void nand_command(struct mtd_info *mtd, unsigned int command,
case NAND_CMD_ERASE1:
case NAND_CMD_ERASE2:
case NAND_CMD_SEQIN:
+ case NAND_CMD_SET_FEATURES:
+ return;
+
case NAND_CMD_STATUS:
case NAND_CMD_READID:
- case NAND_CMD_SET_FEATURES:
+ nand_whr_delay(chip);
return;
case NAND_CMD_RESET:
@@ -871,9 +885,12 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command,
case NAND_CMD_ERASE1:
case NAND_CMD_ERASE2:
case NAND_CMD_SEQIN:
+ case NAND_CMD_SET_FEATURES:
+ return;
+
case NAND_CMD_STATUS:
case NAND_CMD_READID:
- case NAND_CMD_SET_FEATURES:
+ nand_whr_delay(chip);
return;
case NAND_CMD_RNDIN:
diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
index 749bb08..bb0165b 100644
--- a/include/linux/mtd/rawnand.h
+++ b/include/linux/mtd/rawnand.h
@@ -213,13 +213,16 @@ enum nand_ecc_algo {
/*
* In case your controller is implementing ->cmd_ctrl() and is relying on the
- * default ->cmdfunc() implementation, you may want to let the core handle the
- * tCCS delay which is required when a column change (RNDIN or RNDOUT) is
- * requested.
- * If your controller already takes care of this delay, you don't need to set
- * this flag.
+ * default ->cmdfunc() implementation, you may want to let the core handle
+ * some delays to meet the timing specification.
+ * If your controller already takes care of these delays, you don't need to set
+ * the following flags.
*/
+
+/* tCCS for a column change (RNDIN or RNDOUT) */
#define NAND_WAIT_TCCS 0x00200000
+/* tWHR for STATUS, READID, etc. */
+#define NAND_WAIT_TWHR 0x00400000
/* Options set by nand scan */
/* Nand scan has allocated controller struct */
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Boris Brezillon <boris.brezillon@free-electrons.com> |
|---|---|
| Date | 2017-09-29 14:30 +0200 |
| Subject | Re: [PATCH v2 0/2] mtd: nand: wait for tWHR, and fix the setup_data_interface of Denali |
| Message-ID | <uv2Ax-67j-1@gated-at.bofh.it> |
| In reply to | #1742048 |
On Fri, 29 Sep 2017 19:38:38 +0900 Masahiro Yamada <yamada.masahiro@socionext.com> wrote: > 1/2 : add NAND_WAIT_TWHR and nand_whr_delay(). > You can set this new flag if you want nand_command(_lp) > to insert tWHR delay where needed. > > 2/2 : Fix Denali setup_data_interface. > Boris' suggestion in v1 was a good reminder that > made me realize tCCS was missing in the driver. Fix it now. > > > Changes in v2: > - Add nand_whr_delay() helper > Wait for tWHR only for drivers that explicitly set NAND_WAIT_TWHR flag > - newly added > > Masahiro Yamada (2): > mtd: nand: wait for tWHR after NAND_CMD_STATUS / NAND_CMD_READID Hm, I thought you were introducing this to then use it in the denali driver. Sorry, but I don't want to apply something that nobody needs. If someone ever complains about a missing delay I'll point him to your patch, but until then I'll keep the core unchanged. > mtd: nand: denali: fix setup_data_interface to meet tCCS delay This one is valid. I'll queue it to nand/next soon. Thanks, Boris > > drivers/mtd/nand/denali.c | 10 ++++++++-- > drivers/mtd/nand/nand_base.c | 21 +++++++++++++++++++-- > include/linux/mtd/rawnand.h | 13 ++++++++----- > 3 files changed, 35 insertions(+), 9 deletions(-) >
[toc] | [prev] | [next] | [standalone]
| From | Masahiro Yamada <yamada.masahiro@socionext.com> |
|---|---|
| Date | 2017-09-29 16:10 +0200 |
| Subject | Re: [PATCH v2 0/2] mtd: nand: wait for tWHR, and fix the setup_data_interface of Denali |
| Message-ID | <uv49k-7bh-37@gated-at.bofh.it> |
| In reply to | #1742077 |
2017-09-29 21:26 GMT+09:00 Boris Brezillon <boris.brezillon@free-electrons.com>: > On Fri, 29 Sep 2017 19:38:38 +0900 > Masahiro Yamada <yamada.masahiro@socionext.com> wrote: > >> 1/2 : add NAND_WAIT_TWHR and nand_whr_delay(). >> You can set this new flag if you want nand_command(_lp) >> to insert tWHR delay where needed. >> >> 2/2 : Fix Denali setup_data_interface. >> Boris' suggestion in v1 was a good reminder that >> made me realize tCCS was missing in the driver. Fix it now. >> >> >> Changes in v2: >> - Add nand_whr_delay() helper >> Wait for tWHR only for drivers that explicitly set NAND_WAIT_TWHR flag >> - newly added >> >> Masahiro Yamada (2): >> mtd: nand: wait for tWHR after NAND_CMD_STATUS / NAND_CMD_READID > > Hm, I thought you were introducing this to then use it in the denali > driver. Sorry, but I don't want to apply something that nobody needs. > If someone ever complains about a missing delay I'll point him to your > patch, but until then I'll keep the core unchanged. At first, I thought this was necessary for me, but I realized it was my misunderstanding. Please let me explain one more. See commit 3158fa0e739615769cc047d2428f30f4c3b6640e. Prior to that commit, READID waited for #R/B transition, it was wrong, so I fixed it. However, it dropped the delay completely. If somebody was implicitly relying on the delay of chip->dev_ready, the first byte might be read out before the valid data is available. This was motivation of v1, where inserted ndelay(200) unconditionally. >> mtd: nand: denali: fix setup_data_interface to meet tCCS delay > > This one is valid. I'll queue it to nand/next soon. If you drop 1/2, please let me do v3. V2 mentions NAND_WAIT_TWHR, this is strange. -- Best Regards Masahiro Yamada
[toc] | [prev] | [next] | [standalone]
| From | Boris Brezillon <boris.brezillon@free-electrons.com> |
|---|---|
| Date | 2017-09-29 16:30 +0200 |
| Subject | Re: [PATCH v2 0/2] mtd: nand: wait for tWHR, and fix the setup_data_interface of Denali |
| Message-ID | <uv4sG-7iS-9@gated-at.bofh.it> |
| In reply to | #1742147 |
On Fri, 29 Sep 2017 23:06:42 +0900 Masahiro Yamada <yamada.masahiro@socionext.com> wrote: > 2017-09-29 21:26 GMT+09:00 Boris Brezillon <boris.brezillon@free-electrons.com>: > > On Fri, 29 Sep 2017 19:38:38 +0900 > > Masahiro Yamada <yamada.masahiro@socionext.com> wrote: > > > >> 1/2 : add NAND_WAIT_TWHR and nand_whr_delay(). > >> You can set this new flag if you want nand_command(_lp) > >> to insert tWHR delay where needed. > >> > >> 2/2 : Fix Denali setup_data_interface. > >> Boris' suggestion in v1 was a good reminder that > >> made me realize tCCS was missing in the driver. Fix it now. > >> > >> > >> Changes in v2: > >> - Add nand_whr_delay() helper > >> Wait for tWHR only for drivers that explicitly set NAND_WAIT_TWHR flag > >> - newly added > >> > >> Masahiro Yamada (2): > >> mtd: nand: wait for tWHR after NAND_CMD_STATUS / NAND_CMD_READID > > > > Hm, I thought you were introducing this to then use it in the denali > > driver. Sorry, but I don't want to apply something that nobody needs. > > If someone ever complains about a missing delay I'll point him to your > > patch, but until then I'll keep the core unchanged. > > > At first, I thought this was necessary for me, > but I realized it was my misunderstanding. > > > Please let me explain one more. > > See commit 3158fa0e739615769cc047d2428f30f4c3b6640e. > > Prior to that commit, READID waited for #R/B transition, > it was wrong, so I fixed it. > > However, it dropped the delay completely. > If somebody was implicitly relying on the delay of chip->dev_ready, > the first byte might be read out before the valid data > is available. > > This was motivation of v1, where inserted ndelay(200) > unconditionally. Okay. Anyway, this extra delay is activated with an opt-in flag (I know, I'm the one who asked that), and noone set this flag in chip->options, so, if there's a bug, it's still here even after applying "mtd: nand: wait for tWHR after NAND_CMD_STATUS / NAND_CMD_READID". Honestly, I think all advanced controllers have the tWHR/tRHW timings enforced in the HW logic (configurable through a reg). This leaves basic controllers like the nand-gpio one, and even for these ones, the delay between the chip->cmd_ctrl(ADDR) and chip->read_buf() calls is probably long enough to hide the problem. Note that I'm absolutely not against this patch, it's just that I'd like to have a real user before merging this logic. > > > > > > >> mtd: nand: denali: fix setup_data_interface to meet tCCS delay > > > > This one is valid. I'll queue it to nand/next soon. > > If you drop 1/2, please let me do v3. > > V2 mentions NAND_WAIT_TWHR, this is strange. > Sure. > >
[toc] | [prev] | [next] | [standalone]
| From | Masahiro Yamada <yamada.masahiro@socionext.com> |
|---|---|
| Date | 2017-09-29 16:40 +0200 |
| Subject | Re: [PATCH v2 0/2] mtd: nand: wait for tWHR, and fix the setup_data_interface of Denali |
| Message-ID | <uv4Cm-7oK-15@gated-at.bofh.it> |
| In reply to | #1742077 |
(+CC Marc Gonzalez)
2017-09-29 21:26 GMT+09:00 Boris Brezillon <boris.brezillon@free-electrons.com>:
> On Fri, 29 Sep 2017 19:38:38 +0900
> Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
>
>> 1/2 : add NAND_WAIT_TWHR and nand_whr_delay().
>> You can set this new flag if you want nand_command(_lp)
>> to insert tWHR delay where needed.
>>
>> 2/2 : Fix Denali setup_data_interface.
>> Boris' suggestion in v1 was a good reminder that
>> made me realize tCCS was missing in the driver. Fix it now.
>>
>>
>> Changes in v2:
>> - Add nand_whr_delay() helper
>> Wait for tWHR only for drivers that explicitly set NAND_WAIT_TWHR flag
>> - newly added
>>
>> Masahiro Yamada (2):
>> mtd: nand: wait for tWHR after NAND_CMD_STATUS / NAND_CMD_READID
>
> Hm, I thought you were introducing this to then use it in the denali
> driver. Sorry, but I don't want to apply something that nobody needs.
> If someone ever complains about a missing delay I'll point him to your
> patch, but until then I'll keep the core unchanged.
Perhaps, Marc Gonzalez is the person.
tango_nand.c is the only driver that sets NAND_WAIT_TCCS.
Now, there is completely no delay when reading out the ID.
One safe change might be apply this patch,
then set NAND_WAIT_TWHR to tango_nand.c
I am guessing NAND_WAIT_TCCS was added for it.
Theoretically, I do not see logical difference between tCCS and tWHR.
I am CCing Marc Gonzalez, the author of tango_nand.c
commit 6ea40a3ba93e1b14ffb349e276f9dfefc4334b99
Author: Boris Brezillon <boris.brezillon@free-electrons.com>
Date: Sat Oct 1 10:24:03 2016 +0200
mtd: nand: Wait tCCS after a column change
Drivers implementing ->cmd_ctrl() and relying on the default ->cmdfunc()
implementation usually don't wait tCCS when a column change (RNDIN or
RNDOUT) is requested.
Add an option flag to ask the core to do so (note that we keep this as
an opt-in to avoid breaking existing implementations), and make use of
the ->data_interface information is available (otherwise, wait 500ns).
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Tested-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
--
Best Regards
Masahiro Yamada
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web