linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtc: pcf2127: clear the flag TSF1 before enabling interrupt generation
@ 2020-12-01  8:47 Biwen Li
  2020-12-01 10:20 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Biwen Li @ 2020-12-01  8:47 UTC (permalink / raw)
  To: leoyang.li, alexandre.belloni, anson.huang, aisheng.dong
  Cc: linux-kernel, jiafei.pan, linux-rtc, Biwen Li

From: Biwen Li <biwen.li@nxp.com>

- clear the flag TSF1 before enabling interrupt generation
- properly set flag WD_CD for rtc chips(pcf2129, pca2129)

Signed-off-by: Biwen Li <biwen.li@nxp.com>
---
 drivers/rtc/rtc-pcf2127.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
index 07a5630ec841..0a45e2512258 100644
--- a/drivers/rtc/rtc-pcf2127.c
+++ b/drivers/rtc/rtc-pcf2127.c
@@ -601,6 +601,10 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
 	 * Watchdog timer enabled and reset pin /RST activated when timed out.
 	 * Select 1Hz clock source for watchdog timer.
 	 * Note: Countdown timer disabled and not available.
+	 * For pca2129, pcf2129, only bit[7] is for Symbol WD_CD
+	 * of register watchdg_tim_ctl. The bit[6] is labeled
+	 * as T. Bits labeled as T must always be written with
+	 * logic 0.
 	 */
 	ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_WD_CTL,
 				 PCF2127_BIT_WD_CTL_CD1 |
@@ -608,7 +612,7 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
 				 PCF2127_BIT_WD_CTL_TF1 |
 				 PCF2127_BIT_WD_CTL_TF0,
 				 PCF2127_BIT_WD_CTL_CD1 |
-				 PCF2127_BIT_WD_CTL_CD0 |
+				 has_nvmem ? (PCF2127_BIT_WD_CTL_CD0) : (0) |
 				 PCF2127_BIT_WD_CTL_TF1);
 	if (ret) {
 		dev_err(dev, "%s: watchdog config (wd_ctl) failed\n", __func__);
@@ -659,6 +663,21 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
 		return ret;
 	}
 
