Fix issues related to register access in IPQ NAND
PATCH v2 2/2 mtd: rawnand: qcom: set BAM mode only if not set already
In reply to Sivaprakash MurugesanBAM mode is set by writing BAM_MODE_EN bit on NAND_CTRL register. NAND_CTRL is an operational register and in BAM mode operational registers are read only.
So, before writing into NAND_CTRL register check if BAM mode is already enabled by bootloader, and set BAM mode only if it is not set already.
--- drivers/mtd/nand/raw/qcom_nandc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/qcom_nandc.c +8 -1
@@ -2779,7 +2779,14 @@ static int qcom_nandc_setup(struct qcom_nand_controller *nandc)/* enable ADM or BAM DMA */ if (nandc->props->is_bam) { nand_ctrl =nandc_read (nandc,NAND_CTRL ); -nandc_write (nandc,NAND_CTRL , nand_ctrl |BAM_MODE_EN ); +/* NAND_CTRL is an operational registers, and CPU +* access to operational registers are read only +* in BAM mode. So update the NAND_CTRL register +* only if it is not in BAM mode. In most cases BAM +* mode will be enabled in bootloader +*/ +if (!(nand_ctrl |BAM_MODE_EN )) +nandc_write (nandc,NAND_CTRL , nand_ctrl |BAM_MODE_EN ); }else {nandc_write (nandc,NAND_FLASH_CHIP_SELECT ,DM_EN ); }
Signature · 1 line
2.7.4
PATCH v2 1/2 mtd: rawnand: qcom: remove write to unavailable register
In reply to Sivaprakash MurugesanSFLASHC_BURST_CFG register is not available on all ipq nand platforms, it is available only on ipq8064 devices and the nand controller works without configuring these registers in this platform, so register write to this can be removed.
--- drivers/mtd/nand/raw/qcom_nandc.c | 2 -- 1 file changed, 2 deletions(-)
drivers/mtd/nand/raw/qcom_nandc.c +0 -2
@@ -36,7 +36,6 @@#define NAND_DEV_CMD1 0xa4#define NAND_DEV_CMD2 0xa8#define NAND_DEV_CMD_VLD 0xac -#define SFLASHC_BURST_CFG 0xe0#define NAND_ERASED_CW_DETECT_CFG 0xe8#define NAND_ERASED_CW_DETECT_STATUS 0xec#define NAND_EBI2_ECC_BUF_CFG 0xf0
@@ -2774,7 +2773,6 @@ static int qcom_nandc_setup(struct qcom_nand_controller *nandc)u32 nand_ctrl;/* kill onenand */ -nandc_write (nandc,SFLASHC_BURST_CFG ,0 );nandc_write (nandc,dev_cmd_reg_addr (nandc,NAND_DEV_CMD_VLD ),NAND_DEV_CMD_VLD_VAL );
Signature · 1 line
2.7.4
v2 cover Fix issues related to register access in IPQ NAND
Patch 1: avoids register write to unavailable SFLASHC_BURST_CFG register Patch 2: set BAM mode only if not set by bootloader
[V2]
* As per review comments from Miquèl split the original patch into two addressing independent issues.
Sivaprakash Murugesan (2):
mtd: rawnand: qcom: remove write to unavailable register
mtd: rawnand: qcom: set BAM mode only if not set already
drivers/mtd/nand/raw/qcom_nandc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
Signature · 1 line
2.7.4
Miquel Raynal
maintainerRe: [PATCH V2 1/2] mtd: rawnand: qcom: remove write to unavailable register
In reply to Sivaprakash MurugesanHi Sivaprakash,
Sivaprakash Murugesan <[email protected]> wrote on Tue, 9 Jun 2020 16:40:55 +0530:
Quoted 4 lines
SFLASHC_BURST_CFGregister is not available on all ipq nand platforms, it is available only on ipq8064 devices and the nand controller works without configuring these registers in this platform, so register write to this can be removed.
Maybe it works because the bootloader is setting the register itself. What if you use a different bootloader, or the same bootloader without NAND support?
I don't think this is a proper fix, you should instead have a different compatible if the IP is not the same and depending on this compatible do the write, or not.
Quoted 19 lines
Signed-off-by Sivaprakash Murugesan <[email protected]>--- drivers/mtd/nand/raw/qcom_nandc.c | 2 -- 1 file changed, 2 deletions(-)drivers/mtd/nand/raw/qcom_nandc.c +0
-1@@ -36,7 +36,6 @@#define NAND_DEV_CMD1 0xa4#define NAND_DEV_CMD2 0xa8#define NAND_DEV_CMD_VLD 0xac -#define SFLASHC_BURST_CFG 0xe0#define NAND_ERASED_CW_DETECT_CFG 0xe8#define NAND_ERASED_CW_DETECT_STATUS 0xec#define NAND_EBI2_ECC_BUF_CFG 0xf0
drivers/mtd/nand/raw/qcom_nandc.c static int qcom_nandc_setup(struct qcom_nand_controller *nandc) · line 2778
Quoted 7 lines
drivers/mtd/nand/raw/qcom_nandc.c +0
-1@@ -2774,7 +2773,6 @@ static int qcom_nandc_setup(struct qcom_nand_controller *nandc)u32 nand_ctrl;/* kill onenand */ -nandc_write (nandc,SFLASHC_BURST_CFG ,0 );nandc_write (nandc,dev_cmd_reg_addr (nandc,NAND_DEV_CMD_VLD ),NAND_DEV_CMD_VLD_VAL );
Thanks,
Miquèl
Miquel Raynal
maintainerRe: [PATCH V2 2/2] mtd: rawnand: qcom: set BAM mode only if not set already
In reply to Sivaprakash MurugesanHi Sivaprakash,
Sivaprakash Murugesan <[email protected]> wrote on Tue, 9 Jun 2020 16:40:56 +0530:
Quoted 22 lines
BAM mode is set by writing
BAM_MODE_ENbit onNAND_CTRLregister.NAND_CTRLis an operational register and in BAM mode operational registers are read only.So, before writing into
NAND_CTRLregister check if BAM mode is already enabled by bootloader, and set BAM mode only if it is not set already.Signed-off-by Sivaprakash Murugesan <[email protected]>--- drivers/mtd/nand/raw/qcom_nandc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/mtd/nand/raw/qcom_nandc.c +1
-1@@ -2779,7 +2779,14 @@ static int qcom_nandc_setup(struct qcom_nand_controller *nandc)/* enable ADM or BAM DMA */ if (nandc->props->is_bam) { nand_ctrl =nandc_read (nandc,NAND_CTRL ); -nandc_write (nandc,NAND_CTRL , nand_ctrl |BAM_MODE_EN ); +/* NAND_CTRL is an operational registers, and CPU
drivers/mtd/nand/raw/qcom_nandc.c static int qcom_nandc_setup(struct qcom_nand_controller *nandc) · line 2792
Quoted 10 lines
drivers/mtd/nand/raw/qcom_nandc.c +7
-0+* access to operational registers are read only +* in BAM mode. So update the NAND_CTRL register +* only if it is not in BAM mode. In most cases BAM +* mode will be enabled in bootloader +*/ +if (!(nand_ctrl |BAM_MODE_EN )) +nandc_write (nandc,NAND_CTRL , nand_ctrl |BAM_MODE_EN ); }else {nandc_write (nandc,NAND_FLASH_CHIP_SELECT ,DM_EN ); }
Does this currently produces an issue at runtime?
If yes, you should have a Fixes/CC: stable pair of tags.
Also, what is BAM mode? Please tell us in the commit log.
Thanks,
Miquèl
Re: [PATCH V2 2/2] mtd: rawnand: qcom: set BAM mode only if not set already
Hi Miquel,
Thanks for the review.
Quoted 39 lines · Miquel Raynal
Hi Sivaprakash,
Sivaprakash Murugesan <[email protected]> wrote on Tue, 9 Jun 2020 16:40:56 +0530:
Quoted 22 lines
BAM mode is set by writing
BAM_MODE_ENbit onNAND_CTRLregister.NAND_CTRLis an operational register and in BAM mode operational registers are read only.So, before writing into
NAND_CTRLregister check if BAM mode is already enabled by bootloader, and set BAM mode only if it is not set already.Signed-off-by Sivaprakash Murugesan <[email protected]>--- drivers/mtd/nand/raw/qcom_nandc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/mtd/nand/raw/qcom_nandc.c +1
-1@@ -2779,7 +2779,14 @@ static int qcom_nandc_setup(struct qcom_nand_controller *nandc)/* enable ADM or BAM DMA */ if (nandc->props->is_bam) { nand_ctrl =nandc_read (nandc,NAND_CTRL ); -nandc_write (nandc,NAND_CTRL , nand_ctrl |BAM_MODE_EN ); +/* NAND_CTRL is an operational registers, and CPU drivers/mtd/nand/raw/qcom_nandc.c static int qcom_nandc_setup(struct qcom_nand_controller *nandc) · line 2792
Quoted 10 lines
drivers/mtd/nand/raw/qcom_nandc.c +7
-0+* access to operational registers are read only +* in BAM mode. So update the NAND_CTRL register +* only if it is not in BAM mode. In most cases BAM +* mode will be enabled in bootloader +*/ +if (!(nand_ctrl |BAM_MODE_EN )) +nandc_write (nandc,NAND_CTRL , nand_ctrl |BAM_MODE_EN ); }else {nandc_write (nandc,NAND_FLASH_CHIP_SELECT ,DM_EN ); }Does this currently produces an issue at runtime?
Quoted 3 lines
If yes, you should have a Fixes/CC: stable pair of tags.
Also, what is BAM mode? Please tell us in the commit log.
Currently this is not causing any issue on run time.
The writes to this register is silently ignored.
However, this could be an issue in future Hardware designs.
BAM is the DMA engine on QCOM IPQ platforms, sure will explain this
mode in next patchset.
Quoted 3 lines
Thanks,
Miquèl
Re: [PATCH V2 1/2] mtd: rawnand: qcom: remove write to unavailable register
In reply to Miquel RaynalHi Miquel,
Quoted 9 lines · Miquel Raynal
Hi Sivaprakash,
Sivaprakash Murugesan <[email protected]> wrote on Tue, 9 Jun 2020 16:40:55 +0530:
Quoted 4 lines
SFLASHC_BURST_CFGregister is not available on all ipq nand platforms, it is available only on ipq8064 devices and the nand controller works without configuring these registers in this platform, so register write to this can be removed.
Quoted 7 lines
Maybe it works because the bootloader is setting the register itself. What if you use a different bootloader, or the same bootloader without NAND support?
I don't think this is a proper fix, you should instead have a different compatible if the IP is not the same and depending on this compatible do the write, or not.
I understand your point, will fix this in next patch.
Thanks,
Siva
Quoted 2 lines
Thanks,
Miquèl
Miquel Raynal
maintainerRe: [PATCH V2 2/2] mtd: rawnand: qcom: set BAM mode only if not set already
In reply to Sivaprakash MurugesanHi Sivaprakash,
Sivaprakash Murugesan <[email protected]> wrote on Thu, 11 Jun 2020 09:57:59 +0530:
Quoted 50 lines
Hi Miquel,
Thanks for the review.
Quoted 39 lines · Miquel Raynal
Hi Sivaprakash,
Sivaprakash Murugesan <[email protected]> wrote on Tue, 9 Jun 2020 16:40:56 +0530:
Quoted 22 lines
BAM mode is set by writing
BAM_MODE_ENbit onNAND_CTRLregister.NAND_CTRLis an operational register and in BAM mode operational registers are read only.So, before writing into
NAND_CTRLregister check if BAM mode is already enabled by bootloader, and set BAM mode only if it is not set already.Signed-off-by Sivaprakash Murugesan <[email protected]>--- drivers/mtd/nand/raw/qcom_nandc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/mtd/nand/raw/qcom_nandc.c +1
-1@@ -2779,7 +2779,14 @@ static int qcom_nandc_setup(struct qcom_nand_controller *nandc)/* enable ADM or BAM DMA */ if (nandc->props->is_bam) { nand_ctrl =nandc_read (nandc,NAND_CTRL ); -nandc_write (nandc,NAND_CTRL , nand_ctrl |BAM_MODE_EN ); +/* NAND_CTRL is an operational registers, and CPU drivers/mtd/nand/raw/qcom_nandc.c static int qcom_nandc_setup(struct qcom_nand_controller *nandc) · line 2792
Quoted 10 lines
drivers/mtd/nand/raw/qcom_nandc.c +7
-0+* access to operational registers are read only +* in BAM mode. So update the NAND_CTRL register +* only if it is not in BAM mode. In most cases BAM +* mode will be enabled in bootloader +*/ +if (!(nand_ctrl |BAM_MODE_EN )) +nandc_write (nandc,NAND_CTRL , nand_ctrl |BAM_MODE_EN ); }else {nandc_write (nandc,NAND_FLASH_CHIP_SELECT ,DM_EN ); }Does this currently produces an issue at runtime?
Quoted 3 lines
If yes, you should have a Fixes/CC: stable pair of tags.
Also, what is BAM mode? Please tell us in the commit log.
Currently this is not causing any issue on run time.
Quoted 7 lines
The writes to this register is silently ignored.
However, this could be an issue in future Hardware designs.
BAM is the DMA engine on QCOM IPQ platforms, sure will explain this
mode in next patchset.
I don't like so much the idea of DMA being enabled by the Bootloader or not, this is something that should need to be fixed.
Thanks,
Miquèl