mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cxl/core: fix test_bit misuse with CXL_DECODER_F_ bitmask flags
@ 2026-02-21  2:18 Gregory Price
  2026-02-23 17:33 ` Cheatham, Benjamin
  0 siblings, 1 reply; 4+ messages in thread
From: Gregory Price @ 2026-02-21  2:18 UTC (permalink / raw)
  To: linux-cxl
  Cc: linux-kernel, kernel-team, dave, jonathan.cameron, dave.jiang,
	alison.schofield, vishal.l.verma, ira.weiny, dan.j.williams

CXL_DECODER_F_LOCK (BIT(4) = 16) and CXL_DECODER_F_NORMALIZED_ADDRESSING
(BIT(6) = 64) are bit masks, but three call sites pass them to test_bit()
which expects a bit number.

Replace test_bit() with direct bitmask tests, consistent with every other
use of these flags.

Fixes: 2230c4bdc412 ("cxl: Add handling of locked CXL decoder")
Signed-off-by: Gregory Price <gourry@gourry.net>
---
 drivers/cxl/core/hdm.c    | 2 +-
 drivers/cxl/core/region.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
index b2db5967f5c0..c8fcb9d9aa3d 100644
--- a/drivers/cxl/core/hdm.c
+++ b/drivers/cxl/core/hdm.c
@@ -904,7 +904,7 @@ static void cxl_decoder_reset(struct cxl_decoder *cxld)
 	if ((cxld->flags & CXL_DECODER_F_ENABLE) == 0)
 		return;
 
-	if (test_bit(CXL_DECODER_F_LOCK, &cxld->flags))
+	if (cxld->flags & CXL_DECODER_F_LOCK)
 		return;
 
 	if (port->commit_end == id)
diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index bd4c4a4a27da..385be9cb44cd 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -1100,12 +1100,12 @@ static int cxl_rr_assign_decoder(struct cxl_port *port, struct cxl_region *cxlr,
 static void cxl_region_setup_flags(struct cxl_region *cxlr,
 				   struct cxl_decoder *cxld)
 {
-	if (test_bit(CXL_DECODER_F_LOCK, &cxld->flags)) {
+	if (cxld->flags & CXL_DECODER_F_LOCK) {
 		set_bit(CXL_REGION_F_LOCK, &cxlr->flags);
 		clear_bit(CXL_REGION_F_NEEDS_RESET, &cxlr->flags);
 	}
 
-	if (test_bit(CXL_DECODER_F_NORMALIZED_ADDRESSING, &cxld->flags))
+	if (cxld->flags & CXL_DECODER_F_NORMALIZED_ADDRESSING)
 		set_bit(CXL_REGION_F_NORMALIZED_ADDRESSING, &cxlr->flags);
 }
 
-- 
2.53.0


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

* Re: [PATCH] cxl/core: fix test_bit misuse with CXL_DECODER_F_ bitmask flags
  2026-02-21  2:18 [PATCH] cxl/core: fix test_bit misuse with CXL_DECODER_F_ bitmask flags Gregory Price
@ 2026-02-23 17:33 ` Cheatham, Benjamin
  2026-02-23 17:45   ` Gregory Price
  0 siblings, 1 reply; 4+ messages in thread
From: Cheatham, Benjamin @ 2026-02-23 17:33 UTC (permalink / raw)
  To: Gregory Price, linux-cxl
  Cc: linux-kernel, kernel-team, dave, jonathan.cameron, dave.jiang,
	alison.schofield, vishal.l.verma, ira.weiny, dan.j.williams

On 2/20/2026 8:18 PM, Gregory Price wrote:
> CXL_DECODER_F_LOCK (BIT(4) = 16) and CXL_DECODER_F_NORMALIZED_ADDRESSING
> (BIT(6) = 64) are bit masks, but three call sites pass them to test_bit()
> which expects a bit number.
> 
> Replace test_bit() with direct bitmask tests, consistent with every other
> use of these flags.
> 
> Fixes: 2230c4bdc412 ("cxl: Add handling of locked CXL decoder")
> Signed-off-by: Gregory Price <gourry@gourry.net>

Alison sent out a patch [1] two weeks ago for this. I suspect you found this bug
independently, so I figured I should point it out. Otherwise, I would add a Reported-by (or some
other tag) with her name.

Thanks,
Ben

[1]: https://lore.kernel.org/linux-cxl/20260206181404.1025991-1-alison.schofield@intel.com/
> ---
>  drivers/cxl/core/hdm.c    | 2 +-
>  drivers/cxl/core/region.c | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
> index b2db5967f5c0..c8fcb9d9aa3d 100644
> --- a/drivers/cxl/core/hdm.c
> +++ b/drivers/cxl/core/hdm.c
> @@ -904,7 +904,7 @@ static void cxl_decoder_reset(struct cxl_decoder *cxld)
>  	if ((cxld->flags & CXL_DECODER_F_ENABLE) == 0)
>  		return;
>  
> -	if (test_bit(CXL_DECODER_F_LOCK, &cxld->flags))
> +	if (cxld->flags & CXL_DECODER_F_LOCK)
>  		return;
>  
>  	if (port->commit_end == id)
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index bd4c4a4a27da..385be9cb44cd 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -1100,12 +1100,12 @@ static int cxl_rr_assign_decoder(struct cxl_port *port, struct cxl_region *cxlr,
>  static void cxl_region_setup_flags(struct cxl_region *cxlr,
>  				   struct cxl_decoder *cxld)
>  {
> -	if (test_bit(CXL_DECODER_F_LOCK, &cxld->flags)) {
> +	if (cxld->flags & CXL_DECODER_F_LOCK) {
>  		set_bit(CXL_REGION_F_LOCK, &cxlr->flags);
>  		clear_bit(CXL_REGION_F_NEEDS_RESET, &cxlr->flags);
>  	}
>  
> -	if (test_bit(CXL_DECODER_F_NORMALIZED_ADDRESSING, &cxld->flags))
> +	if (cxld->flags & CXL_DECODER_F_NORMALIZED_ADDRESSING)
>  		set_bit(CXL_REGION_F_NORMALIZED_ADDRESSING, &cxlr->flags);
>  }
>  


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

* Re: [PATCH] cxl/core: fix test_bit misuse with CXL_DECODER_F_ bitmask flags
  2026-02-23 17:33 ` Cheatham, Benjamin