+	/*
+	 * Clear TSF1 field of ctrl1 register to clear interrupt
+	 * before enabling interrupt generation when
+	 * timestamp flag set. Unless the flag TSF1 won't
+	 * be cleared and the interrupt(INT pin) is
+	 * triggered continueously.
+	 */
+	ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_CTRL1,
+				 PCF2127_BIT_CTRL1_TSF1,
+				 0);
+	if (ret) {
+		dev_err(dev, "%s:  control and status register 1 (ctrl1) failed, ret = 0x%x\n",
+			__func__, ret);
+		return ret;
+	}
 	/*
 	 * Enable interrupt generation when TSF1 or TSF2 timestamp flags
 	 * are set. Interrupt signal is an open-drain output and can be
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] rtc: pcf2127: clear the flag TSF1 before enabling interrupt generation
  2020-12-01  8:47 [PATCH] rtc: pcf2127: clear the flag TSF1 before enabling interrupt generation Biwen Li
@ 2020-12-01 10:20 ` kernel test robot
  2020-12-01 11:02 ` Alexandre Belloni
  2020-12-02 17:10 ` kernel test robot
  2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2020-12-01 10:20 UTC (permalink / raw)
  To: Biwen Li, leoyang.li, alexandre.belloni, anson.huang, aisheng.dong
  Cc: kbuild-all, clang-built-linux, linux-kernel, jiafei.pan,
	linux-rtc, Biwen Li

[-- Attachment #1: Type: text/plain, Size: 8469 bytes --]

Hi Biwen,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on abelloni/rtc-next]
[also build test WARNING on v5.10-rc6 next-20201130]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Biwen-Li/rtc-pcf2127-clear-the-flag-TSF1-before-enabling-interrupt-generation/20201201-165409
base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next
config: mips-randconfig-r023-20201201 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project ac40a2d8f16b8a8c68fc811d67f647740e965cb8)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install mips cross compiling tool for clang build
        # apt-get install binutils-mips-linux-gnu
        # https://github.com/0day-ci/linux/commit/54db60db88e4fd3ab6ac26f9a5b4768316347f95
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Biwen-Li/rtc-pcf2127-clear-the-flag-TSF1-before-enabling-interrupt-generation/20201201-165409
        git checkout 54db60db88e4fd3ab6ac26f9a5b4768316347f95
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/rtc/rtc-pcf2127.c:629:16: warning: operator has lower precedence than '|'; '|' will be evaluated first
   has_nvmem (PCF2127_BIT_WD_CTL_CD0) : (0) |
   ~~~~~~~~~ ^
   drivers/rtc/rtc-pcf2127.c:629:16: note: place parentheses around the '|' expression to silence this warning
   has_nvmem (PCF2127_BIT_WD_CTL_CD0) : (0) |
   ~~~~~~~~~ ^
   drivers/rtc/rtc-pcf2127.c:629:16: note: place parentheses around the expression to evaluate it first
   has_nvmem (PCF2127_BIT_WD_CTL_CD0) : (0) |
   ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fatal error: error in backend: Nested variants found in inline asm string: ' .set push
   .set mips64r2
   .if ( 0x00 ) != -1)) 0x00 ) != -1)) : ($( static struct ftrace_branch_data __attribute__((__aligned__(4))) __attribute__((__section__("_ftrace_branch"))) __if_trace = $( .func = __func__, .file = "arch/mips/include/asm/bitops.h", .line = 105, $); 0x00 ) != -1)) : $))) ) && ( 0 ); .set push; .set mips64r2; .rept 1; sync 0x00; .endr; .set pop; .else; ; .endif
   1: ll $0, $1
   or $0, $2
   sc $0, $1
   beqz $0, 1b
   .set pop
   '
   clang-12: error: clang frontend command failed with exit code 70 (use -v to see invocation)
   clang version 12.0.0 (git://gitmirror/llvm_project ac40a2d8f16b8a8c68fc811d67f647740e965cb8)
   Target: mips-unknown-linux-gnu
   Thread model: posix
   InstalledDir: /opt/cross/clang-ac40a2d8f1/bin
   clang-12: note: diagnostic msg:
   Makefile arch drivers include kernel scripts source usr

vim +629 drivers/rtc/rtc-pcf2127.c

   560	
   561	static int pcf2127_probe(struct device *dev, struct regmap *regmap,
   562				 int alarm_irq, const char *name, bool has_nvmem)
   563	{
   564		struct pcf2127 *pcf2127;
   565		int ret = 0;
   566	
   567		dev_dbg(dev, "%s\n", __func__);
   568	
   569		pcf2127 = devm_kzalloc(dev, sizeof(*pcf2127), GFP_KERNEL);
   570		if (!pcf2127)
   571			return -ENOMEM;
   572	
   573		pcf2127->regmap = regmap;
   574	
   575		dev_set_drvdata(dev, pcf2127);
   576	
   577		pcf2127->rtc = devm_rtc_allocate_device(dev);
   578		if (IS_ERR(pcf2127->rtc))
   579			return PTR_ERR(pcf2127->rtc);
   580	
   581		pcf2127->rtc->ops = &pcf2127_rtc_ops;
   582		pcf2127->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
   583		pcf2127->rtc->range_max = RTC_TIMESTAMP_END_2099;
   584		pcf2127->rtc->set_start_time = true; /* Sets actual start to 1970 */
   585		pcf2127->rtc->uie_unsupported = 1;
   586	
   587		if (alarm_irq > 0) {
   588			ret = devm_request_threaded_irq(dev, alarm_irq, NULL,
   589							pcf2127_rtc_irq,
   590							IRQF_TRIGGER_LOW | IRQF_ONESHOT,
   591							dev_name(dev), dev);
   592			if (ret) {
   593				dev_err(dev, "failed to request alarm irq\n");
   594				return ret;
   595			}
   596		}
   597	
   598		if (alarm_irq > 0 || device_property_read_bool(dev, "wakeup-source")) {
   599			device_init_wakeup(dev, true);
   600			pcf2127->rtc->ops = &pcf2127_rtc_alrm_ops;
   601		}
   602	
   603		if (has_nvmem) {
   604			struct nvmem_config nvmem_cfg = {
   605				.priv = pcf2127,
   606				.reg_read = pcf2127_nvmem_read,
   607				.reg_write = pcf2127_nvmem_write,
   608				.size = 512,
   609			};
   610	
   611			ret = devm_rtc_nvmem_register(pcf2127->rtc, &nvmem_cfg);
   612		}
   613	
   614		/*
   615		 * Watchdog timer enabled and reset pin /RST activated when timed out.
   616		 * Select 1Hz clock source for watchdog timer.
   617		 * Note: Countdown timer disabled and not available.
   618		 * For pca2129, pcf2129, only bit[7] is for Symbol WD_CD
   619		 * of register watchdg_tim_ctl. The bit[6] is labeled
   620		 * as T. Bits labeled as T must always be written with
   621		 * logic 0.
   622		 */
   623		ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_WD_CTL,
   624					 PCF2127_BIT_WD_CTL_CD1 |
   625					 PCF2127_BIT_WD_CTL_CD0 |
   626					 PCF2127_BIT_WD_CTL_TF1 |
   627					 PCF2127_BIT_WD_CTL_TF0,
   628					 PCF2127_BIT_WD_CTL_CD1 |
 > 629					 has_nvmem ? (PCF2127_BIT_WD_CTL_CD0) : (0) |
   630					 PCF2127_BIT_WD_CTL_TF1);
   631		if (ret) {
   632			dev_err(dev, "%s: watchdog config (wd_ctl) failed\n", __func__);
   633			return ret;
   634		}
   635	
   636		pcf2127_watchdog_init(dev, pcf2127);
   637	
   638		/*
   639		 * Disable battery low/switch-over timestamp and interrupts.
   640		 * Clear battery interrupt flags which can block new trigger events.
   641		 * Note: This is the default chip behaviour but added to ensure
   642		 * correct tamper timestamp and interrupt function.
   643		 */
   644		ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_CTRL3,
   645					 PCF2127_BIT_CTRL3_BTSE |
   646					 PCF2127_BIT_CTRL3_BIE |
   647					 PCF2127_BIT_CTRL3_BLIE, 0);
   648		if (ret) {
   649			dev_err(dev, "%s: interrupt config (ctrl3) failed\n",
   650				__func__);
   651			return ret;
   652		}
   653	
   654		/*
   655		 * Enable timestamp function and store timestamp of first trigger
   656		 * event until TSF1 and TFS2 interrupt flags are cleared.
   657		 */
   658		ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_TS_CTRL,
   659					 PCF2127_BIT_TS_CTRL_TSOFF |
   660					 PCF2127_BIT_TS_CTRL_TSM,
   661					 PCF2127_BIT_TS_CTRL_TSM);
   662		if (ret) {
   663			dev_err(dev, "%s: tamper detection config (ts_ctrl) failed\n",
   664				__func__);
   665			return ret;
   666		}
   667	
   668		/*
   669		 * Clear TSF1 field of ctrl1 register to clear interrupt
   670		 * before enabling interrupt generation when
   671		 * timestamp flag set. Unless the flag TSF1 won't
   672		 * be cleared and the interrupt(INT pin) is
   673		 * triggered continueously.
   674		 */
   675		ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_CTRL1,
   676					 PCF2127_BIT_CTRL1_TSF1,
   677					 0);
   678		if (ret) {
   679			dev_err(dev, "%s:  control and status register 1 (ctrl1) failed, ret = 0x%x\n",
   680				__func__, ret);
   681			return ret;
   682		}
   683		/*
   684		 * Enable interrupt generation when TSF1 or TSF2 timestamp flags
   685		 * are set. Interrupt signal is an open-drain output and can be
   686		 * left floating if unused.
   687		 */
   688		ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_CTRL2,
   689					 PCF2127_BIT_CTRL2_TSIE,
   690					 PCF2127_BIT_CTRL2_TSIE);
   691		if (ret) {
   692			dev_err(dev, "%s: tamper detection config (ctrl2) failed\n",
   693				__func__);
   694			return ret;
   695		}
   696	
   697		ret = rtc_add_group(pcf2127->rtc, &pcf2127_attr_group);
   698		if (ret) {
   699			dev_err(dev, "%s: tamper sysfs registering failed\n",
   700				__func__);
   701			return ret;
   702		}
   703	
   704		return devm_rtc_register_device(pcf2127->rtc);
   705	}
   706	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 24405 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] rtc: pcf2127: clear the flag TSF1 before enabling interrupt generation
  2020-12-01  8:47 [PATCH] rtc: pcf2127: clear the flag TSF1 before enabling interrupt generation Biwen Li
  2020-12-01 10:20 ` kernel test robot
@ 2020-12-01 11:02 ` Alexandre Belloni
  2020-12-02  2:14   ` Biwen Li (OSS)
  2020-12-02 17:10 ` kernel test robot
  2 siblings, 1 reply; 5+ messages in thread
