Linux PWM subsystem development
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: "Rafael V. Volkmer" <rafael.v.volkmer@gmail.com>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
	linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org,
	ukleinek@kernel.org
Subject: Re: [PATCH v2 1/1] pwm: tiehrpwm: ensures that state.enabled is synchronized in .probe()
Date: Sun, 20 Apr 2025 13:17:29 +0800	[thread overview]
Message-ID: <202504201347.OiWigSUq-lkp@intel.com> (raw)
In-Reply-To: <20250206031852.64853-1-rafael.v.volkmer@gmail.com>

Hi Rafael,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linus/master]
[also build test WARNING on v6.15-rc2 next-20250417]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Rafael-V-Volkmer/pwm-tiehrpwm-ensures-that-state-enabled-is-synchronized-in-probe/20250420-075200
base:   linus/master
patch link:    https://lore.kernel.org/r/20250206031852.64853-1-rafael.v.volkmer%40gmail.com
patch subject: [PATCH v2 1/1] pwm: tiehrpwm: ensures that state.enabled is synchronized in .probe()
config: um-randconfig-002-20250420 (https://download.01.org/0day-ci/archive/20250420/202504201347.OiWigSUq-lkp@intel.com/config)
compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project f819f46284f2a79790038e1f6649172789734ae8)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250420/202504201347.OiWigSUq-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202504201347.OiWigSUq-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from drivers/pwm/pwm-tiehrpwm.c:11:
   In file included from include/linux/io.h:12:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:549:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     549 |         val = __raw_readb(PCI_IOBASE + addr);
         |                           ~~~~~~~~~~ ^
   include/asm-generic/io.h:567:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     567 |         val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   In file included from drivers/pwm/pwm-tiehrpwm.c:11:
   In file included from include/linux/io.h:12:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:585:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     585 |         val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
      35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
         |                                                   ^
   In file included from drivers/pwm/pwm-tiehrpwm.c:11:
   In file included from include/linux/io.h:12:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:601:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     601 |         __raw_writeb(value, PCI_IOBASE + addr);
         |                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:616:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     616 |         __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:631:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     631 |         __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:724:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     724 |         readsb(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:737:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     737 |         readsw(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:750:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     750 |         readsl(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:764:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     764 |         writesb(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:778:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     778 |         writesw(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:792:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     792 |         writesl(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
>> drivers/pwm/pwm-tiehrpwm.c:675:7: warning: variable 'tbclk_enabled' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
     675 |                 if (ret) {
         |                     ^~~
   drivers/pwm/pwm-tiehrpwm.c:706:6: note: uninitialized use occurs here
     706 |         if (tbclk_enabled)
         |             ^~~~~~~~~~~~~
   drivers/pwm/pwm-tiehrpwm.c:675:3: note: remove the 'if' if its condition is always false
     675 |                 if (ret) {
         |                 ^~~~~~~~~~
     676 |                         dev_err_probe(&pdev->dev, ret, "clk_prepare_enable() failed");
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     677 |                         goto err_pwmchip_remove;
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~
     678 |                 }
         |                 ~
   drivers/pwm/pwm-tiehrpwm.c:629:20: note: initialize the variable 'tbclk_enabled' to silence this warning
     629 |         bool tbclk_enabled;
         |                           ^
         |                            = 0
   13 warnings generated.


vim +675 drivers/pwm/pwm-tiehrpwm.c

   621	
   622	static int ehrpwm_pwm_probe(struct platform_device *pdev)
   623	{
   624		struct device_node *np = pdev->dev.of_node;
   625		struct ehrpwm_pwm_chip *pc;
   626		struct pwm_state state;
   627		struct pwm_chip *chip;
   628		struct clk *clk;
   629		bool tbclk_enabled;
   630		int ret;
   631	
   632		chip = devm_pwmchip_alloc(&pdev->dev, NUM_PWM_CHANNEL, sizeof(*pc));
   633		if (IS_ERR(chip))
   634			return PTR_ERR(chip);
   635		pc = to_ehrpwm_pwm_chip(chip);
   636	
   637		clk = devm_clk_get(&pdev->dev, "fck");
   638		if (IS_ERR(clk)) {
   639			if (of_device_is_compatible(np, "ti,am33xx-ecap")) {
   640				dev_warn(&pdev->dev, "Binding is obsolete.\n");
   641				clk = devm_clk_get(pdev->dev.parent, "fck");
   642			}
   643		}
   644	
   645		if (IS_ERR(clk))
   646			return dev_err_probe(&pdev->dev, PTR_ERR(clk), "Failed to get fck\n");
   647	
   648		pc->clk_rate = clk_get_rate(clk);
   649		if (!pc->clk_rate) {
   650			dev_err(&pdev->dev, "failed to get clock rate\n");
   651			return -EINVAL;
   652		}
   653	
   654		chip->ops = &ehrpwm_pwm_ops;
   655	
   656		pc->mmio_base = devm_platform_ioremap_resource(pdev, 0);
   657		if (IS_ERR(pc->mmio_base))
   658			return PTR_ERR(pc->mmio_base);
   659	
   660		/* Acquire tbclk for Time Base EHRPWM submodule */
   661		pc->tbclk = devm_clk_get(&pdev->dev, "tbclk");
   662		if (IS_ERR(pc->tbclk))
   663			return dev_err_probe(&pdev->dev, PTR_ERR(pc->tbclk), "Failed to get tbclk\n");
   664	
   665		ret = clk_prepare(pc->tbclk);
   666		if (ret < 0) {
   667			dev_err(&pdev->dev, "clk_prepare() failed: %d\n", ret);
   668			return ret;
   669		}
   670	
   671		ehrpwm_get_state(chip, &chip->pwms[0], &state);
   672	
   673		if (state.enabled == true) {
   674			ret = clk_prepare_enable(pc->tbclk);
 > 675			if (ret) {
   676				dev_err_probe(&pdev->dev, ret, "clk_prepare_enable() failed");
   677				goto err_pwmchip_remove;
   678			}
   679	
   680			tbclk_enabled = true;
   681		}
   682	
   683		ret = pwmchip_add(chip);
   684		if (ret < 0) {
   685			dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret);
   686			goto err_clk_unprepare;
   687		}
   688	
   689		platform_set_drvdata(pdev, chip);
   690		pm_runtime_enable(&pdev->dev);
   691	
   692		if (state.enabled == true) {
   693			ret = pm_runtime_get_sync(&pdev->dev);
   694			if (ret < 0) {
   695				dev_err_probe(&pdev->dev, ret, "pm_runtime_get_sync() failed");
   696				clk_disable_unprepare(pc->tbclk);
   697				goto err_pwmchip_remove;
   698			}
   699		}
   700	
   701		return 0;
   702	
   703	err_pwmchip_remove:
   704		pwmchip_remove(chip);
   705	err_clk_unprepare:
   706		if (tbclk_enabled)
   707			clk_unprepare(pc->tbclk);
   708	
   709		return ret;
   710	}
   711	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

      parent reply	other threads:[~2025-04-20  5:18 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-04 18:55 [PATCH] pwm: tiehrpwm: ensures that state.enabled is synchronized in .probe() Rafael V. Volkmer
2025-02-05 11:12 ` Uwe Kleine-König
2025-02-06  3:13   ` [PATCH v2 0/1] pwm: tiehrpwm: ensures that state.enabled is Rafael V. Volkmer
2025-02-06  3:18     ` [PATCH v2 1/1] pwm: tiehrpwm: ensures that state.enabled is synchronized in .probe() Rafael V. Volkmer
2025-02-07  8:49       ` Uwe Kleine-König
2025-02-07 21:29         ` [PATCH v3 1/3] pwm: tiehrpwm: replace manual bit definitions with bitfield.h macros Rafael V. Volkmer
2025-02-07 21:32           ` [PATCH v3 2/3] pwm: ehrpwm: add get_state function to retrieve PWM channel state Rafael V. Volkmer
2025-02-07 21:34             ` [PATCH v3 3/3] pwm: ehrpwm: ensure clock and runtime PM are enabled if hardware is active Rafael V. Volkmer
2025-03-26 11:45               ` Uwe Kleine-König
2025-04-19 19:48                 ` [PATCH v4 1/4] pwm: tiehrpwm: replace manual bit definitions with bitfield.h macros Rafael V. Volkmer
2025-04-19 19:55                   ` [PATCH v4 2/4] pwm: tiehrpwm: add get_state function to retrieve PWM channel state Rafael V. Volkmer
2025-04-19 19:58                     ` [PATCH v4 3/4] pwm: tiehrpwm: ensure clock and runtime PM are enabled if hardware is active Rafael V. Volkmer
2025-04-19 20:01                       ` [PATCH v4 4/4] pwm: tiehrpwm: drop unnecessary parentheses and fix spacing Rafael V. Volkmer
2025-05-13  9:36                         ` Uwe Kleine-König
2025-05-13  9:33                       ` [PATCH v4 3/4] pwm: tiehrpwm: ensure clock and runtime PM are enabled if hardware is active Uwe Kleine-König
2025-05-13  9:27                     ` [PATCH v4 2/4] pwm: tiehrpwm: add get_state function to retrieve PWM channel state Uwe Kleine-König
2025-05-13  9:18                   ` [PATCH v4 1/4] pwm: tiehrpwm: replace manual bit definitions with bitfield.h macros Uwe Kleine-König
2025-03-26 11:32             ` [PATCH v3 2/3] pwm: ehrpwm: add get_state function to retrieve PWM channel state Uwe Kleine-König
2025-04-20  2:21       ` [PATCH v2 1/1] pwm: tiehrpwm: ensures that state.enabled is synchronized in .probe() kernel test robot
2025-04-20  5:17       ` kernel test robot [this message]

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=202504201347.OiWigSUq-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=rafael.v.volkmer@gmail.com \
    --cc=ukleinek@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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox