All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: "Baruch Siach" <baruch@tkos.co.il>,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Lee Jones" <lee.jones@linaro.org>
Cc: kbuild-all@lists.01.org, Baruch Siach <baruch@tkos.co.il>,
	Andy Gross <agross@kernel.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Balaji Prakash J <bjagadee@codeaurora.org>,
	Rob Herring <robh+dt@kernel.org>,
	Robert Marko <robert.marko@sartura.hr>,
	linux-pwm@vger.kernel.org
Subject: Re: [PATCH v2 1/3] pwm: driver for qualcomm ipq6018 pwm block
Date: Mon, 24 May 2021 22:48:31 +0800	[thread overview]
Message-ID: <202105242244.N53xBmkq-lkp@intel.com> (raw)
In-Reply-To: <ea071bbcab92d4a296c7aee5d72de0427676847a.1621851644.git.baruch@tkos.co.il>

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

Hi Baruch,

I love your patch! Perhaps something to improve:

[auto build test WARNING on pwm/for-next]
[also build test WARNING on robh/for-next v5.13-rc3 next-20210524]
[cannot apply to agross-msm/qcom/for-next]
[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/Baruch-Siach/pwm-driver-for-qualcomm-ipq6018-pwm-block/20210524-182306
base:   https://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm.git for-next
config: arc-allyesconfig (attached as .config)
compiler: arceb-elf-gcc (GCC) 9.3.0
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
        # https://github.com/0day-ci/linux/commit/fd963192953e74575c0bba469b6a1ef769db9d33
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Baruch-Siach/pwm-driver-for-qualcomm-ipq6018-pwm-block/20210524-182306
        git checkout fd963192953e74575c0bba469b6a1ef769db9d33
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc 

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/pwm/pwm-ipq.c: In function 'ipq_pwm_apply':
>> drivers/pwm/pwm-ipq.c:125:34: warning: integer overflow in expression of type 'long int' results in '-727379968' [-Woverflow]
     125 |  fin_ps = div64_u64(NSEC_PER_SEC * 1000, rate);
         |                                  ^


vim +125 drivers/pwm/pwm-ipq.c

   103	
   104	static int ipq_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
   105				 const struct pwm_state *state)
   106	{
   107		struct ipq_pwm_chip *ipq_chip = to_ipq_pwm_chip(chip);
   108		unsigned long freq;
   109		int pre_div, close_pre_div, close_pwm_div;
   110		int pwm_div;
   111		long long diff;
   112		unsigned long rate = clk_get_rate(ipq_chip->clk);
   113		unsigned long min_diff = rate;
   114		uint64_t fin_ps;
   115		u64 period_ns, duty_ns;
   116	
   117		if (state->period < MIN_PERIOD_NS)
   118			return -ERANGE;
   119	
   120		period_ns = min_t(u64, state->period, MAX_PERIOD_NS);
   121		duty_ns = min_t(u64, state->duty_cycle, period_ns);
   122	
   123		/* freq in Hz for period in nano second*/
   124		freq = NSEC_PER_SEC / period_ns;
 > 125		fin_ps = div64_u64(NSEC_PER_SEC * 1000, rate);
   126		close_pre_div = MAX_PWM_CFG;
   127		close_pwm_div = MAX_PWM_CFG;
   128	
   129		for (pre_div = 0; pre_div <= MAX_PWM_CFG; pre_div++) {
   130			pwm_div = DIV64_U64_ROUND_CLOSEST(period_ns * 1000,
   131							  fin_ps * (pre_div + 1));
   132			pwm_div--;
   133			if (pwm_div < 0 || pwm_div > MAX_PWM_CFG)
   134				continue;
   135	
   136			diff = ((uint64_t)freq * (pre_div + 1) * (pwm_div + 1))
   137				- (uint64_t)rate;
   138	
   139			if (diff < 0) /* period larger than requested */
   140				continue;
   141			if (diff == 0) { /* bingo */
   142				close_pre_div = pre_div;
   143				close_pwm_div = pwm_div;
   144				break;
   145			}
   146			if (diff < min_diff) {
   147				min_diff = diff;
   148				close_pre_div = pre_div;
   149				close_pwm_div = pwm_div;
   150			}
   151		}
   152	
   153		/* config divider values for the closest possible frequency */
   154		config_div_and_duty(pwm, close_pre_div, close_pwm_div,
   155				    period_ns, duty_ns);
   156		if (state->enabled)
   157			ipq_pwm_enable(pwm);
   158		else
   159			ipq_pwm_disable(pwm);
   160	
   161		return 0;
   162	}
   163	

---
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: 67491 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: kernel test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: Re: [PATCH v2 1/3] pwm: driver for qualcomm ipq6018 pwm block
Date: Mon, 24 May 2021 22:48:31 +0800	[thread overview]
Message-ID: <202105242244.N53xBmkq-lkp@intel.com> (raw)
In-Reply-To: <ea071bbcab92d4a296c7aee5d72de0427676847a.1621851644.git.baruch@tkos.co.il>

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

Hi Baruch,

I love your patch! Perhaps something to improve:

[auto build test WARNING on pwm/for-next]
[also build test WARNING on robh/for-next v5.13-rc3 next-20210524]
[cannot apply to agross-msm/qcom/for-next]
[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/Baruch-Siach/pwm-driver-for-qualcomm-ipq6018-pwm-block/20210524-182306
base:   https://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm.git for-next
config: arc-allyesconfig (attached as .config)
compiler: arceb-elf-gcc (GCC) 9.3.0
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
        # https://github.com/0day-ci/linux/commit/fd963192953e74575c0bba469b6a1ef769db9d33
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Baruch-Siach/pwm-driver-for-qualcomm-ipq6018-pwm-block/20210524-182306
        git checkout fd963192953e74575c0bba469b6a1ef769db9d33
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc 

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/pwm/pwm-ipq.c: In function 'ipq_pwm_apply':
>> drivers/pwm/pwm-ipq.c:125:34: warning: integer overflow in expression of type 'long int' results in '-727379968' [-Woverflow]
     125 |  fin_ps = div64_u64(NSEC_PER_SEC * 1000, rate);
         |                                  ^


vim +125 drivers/pwm/pwm-ipq.c

   103	
   104	static int ipq_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
   105				 const struct pwm_state *state)
   106	{
   107		struct ipq_pwm_chip *ipq_chip = to_ipq_pwm_chip(chip);
   108		unsigned long freq;
   109		int pre_div, close_pre_div, close_pwm_div;
   110		int pwm_div;
   111		long long diff;
   112		unsigned long rate = clk_get_rate(ipq_chip->clk);
   113		unsigned long min_diff = rate;
   114		uint64_t fin_ps;
   115		u64 period_ns, duty_ns;
   116	
   117		if (state->period < MIN_PERIOD_NS)
   118			return -ERANGE;
   119	
   120		period_ns = min_t(u64, state->period, MAX_PERIOD_NS);
   121		duty_ns = min_t(u64, state->duty_cycle, period_ns);
   122	
   123		/* freq in Hz for period in nano second*/
   124		freq = NSEC_PER_SEC / period_ns;
 > 125		fin_ps = div64_u64(NSEC_PER_SEC * 1000, rate);
   126		close_pre_div = MAX_PWM_CFG;
   127		close_pwm_div = MAX_PWM_CFG;
   128	
   129		for (pre_div = 0; pre_div <= MAX_PWM_CFG; pre_div++) {
   130			pwm_div = DIV64_U64_ROUND_CLOSEST(period_ns * 1000,
   131							  fin_ps * (pre_div + 1));
   132			pwm_div--;
   133			if (pwm_div < 0 || pwm_div > MAX_PWM_CFG)
   134				continue;
   135	
   136			diff = ((uint64_t)freq * (pre_div + 1) * (pwm_div + 1))
   137				- (uint64_t)rate;
   138	
   139			if (diff < 0) /* period larger than requested */
   140				continue;
   141			if (diff == 0) { /* bingo */
   142				close_pre_div = pre_div;
   143				close_pwm_div = pwm_div;
   144				break;
   145			}
   146			if (diff < min_diff) {
   147				min_diff = diff;
   148				close_pre_div = pre_div;
   149				close_pwm_div = pwm_div;
   150			}
   151		}
   152	
   153		/* config divider values for the closest possible frequency */
   154		config_div_and_duty(pwm, close_pre_div, close_pwm_div,
   155				    period_ns, duty_ns);
   156		if (state->enabled)
   157			ipq_pwm_enable(pwm);
   158		else
   159			ipq_pwm_disable(pwm);
   160	
   161		return 0;
   162	}
   163	

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

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

  parent reply	other threads:[~2021-05-24 14:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-24 10:20 [PATCH v2 1/3] pwm: driver for qualcomm ipq6018 pwm block Baruch Siach
2021-05-24 10:20 ` Baruch Siach
2021-05-24 10:20 ` [PATCH v2 2/3] dt-bindings: pwm: add IPQ6018 binding Baruch Siach
2021-05-24 10:20   ` Baruch Siach
2021-06-02 19:47   ` Rob Herring
2021-06-02 19:47     ` Rob Herring
2021-06-02 23:05   ` Bjorn Andersson
2021-06-02 23:05     ` Bjorn Andersson
2021-06-30 14:46     ` Kathiravan T
2021-05-24 10:20 ` [PATCH v2 3/3] arm64: dts: ipq6018: add pwm node Baruch Siach
2021-05-24 10:20   ` Baruch Siach
2021-05-24 14:48 ` kernel test robot [this message]
2021-05-24 14:48   ` [PATCH v2 1/3] pwm: driver for qualcomm ipq6018 pwm block kernel test robot
2021-05-24 16:08 ` kernel test robot
2021-05-24 16:08   ` kernel test robot

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=202105242244.N53xBmkq-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=agross@kernel.org \
    --cc=baruch@tkos.co.il \
    --cc=bjagadee@codeaurora.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=kbuild-all@lists.01.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=robert.marko@sartura.hr \
    --cc=robh+dt@kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.