From: Alexandre Belloni @ 2020-12-01 11:02 UTC (permalink / raw)
  To: Biwen Li
  Cc: leoyang.li, anson.huang, aisheng.dong, linux-kernel, jiafei.pan,
	linux-rtc, Biwen Li

Hi,

On 01/12/2020 16:47:46+0800, Biwen Li wrote:
> From: Biwen Li <biwen.li@nxp.com>
> 
> - clear the flag TSF1 before enabling interrupt generation
> - properly set flag WD_CD for rtc chips(pcf2129, pca2129)
> 

This change has to be a separate patch.

> Signed-off-by: Biwen Li <biwen.li@nxp.com>
> ---
>  drivers/rtc/rtc-pcf2127.c | 21 ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
> index 07a5630ec841..0a45e2512258 100644
> --- a/drivers/rtc/rtc-pcf2127.c
> +++ b/drivers/rtc/rtc-pcf2127.c
> @@ -601,6 +601,10 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
>  	 * Watchdog timer enabled and reset pin /RST activated when timed out.
>  	 * Select 1Hz clock source for watchdog timer.
>  	 * Note: Countdown timer disabled and not available.
> +	 * For pca2129, pcf2129, only bit[7] is for Symbol WD_CD
> +	 * of register watchdg_tim_ctl. The bit[6] is labeled
> +	 * as T. Bits labeled as T must always be written with
> +	 * logic 0.
>  	 */
>  	ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_WD_CTL,
>  				 PCF2127_BIT_WD_CTL_CD1 |
> @@ -608,7 +612,7 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
>  				 PCF2127_BIT_WD_CTL_TF1 |
>  				 PCF2127_BIT_WD_CTL_TF0,
>  				 PCF2127_BIT_WD_CTL_CD1 |
> -				 PCF2127_BIT_WD_CTL_CD0 |
> +				 has_nvmem ? (PCF2127_BIT_WD_CTL_CD0) : (0) |

