All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: "Ayyathurai, Vijayakannan" <vijayakannan.ayyathurai@intel.com>
Cc: Thierry Reding <thierry.reding@gmail.com>,
	"kbuild-all@lists.01.org" <kbuild-all@lists.01.org>,
	lkp <lkp@intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Linux Memory Management List <linux-mm@kvack.org>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	"Lai, Poey Seng" <poey.seng.lai@intel.com>
Subject: Re: [PATCH RFC] pwm: keembay: Fix build failure with -Os
Date: Wed, 18 Nov 2020 10:48:23 +0100	[thread overview]
Message-ID: <20201118094823.3a4usmbzvkbeaavg@pengutronix.de> (raw)
In-Reply-To: <DM6PR11MB4250E11A47E3B45FE0BEDC26FBE20@DM6PR11MB4250.namprd11.prod.outlook.com>

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

On Tue, Nov 17, 2020 at 05:29:01PM +0000, Ayyathurai, Vijayakannan wrote:
> Hi Uwe,
> 
> > From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > Sent: Monday, 16 November, 2020 5:08 PM
> > Subject: [PATCH RFC] pwm: keembay: Fix build failure with -Os
> > 
> > The driver used this construct:
> > 
> > 	#define KMB_PWM_LEADIN_MASK             GENMASK(30, 0)
> > 
> > 	static inline void keembay_pwm_update_bits(struct keembay_pwm
> > *priv, u32 mask,
> > 						   u32 val, u32 offset)
> > 	{
> > 		u32 buff = readl(priv->base + offset);
> > 
> > 		buff = u32_replace_bits(buff, val, mask);
> > 		writel(buff, priv->base + offset);
> > 	}
> > 
> > 	...
> > 	keembay_pwm_update_bits(priv, KMB_PWM_LEADIN_MASK, 0,
> > 					KMB_PWM_LEADIN_OFFSET(pwm-
> > >hwpwm));
> > 
> > With CONFIG_CC_OPTIMIZE_FOR_SIZE the compiler (here: gcc 10.2.0) this
> > triggers:
> > 
> > 	In file included from /home/uwe/gsrc/linux/drivers/pwm/pwm-
> > keembay.c:16:
> > 	In function ‘field_multiplier’,
> > 	    inlined from ‘keembay_pwm_update_bits’ at
> > /home/uwe/gsrc/linux/include/linux/bitfield.h:124:17:
> > 	/home/uwe/gsrc/linux/include/linux/bitfield.h:119:3: error: call to
> > ‘__bad_mask’ declared with attribute error: bad bitfield mask
> > 	  119 |   __bad_mask();
> > 	      |   ^~~~~~~~~~~~
> > 	In function ‘field_multiplier’,
> > 	    inlined from ‘keembay_pwm_update_bits’ at
> > /home/uwe/gsrc/linux/include/linux/bitfield.h:154:1:
> > 	/home/uwe/gsrc/linux/include/linux/bitfield.h:119:3: error: call to
> > ‘__bad_mask’ declared with attribute error: bad bitfield mask
> > 	  119 |   __bad_mask();
> > 	      |   ^~~~~~~~~~~~
> > 
> > The compiler doesn't seem to be able to notice that with field being
> > 0x3ffffff the expression
> > 
> > 	if ((field | (field - 1)) & ((field | (field - 1)) + 1))
> > 		__bad_mask();
> > 
> > can be optimized away.
> > 
> > So use __always_inline and document the problem in a comment to fix
> > this.
> > 
> > Reported-by: kernel test robot <lkp@intel.com>
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> 
> Thank you for spending time in resolving this build failure.
> 
> I shall prepare and share the next version of patch with your approach.

I don't understand this last sentence. IMHO there is currently nothing
you have to do for this problem. You can send an Ack however if you want
to.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
To: kbuild-all@lists.01.org
Subject: Re: [PATCH RFC] pwm: keembay: Fix build failure with -Os
Date: Wed, 18 Nov 2020 10:48:23 +0100	[thread overview]
Message-ID: <20201118094823.3a4usmbzvkbeaavg@pengutronix.de> (raw)
In-Reply-To: <DM6PR11MB4250E11A47E3B45FE0BEDC26FBE20@DM6PR11MB4250.namprd11.prod.outlook.com>

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