@ 2026-02-23 17:45   ` Gregory Price
  2026-02-23 18:04     ` Dave Jiang
  0 siblings, 1 reply; 4+ messages in thread
From: Gregory Price @ 2026-02-23 17:45 UTC (permalink / raw)
  To: Cheatham, Benjamin
  Cc: linux-cxl, linux-kernel, kernel-team, dave, jonathan.cameron,
	dave.jiang, alison.schofield, vishal.l.verma, ira.weiny,
	dan.j.williams

On Mon, Feb 23, 2026 at 11:33:13AM -0600, Cheatham, Benjamin wrote:
> On 2/20/2026 8:18 PM, Gregory Price wrote:
> > CXL_DECODER_F_LOCK (BIT(4) = 16) and CXL_DECODER_F_NORMALIZED_ADDRESSING
> > (BIT(6) = 64) are bit masks, but three call sites pass them to test_bit()
> > which expects a bit number.
> > 
> > Replace test_bit() with direct bitmask tests, consistent with every other
> > use of these flags.
> > 
> > Fixes: 2230c4bdc412 ("cxl: Add handling of locked CXL decoder")
> > Signed-off-by: Gregory Price <gourry@gourry.net>
> 
> Alison sent out a patch [1] two weeks ago for this. I suspect you found this bug
> independently, so I figured I should point it out. Otherwise, I would add a Reported-by (or some
> other tag) with her name.
> 
> Thanks,
> Ben
> 
> [1]: https://lore.kernel.org/linux-cxl/20260206181404.1025991-1-alison.schofield@intel.com/

Ah, yeah, missed this, and did find independently when testing unbinds.

Wasn't on cxl/next so I thought it hadn't been found yet.

Cool, thanks!
~Gregory

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

* Re: [PATCH] cxl/core: fix test_bit misuse with CXL_DECODER_F_ bitmask flags
  2026-02-23 17:45   ` Gregory Price
@ 2026-02-23 18:04     ` Dave Jiang
  0 siblings, 0 replies; 4+ messages in thread
From: Dave Jiang @ 2026-02-23 18:04 UTC (permalink / raw)
  To: Gregory Price, Cheatham, Benjamin
  Cc: linux-cxl, linux-kernel, kernel-team, dave, jonathan.cameron,
	alison.schofield, vishal.l.verma, ira.weiny, dan.j.williams



On 2/23/26 10:45 AM, Gregory Price wrote:
> On Mon, Feb 23, 2026 at 11:33:13AM -0600, Cheatham, Benjamin wrote:
>> On 2/20/2026 8:18 PM, Gregory Price wrote:
>>> CXL_DECODER_F_LOCK (BIT(4) = 16) and CXL_DECODER_F_NORMALIZED_ADDRESSING
>>> (BIT(6) = 64) are bit masks, but three call sites pass them to test_bit()
>>> which expects a bit number.
>>>
>>> Replace test_bit() with direct bitmask tests, consistent with every other
>>> use of these flags.
>>>
>>> Fixes: 2230c4bdc412 ("cxl: Add handling of locked CXL decoder")
>>> Signed-off-by: Gregory Price <gourry@gourry.net>
>>
>> Alison sent out a patch [1] two weeks ago for this. I suspect you found this bug
>> independently, so I figured I should point it out. Otherwise, I would add a Reported-by (or some
>> other tag) with her name.
>>
>> Thanks,
>> Ben
>>
>> [1]: https://lore.kernel.org/linux-cxl/20260206181404.1025991-1-alison.schofield@intel.com/
> 
> Ah, yeah, missed this, and did find independently when testing unbinds.
> 
> Wasn't on cxl/next so I thought it hadn't been found yet.

Yeah waiting on 7.0-rc1 for cxl/fixes. I also asked her to split the patches into 2 fixes. But if you don't mind go add your review tag that'd be great! :) 

> 
> Cool, thanks!
> ~Gregory


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

end of thread, other threads:[~2026-02-23 18:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-21  2:18 [PATCH] cxl/core: fix test_bit misuse with CXL_DECODER_F_ bitmask flags Gregory Price
2026-02-23 17:33 ` Cheatham, Benjamin
2026-02-23 17:45   ` Gregory Price
2026-02-23 18:04     ` Dave Jiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®