I don't like that because has_nvmem has nothing to do with
PCF2127_BIT_WD_CTL_CD0 and nothing guarantees that we won't ever get an
RTC without RST but with NVRAM and that willprobbly be overlooked.

>  				 PCF2127_BIT_WD_CTL_TF1);
>  	if (ret) {
>  		dev_err(dev, "%s: watchdog config (wd_ctl) failed\n", __func__);
> @@ -659,6 +663,21 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
>  		return ret;
>  	}
>  
> +	/*
> +	 * Clear TSF1 field of ctrl1 register to clear interrupt
> +	 * before enabling interrupt generation when
> +	 * timestamp flag set. Unless the flag TSF1 won't
> +	 * be cleared and the interrupt(INT pin) is
> +	 * triggered continueously.
> +	 */
> +	ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_CTRL1,
> +				 PCF2127_BIT_CTRL1_TSF1,
> +				 0);
> +	if (ret) {
> +		dev_err(dev, "%s:  control and status register 1 (ctrl1) failed, ret = 0x%x\n",
> +			__func__, ret);
> +		return ret;
> +	}

Doing that means ignoring timestamps taken while the system is offline.
It also doesn't fully solve the issue because you are not clearing TSF2
here and also it never gets cleared by the driver later on so I guess
you will get the interrupt storm once a timestamp is taken.


-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] rtc: pcf2127: clear the flag TSF1 before enabling interrupt generation
  2020-12-01 11:02 ` Alexandre Belloni
@ 2020-12-02  2:14   ` Biwen Li (OSS)
  0 siblings, 0 replies; 5+ messages in thread
From: Biwen Li (OSS) @ 2020-12-02  2:14 UTC (permalink / raw)
  To: Alexandre Belloni, Biwen Li (OSS)
  Cc: Leo Li, Anson Huang, Aisheng Dong, linux-kernel, Jiafei Pan, linux-rtc

