From: Ping-Ke Shih <pkshih@realtek.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: "Andy Shevchenko" <andriy.shevchenko@intel.com>,
"Yury Norov" <yury.norov@gmail.com>,
"Michael Turquette" <mturquette@baylibre.com>,
"Stephen Boyd" <sboyd@kernel.org>,
"Nicolas Ferre" <nicolas.ferre@microchip.com>,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
"Claudiu Beznea" <claudiu.beznea@tuxon.dev>,
"Giovanni Cabiddu" <giovanni.cabiddu@intel.com>,
"Herbert Xu" <herbert@gondor.apana.org.au>,
"David Miller" <davem@davemloft.net>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Bartosz Golaszewski" <brgl@bgdev.pl>,
"Joel Stanley" <joel@jms.id.au>,
"Andrew Jeffery" <andrew@codeconstruct.com.au>,
"Crt Mori" <cmo@melexis.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Jacky Huang" <ychuang3@nuvoton.com>,
"Shan-Chun Hung" <schung@nuvoton.com>,
"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
"Jaroslav Kysela" <perex@perex.cz>,
"Takashi Iwai" <tiwai@suse.com>,
"Johannes Berg" <johannes@sipsolutions.net>,
"Jakub Kicinski" <kuba@kernel.org>, "Alex Elder" <elder@ieee.org>,
"David Laight" <david.laight.linux@gmail.com>,
"Vincent Mailhol" <mailhol.vincent@wanadoo.fr>,
"Jason Baron" <jbaron@akamai.com>,
"Borislav Petkov" <bp@alien8.de>,
"Tony Luck" <tony.luck@intel.com>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Kim Seer Paller" <kimseer.paller@analog.com>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Richard Genoud" <richard.genoud@bootlin.com>,
"Cosmin Tanislav" <demonsingur@gmail.com>,
"Biju Das" <biju.das.jz@bp.renesas.com>,
"Jianping Shen" <Jianping.Shen@de.bosch.com>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nick Desaulniers" <nick.desaulniers+lkml@gmail.com>,
"Miquel Raynal" <miquel.raynal@bootlin.com>,
"Richard Weinberger" <richard@nod.at>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
"linux-clk@vger.kernel.org" <linux-clk@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-renesas-soc@vger.kernel.org"
<linux-renesas-soc@vger.kernel.org>,
"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
"linux-edac@vger.kernel.org" <linux-edac@vger.kernel.org>,
"qat-linux@intel.com" <qat-linux@intel.com>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
"linux-aspeed@lists.ozlabs.org" <linux-aspeed@lists.ozlabs.org>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"linux-sound@vger.kernel.org" <linux-sound@vger.kernel.org>,
"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
linux-wireless <linux-wireless@vger.kernel.org>
Subject: RE: [PATCH v6 12/26] bitfield: Add less-checking __FIELD_{GET,PREP}()
Date: Mon, 10 Nov 2025 02:43:37 +0000 [thread overview]
Message-ID: <5cc8a69c155948078bd14e5f031e4468@realtek.com> (raw)
In-Reply-To: CAMuHMdU3hWDOWXxuOJcBA7tphBT7X-0H+g0-oq0tZdKw+O5W3A@mail.gmail.com
Hi Geert,
Ping-Ke Shih <pkshih@realtek.com> wrote:
> Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > Hi Ping-Ke,
> >
> > On Fri, 7 Nov 2025 at 02:16, Ping-Ke Shih <pkshih@realtek.com> wrote:
> > > Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > > > The extra checking in field_prep() in case the compiler can
> > > > determine that the mask is a constant already found a possible bug
> > > > in drivers/net/wireless/realtek/rtw89/core.c:rtw89_roc_end():
> > > >
> > > > rtw89_write32_mask(rtwdev, reg, B_AX_RX_FLTR_CFG_MASK, rtwdev->hal.rx_fltr);
> > > >
> > > > drivers/net/wireless/realtek/rtw89/reg.h:
> > > >
> > > > #define B_AX_RX_MPDU_MAX_LEN_MASK GENMASK(21, 16)
> > > > #define B_AX_RX_FLTR_CFG_MASK ((u32)~B_AX_RX_MPDU_MAX_LEN_MASK)
> > > >
> > > > so it looks like B_AX_RX_FLTR_CFG_MASK is not the proper mask for
> > > > this operation...
> > >
> > > The purpose of the statements is to update values excluding bits of
> > > B_AX_RX_MPDU_MAX_LEN_MASK. The use of B_AX_RX_FLTR_CFG_MASK is tricky, but
> > > the operation is correct because bit 0 is set, so __ffs(mask) returns 0 in
> > > rtw89_write32_mask(). Then, operation looks like
> > >
> > > orig = read(reg);
> > > new = (orig & ~mask) | (data & mask);
> > > write(new);
> >
> > Thanks for your quick confirmation!
> > So the intention really is to clear bits 22-31, and write the rx_fltr
> > value to bits 0-15?
> >
> > if the clearing is not needed, it would be better to use
> > #define B_AX_RX_FLTR_CFG_MASK GENMASK(15, 0)
>
> But it should be
> #define B_AX_RX_FLTR_CFG_MASK (GENMASK(31, 22) | GENMASK(15, 0))
>
> Originally (with bug) we just backup rx_fltr and write whole 32-bits back,
> but it's incorrect to modify GENMASK(21, 16) which is written by another
> code.
>
> One way is to implement a special function to replace
> rtw89_write32_mask(rtwdev, reg, B_AX_RX_FLTR_CFG_MASK, rtwdev->hal.rx_fltr);
> Such as
> rtw89_write_rx_flter(rtwdev, rtwdev->hal.rx_fltr)
> {
> orig = read(reg);
> new = (orig & ~mask) | (data & mask);
> write(new);
> }
>
> Another way is that I add value of B_AX_RX_MPDU_MAX_LEN_MASK into
> rtwdev->hal.rx_fltr. Then, just write whole 32-bit, no need mask.
>
> >
> > If the clearing is needed, I still think it would be better to
> > change B_AX_RX_FLTR_CFG_MASK, and split the clearing off in a separate
> > operation, to make it more explicit and obvious for the casual reader.
I missed this paragraph last week, but that is like my thought.
Then I spin a RFT [1]. Please try if it can work with your changes.
[1] https://lore.kernel.org/linux-wireless/20251110023707.6272-1-pkshih@realtek.com/T/#u
> >
> > > Since we don't use FIELD_{GET,PREP} macros with B_AX_RX_FLTR_CFG_MASK, how
> > > can you find the problem? Please guide us. Thanks.
> >
> > I still have "[PATCH/RFC 17/17] rtw89: Use bitfield helpers"
> >
> https://lore.kernel.org/all/f7b81122f7596fa004188bfae68f25a68c2d2392.1637592133.git.geert+renesas@glid
> > er.be/
> > in my local tree, which started flagging the use of a discontiguous
> > mask with the improved checking in field_prep().
>
> Got it. You are doing "Non-const bitfield helper conversions".
>
> Ping-Ke
next prev parent reply other threads:[~2025-11-11 22:16 UTC|newest]
Thread overview: 111+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-06 13:33 [PATCH v6 00/26] Non-const bitfield helpers Geert Uytterhoeven
2025-11-06 13:33 ` Geert Uytterhoeven
2025-11-06 13:33 ` [PATCH v6 01/26] clk: at91: pmc: #undef field_{get,prep}() before definition Geert Uytterhoeven
2025-11-06 13:33 ` Geert Uytterhoeven
2025-11-06 15:36 ` Claudiu Beznea
2025-11-06 15:36 ` Claudiu Beznea
2025-11-14 2:29 ` Stephen Boyd
2025-11-14 2:29 ` Stephen Boyd
2025-11-06 13:33 ` [PATCH v6 02/26] crypto: qat - #undef field_get() before local definition Geert Uytterhoeven
2025-11-06 13:33 ` Geert Uytterhoeven
2025-11-06 13:33 ` [PATCH v6 03/26] EDAC/ie31200: " Geert Uytterhoeven
2025-11-06 13:33 ` Geert Uytterhoeven
2025-11-10 14:02 ` Zhuo, Qiuxu
2025-11-10 14:02 ` Zhuo, Qiuxu
2025-11-06 13:33 ` [PATCH v6 04/26] gpio: aspeed: #undef field_{get,prep}() " Geert Uytterhoeven
2025-11-06 13:33 ` Geert Uytterhoeven
2025-11-06 13:33 ` [PATCH v6 05/26] iio: dac: ad3530r: #undef field_prep() " Geert Uytterhoeven
2025-11-06 13:33 ` Geert Uytterhoeven
2025-11-09 13:35 ` Jonathan Cameron
2025-11-09 13:35 ` Jonathan Cameron
2025-11-06 13:33 ` [PATCH v6 06/26] iio: mlx90614: #undef field_{get,prep}() " Geert Uytterhoeven
2025-11-06 13:33 ` Geert Uytterhoeven
2025-11-09 13:35 ` Jonathan Cameron
2025-11-09 13:35 ` Jonathan Cameron
2025-11-06 13:33 ` [PATCH v6 07/26] pinctrl: ma35: " Geert Uytterhoeven
2025-11-06 13:33 ` Geert Uytterhoeven
2025-11-06 13:33 ` [PATCH v6 08/26] soc: renesas: rz-sysc: #undef field_get() " Geert Uytterhoeven
2025-11-06 13:33 ` Geert Uytterhoeven
2025-11-06 15:39 ` Claudiu Beznea
2025-11-06 15:39 ` Claudiu Beznea
2025-11-06 13:33 ` [PATCH v6 09/26] ALSA: usb-audio: #undef field_{get,prep}() " Geert Uytterhoeven
2025-11-06 13:33 ` Geert Uytterhoeven
2025-11-06 13:33 ` [PATCH -next v6 10/26] iio: imu: smi330: #undef field_{get,prep}() before definition Geert Uytterhoeven
2025-11-06 13:33 ` Geert Uytterhoeven
2025-11-09 13:34 ` Jonathan Cameron
2025-11-09 13:34 ` Jonathan Cameron
2025-11-06 13:33 ` [PATCH -next v6 11/26] mtd: rawnand: sunxi: #undef field_{get,prep}() before local definition Geert Uytterhoeven
2025-11-06 13:33 ` Geert Uytterhoeven
2025-11-29 12:45 ` Miquel Raynal
2025-11-29 12:45 ` Miquel Raynal
2025-11-06 13:34 ` [PATCH v6 12/26] bitfield: Add less-checking __FIELD_{GET,PREP}() Geert Uytterhoeven
2025-11-06 13:34 ` Geert Uytterhoeven
2025-11-06 14:44 ` Andy Shevchenko
2025-11-06 14:44 ` Andy Shevchenko
2025-11-06 14:49 ` Geert Uytterhoeven
2025-11-06 14:49 ` Geert Uytterhoeven
2025-11-06 16:09 ` Andy Shevchenko
2025-11-06 16:09 ` Andy Shevchenko
2025-11-06 16:20 ` Geert Uytterhoeven
2025-11-06 16:20 ` Geert Uytterhoeven
2025-11-07 1:13 ` Ping-Ke Shih
2025-11-07 7:59 ` Andy Shevchenko
2025-11-07 7:59 ` Andy Shevchenko
2025-11-10 9:33 ` Geert Uytterhoeven
2025-11-10 9:33 ` Geert Uytterhoeven
2025-11-07 8:35 ` Geert Uytterhoeven
2025-11-07 8:35 ` Geert Uytterhoeven
2025-11-07 9:16 ` Ping-Ke Shih
2025-11-10 2:43 ` Ping-Ke Shih [this message]
2025-11-06 16:01 ` Yury Norov
2025-11-06 16:01 ` Yury Norov
2025-11-06 16:08 ` Andy Shevchenko
2025-11-06 16:08 ` Andy Shevchenko
2025-11-06 13:34 ` [PATCH v6 13/26] bitfield: Add non-constant field_{prep,get}() helpers Geert Uytterhoeven
2025-11-06 13:34 ` Geert Uytterhoeven
2025-11-06 16:31 ` Yury Norov
2025-11-06 16:31 ` Yury Norov
2025-11-06 13:34 ` [PATCH v6 14/26] clk: at91: Convert to common field_{get,prep}() helpers Geert Uytterhoeven
2025-11-06 13:34 ` Geert Uytterhoeven
2025-11-06 15:44 ` Claudiu Beznea
2025-11-06 15:44 ` Claudiu Beznea
2025-11-14 2:26 ` Stephen Boyd
2025-11-14 2:26 ` Stephen Boyd
2025-11-06 13:34 ` [PATCH v6 15/26] crypto: qat - convert to common field_get() helper Geert Uytterhoeven
2025-11-06 13:34 ` Geert Uytterhoeven
2025-11-06 13:34 ` [PATCH v6 16/26] EDAC/ie31200: Convert " Geert Uytterhoeven
2025-11-06 13:34 ` Geert Uytterhoeven
2025-11-10 14:03 ` Zhuo, Qiuxu
2025-11-10 14:03 ` Zhuo, Qiuxu
2025-11-06 13:34 ` [PATCH v6 17/26] gpio: aspeed: Convert to common field_{get,prep}() helpers Geert Uytterhoeven
2025-11-06 13:34 ` Geert Uytterhoeven
2025-11-06 13:34 ` [PATCH v6 18/26] iio: dac: Convert to common field_prep() helper Geert Uytterhoeven
2025-11-06 13:34 ` Geert Uytterhoeven
2025-11-06 13:34 ` [PATCH v6 19/26] iio: mlx90614: Convert to common field_{get,prep}() helpers Geert Uytterhoeven
2025-11-06 13:34 ` Geert Uytterhoeven
2025-11-06 13:34 ` [PATCH v6 20/26] pinctrl: ma35: " Geert Uytterhoeven
2025-11-06 13:34 ` Geert Uytterhoeven
2025-11-06 13:34 ` [PATCH v6 21/26] soc: renesas: rz-sysc: Convert to common field_get() helper Geert Uytterhoeven
2025-11-06 13:34 ` Geert Uytterhoeven
2025-11-06 15:40 ` Claudiu Beznea
2025-11-06 15:40 ` Claudiu Beznea
2025-11-06 13:34 ` [PATCH v6 22/26] ALSA: usb-audio: Convert to common field_{get,prep}() helpers Geert Uytterhoeven
2025-11-06 13:34 ` Geert Uytterhoeven
2025-11-06 13:34 ` [PATCH -next v6 23/26] iio: imu: smi330: " Geert Uytterhoeven
2025-11-06 13:34 ` Geert Uytterhoeven
2025-11-09 13:39 ` Jonathan Cameron
2025-11-09 13:39 ` Jonathan Cameron
2025-11-06 13:34 ` [PATCH -next v6 24/26] mtd: rawnand: sunxi: " Geert Uytterhoeven
2025-11-06 13:34 ` Geert Uytterhoeven
2025-11-06 13:51 ` Miquel Raynal
2025-11-06 13:51 ` Miquel Raynal
2025-11-06 13:34 ` [PATCH v6 25/26] clk: renesas: Use bitfield helpers Geert Uytterhoeven
2025-11-06 13:34 ` Geert Uytterhoeven
2025-11-14 2:28 ` Stephen Boyd
2025-11-14 2:28 ` Stephen Boyd
2025-11-06 13:34 ` [PATCH v6 26/26] soc: " Geert Uytterhoeven
2025-11-06 13:34 ` Geert Uytterhoeven
2025-11-06 16:45 ` [PATCH v6 00/26] Non-const " Yury Norov
2025-11-06 16:45 ` Yury Norov
2025-11-19 14:50 ` Yury Norov
2025-11-19 14:50 ` Yury Norov
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=5cc8a69c155948078bd14e5f031e4468@realtek.com \
--to=pkshih@realtek.com \
--cc=Jianping.Shen@de.bosch.com \
--cc=Michael.Hennerich@analog.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andrew@codeconstruct.com.au \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=biju.das.jz@bp.renesas.com \
--cc=bp@alien8.de \
--cc=brgl@bgdev.pl \
--cc=claudiu.beznea@tuxon.dev \
--cc=cmo@melexis.com \
--cc=davem@davemloft.net \
--cc=david.laight.linux@gmail.com \
--cc=demonsingur@gmail.com \
--cc=dlechner@baylibre.com \
--cc=elder@ieee.org \
--cc=geert@linux-m68k.org \
--cc=giovanni.cabiddu@intel.com \
--cc=herbert@gondor.apana.org.au \
--cc=jbaron@akamai.com \
--cc=jic23@kernel.org \
--cc=joel@jms.id.au \
--cc=johannes@sipsolutions.net \
--cc=kimseer.paller@analog.com \
--cc=kuba@kernel.org \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-edac@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mailhol.vincent@wanadoo.fr \
--cc=miquel.raynal@bootlin.com \
--cc=mturquette@baylibre.com \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=nicolas.ferre@microchip.com \
--cc=nuno.sa@analog.com \
--cc=perex@perex.cz \
--cc=qat-linux@intel.com \
--cc=richard.genoud@bootlin.com \
--cc=richard@nod.at \
--cc=sboyd@kernel.org \
--cc=schung@nuvoton.com \
--cc=tiwai@suse.com \
--cc=tony.luck@intel.com \
--cc=vigneshr@ti.com \
--cc=ychuang3@nuvoton.com \
--cc=yury.norov@gmail.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.