diff mbox series

mtd: nand: Fix build error while CONFIG_MTD_NAND_ECC_SW_BCH is set to module

Message ID 20190410130747.35692-1-yuehaibing@huawei.com
State Changes Requested
Delegated to: Miquel Raynal
Headers show
Series mtd: nand: Fix build error while CONFIG_MTD_NAND_ECC_SW_BCH is set to module | expand

Commit Message

Yue Haibing April 10, 2019, 1:07 p.m. UTC
From: YueHaibing <yuehaibing@huawei.com>

Fix gcc build error while CONFIG_MTD_NAND_ECC_SW_BCH
is set to module:

drivers/mtd/nand/raw/nand_base.o: In function `nand_cleanup':
(.text+0xef6): undefined reference to `nand_bch_free'
drivers/mtd/nand/raw/nand_base.o: In function `nand_scan_tail':
nand_base.c:(.text+0xa101): undefined reference to `nand_bch_calculate_ecc'
nand_base.c:(.text+0xa120): undefined reference to `nand_bch_correct_data'
nand_base.c:(.text+0xa269): undefined reference to `nand_bch_init'

CONFIG_MTD_NAND_ECC_SW_BCH should not be set to M,
because MTD_RAW_NAND need it while linked.

Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes: 193bd4002644 ("mtd: nand: add software BCH ECC support"
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/mtd/nand/raw/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Boris Brezillon April 10, 2019, 1:39 p.m. UTC | #1
On Wed, 10 Apr 2019 21:07:47 +0800
Yue Haibing <yuehaibing@huawei.com> wrote:

> From: YueHaibing <yuehaibing@huawei.com>
> 
> Fix gcc build error while CONFIG_MTD_NAND_ECC_SW_BCH
> is set to module:
> 
> drivers/mtd/nand/raw/nand_base.o: In function `nand_cleanup':
> (.text+0xef6): undefined reference to `nand_bch_free'
> drivers/mtd/nand/raw/nand_base.o: In function `nand_scan_tail':
> nand_base.c:(.text+0xa101): undefined reference to `nand_bch_calculate_ecc'
> nand_base.c:(.text+0xa120): undefined reference to `nand_bch_correct_data'
> nand_base.c:(.text+0xa269): undefined reference to `nand_bch_init'
> 
> CONFIG_MTD_NAND_ECC_SW_BCH should not be set to M,
> because MTD_RAW_NAND need it while linked.
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Fixes: 193bd4002644 ("mtd: nand: add software BCH ECC support"

Nope, it's not this one that introduced the regression.



> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>  drivers/mtd/nand/raw/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
> index 615d738..0500c42 100644
> --- a/drivers/mtd/nand/raw/Kconfig
> +++ b/drivers/mtd/nand/raw/Kconfig
> @@ -22,7 +22,7 @@ menuconfig MTD_RAW_NAND
>  if MTD_RAW_NAND
>  
>  config MTD_NAND_ECC_SW_BCH
> -	tristate "Support software BCH ECC"
> +	bool "Support software BCH ECC"
>  	select BCH
>  	default n
>  	help

Should be fixed with the following diff squashed into:

51ef1d0b2095 ("mtd: nand: Clarify Kconfig entry for software BCH ECC algorithm")

--->8---
diff --git a/include/linux/mtd/nand_bch.h b/include/linux/mtd/nand_bch.h
index b8106651f807..06ce2b655c13 100644
--- a/include/linux/mtd/nand_bch.h
+++ b/include/linux/mtd/nand_bch.h
@@ -15,7 +15,7 @@ struct mtd_info;
 struct nand_chip;
 struct nand_bch_control;
 
-#if defined(CONFIG_MTD_NAND_ECC_BCH)
+#if defined(CONFIG_MTD_NAND_ECC_SW_BCH)
 
 static inline int mtd_nand_has_bch(void) { return 1; }
 
@@ -39,7 +39,7 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd);
  */
 void nand_bch_free(struct nand_bch_control *nbc);
 
-#else /* !CONFIG_MTD_NAND_ECC_BCH */
+#else /* !CONFIG_MTD_NAND_ECC_SW_BCH */
 
 static inline int mtd_nand_has_bch(void) { return 0; }
 
@@ -64,6 +64,6 @@ static inline struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
 
 static inline void nand_bch_free(struct nand_bch_control *nbc) {}
 
-#endif /* CONFIG_MTD_NAND_ECC_BCH */
+#endif /* CONFIG_MTD_NAND_ECC_SW_BCH */
 
 #endif /* __MTD_NAND_BCH_H__ */
Boris Brezillon April 10, 2019, 1:58 p.m. UTC | #2
On Wed, 10 Apr 2019 15:39:28 +0200
Boris Brezillon <boris.brezillon@collabora.com> wrote:

> On Wed, 10 Apr 2019 21:07:47 +0800
> Yue Haibing <yuehaibing@huawei.com> wrote:
> 
> > From: YueHaibing <yuehaibing@huawei.com>
> > 
> > Fix gcc build error while CONFIG_MTD_NAND_ECC_SW_BCH
> > is set to module:
> > 
> > drivers/mtd/nand/raw/nand_base.o: In function `nand_cleanup':
> > (.text+0xef6): undefined reference to `nand_bch_free'
> > drivers/mtd/nand/raw/nand_base.o: In function `nand_scan_tail':
> > nand_base.c:(.text+0xa101): undefined reference to `nand_bch_calculate_ecc'
> > nand_base.c:(.text+0xa120): undefined reference to `nand_bch_correct_data'
> > nand_base.c:(.text+0xa269): undefined reference to `nand_bch_init'
> > 
> > CONFIG_MTD_NAND_ECC_SW_BCH should not be set to M,
> > because MTD_RAW_NAND need it while linked.
> > 
> > Reported-by: Hulk Robot <hulkci@huawei.com>
> > Fixes: 193bd4002644 ("mtd: nand: add software BCH ECC support"  
> 
> Nope, it's not this one that introduced the regression.
> 
> 
> 
> > Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> > ---
> >  drivers/mtd/nand/raw/Kconfig | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
> > index 615d738..0500c42 100644
> > --- a/drivers/mtd/nand/raw/Kconfig
> > +++ b/drivers/mtd/nand/raw/Kconfig
> > @@ -22,7 +22,7 @@ menuconfig MTD_RAW_NAND
> >  if MTD_RAW_NAND
> >  
> >  config MTD_NAND_ECC_SW_BCH
> > -	tristate "Support software BCH ECC"
> > +	bool "Support software BCH ECC"
> >  	select BCH
> >  	default n
> >  	help  
> 
> Should be fixed with the following diff squashed into:
> 
> 51ef1d0b2095 ("mtd: nand: Clarify Kconfig entry for software BCH ECC algorithm")
> 
> --->8---  
> diff --git a/include/linux/mtd/nand_bch.h b/include/linux/mtd/nand_bch.h
> index b8106651f807..06ce2b655c13 100644
> --- a/include/linux/mtd/nand_bch.h
> +++ b/include/linux/mtd/nand_bch.h
> @@ -15,7 +15,7 @@ struct mtd_info;
>  struct nand_chip;
>  struct nand_bch_control;
>  
> -#if defined(CONFIG_MTD_NAND_ECC_BCH)
> +#if defined(CONFIG_MTD_NAND_ECC_SW_BCH)
>  
>  static inline int mtd_nand_has_bch(void) { return 1; }
>  
> @@ -39,7 +39,7 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd);
>   */
>  void nand_bch_free(struct nand_bch_control *nbc);
>  
> -#else /* !CONFIG_MTD_NAND_ECC_BCH */
> +#else /* !CONFIG_MTD_NAND_ECC_SW_BCH */
>  
>  static inline int mtd_nand_has_bch(void) { return 0; }
>  
> @@ -64,6 +64,6 @@ static inline struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
>  
>  static inline void nand_bch_free(struct nand_bch_control *nbc) {}
>  
> -#endif /* CONFIG_MTD_NAND_ECC_BCH */
> +#endif /* CONFIG_MTD_NAND_ECC_SW_BCH */
>  
>  #endif /* __MTD_NAND_BCH_H__ */

Sorry, I didn't look at the right branch, this part of the code was
correct, but we still have a problem to express the RAW_NAND(y) ->
SW_BCH(y) dependency.
Boris Brezillon April 10, 2019, 2:10 p.m. UTC | #3
On Wed, 10 Apr 2019 15:58:56 +0200
Boris Brezillon <boris.brezillon@collabora.com> wrote:

> On Wed, 10 Apr 2019 15:39:28 +0200
> Boris Brezillon <boris.brezillon@collabora.com> wrote:
> 
> > On Wed, 10 Apr 2019 21:07:47 +0800
> > Yue Haibing <yuehaibing@huawei.com> wrote:
> >   
> > > From: YueHaibing <yuehaibing@huawei.com>
> > > 
> > > Fix gcc build error while CONFIG_MTD_NAND_ECC_SW_BCH
> > > is set to module:
> > > 
> > > drivers/mtd/nand/raw/nand_base.o: In function `nand_cleanup':
> > > (.text+0xef6): undefined reference to `nand_bch_free'
> > > drivers/mtd/nand/raw/nand_base.o: In function `nand_scan_tail':
> > > nand_base.c:(.text+0xa101): undefined reference to `nand_bch_calculate_ecc'
> > > nand_base.c:(.text+0xa120): undefined reference to `nand_bch_correct_data'
> > > nand_base.c:(.text+0xa269): undefined reference to `nand_bch_init'
> > > 
> > > CONFIG_MTD_NAND_ECC_SW_BCH should not be set to M,
> > > because MTD_RAW_NAND need it while linked.
> > > 
> > > Reported-by: Hulk Robot <hulkci@huawei.com>
> > > Fixes: 193bd4002644 ("mtd: nand: add software BCH ECC support"    
> > 
> > Nope, it's not this one that introduced the regression.
> > 
> > 
> >   
> > > Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> > > ---
> > >  drivers/mtd/nand/raw/Kconfig | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
> > > index 615d738..0500c42 100644
> > > --- a/drivers/mtd/nand/raw/Kconfig
> > > +++ b/drivers/mtd/nand/raw/Kconfig
> > > @@ -22,7 +22,7 @@ menuconfig MTD_RAW_NAND
> > >  if MTD_RAW_NAND
> > >  
> > >  config MTD_NAND_ECC_SW_BCH
> > > -	tristate "Support software BCH ECC"
> > > +	bool "Support software BCH ECC"
> > >  	select BCH
> > >  	default n
> > >  	help    
> > 
> > Should be fixed with the following diff squashed into:
> > 
> > 51ef1d0b2095 ("mtd: nand: Clarify Kconfig entry for software BCH ECC algorithm")
> >   
> > --->8---    
> > diff --git a/include/linux/mtd/nand_bch.h b/include/linux/mtd/nand_bch.h
> > index b8106651f807..06ce2b655c13 100644
> > --- a/include/linux/mtd/nand_bch.h
> > +++ b/include/linux/mtd/nand_bch.h
> > @@ -15,7 +15,7 @@ struct mtd_info;
> >  struct nand_chip;
> >  struct nand_bch_control;
> >  
> > -#if defined(CONFIG_MTD_NAND_ECC_BCH)
> > +#if defined(CONFIG_MTD_NAND_ECC_SW_BCH)
> >  
> >  static inline int mtd_nand_has_bch(void) { return 1; }
> >  
> > @@ -39,7 +39,7 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd);
> >   */
> >  void nand_bch_free(struct nand_bch_control *nbc);
> >  
> > -#else /* !CONFIG_MTD_NAND_ECC_BCH */
> > +#else /* !CONFIG_MTD_NAND_ECC_SW_BCH */
> >  
> >  static inline int mtd_nand_has_bch(void) { return 0; }
> >  
> > @@ -64,6 +64,6 @@ static inline struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
> >  
> >  static inline void nand_bch_free(struct nand_bch_control *nbc) {}
> >  
> > -#endif /* CONFIG_MTD_NAND_ECC_BCH */
> > +#endif /* CONFIG_MTD_NAND_ECC_SW_BCH */
> >  
> >  #endif /* __MTD_NAND_BCH_H__ */  
> 
> Sorry, I didn't look at the right branch, this part of the code was
> correct, but we still have a problem to express the RAW_NAND(y) ->
> SW_BCH(y) dependency.

This one should do the trick, though imply means MTD_NAND_ECC_SW_BCH will
now be selected by default.

--->8---
diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
index 7fcdaf6c279d..f9258d666846 100644
--- a/drivers/mtd/devices/Kconfig
+++ b/drivers/mtd/devices/Kconfig
@@ -207,7 +207,7 @@ comment "Disk-On-Chip Device Drivers"
 config MTD_DOCG3
        tristate "M-Systems Disk-On-Chip G3"
        select BCH
-       select BCH_CONST_PARAMS if !CONFIG_MTD_NAND_ECC_SW_BCH
+       select BCH_CONST_PARAMS if !MTD_NAND_ECC_SW_BCH
        select BITREVERSE
        help
          This provides an MTD device driver for the M-Systems DiskOnChip
diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index 615d738be411..65c85fc53c41 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -9,18 +9,6 @@ config MTD_NAND_ECC_SW_HAMMING_SMC
          Software ECC according to the Smart Media Specification.
          The original Linux implementation had byte 0 and 1 swapped.
 
-menuconfig MTD_RAW_NAND
-       tristate "Raw/Parallel NAND Device Support"
-       depends on MTD
-       select MTD_NAND_CORE
-       select MTD_NAND_ECC_SW_HAMMING
-       help
-         This enables support for accessing all type of raw/parallel
-         NAND flash devices. For further information see
-         <http://www.linux-mtd.infradead.org/doc/nand.html>.
-
-if MTD_RAW_NAND
-
 config MTD_NAND_ECC_SW_BCH
        tristate "Support software BCH ECC"
        select BCH
@@ -31,6 +19,19 @@ config MTD_NAND_ECC_SW_BCH
          ECC codes. They are used with NAND devices requiring more than 1 bit
          of error correction.
 
+menuconfig MTD_RAW_NAND
+       tristate "Raw/Parallel NAND Device Support"
+       depends on MTD
+       select MTD_NAND_CORE
+       select MTD_NAND_ECC_SW_HAMMING
+       imply MTD_NAND_ECC_SW_BCH
+       help
+         This enables support for accessing all type of raw/parallel
+         NAND flash devices. For further information see
+         <http://www.linux-mtd.infradead.org/doc/nand.html>.
+
+if MTD_RAW_NAND
+
 comment "Raw/parallel NAND flash controllers"
 
 config MTD_NAND_DENALI
Yue Haibing April 10, 2019, 2:22 p.m. UTC | #4
On 2019/4/10 21:58, Boris Brezillon wrote:
> On Wed, 10 Apr 2019 15:39:28 +0200
> Boris Brezillon <boris.brezillon@collabora.com> wrote:
> 
>> On Wed, 10 Apr 2019 21:07:47 +0800
>> Yue Haibing <yuehaibing@huawei.com> wrote:
>>
>>> From: YueHaibing <yuehaibing@huawei.com>
>>>
>>> Fix gcc build error while CONFIG_MTD_NAND_ECC_SW_BCH
>>> is set to module:
>>>
>>> drivers/mtd/nand/raw/nand_base.o: In function `nand_cleanup':
>>> (.text+0xef6): undefined reference to `nand_bch_free'
>>> drivers/mtd/nand/raw/nand_base.o: In function `nand_scan_tail':
>>> nand_base.c:(.text+0xa101): undefined reference to `nand_bch_calculate_ecc'
>>> nand_base.c:(.text+0xa120): undefined reference to `nand_bch_correct_data'
>>> nand_base.c:(.text+0xa269): undefined reference to `nand_bch_init'
>>>
>>> CONFIG_MTD_NAND_ECC_SW_BCH should not be set to M,
>>> because MTD_RAW_NAND need it while linked.
>>>
>>> Reported-by: Hulk Robot <hulkci@huawei.com>
>>> Fixes: 193bd4002644 ("mtd: nand: add software BCH ECC support"  
>>
>> Nope, it's not this one that introduced the regression.
>>
>>
>>
>>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>>> ---
>>>  drivers/mtd/nand/raw/Kconfig | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
>>> index 615d738..0500c42 100644
>>> --- a/drivers/mtd/nand/raw/Kconfig
>>> +++ b/drivers/mtd/nand/raw/Kconfig
>>> @@ -22,7 +22,7 @@ menuconfig MTD_RAW_NAND
>>>  if MTD_RAW_NAND
>>>  
>>>  config MTD_NAND_ECC_SW_BCH
>>> -	tristate "Support software BCH ECC"
>>> +	bool "Support software BCH ECC"
>>>  	select BCH
>>>  	default n
>>>  	help  
>>
>> Should be fixed with the following diff squashed into:
>>
>> 51ef1d0b2095 ("mtd: nand: Clarify Kconfig entry for software BCH ECC algorithm")
>>
>> --->8---  
>> diff --git a/include/linux/mtd/nand_bch.h b/include/linux/mtd/nand_bch.h
>> index b8106651f807..06ce2b655c13 100644
>> --- a/include/linux/mtd/nand_bch.h
>> +++ b/include/linux/mtd/nand_bch.h
>> @@ -15,7 +15,7 @@ struct mtd_info;
>>  struct nand_chip;
>>  struct nand_bch_control;
>>  
>> -#if defined(CONFIG_MTD_NAND_ECC_BCH)
>> +#if defined(CONFIG_MTD_NAND_ECC_SW_BCH)
>>  
>>  static inline int mtd_nand_has_bch(void) { return 1; }
>>  
>> @@ -39,7 +39,7 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd);
>>   */
>>  void nand_bch_free(struct nand_bch_control *nbc);
>>  
>> -#else /* !CONFIG_MTD_NAND_ECC_BCH */
>> +#else /* !CONFIG_MTD_NAND_ECC_SW_BCH */
>>  
>>  static inline int mtd_nand_has_bch(void) { return 0; }
>>  
>> @@ -64,6 +64,6 @@ static inline struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
>>  
>>  static inline void nand_bch_free(struct nand_bch_control *nbc) {}
>>  
>> -#endif /* CONFIG_MTD_NAND_ECC_BCH */
>> +#endif /* CONFIG_MTD_NAND_ECC_SW_BCH */
>>  
>>  #endif /* __MTD_NAND_BCH_H__ */
> 
> Sorry, I didn't look at the right branch, this part of the code was
> correct, but we still have a problem to express the RAW_NAND(y) ->
> SW_BCH(y) dependency.

It seems this dependency is not always need,

case MTD_RAW_NAND set to y works well while CONFIG_MTD_NAND_ECC_SW_BCH is not set.

> 
> .
>
Boris Brezillon April 10, 2019, 2:29 p.m. UTC | #5
On Wed, 10 Apr 2019 22:22:16 +0800
YueHaibing <yuehaibing@huawei.com> wrote:

> On 2019/4/10 21:58, Boris Brezillon wrote:
> > On Wed, 10 Apr 2019 15:39:28 +0200
> > Boris Brezillon <boris.brezillon@collabora.com> wrote:
> >   
> >> On Wed, 10 Apr 2019 21:07:47 +0800
> >> Yue Haibing <yuehaibing@huawei.com> wrote:
> >>  
> >>> From: YueHaibing <yuehaibing@huawei.com>
> >>>
> >>> Fix gcc build error while CONFIG_MTD_NAND_ECC_SW_BCH
> >>> is set to module:
> >>>
> >>> drivers/mtd/nand/raw/nand_base.o: In function `nand_cleanup':
> >>> (.text+0xef6): undefined reference to `nand_bch_free'
> >>> drivers/mtd/nand/raw/nand_base.o: In function `nand_scan_tail':
> >>> nand_base.c:(.text+0xa101): undefined reference to `nand_bch_calculate_ecc'
> >>> nand_base.c:(.text+0xa120): undefined reference to `nand_bch_correct_data'
> >>> nand_base.c:(.text+0xa269): undefined reference to `nand_bch_init'
> >>>
> >>> CONFIG_MTD_NAND_ECC_SW_BCH should not be set to M,
> >>> because MTD_RAW_NAND need it while linked.
> >>>
> >>> Reported-by: Hulk Robot <hulkci@huawei.com>
> >>> Fixes: 193bd4002644 ("mtd: nand: add software BCH ECC support"    
> >>
> >> Nope, it's not this one that introduced the regression.
> >>
> >>
> >>  
> >>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> >>> ---
> >>>  drivers/mtd/nand/raw/Kconfig | 2 +-
> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>
> >>> diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
> >>> index 615d738..0500c42 100644
> >>> --- a/drivers/mtd/nand/raw/Kconfig
> >>> +++ b/drivers/mtd/nand/raw/Kconfig
> >>> @@ -22,7 +22,7 @@ menuconfig MTD_RAW_NAND
> >>>  if MTD_RAW_NAND
> >>>  
> >>>  config MTD_NAND_ECC_SW_BCH
> >>> -	tristate "Support software BCH ECC"
> >>> +	bool "Support software BCH ECC"
> >>>  	select BCH
> >>>  	default n
> >>>  	help    
> >>
> >> Should be fixed with the following diff squashed into:
> >>
> >> 51ef1d0b2095 ("mtd: nand: Clarify Kconfig entry for software BCH ECC algorithm")
> >>  
> >> --->8---    
> >> diff --git a/include/linux/mtd/nand_bch.h b/include/linux/mtd/nand_bch.h
> >> index b8106651f807..06ce2b655c13 100644
> >> --- a/include/linux/mtd/nand_bch.h
> >> +++ b/include/linux/mtd/nand_bch.h
> >> @@ -15,7 +15,7 @@ struct mtd_info;
> >>  struct nand_chip;
> >>  struct nand_bch_control;
> >>  
> >> -#if defined(CONFIG_MTD_NAND_ECC_BCH)
> >> +#if defined(CONFIG_MTD_NAND_ECC_SW_BCH)
> >>  
> >>  static inline int mtd_nand_has_bch(void) { return 1; }
> >>  
> >> @@ -39,7 +39,7 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd);
> >>   */
> >>  void nand_bch_free(struct nand_bch_control *nbc);
> >>  
> >> -#else /* !CONFIG_MTD_NAND_ECC_BCH */
> >> +#else /* !CONFIG_MTD_NAND_ECC_SW_BCH */
> >>  
> >>  static inline int mtd_nand_has_bch(void) { return 0; }
> >>  
> >> @@ -64,6 +64,6 @@ static inline struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
> >>  
> >>  static inline void nand_bch_free(struct nand_bch_control *nbc) {}
> >>  
> >> -#endif /* CONFIG_MTD_NAND_ECC_BCH */
> >> +#endif /* CONFIG_MTD_NAND_ECC_SW_BCH */
> >>  
> >>  #endif /* __MTD_NAND_BCH_H__ */  
> > 
> > Sorry, I didn't look at the right branch, this part of the code was
> > correct, but we still have a problem to express the RAW_NAND(y) ->
> > SW_BCH(y) dependency.  
> 
> It seems this dependency is not always need,
> 
> case MTD_RAW_NAND set to y works well while CONFIG_MTD_NAND_ECC_SW_BCH is not set.

Yes, I know, but forcing nand_bch to a be a boolean is not the right
solution either, hence my suggestion to use 'imply'.
Yue Haibing April 10, 2019, 3:03 p.m. UTC | #6
On 2019/4/10 22:29, Boris Brezillon wrote:
> On Wed, 10 Apr 2019 22:22:16 +0800
> YueHaibing <yuehaibing@huawei.com> wrote:
> 
>> On 2019/4/10 21:58, Boris Brezillon wrote:
>>> On Wed, 10 Apr 2019 15:39:28 +0200
>>> Boris Brezillon <boris.brezillon@collabora.com> wrote:
>>>   
>>>> On Wed, 10 Apr 2019 21:07:47 +0800
>>>> Yue Haibing <yuehaibing@huawei.com> wrote:
>>>>  
>>>>> From: YueHaibing <yuehaibing@huawei.com>
>>>>>
>>>>> Fix gcc build error while CONFIG_MTD_NAND_ECC_SW_BCH
>>>>> is set to module:
>>>>>
>>>>> drivers/mtd/nand/raw/nand_base.o: In function `nand_cleanup':
>>>>> (.text+0xef6): undefined reference to `nand_bch_free'
>>>>> drivers/mtd/nand/raw/nand_base.o: In function `nand_scan_tail':
>>>>> nand_base.c:(.text+0xa101): undefined reference to `nand_bch_calculate_ecc'
>>>>> nand_base.c:(.text+0xa120): undefined reference to `nand_bch_correct_data'
>>>>> nand_base.c:(.text+0xa269): undefined reference to `nand_bch_init'
>>>>>
>>>>> CONFIG_MTD_NAND_ECC_SW_BCH should not be set to M,
>>>>> because MTD_RAW_NAND need it while linked.
>>>>>
>>>>> Reported-by: Hulk Robot <hulkci@huawei.com>
>>>>> Fixes: 193bd4002644 ("mtd: nand: add software BCH ECC support"    
>>>>
>>>> Nope, it's not this one that introduced the regression.
>>>>
>>>>
>>>>  
>>>>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>>>>> ---
>>>>>  drivers/mtd/nand/raw/Kconfig | 2 +-
>>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
>>>>> index 615d738..0500c42 100644
>>>>> --- a/drivers/mtd/nand/raw/Kconfig
>>>>> +++ b/drivers/mtd/nand/raw/Kconfig
>>>>> @@ -22,7 +22,7 @@ menuconfig MTD_RAW_NAND
>>>>>  if MTD_RAW_NAND
>>>>>  
>>>>>  config MTD_NAND_ECC_SW_BCH
>>>>> -	tristate "Support software BCH ECC"
>>>>> +	bool "Support software BCH ECC"
>>>>>  	select BCH
>>>>>  	default n
>>>>>  	help    
>>>>
>>>> Should be fixed with the following diff squashed into:
>>>>
>>>> 51ef1d0b2095 ("mtd: nand: Clarify Kconfig entry for software BCH ECC algorithm")
>>>>  
>>>> --->8---    
>>>> diff --git a/include/linux/mtd/nand_bch.h b/include/linux/mtd/nand_bch.h
>>>> index b8106651f807..06ce2b655c13 100644
>>>> --- a/include/linux/mtd/nand_bch.h
>>>> +++ b/include/linux/mtd/nand_bch.h
>>>> @@ -15,7 +15,7 @@ struct mtd_info;
>>>>  struct nand_chip;
>>>>  struct nand_bch_control;
>>>>  
>>>> -#if defined(CONFIG_MTD_NAND_ECC_BCH)
>>>> +#if defined(CONFIG_MTD_NAND_ECC_SW_BCH)
>>>>  
>>>>  static inline int mtd_nand_has_bch(void) { return 1; }
>>>>  
>>>> @@ -39,7 +39,7 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd);
>>>>   */
>>>>  void nand_bch_free(struct nand_bch_control *nbc);
>>>>  
>>>> -#else /* !CONFIG_MTD_NAND_ECC_BCH */
>>>> +#else /* !CONFIG_MTD_NAND_ECC_SW_BCH */
>>>>  
>>>>  static inline int mtd_nand_has_bch(void) { return 0; }
>>>>  
>>>> @@ -64,6 +64,6 @@ static inline struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
>>>>  
>>>>  static inline void nand_bch_free(struct nand_bch_control *nbc) {}
>>>>  
>>>> -#endif /* CONFIG_MTD_NAND_ECC_BCH */
>>>> +#endif /* CONFIG_MTD_NAND_ECC_SW_BCH */
>>>>  
>>>>  #endif /* __MTD_NAND_BCH_H__ */  
>>>
>>> Sorry, I didn't look at the right branch, this part of the code was
>>> correct, but we still have a problem to express the RAW_NAND(y) ->
>>> SW_BCH(y) dependency.  
>>
>> It seems this dependency is not always need,
>>
>> case MTD_RAW_NAND set to y works well while CONFIG_MTD_NAND_ECC_SW_BCH is not set.
> 
> Yes, I know, but forcing nand_bch to a be a boolean is not the right
> solution either, hence my suggestion to use 'imply'.

Got it, Thanks, will send v2 as your suggestion.

> 
> .
>
Miquel Raynal April 10, 2019, 4:18 p.m. UTC | #7
Hi YueHaibing,

YueHaibing <yuehaibing@huawei.com> wrote on Wed, 10 Apr 2019 23:03:24
+0800:

> On 2019/4/10 22:29, Boris Brezillon wrote:
> > On Wed, 10 Apr 2019 22:22:16 +0800
> > YueHaibing <yuehaibing@huawei.com> wrote:
> >   
> >> On 2019/4/10 21:58, Boris Brezillon wrote:  
> >>> On Wed, 10 Apr 2019 15:39:28 +0200
> >>> Boris Brezillon <boris.brezillon@collabora.com> wrote:
> >>>     
> >>>> On Wed, 10 Apr 2019 21:07:47 +0800
> >>>> Yue Haibing <yuehaibing@huawei.com> wrote:
> >>>>    
> >>>>> From: YueHaibing <yuehaibing@huawei.com>
> >>>>>
> >>>>> Fix gcc build error while CONFIG_MTD_NAND_ECC_SW_BCH
> >>>>> is set to module:
> >>>>>
> >>>>> drivers/mtd/nand/raw/nand_base.o: In function `nand_cleanup':
> >>>>> (.text+0xef6): undefined reference to `nand_bch_free'
> >>>>> drivers/mtd/nand/raw/nand_base.o: In function `nand_scan_tail':
> >>>>> nand_base.c:(.text+0xa101): undefined reference to `nand_bch_calculate_ecc'
> >>>>> nand_base.c:(.text+0xa120): undefined reference to `nand_bch_correct_data'
> >>>>> nand_base.c:(.text+0xa269): undefined reference to `nand_bch_init'
> >>>>>
> >>>>> CONFIG_MTD_NAND_ECC_SW_BCH should not be set to M,
> >>>>> because MTD_RAW_NAND need it while linked.
> >>>>>
> >>>>> Reported-by: Hulk Robot <hulkci@huawei.com>
> >>>>> Fixes: 193bd4002644 ("mtd: nand: add software BCH ECC support"      
> >>>>
> >>>> Nope, it's not this one that introduced the regression.
> >>>>
> >>>>
> >>>>    
> >>>>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> >>>>> ---
> >>>>>  drivers/mtd/nand/raw/Kconfig | 2 +-
> >>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>>>
> >>>>> diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
> >>>>> index 615d738..0500c42 100644
> >>>>> --- a/drivers/mtd/nand/raw/Kconfig
> >>>>> +++ b/drivers/mtd/nand/raw/Kconfig
> >>>>> @@ -22,7 +22,7 @@ menuconfig MTD_RAW_NAND
> >>>>>  if MTD_RAW_NAND
> >>>>>  
> >>>>>  config MTD_NAND_ECC_SW_BCH
> >>>>> -	tristate "Support software BCH ECC"
> >>>>> +	bool "Support software BCH ECC"
> >>>>>  	select BCH
> >>>>>  	default n
> >>>>>  	help      
> >>>>
> >>>> Should be fixed with the following diff squashed into:
> >>>>
> >>>> 51ef1d0b2095 ("mtd: nand: Clarify Kconfig entry for software BCH ECC algorithm")
> >>>>    
> >>>> --->8---      
> >>>> diff --git a/include/linux/mtd/nand_bch.h b/include/linux/mtd/nand_bch.h
> >>>> index b8106651f807..06ce2b655c13 100644
> >>>> --- a/include/linux/mtd/nand_bch.h
> >>>> +++ b/include/linux/mtd/nand_bch.h
> >>>> @@ -15,7 +15,7 @@ struct mtd_info;
> >>>>  struct nand_chip;
> >>>>  struct nand_bch_control;
> >>>>  
> >>>> -#if defined(CONFIG_MTD_NAND_ECC_BCH)
> >>>> +#if defined(CONFIG_MTD_NAND_ECC_SW_BCH)
> >>>>  
> >>>>  static inline int mtd_nand_has_bch(void) { return 1; }
> >>>>  
> >>>> @@ -39,7 +39,7 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd);
> >>>>   */
> >>>>  void nand_bch_free(struct nand_bch_control *nbc);
> >>>>  
> >>>> -#else /* !CONFIG_MTD_NAND_ECC_BCH */
> >>>> +#else /* !CONFIG_MTD_NAND_ECC_SW_BCH */
> >>>>  
> >>>>  static inline int mtd_nand_has_bch(void) { return 0; }
> >>>>  
> >>>> @@ -64,6 +64,6 @@ static inline struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
> >>>>  
> >>>>  static inline void nand_bch_free(struct nand_bch_control *nbc) {}
> >>>>  
> >>>> -#endif /* CONFIG_MTD_NAND_ECC_BCH */
> >>>> +#endif /* CONFIG_MTD_NAND_ECC_SW_BCH */
> >>>>  
> >>>>  #endif /* __MTD_NAND_BCH_H__ */    
> >>>
> >>> Sorry, I didn't look at the right branch, this part of the code was
> >>> correct, but we still have a problem to express the RAW_NAND(y) ->
> >>> SW_BCH(y) dependency.    
> >>
> >> It seems this dependency is not always need,
> >>
> >> case MTD_RAW_NAND set to y works well while CONFIG_MTD_NAND_ECC_SW_BCH is not set.  
> > 
> > Yes, I know, but forcing nand_bch to a be a boolean is not the right
> > solution either, hence my suggestion to use 'imply'.  

Why exactly? SW BCH is going to be converted to the generic ECC engine
abstraction and IIRC you told me that it would not be problematic to
turn it into a boolean?


Thanks,
Miquèl
Boris Brezillon April 10, 2019, 5:03 p.m. UTC | #8
On Wed, 10 Apr 2019 18:18:43 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> Hi YueHaibing,
> 
> YueHaibing <yuehaibing@huawei.com> wrote on Wed, 10 Apr 2019 23:03:24
> +0800:
> 
> > On 2019/4/10 22:29, Boris Brezillon wrote:  
> > > On Wed, 10 Apr 2019 22:22:16 +0800
> > > YueHaibing <yuehaibing@huawei.com> wrote:
> > >     
> > >> On 2019/4/10 21:58, Boris Brezillon wrote:    
> > >>> On Wed, 10 Apr 2019 15:39:28 +0200
> > >>> Boris Brezillon <boris.brezillon@collabora.com> wrote:
> > >>>       
> > >>>> On Wed, 10 Apr 2019 21:07:47 +0800
> > >>>> Yue Haibing <yuehaibing@huawei.com> wrote:
> > >>>>      
> > >>>>> From: YueHaibing <yuehaibing@huawei.com>
> > >>>>>
> > >>>>> Fix gcc build error while CONFIG_MTD_NAND_ECC_SW_BCH
> > >>>>> is set to module:
> > >>>>>
> > >>>>> drivers/mtd/nand/raw/nand_base.o: In function `nand_cleanup':
> > >>>>> (.text+0xef6): undefined reference to `nand_bch_free'
> > >>>>> drivers/mtd/nand/raw/nand_base.o: In function `nand_scan_tail':
> > >>>>> nand_base.c:(.text+0xa101): undefined reference to `nand_bch_calculate_ecc'
> > >>>>> nand_base.c:(.text+0xa120): undefined reference to `nand_bch_correct_data'
> > >>>>> nand_base.c:(.text+0xa269): undefined reference to `nand_bch_init'
> > >>>>>
> > >>>>> CONFIG_MTD_NAND_ECC_SW_BCH should not be set to M,
> > >>>>> because MTD_RAW_NAND need it while linked.
> > >>>>>
> > >>>>> Reported-by: Hulk Robot <hulkci@huawei.com>
> > >>>>> Fixes: 193bd4002644 ("mtd: nand: add software BCH ECC support"        
> > >>>>
> > >>>> Nope, it's not this one that introduced the regression.
> > >>>>
> > >>>>
> > >>>>      
> > >>>>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> > >>>>> ---
> > >>>>>  drivers/mtd/nand/raw/Kconfig | 2 +-
> > >>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
> > >>>>>
> > >>>>> diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
> > >>>>> index 615d738..0500c42 100644
> > >>>>> --- a/drivers/mtd/nand/raw/Kconfig
> > >>>>> +++ b/drivers/mtd/nand/raw/Kconfig
> > >>>>> @@ -22,7 +22,7 @@ menuconfig MTD_RAW_NAND
> > >>>>>  if MTD_RAW_NAND
> > >>>>>  
> > >>>>>  config MTD_NAND_ECC_SW_BCH
> > >>>>> -	tristate "Support software BCH ECC"
> > >>>>> +	bool "Support software BCH ECC"
> > >>>>>  	select BCH
> > >>>>>  	default n
> > >>>>>  	help        
> > >>>>
> > >>>> Should be fixed with the following diff squashed into:
> > >>>>
> > >>>> 51ef1d0b2095 ("mtd: nand: Clarify Kconfig entry for software BCH ECC algorithm")
> > >>>>      
> > >>>> --->8---        
> > >>>> diff --git a/include/linux/mtd/nand_bch.h b/include/linux/mtd/nand_bch.h
> > >>>> index b8106651f807..06ce2b655c13 100644
> > >>>> --- a/include/linux/mtd/nand_bch.h
> > >>>> +++ b/include/linux/mtd/nand_bch.h
> > >>>> @@ -15,7 +15,7 @@ struct mtd_info;
> > >>>>  struct nand_chip;
> > >>>>  struct nand_bch_control;
> > >>>>  
> > >>>> -#if defined(CONFIG_MTD_NAND_ECC_BCH)
> > >>>> +#if defined(CONFIG_MTD_NAND_ECC_SW_BCH)
> > >>>>  
> > >>>>  static inline int mtd_nand_has_bch(void) { return 1; }
> > >>>>  
> > >>>> @@ -39,7 +39,7 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd);
> > >>>>   */
> > >>>>  void nand_bch_free(struct nand_bch_control *nbc);
> > >>>>  
> > >>>> -#else /* !CONFIG_MTD_NAND_ECC_BCH */
> > >>>> +#else /* !CONFIG_MTD_NAND_ECC_SW_BCH */
> > >>>>  
> > >>>>  static inline int mtd_nand_has_bch(void) { return 0; }
> > >>>>  
> > >>>> @@ -64,6 +64,6 @@ static inline struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
> > >>>>  
> > >>>>  static inline void nand_bch_free(struct nand_bch_control *nbc) {}
> > >>>>  
> > >>>> -#endif /* CONFIG_MTD_NAND_ECC_BCH */
> > >>>> +#endif /* CONFIG_MTD_NAND_ECC_SW_BCH */
> > >>>>  
> > >>>>  #endif /* __MTD_NAND_BCH_H__ */      
> > >>>
> > >>> Sorry, I didn't look at the right branch, this part of the code was
> > >>> correct, but we still have a problem to express the RAW_NAND(y) ->
> > >>> SW_BCH(y) dependency.      
> > >>
> > >> It seems this dependency is not always need,
> > >>
> > >> case MTD_RAW_NAND set to y works well while CONFIG_MTD_NAND_ECC_SW_BCH is not set.    
> > > 
> > > Yes, I know, but forcing nand_bch to a be a boolean is not the right
> > > solution either, hence my suggestion to use 'imply'.    
> 
> Why exactly? SW BCH is going to be converted to the generic ECC engine
> abstraction and IIRC you told me that it would not be problematic to
> turn it into a boolean?

Yes, I told you we should turn it into a boolean and embed the code in
the nandcore.o object which can itself be linked as a module or embedded
in the kernel image (see above for a version adapted for nand.o). That's
not exactly what Yue proposed.

--->8---
diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
index 7fcdaf6c279d..f9258d666846 100644
--- a/drivers/mtd/devices/Kconfig
+++ b/drivers/mtd/devices/Kconfig
@@ -207,7 +207,7 @@ comment "Disk-On-Chip Device Drivers"
 config MTD_DOCG3
        tristate "M-Systems Disk-On-Chip G3"
        select BCH
-       select BCH_CONST_PARAMS if !CONFIG_MTD_NAND_ECC_SW_BCH
+       select BCH_CONST_PARAMS if !MTD_NAND_ECC_SW_BCH
        select BITREVERSE
        help
          This provides an MTD device driver for the M-Systems DiskOnChip
diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index 615d738be411..0500c42f31cb 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -22,7 +22,7 @@ menuconfig MTD_RAW_NAND
 if MTD_RAW_NAND
 
 config MTD_NAND_ECC_SW_BCH
-       tristate "Support software BCH ECC"
+       bool "Support software BCH ECC"
        select BCH
        default n
        help
diff --git a/drivers/mtd/nand/raw/Makefile b/drivers/mtd/nand/raw/Makefile
index 8bc6faaa3bc7..d644185fa18d 100644
--- a/drivers/mtd/nand/raw/Makefile
+++ b/drivers/mtd/nand/raw/Makefile
@@ -2,7 +2,6 @@
 
 obj-$(CONFIG_MTD_RAW_NAND)             += nand.o
 obj-$(CONFIG_MTD_NAND_ECC_SW_HAMMING)  += nand_ecc.o
-obj-$(CONFIG_MTD_NAND_ECC_SW_BCH)      += nand_bch.o
 obj-$(CONFIG_MTD_SM_COMMON)            += sm_common.o
 
 obj-$(CONFIG_MTD_NAND_CAFE)            += cafe_nand.o
@@ -68,3 +67,5 @@ nand-objs += nand_macronix.o
 nand-objs += nand_micron.o
 nand-objs += nand_samsung.o
 nand-objs += nand_toshiba.o
+nand-objs-$(CONFIG_MTD_NAND_ECC_SW_BCH)        += nand_bch.o
+nand-objs += $(nand-objs-y)
Yue Haibing April 12, 2019, 2:28 p.m. UTC | #9
On 2019/4/11 1:03, Boris Brezillon wrote:
> On Wed, 10 Apr 2019 18:18:43 +0200
> Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> 
>> Hi YueHaibing,
>>
>> YueHaibing <yuehaibing@huawei.com> wrote on Wed, 10 Apr 2019 23:03:24
>> +0800:
>>
>>> On 2019/4/10 22:29, Boris Brezillon wrote:  
>>>> On Wed, 10 Apr 2019 22:22:16 +0800
>>>> YueHaibing <yuehaibing@huawei.com> wrote:
>>>>     
>>>>> On 2019/4/10 21:58, Boris Brezillon wrote:    
>>>>>> On Wed, 10 Apr 2019 15:39:28 +0200
>>>>>> Boris Brezillon <boris.brezillon@collabora.com> wrote:
>>>>>>       
>>>>>>> On Wed, 10 Apr 2019 21:07:47 +0800
>>>>>>> Yue Haibing <yuehaibing@huawei.com> wrote:
>>>>>>>      
>>>>>>>> From: YueHaibing <yuehaibing@huawei.com>
>>>>>>>>
>>>>>>>> Fix gcc build error while CONFIG_MTD_NAND_ECC_SW_BCH
>>>>>>>> is set to module:
>>>>>>>>
>>>>>>>> drivers/mtd/nand/raw/nand_base.o: In function `nand_cleanup':
>>>>>>>> (.text+0xef6): undefined reference to `nand_bch_free'
>>>>>>>> drivers/mtd/nand/raw/nand_base.o: In function `nand_scan_tail':
>>>>>>>> nand_base.c:(.text+0xa101): undefined reference to `nand_bch_calculate_ecc'
>>>>>>>> nand_base.c:(.text+0xa120): undefined reference to `nand_bch_correct_data'
>>>>>>>> nand_base.c:(.text+0xa269): undefined reference to `nand_bch_init'
>>>>>>>>
>>>>>>>> CONFIG_MTD_NAND_ECC_SW_BCH should not be set to M,
>>>>>>>> because MTD_RAW_NAND need it while linked.
>>>>>>>>
>>>>>>>> Reported-by: Hulk Robot <hulkci@huawei.com>
>>>>>>>> Fixes: 193bd4002644 ("mtd: nand: add software BCH ECC support"        
>>>>>>>
>>>>>>> Nope, it's not this one that introduced the regression.
>>>>>>>
>>>>>>>
>>>>>>>      
>>>>>>>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>>>>>>>> ---
>>>>>>>>  drivers/mtd/nand/raw/Kconfig | 2 +-
>>>>>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>>>>
>>>>>>>> diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
>>>>>>>> index 615d738..0500c42 100644
>>>>>>>> --- a/drivers/mtd/nand/raw/Kconfig
>>>>>>>> +++ b/drivers/mtd/nand/raw/Kconfig
>>>>>>>> @@ -22,7 +22,7 @@ menuconfig MTD_RAW_NAND
>>>>>>>>  if MTD_RAW_NAND
>>>>>>>>  
>>>>>>>>  config MTD_NAND_ECC_SW_BCH
>>>>>>>> -	tristate "Support software BCH ECC"
>>>>>>>> +	bool "Support software BCH ECC"
>>>>>>>>  	select BCH
>>>>>>>>  	default n
>>>>>>>>  	help        
>>>>>>>
>>>>>>> Should be fixed with the following diff squashed into:
>>>>>>>
>>>>>>> 51ef1d0b2095 ("mtd: nand: Clarify Kconfig entry for software BCH ECC algorithm")
>>>>>>>      
>>>>>>> --->8---        
>>>>>>> diff --git a/include/linux/mtd/nand_bch.h b/include/linux/mtd/nand_bch.h
>>>>>>> index b8106651f807..06ce2b655c13 100644
>>>>>>> --- a/include/linux/mtd/nand_bch.h
>>>>>>> +++ b/include/linux/mtd/nand_bch.h
>>>>>>> @@ -15,7 +15,7 @@ struct mtd_info;
>>>>>>>  struct nand_chip;
>>>>>>>  struct nand_bch_control;
>>>>>>>  
>>>>>>> -#if defined(CONFIG_MTD_NAND_ECC_BCH)
>>>>>>> +#if defined(CONFIG_MTD_NAND_ECC_SW_BCH)
>>>>>>>  
>>>>>>>  static inline int mtd_nand_has_bch(void) { return 1; }
>>>>>>>  
>>>>>>> @@ -39,7 +39,7 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd);
>>>>>>>   */
>>>>>>>  void nand_bch_free(struct nand_bch_control *nbc);
>>>>>>>  
>>>>>>> -#else /* !CONFIG_MTD_NAND_ECC_BCH */
>>>>>>> +#else /* !CONFIG_MTD_NAND_ECC_SW_BCH */
>>>>>>>  
>>>>>>>  static inline int mtd_nand_has_bch(void) { return 0; }
>>>>>>>  
>>>>>>> @@ -64,6 +64,6 @@ static inline struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
>>>>>>>  
>>>>>>>  static inline void nand_bch_free(struct nand_bch_control *nbc) {}
>>>>>>>  
>>>>>>> -#endif /* CONFIG_MTD_NAND_ECC_BCH */
>>>>>>> +#endif /* CONFIG_MTD_NAND_ECC_SW_BCH */
>>>>>>>  
>>>>>>>  #endif /* __MTD_NAND_BCH_H__ */      
>>>>>>
>>>>>> Sorry, I didn't look at the right branch, this part of the code was
>>>>>> correct, but we still have a problem to express the RAW_NAND(y) ->
>>>>>> SW_BCH(y) dependency.      
>>>>>
>>>>> It seems this dependency is not always need,
>>>>>
>>>>> case MTD_RAW_NAND set to y works well while CONFIG_MTD_NAND_ECC_SW_BCH is not set.    
>>>>
>>>> Yes, I know, but forcing nand_bch to a be a boolean is not the right
>>>> solution either, hence my suggestion to use 'imply'.    
>>
>> Why exactly? SW BCH is going to be converted to the generic ECC engine
>> abstraction and IIRC you told me that it would not be problematic to
>> turn it into a boolean?
> 
> Yes, I told you we should turn it into a boolean and embed the code in
> the nandcore.o object which can itself be linked as a module or embedded
> in the kernel image (see above for a version adapted for nand.o). That's
> not exactly what Yue proposed.

So is there anothor fix or just to pick my v2 ?

https://patchwork.ozlabs.org/patch/1083480/

> 
> --->8---
> diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
> index 7fcdaf6c279d..f9258d666846 100644
> --- a/drivers/mtd/devices/Kconfig
> +++ b/drivers/mtd/devices/Kconfig
> @@ -207,7 +207,7 @@ comment "Disk-On-Chip Device Drivers"
>  config MTD_DOCG3
>         tristate "M-Systems Disk-On-Chip G3"
>         select BCH
> -       select BCH_CONST_PARAMS if !CONFIG_MTD_NAND_ECC_SW_BCH
> +       select BCH_CONST_PARAMS if !MTD_NAND_ECC_SW_BCH
>         select BITREVERSE
>         help
>           This provides an MTD device driver for the M-Systems DiskOnChip
> diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
> index 615d738be411..0500c42f31cb 100644
> --- a/drivers/mtd/nand/raw/Kconfig
> +++ b/drivers/mtd/nand/raw/Kconfig
> @@ -22,7 +22,7 @@ menuconfig MTD_RAW_NAND
>  if MTD_RAW_NAND
>  
>  config MTD_NAND_ECC_SW_BCH
> -       tristate "Support software BCH ECC"
> +       bool "Support software BCH ECC"
>         select BCH
>         default n
>         help
> diff --git a/drivers/mtd/nand/raw/Makefile b/drivers/mtd/nand/raw/Makefile
> index 8bc6faaa3bc7..d644185fa18d 100644
> --- a/drivers/mtd/nand/raw/Makefile
> +++ b/drivers/mtd/nand/raw/Makefile
> @@ -2,7 +2,6 @@
>  
>  obj-$(CONFIG_MTD_RAW_NAND)             += nand.o
>  obj-$(CONFIG_MTD_NAND_ECC_SW_HAMMING)  += nand_ecc.o
> -obj-$(CONFIG_MTD_NAND_ECC_SW_BCH)      += nand_bch.o
>  obj-$(CONFIG_MTD_SM_COMMON)            += sm_common.o
>  
>  obj-$(CONFIG_MTD_NAND_CAFE)            += cafe_nand.o
> @@ -68,3 +67,5 @@ nand-objs += nand_macronix.o
>  nand-objs += nand_micron.o
>  nand-objs += nand_samsung.o
>  nand-objs += nand_toshiba.o
> +nand-objs-$(CONFIG_MTD_NAND_ECC_SW_BCH)        += nand_bch.o
> +nand-objs += $(nand-objs-y)
> 
> 
> 
> .
>
Boris Brezillon April 12, 2019, 3:04 p.m. UTC | #10
On Fri, 12 Apr 2019 22:28:57 +0800
YueHaibing <yuehaibing@huawei.com> wrote:

> On 2019/4/11 1:03, Boris Brezillon wrote:
> > On Wed, 10 Apr 2019 18:18:43 +0200
> > Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> >   
> >> Hi YueHaibing,
> >>
> >> YueHaibing <yuehaibing@huawei.com> wrote on Wed, 10 Apr 2019 23:03:24
> >> +0800:
> >>  
> >>> On 2019/4/10 22:29, Boris Brezillon wrote:    
> >>>> On Wed, 10 Apr 2019 22:22:16 +0800
> >>>> YueHaibing <yuehaibing@huawei.com> wrote:
> >>>>       
> >>>>> On 2019/4/10 21:58, Boris Brezillon wrote:      
> >>>>>> On Wed, 10 Apr 2019 15:39:28 +0200
> >>>>>> Boris Brezillon <boris.brezillon@collabora.com> wrote:
> >>>>>>         
> >>>>>>> On Wed, 10 Apr 2019 21:07:47 +0800
> >>>>>>> Yue Haibing <yuehaibing@huawei.com> wrote:
> >>>>>>>        
> >>>>>>>> From: YueHaibing <yuehaibing@huawei.com>
> >>>>>>>>
> >>>>>>>> Fix gcc build error while CONFIG_MTD_NAND_ECC_SW_BCH
> >>>>>>>> is set to module:
> >>>>>>>>
> >>>>>>>> drivers/mtd/nand/raw/nand_base.o: In function `nand_cleanup':
> >>>>>>>> (.text+0xef6): undefined reference to `nand_bch_free'
> >>>>>>>> drivers/mtd/nand/raw/nand_base.o: In function `nand_scan_tail':
> >>>>>>>> nand_base.c:(.text+0xa101): undefined reference to `nand_bch_calculate_ecc'
> >>>>>>>> nand_base.c:(.text+0xa120): undefined reference to `nand_bch_correct_data'
> >>>>>>>> nand_base.c:(.text+0xa269): undefined reference to `nand_bch_init'
> >>>>>>>>
> >>>>>>>> CONFIG_MTD_NAND_ECC_SW_BCH should not be set to M,
> >>>>>>>> because MTD_RAW_NAND need it while linked.
> >>>>>>>>
> >>>>>>>> Reported-by: Hulk Robot <hulkci@huawei.com>
> >>>>>>>> Fixes: 193bd4002644 ("mtd: nand: add software BCH ECC support"          
> >>>>>>>
> >>>>>>> Nope, it's not this one that introduced the regression.
> >>>>>>>
> >>>>>>>
> >>>>>>>        
> >>>>>>>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> >>>>>>>> ---
> >>>>>>>>  drivers/mtd/nand/raw/Kconfig | 2 +-
> >>>>>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>>>>>>
> >>>>>>>> diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
> >>>>>>>> index 615d738..0500c42 100644
> >>>>>>>> --- a/drivers/mtd/nand/raw/Kconfig
> >>>>>>>> +++ b/drivers/mtd/nand/raw/Kconfig
> >>>>>>>> @@ -22,7 +22,7 @@ menuconfig MTD_RAW_NAND
> >>>>>>>>  if MTD_RAW_NAND
> >>>>>>>>  
> >>>>>>>>  config MTD_NAND_ECC_SW_BCH
> >>>>>>>> -	tristate "Support software BCH ECC"
> >>>>>>>> +	bool "Support software BCH ECC"
> >>>>>>>>  	select BCH
> >>>>>>>>  	default n
> >>>>>>>>  	help          
> >>>>>>>
> >>>>>>> Should be fixed with the following diff squashed into:
> >>>>>>>
> >>>>>>> 51ef1d0b2095 ("mtd: nand: Clarify Kconfig entry for software BCH ECC algorithm")
> >>>>>>>        
> >>>>>>> --->8---          
> >>>>>>> diff --git a/include/linux/mtd/nand_bch.h b/include/linux/mtd/nand_bch.h
> >>>>>>> index b8106651f807..06ce2b655c13 100644
> >>>>>>> --- a/include/linux/mtd/nand_bch.h
> >>>>>>> +++ b/include/linux/mtd/nand_bch.h
> >>>>>>> @@ -15,7 +15,7 @@ struct mtd_info;
> >>>>>>>  struct nand_chip;
> >>>>>>>  struct nand_bch_control;
> >>>>>>>  
> >>>>>>> -#if defined(CONFIG_MTD_NAND_ECC_BCH)
> >>>>>>> +#if defined(CONFIG_MTD_NAND_ECC_SW_BCH)
> >>>>>>>  
> >>>>>>>  static inline int mtd_nand_has_bch(void) { return 1; }
> >>>>>>>  
> >>>>>>> @@ -39,7 +39,7 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd);
> >>>>>>>   */
> >>>>>>>  void nand_bch_free(struct nand_bch_control *nbc);
> >>>>>>>  
> >>>>>>> -#else /* !CONFIG_MTD_NAND_ECC_BCH */
> >>>>>>> +#else /* !CONFIG_MTD_NAND_ECC_SW_BCH */
> >>>>>>>  
> >>>>>>>  static inline int mtd_nand_has_bch(void) { return 0; }
> >>>>>>>  
> >>>>>>> @@ -64,6 +64,6 @@ static inline struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
> >>>>>>>  
> >>>>>>>  static inline void nand_bch_free(struct nand_bch_control *nbc) {}
> >>>>>>>  
> >>>>>>> -#endif /* CONFIG_MTD_NAND_ECC_BCH */
> >>>>>>> +#endif /* CONFIG_MTD_NAND_ECC_SW_BCH */
> >>>>>>>  
> >>>>>>>  #endif /* __MTD_NAND_BCH_H__ */        
> >>>>>>
> >>>>>> Sorry, I didn't look at the right branch, this part of the code was
> >>>>>> correct, but we still have a problem to express the RAW_NAND(y) ->
> >>>>>> SW_BCH(y) dependency.        
> >>>>>
> >>>>> It seems this dependency is not always need,
> >>>>>
> >>>>> case MTD_RAW_NAND set to y works well while CONFIG_MTD_NAND_ECC_SW_BCH is not set.      
> >>>>
> >>>> Yes, I know, but forcing nand_bch to a be a boolean is not the right
> >>>> solution either, hence my suggestion to use 'imply'.      
> >>
> >> Why exactly? SW BCH is going to be converted to the generic ECC engine
> >> abstraction and IIRC you told me that it would not be problematic to
> >> turn it into a boolean?  
> > 
> > Yes, I told you we should turn it into a boolean and embed the code in
> > the nandcore.o object which can itself be linked as a module or embedded
> > in the kernel image (see above for a version adapted for nand.o). That's
> > not exactly what Yue proposed.  
> 
> So is there anothor fix or just to pick my v2 ?
> 
> https://patchwork.ozlabs.org/patch/1083480/


Looks like someone posted it already:

https://patchwork.ozlabs.org/patch/1083603/
Yue Haibing April 12, 2019, 3:23 p.m. UTC | #11
On 2019/4/12 23:04, Boris Brezillon wrote:
> On Fri, 12 Apr 2019 22:28:57 +0800
> YueHaibing <yuehaibing@huawei.com> wrote:
> 
>> On 2019/4/11 1:03, Boris Brezillon wrote:
>>> On Wed, 10 Apr 2019 18:18:43 +0200
>>> Miquel Raynal <miquel.raynal@bootlin.com> wrote:
>>>   
>>>> Hi YueHaibing,
>>>>
>>>> YueHaibing <yuehaibing@huawei.com> wrote on Wed, 10 Apr 2019 23:03:24
>>>> +0800:
>>>>  
>>>>> On 2019/4/10 22:29, Boris Brezillon wrote:    
>>>>>> On Wed, 10 Apr 2019 22:22:16 +0800
>>>>>> YueHaibing <yuehaibing@huawei.com> wrote:
>>>>>>       
>>>>>>> On 2019/4/10 21:58, Boris Brezillon wrote:      
>>>>>>>> On Wed, 10 Apr 2019 15:39:28 +0200
>>>>>>>> Boris Brezillon <boris.brezillon@collabora.com> wrote:
>>>>>>>>         
>>>>>>>>> On Wed, 10 Apr 2019 21:07:47 +0800
>>>>>>>>> Yue Haibing <yuehaibing@huawei.com> wrote:
>>>>>>>>>        
>>>>>>>>>> From: YueHaibing <yuehaibing@huawei.com>
>>>>>>>>>>
>>>>>>>>>> Fix gcc build error while CONFIG_MTD_NAND_ECC_SW_BCH
>>>>>>>>>> is set to module:
>>>>>>>>>>
>>>>>>>>>> drivers/mtd/nand/raw/nand_base.o: In function `nand_cleanup':
>>>>>>>>>> (.text+0xef6): undefined reference to `nand_bch_free'
>>>>>>>>>> drivers/mtd/nand/raw/nand_base.o: In function `nand_scan_tail':
>>>>>>>>>> nand_base.c:(.text+0xa101): undefined reference to `nand_bch_calculate_ecc'
>>>>>>>>>> nand_base.c:(.text+0xa120): undefined reference to `nand_bch_correct_data'
>>>>>>>>>> nand_base.c:(.text+0xa269): undefined reference to `nand_bch_init'
>>>>>>>>>>
>>>>>>>>>> CONFIG_MTD_NAND_ECC_SW_BCH should not be set to M,
>>>>>>>>>> because MTD_RAW_NAND need it while linked.
>>>>>>>>>>
>>>>>>>>>> Reported-by: Hulk Robot <hulkci@huawei.com>
>>>>>>>>>> Fixes: 193bd4002644 ("mtd: nand: add software BCH ECC support"          
>>>>>>>>>
>>>>>>>>> Nope, it's not this one that introduced the regression.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>        
>>>>>>>>>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>>>>>>>>>> ---
>>>>>>>>>>  drivers/mtd/nand/raw/Kconfig | 2 +-
>>>>>>>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>>>>>>
>>>>>>>>>> diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
>>>>>>>>>> index 615d738..0500c42 100644
>>>>>>>>>> --- a/drivers/mtd/nand/raw/Kconfig
>>>>>>>>>> +++ b/drivers/mtd/nand/raw/Kconfig
>>>>>>>>>> @@ -22,7 +22,7 @@ menuconfig MTD_RAW_NAND
>>>>>>>>>>  if MTD_RAW_NAND
>>>>>>>>>>  
>>>>>>>>>>  config MTD_NAND_ECC_SW_BCH
>>>>>>>>>> -	tristate "Support software BCH ECC"
>>>>>>>>>> +	bool "Support software BCH ECC"
>>>>>>>>>>  	select BCH
>>>>>>>>>>  	default n
>>>>>>>>>>  	help          
>>>>>>>>>
>>>>>>>>> Should be fixed with the following diff squashed into:
>>>>>>>>>
>>>>>>>>> 51ef1d0b2095 ("mtd: nand: Clarify Kconfig entry for software BCH ECC algorithm")
>>>>>>>>>        
>>>>>>>>> --->8---          
>>>>>>>>> diff --git a/include/linux/mtd/nand_bch.h b/include/linux/mtd/nand_bch.h
>>>>>>>>> index b8106651f807..06ce2b655c13 100644
>>>>>>>>> --- a/include/linux/mtd/nand_bch.h
>>>>>>>>> +++ b/include/linux/mtd/nand_bch.h
>>>>>>>>> @@ -15,7 +15,7 @@ struct mtd_info;
>>>>>>>>>  struct nand_chip;
>>>>>>>>>  struct nand_bch_control;
>>>>>>>>>  
>>>>>>>>> -#if defined(CONFIG_MTD_NAND_ECC_BCH)
>>>>>>>>> +#if defined(CONFIG_MTD_NAND_ECC_SW_BCH)
>>>>>>>>>  
>>>>>>>>>  static inline int mtd_nand_has_bch(void) { return 1; }
>>>>>>>>>  
>>>>>>>>> @@ -39,7 +39,7 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd);
>>>>>>>>>   */
>>>>>>>>>  void nand_bch_free(struct nand_bch_control *nbc);
>>>>>>>>>  
>>>>>>>>> -#else /* !CONFIG_MTD_NAND_ECC_BCH */
>>>>>>>>> +#else /* !CONFIG_MTD_NAND_ECC_SW_BCH */
>>>>>>>>>  
>>>>>>>>>  static inline int mtd_nand_has_bch(void) { return 0; }
>>>>>>>>>  
>>>>>>>>> @@ -64,6 +64,6 @@ static inline struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
>>>>>>>>>  
>>>>>>>>>  static inline void nand_bch_free(struct nand_bch_control *nbc) {}
>>>>>>>>>  
>>>>>>>>> -#endif /* CONFIG_MTD_NAND_ECC_BCH */
>>>>>>>>> +#endif /* CONFIG_MTD_NAND_ECC_SW_BCH */
>>>>>>>>>  
>>>>>>>>>  #endif /* __MTD_NAND_BCH_H__ */        
>>>>>>>>
>>>>>>>> Sorry, I didn't look at the right branch, this part of the code was
>>>>>>>> correct, but we still have a problem to express the RAW_NAND(y) ->
>>>>>>>> SW_BCH(y) dependency.        
>>>>>>>
>>>>>>> It seems this dependency is not always need,
>>>>>>>
>>>>>>> case MTD_RAW_NAND set to y works well while CONFIG_MTD_NAND_ECC_SW_BCH is not set.      
>>>>>>
>>>>>> Yes, I know, but forcing nand_bch to a be a boolean is not the right
>>>>>> solution either, hence my suggestion to use 'imply'.      
>>>>
>>>> Why exactly? SW BCH is going to be converted to the generic ECC engine
>>>> abstraction and IIRC you told me that it would not be problematic to
>>>> turn it into a boolean?  
>>>
>>> Yes, I told you we should turn it into a boolean and embed the code in
>>> the nandcore.o object which can itself be linked as a module or embedded
>>> in the kernel image (see above for a version adapted for nand.o). That's
>>> not exactly what Yue proposed.  
>>
>> So is there anothor fix or just to pick my v2 ?
>>
>> https://patchwork.ozlabs.org/patch/1083480/
> 
> 
> Looks like someone posted it already:

Thanks!

> 
> https://patchwork.ozlabs.org/patch/1083603/
> 
> .
>
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index 615d738..0500c42 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -22,7 +22,7 @@  menuconfig MTD_RAW_NAND
 if MTD_RAW_NAND
 
 config MTD_NAND_ECC_SW_BCH
-	tristate "Support software BCH ECC"
+	bool "Support software BCH ECC"
 	select BCH
 	default n
 	help