> 
> Hi,
> 
> On 01/12/2020 16:47:46+0800, Biwen Li wrote:
> > From: Biwen Li <biwen.li@nxp.com>
> >
> > - clear the flag TSF1 before enabling interrupt generation
> > - properly set flag WD_CD for rtc chips(pcf2129, pca2129)
> >
> 
> This change has to be a separate patch.
Sure, np. Will separate the patch in v2.
> 
> > Signed-off-by: Biwen Li <biwen.li@nxp.com>
> > ---
> >  drivers/rtc/rtc-pcf2127.c | 21 ++++++++++++++++++++-
> >  1 file changed, 20 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
> > index 07a5630ec841..0a45e2512258 100644
> > --- a/drivers/rtc/rtc-pcf2127.c
> > +++ b/drivers/rtc/rtc-pcf2127.c
> > @@ -601,6 +601,10 @@ static int pcf2127_probe(struct device *dev, struct
> regmap *regmap,
> >  	 * Watchdog timer enabled and reset pin /RST activated when timed out.
> >  	 * Select 1Hz clock source for watchdog timer.
> >  	 * Note: Countdown timer disabled and not available.
> > +	 * For pca2129, pcf2129, only bit[7] is for Symbol WD_CD
> > +	 * of register watchdg_tim_ctl. The bit[6] is labeled
> > +	 * as T. Bits labeled as T must always be written with
> > +	 * logic 0.
> >  	 */
> >  	ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_WD_CTL,
> >  				 PCF2127_BIT_WD_CTL_CD1 |
> > @@ -608,7 +612,7 @@ static int pcf2127_probe(struct device *dev, struct
> regmap *regmap,
> >  				 PCF2127_BIT_WD_CTL_TF1 |
> >  				 PCF2127_BIT_WD_CTL_TF0,
> >  				 PCF2127_BIT_WD_CTL_CD1 |
> > -				 PCF2127_BIT_WD_CTL_CD0 |
> > +				 has_nvmem ? (PCF2127_BIT_WD_CTL_CD0) : (0) |
> 
> I don't like that because has_nvmem has nothing to do with
> PCF2127_BIT_WD_CTL_CD0 and nothing guarantees that we won't ever get an
> RTC without RST but with NVRAM and that willprobbly be overlooked.
Okay, got it. Will correct it in v2.
> 
> >  				 PCF2127_BIT_WD_CTL_TF1);
> >  	if (ret) {
> >  		dev_err(dev, "%s: watchdog config (wd_ctl) failed\n", __func__); @@
> > -659,6 +663,21 @@ static int pcf2127_probe(struct device *dev, struct
> regmap *regmap,
> >  		return ret;
> >  	}
> >
> > +	/*
> > +	 * Clear TSF1 field of ctrl1 register to clear interrupt
> > +	 * before enabling interrupt generation when
> > +	 * timestamp flag set. Unless the flag TSF1 won't
> > +	 * be cleared and the interrupt(INT pin) is
> > +	 * triggered continueously.
> > +	 */
> > +	ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_CTRL1,
> > +				 PCF2127_BIT_CTRL1_TSF1,
> > +				 0);
> > +	if (ret) {
> > +		dev_err(dev, "%s:  control and status register 1 (ctrl1) failed, ret =
> 0x%x\n",
> > +			__func__, ret);
> > +		return ret;
> > +	}
> 
> Doing that means ignoring timestamps taken while the system is offline.
> It also doesn't fully solve the issue because you are not clearing TSF2 here and
> also it never gets cleared by the driver later on so I guess you will get the
> interrupt storm once a timestamp is taken.
Okay, got it. Thanks. Will clear TSF2 flag in v2.
> 
> 
> --
> Alexandre Belloni, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] rtc: pcf2127: clear the flag TSF1 before enabling interrupt generation
  2020-12-01  8:47 [PATCH] rtc: pcf2127: clear the flag TSF1 before enabling interrupt generation Biwen Li
  2020-12-01 10:20 ` kernel test robot
  2020-12-01 11:02 ` Alexandre Belloni