On Tue, Nov 17, 2020 at 05:29:01PM +0000, Ayyathurai, Vijayakannan wrote:
> Hi Uwe,
> 
> > From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > Sent: Monday, 16 November, 2020 5:08 PM
> > Subject: [PATCH RFC] pwm: keembay: Fix build failure with -Os
> > 
> > The driver used this construct:
> > 
> > 	#define KMB_PWM_LEADIN_MASK             GENMASK(30, 0)
> > 
> > 	static inline void keembay_pwm_update_bits(struct keembay_pwm
> > *priv, u32 mask,
> > 						   u32 val, u32 offset)
> > 	{
> > 		u32 buff = readl(priv->base + offset);
> > 
> > 		buff = u32_replace_bits(buff, val, mask);
> > 		writel(buff, priv->base + offset);
> > 	}
> > 
> > 	...
> > 	keembay_pwm_update_bits(priv, KMB_PWM_LEADIN_MASK, 0,
> > 					KMB_PWM_LEADIN_OFFSET(pwm-
> > >hwpwm));
> > 
> > With CONFIG_CC_OPTIMIZE_FOR_SIZE the compiler (here: gcc 10.2.0) this
> > triggers:
> > 
> > 	In file included from /home/uwe/gsrc/linux/drivers/pwm/pwm-
> > keembay.c:16:
> > 	In function ‘field_multiplier’,
> > 	    inlined from ‘keembay_pwm_update_bits’ at
> > /home/uwe/gsrc/linux/include/linux/bitfield.h:124:17:
> > 	/home/uwe/gsrc/linux/include/linux/bitfield.h:119:3: error: call to
> > ‘__bad_mask’ declared with attribute error: bad bitfield mask
> > 	  119 |   __bad_mask();
> > 	      |   ^~~~~~~~~~~~
> > 	In function ‘field_multiplier’,
> > 	    inlined from ‘keembay_pwm_update_bits’ at
> > /home/uwe/gsrc/linux/include/linux/bitfield.h:154:1:
> > 	/home/uwe/gsrc/linux/include/linux/bitfield.h:119:3: error: call to
> > ‘__bad_mask’ declared with attribute error: bad bitfield mask
> > 	  119 |   __bad_mask();
> > 	      |   ^~~~~~~~~~~~
> > 
> > The compiler doesn't seem to be able to notice that with field being
> > 0x3ffffff the expression
> > 
> > 	if ((field | (field - 1)) & ((field | (field - 1)) + 1))
> > 		__bad_mask();
> > 
> > can be optimized away.
> > 
> > So use __always_inline and document the problem in a comment to fix
> > this.
> > 
> > Reported-by: kernel test robot <lkp@intel.com>
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> 
> Thank you for spending time in resolving this build failure.
> 
> I shall prepare and share the next version of patch with your approach.

I don't understand this last sentence. IMHO there is currently nothing
you have to do for this problem. You can send an Ack however if you want
to.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2020-11-18  9:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-15 19:58 [linux-next:master 4911/5794] include/linux/bitfield.h:119:3: error: call to '__bad_mask' declared with attribute error: bad bitfield mask kernel test robot
2020-11-15 19:58 ` kernel test robot
2020-11-16  9:08 ` [PATCH RFC] pwm: keembay: Fix build failure with -Os Uwe Kleine-König
2020-11-16  9:08   ` Uwe Kleine-König
2020-11-17 17:29   ` Ayyathurai, Vijayakannan
2020-11-17 17:29     ` Ayyathurai, Vijayakannan
2020-11-18  9:48     ` Uwe Kleine-König [this message]
2020-11-18  9:48       ` Uwe Kleine-König
2020-11-18 10:06   ` Uwe Kleine-König
2020-11-18 10:06     ` Uwe Kleine-König
2020-11-18 17:41     ` Ayyathurai, Vijayakannan
2020-11-18 17:41       ` Ayyathurai, Vijayakannan
2020-11-18 18:01       ` Thierry Reding
2020-11-18 18:01         ` Thierry Reding
2020-11-18 18:00   ` Thierry Reding
2020-11-18 18:00     ` Thierry Reding

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=20201118094823.3a4usmbzvkbeaavg@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=kbuild-all@lists.01.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=poey.seng.lai@intel.com \
    --cc=thierry.reding@gmail.com \
    --cc=vijayakannan.ayyathurai@intel.com \
    /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.