From: Han Xu <han.xu@nxp.com> To: Sascha Hauer <s.hauer@pengutronix.de>, "linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org> Cc: Miquel Raynal <miquel.raynal@bootlin.com>, "kernel@pengutronix.de" <kernel@pengutronix.de>, Richard Weinberger <richard@nod.at>, "stable@vger.kernel.org" <stable@vger.kernel.org> Subject: RE: [PATCH] mtd: rawnand: gpmi: Set WAIT_FOR_READY timeout based on program/erase times Date: Fri, 1 Jul 2022 12:53:12 +0000 [thread overview] Message-ID: <DU2PR04MB877447C730B0E64D7B19399397BD9@DU2PR04MB8774.eurprd04.prod.outlook.com> (raw) In-Reply-To: <20220701110341.3094023-1-s.hauer@pengutronix.de> >-----Original Message----- >From: Sascha Hauer <s.hauer@pengutronix.de> >Sent: Friday, July 1, 2022 6:04 AM >To: linux-mtd@lists.infradead.org >Cc: Han Xu <han.xu@nxp.com>; Miquel Raynal <miquel.raynal@bootlin.com>; >kernel@pengutronix.de; Richard Weinberger <richard@nod.at>; Sascha Hauer ><s.hauer@pengutronix.de>; stable@vger.kernel.org >Subject: [PATCH] mtd: rawnand: gpmi: Set WAIT_FOR_READY timeout based on >program/erase times > >06781a5026350 Fixes the calculation of the DEVICE_BUSY_TIMEOUT register value >from busy_timeout_cycles. busy_timeout_cycles is calculated wrong >though: It is calculated based on the maximum page read time, but the timeout is >also used for page write and block erase operations which require orders of >magnitude bigger timeouts. > >Fix this by calculating busy_timeout_cycles from the maximum of tBERS_max and >tPROG_max. > >This is for now the easiest and most obvious way to fix the driver. >There's room for improvements though: The NAND_OP_WAITRDY_INSTR tells us >the desired timeout for the current operation, so we could program the timeout >dynamically for each operation instead of setting a fixed timeout. Also we could >wire up the interrupt handler to actually detect and forward timeouts occurred >when waiting for the chip being ready. > >As a sidenote I verified that the change in 06781a5026350 is really correct. I wired >up the interrupt handler in my tree and measured the time between starting the >operation and the timeout interrupt handler coming in. The time increases 41us >with each step in the timeout register which corresponds to 4096 clock cycles with >the 99MHz clock that I have. > >Fixes: 06781a5026350 ("mtd: rawnand: gpmi: Fix setting busy timeout setting") >Fixes: b1206122069aa ("mtd: rawniand: gpmi: use core timings instead of an >empirical derivation") >Cc: stable@vger.kernel.org >Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Acked-by: Han Xu <han.xu@nxp.com> >--- > drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > >diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c >b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c >index 889e403299568..93da23682d862 100644 >--- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c >+++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c >@@ -850,9 +850,10 @@ static int gpmi_nfc_compute_timings(struct >gpmi_nand_data *this, > unsigned int tRP_ps; > bool use_half_period; > int sample_delay_ps, sample_delay_factor; >- u16 busy_timeout_cycles; >+ unsigned int busy_timeout_cycles; > u8 wrn_dly_sel; > unsigned long clk_rate, min_rate; >+ u64 busy_timeout_ps; > > if (sdr->tRC_min >= 30000) { > /* ONFI non-EDO modes [0-3] */ >@@ -885,7 +886,8 @@ static int gpmi_nfc_compute_timings(struct >gpmi_nand_data *this, > addr_setup_cycles = TO_CYCLES(sdr->tALS_min, period_ps); > data_setup_cycles = TO_CYCLES(sdr->tDS_min, period_ps); > data_hold_cycles = TO_CYCLES(sdr->tDH_min, period_ps); >- busy_timeout_cycles = TO_CYCLES(sdr->tWB_max + sdr->tR_max, >period_ps); >+ busy_timeout_ps = max(sdr->tBERS_max, sdr->tPROG_max); >+ busy_timeout_cycles = TO_CYCLES(busy_timeout_ps, period_ps); > > hw->timing0 = BF_GPMI_TIMING0_ADDRESS_SETUP(addr_setup_cycles) | > BF_GPMI_TIMING0_DATA_HOLD(data_hold_cycles) | >-- >2.30.2
WARNING: multiple messages have this Message-ID (diff)
From: Han Xu <han.xu@nxp.com> To: Sascha Hauer <s.hauer@pengutronix.de>, "linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org> Cc: Miquel Raynal <miquel.raynal@bootlin.com>, "kernel@pengutronix.de" <kernel@pengutronix.de>, Richard Weinberger <richard@nod.at>, "stable@vger.kernel.org" <stable@vger.kernel.org> Subject: RE: [PATCH] mtd: rawnand: gpmi: Set WAIT_FOR_READY timeout based on program/erase times Date: Fri, 1 Jul 2022 12:53:12 +0000 [thread overview] Message-ID: <DU2PR04MB877447C730B0E64D7B19399397BD9@DU2PR04MB8774.eurprd04.prod.outlook.com> (raw) In-Reply-To: <20220701110341.3094023-1-s.hauer@pengutronix.de> >-----Original Message----- >From: Sascha Hauer <s.hauer@pengutronix.de> >Sent: Friday, July 1, 2022 6:04 AM >To: linux-mtd@lists.infradead.org >Cc: Han Xu <han.xu@nxp.com>; Miquel Raynal <miquel.raynal@bootlin.com>; >kernel@pengutronix.de; Richard Weinberger <richard@nod.at>; Sascha Hauer ><s.hauer@pengutronix.de>; stable@vger.kernel.org >Subject: [PATCH] mtd: rawnand: gpmi: Set WAIT_FOR_READY timeout based on >program/erase times > >06781a5026350 Fixes the calculation of the DEVICE_BUSY_TIMEOUT register value >from busy_timeout_cycles. busy_timeout_cycles is calculated wrong >though: It is calculated based on the maximum page read time, but the timeout is >also used for page write and block erase operations which require orders of >magnitude bigger timeouts. > >Fix this by calculating busy_timeout_cycles from the maximum of tBERS_max and >tPROG_max. > >This is for now the easiest and most obvious way to fix the driver. >There's room for improvements though: The NAND_OP_WAITRDY_INSTR tells us >the desired timeout for the current operation, so we could program the timeout >dynamically for each operation instead of setting a fixed timeout. Also we could >wire up the interrupt handler to actually detect and forward timeouts occurred >when waiting for the chip being ready. > >As a sidenote I verified that the change in 06781a5026350 is really correct. I wired >up the interrupt handler in my tree and measured the time between starting the >operation and the timeout interrupt handler coming in. The time increases 41us >with each step in the timeout register which corresponds to 4096 clock cycles with >the 99MHz clock that I have. > >Fixes: 06781a5026350 ("mtd: rawnand: gpmi: Fix setting busy timeout setting") >Fixes: b1206122069aa ("mtd: rawniand: gpmi: use core timings instead of an >empirical derivation") >Cc: stable@vger.kernel.org >Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Acked-by: Han Xu <han.xu@nxp.com> >--- > drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > >diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c >b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c >index 889e403299568..93da23682d862 100644 >--- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c >+++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c >@@ -850,9 +850,10 @@ static int gpmi_nfc_compute_timings(struct >gpmi_nand_data *this, > unsigned int tRP_ps; > bool use_half_period; > int sample_delay_ps, sample_delay_factor; >- u16 busy_timeout_cycles; >+ unsigned int busy_timeout_cycles; > u8 wrn_dly_sel; > unsigned long clk_rate, min_rate; >+ u64 busy_timeout_ps; > > if (sdr->tRC_min >= 30000) { > /* ONFI non-EDO modes [0-3] */ >@@ -885,7 +886,8 @@ static int gpmi_nfc_compute_timings(struct >gpmi_nand_data *this, > addr_setup_cycles = TO_CYCLES(sdr->tALS_min, period_ps); > data_setup_cycles = TO_CYCLES(sdr->tDS_min, period_ps); > data_hold_cycles = TO_CYCLES(sdr->tDH_min, period_ps); >- busy_timeout_cycles = TO_CYCLES(sdr->tWB_max + sdr->tR_max, >period_ps); >+ busy_timeout_ps = max(sdr->tBERS_max, sdr->tPROG_max); >+ busy_timeout_cycles = TO_CYCLES(busy_timeout_ps, period_ps); > > hw->timing0 = BF_GPMI_TIMING0_ADDRESS_SETUP(addr_setup_cycles) | > BF_GPMI_TIMING0_DATA_HOLD(data_hold_cycles) | >-- >2.30.2 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2022-07-01 12:53 UTC|newest] Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-07-01 11:03 [PATCH] mtd: rawnand: gpmi: Set WAIT_FOR_READY timeout based on program/erase times Sascha Hauer 2022-07-01 11:03 ` Sascha Hauer 2022-07-01 12:53 ` Han Xu [this message] 2022-07-01 12:53 ` Han Xu 2022-07-11 9:12 ` Tomasz Moń 2022-07-11 9:12 ` Tomasz Moń 2022-07-15 5:27 ` Tomasz Moń 2022-07-15 5:27 ` Tomasz Moń 2022-07-15 5:49 ` Greg Kroah-Hartman 2022-07-15 5:49 ` Greg Kroah-Hartman 2022-07-15 7:46 ` Sascha Hauer 2022-07-15 7:46 ` Sascha Hauer 2022-07-15 7:54 ` Greg Kroah-Hartman 2022-07-15 7:54 ` Greg Kroah-Hartman 2022-07-15 7:54 ` Greg Kroah-Hartman 2022-07-15 7:54 ` Greg Kroah-Hartman 2022-07-15 7:59 ` Richard Weinberger 2022-07-15 7:59 ` Richard Weinberger 2022-09-02 7:02 ` Miquel Raynal 2022-09-02 7:02 ` Miquel Raynal 2022-10-21 21:55 ` Tim Harvey 2022-10-21 21:55 ` Tim Harvey 2022-10-22 0:37 ` Tim Harvey 2022-10-22 0:37 ` Tim Harvey 2022-10-24 8:01 ` Miquel Raynal 2022-10-24 8:01 ` Miquel Raynal 2022-10-25 22:02 ` Tim Harvey 2022-10-25 22:02 ` Tim Harvey 2022-10-26 8:18 ` Miquel Raynal 2022-10-26 8:18 ` Miquel Raynal 2022-10-26 10:50 ` Greg Kroah-Hartman 2022-10-26 10:50 ` Greg Kroah-Hartman
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=DU2PR04MB877447C730B0E64D7B19399397BD9@DU2PR04MB8774.eurprd04.prod.outlook.com \ --to=han.xu@nxp.com \ --cc=kernel@pengutronix.de \ --cc=linux-mtd@lists.infradead.org \ --cc=miquel.raynal@bootlin.com \ --cc=richard@nod.at \ --cc=s.hauer@pengutronix.de \ --cc=stable@vger.kernel.org \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.