@ 2020-12-02 17:10 ` kernel test robot
  2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2020-12-02 17:10 UTC (permalink / raw)
  To: Biwen Li, leoyang.li, alexandre.belloni, anson.huang, aisheng.dong
  Cc: kbuild-all, clang-built-linux, linux-kernel, jiafei.pan,
	linux-rtc, Biwen Li

[-- Attachment #1: Type: text/plain, Size: 7814 bytes --]

Hi Biwen,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on abelloni/rtc-next]
[also build test WARNING on v5.10-rc6 next-20201201]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Biwen-Li/rtc-pcf2127-clear-the-flag-TSF1-before-enabling-interrupt-generation/20201201-165409
base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next
config: arm64-randconfig-r014-20201202 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 2671fccf0381769276ca8246ec0499adcb9b0355)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm64 cross compiling tool for clang build
        # apt-get install binutils-aarch64-linux-gnu
        # https://github.com/0day-ci/linux/commit/54db60db88e4fd3ab6ac26f9a5b4768316347f95
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Biwen-Li/rtc-pcf2127-clear-the-flag-TSF1-before-enabling-interrupt-generation/20201201-165409
        git checkout 54db60db88e4fd3ab6ac26f9a5b4768316347f95
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/rtc/rtc-pcf2127.c:629:16: warning: operator '?:' has lower precedence than '|'; '|' will be evaluated first [-Wbitwise-conditional-parentheses]
                                    has_nvmem ? (PCF2127_BIT_WD_CTL_CD0) : (0) |
                                    ~~~~~~~~~ ^
   drivers/rtc/rtc-pcf2127.c:629:16: note: place parentheses around the '|' expression to silence this warning
                                    has_nvmem ? (PCF2127_BIT_WD_CTL_CD0) : (0) |
                                    ~~~~~~~~~ ^
   drivers/rtc/rtc-pcf2127.c:629:16: note: place parentheses around the '?:' expression to evaluate it first
                                    has_nvmem ? (PCF2127_BIT_WD_CTL_CD0) : (0) |
                                    ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   1 warning generated.

vim +629 drivers/rtc/rtc-pcf2127.c

   560	
   561	static int pcf2127_probe(struct device *dev, struct regmap *regmap,
   562				 int alarm_irq, const char *name, bool has_nvmem)
   563	{
   564		struct pcf2127 *pcf2127;
   565		int ret = 0;
   566	
   567		dev_dbg(dev, "%s\n", __func__);
   568	
   569		pcf2127 = devm_kzalloc(dev, sizeof(*pcf2127), GFP_KERNEL);
   570		if (!pcf2127)
   571			return -ENOMEM;
   572	
   573		pcf2127->regmap = regmap;
   574	
   575		dev_set_drvdata(dev, pcf2127);
   576	
   577		pcf2127->rtc = devm_rtc_allocate_device(dev);
   578		if (IS_ERR(pcf2127->rtc))
   579			return PTR_ERR(pcf2127->rtc);
   580	
   581		pcf2127->rtc->ops = &pcf2127_rtc_ops;
   582		pcf2127->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
   583		pcf2127->rtc->range_max = RTC_TIMESTAMP_END_2099;
   584		pcf2127->rtc->set_start_time = true; /* Sets actual start to 1970 */
   585		pcf2127->rtc->uie_unsupported = 1;
   586	
   587		if (alarm_irq > 0) {
   588			ret = devm_request_threaded_irq(dev, alarm_irq, NULL,
   589							pcf2127_rtc_irq,
   590							IRQF_TRIGGER_LOW | IRQF_ONESHOT,
   591							dev_name(dev), dev);
   592			if (ret) {
   593				dev_err(dev, "failed to request alarm irq\n");
   594				return ret;
   595			}
   596		}
   597	
   598		if (alarm_irq > 0 || device_property_read_bool(dev, "wakeup-source")) {
   599			device_init_wakeup(dev, true);
   600			pcf2127->rtc->ops = &pcf2127_rtc_alrm_ops;
   601		}
   602	
   603		if (has_nvmem) {
   604			struct nvmem_config nvmem_cfg = {
   605				.priv = pcf2127,
   606				.reg_read = pcf2127_nvmem_read,
   607				.reg_write = pcf2127_nvmem_write,
   608				.size = 512,
   609			};
   610	
   611			ret = devm_rtc_nvmem_register(pcf2127->rtc, &nvmem_cfg);
   612		}
   613	
   614		/*
   615		 * Watchdog timer enabled and reset pin /RST activated when timed out.
   616		 * Select 1Hz clock source for watchdog timer.
   617		 * Note: Countdown timer disabled and not available.
   618		 * For pca2129, pcf2129, only bit[7] is for Symbol WD_CD
   619		 * of register watchdg_tim_ctl. The bit[6] is labeled
   620		 * as T. Bits labeled as T must always be written with
   621		 * logic 0.
   622		 */
   623		ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_WD_CTL,
   624					 PCF2127_BIT_WD_CTL_CD1 |
   625					 PCF2127_BIT_WD_CTL_CD0 |
   626					 PCF2127_BIT_WD_CTL_TF1 |
   627					 PCF2127_BIT_WD_CTL_TF0,
   628					 PCF2127_BIT_WD_CTL_CD1 |
 > 629					 has_nvmem ? (PCF2127_BIT_WD_CTL_CD0) : (0) |
   630					 PCF2127_BIT_WD_CTL_TF1);
   631		if (ret) {
   632			dev_err(dev, "%s: watchdog config (wd_ctl) failed\n", __func__);
   633			return ret;
   634		}
   635	
   636		pcf2127_watchdog_init(dev, pcf2127);
   637	
   638		/*
   639		 * Disable battery low/switch-over timestamp and interrupts.
   640		 * Clear battery interrupt flags which can block new trigger events.
   641		 * Note: This is the default chip behaviour but added to ensure
   642		 * correct tamper timestamp and interrupt function.
   643		 */
   644		ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_CTRL3,
   645					 PCF2127_BIT_CTRL3_BTSE |
   646					 PCF2127_BIT_CTRL3_BIE |
   647					 PCF2127_BIT_CTRL3_BLIE, 0);
   648		if (ret) {
   649			dev_err(dev, "%s: interrupt config (ctrl3) failed\n",
   650				__func__);
   651			return ret;
   652		}
   653	
   654		/*
   655		 * Enable timestamp function and store timestamp of first trigger
   656		 * event until TSF1 and TFS2 interrupt flags are cleared.
   657		 */
   658		ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_TS_CTRL,
   659					 PCF2127_BIT_TS_CTRL_TSOFF |
   660					 PCF2127_BIT_TS_CTRL_TSM,
   661					 PCF2127_BIT_TS_CTRL_TSM);
   662		if (ret) {
   663			dev_err(dev, "%s: tamper detection config (ts_ctrl) failed\n",
   664				__func__);
   665			return ret;
   666		}
   667	
   668		/*
   669		 * Clear TSF1 field of ctrl1 register to clear interrupt
   670		 * before enabling interrupt generation when
   671		 * timestamp flag set. Unless the flag TSF1 won't
   672		 * be cleared and the interrupt(INT pin) is
   673		 * triggered continueously.
   674		 */
   675		ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_CTRL1,
   676					 PCF2127_BIT_CTRL1_TSF1,
   677					 0);
   678		if (ret) {
   679			dev_err(dev, "%s:  control and status register 1 (ctrl1) failed, ret = 0x%x\n",
   680				__func__, ret);
   681			return ret;
   682		}
   683		/*
   684		 * Enable interrupt generation when TSF1 or TSF2 timestamp flags
   685		 * are set. Interrupt signal is an open-drain output and can be
   686		 * left floating if unused.
   687		 */
   688		ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_CTRL2,
   689					 PCF2127_BIT_CTRL2_TSIE,
   690					 PCF2127_BIT_CTRL2_TSIE);
   691		if (ret) {
   692			dev_err(dev, "%s: tamper detection config (ctrl2) failed\n",
   693				__func__);
   694			return ret;
   695		}
   696	
   697		ret = rtc_add_group(pcf2127->rtc, &pcf2127_attr_group);
   698		if (ret) {
   699			dev_err(dev, "%s: tamper sysfs registering failed\n",
   700				__func__);
   701			return ret;
   702		}
   703	
   704		return devm_rtc_register_device(pcf2127->rtc);
   705	}
   706	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 36431 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-12-02 17:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-01  8:47 [PATCH] rtc: pcf2127: clear the flag TSF1 before enabling interrupt generation Biwen Li
2020-12-01 10:20 ` kernel test robot
2020-12-01 11:02 ` Alexandre Belloni
2020-12-02  2:14   ` Biwen Li (OSS)
2020-12-02 17:10 ` kernel test robot

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).