* [PATCH v2] cxl: Replace HDM decoder granularity magic numbers
[not found] <CGME20220829220315uscas1p125d01bdd52a7aa6fd07c26bef7ead825@uscas1p1.samsung.com>
@ 2022-08-29 22:03 ` Adam Manzanares
2022-09-28 15:45 ` Dave Jiang
2022-10-21 17:52 ` Dan Williams
0 siblings, 2 replies; 3+ messages in thread
From: Adam Manzanares @ 2022-08-29 22:03 UTC (permalink / raw)
To: alison.schofield, vishal.l.verma, ira.weiny, bwidawsk,
dan.j.williams, dave, Jonathan.Cameron
Cc: linux-cxl, linux-kernel, Adam Manzanares
When reviewing the CFMWS parsing code that deals with the HDM decoders,
I noticed a couple of magic numbers. This commit replaces these magic numbers
with constants defined by the CXL 3.0 specification.
v2:
- Change references to CXL 3.0 specification (David)
- CXL_DECODER_MAX_GRANULARITY_ORDER -> CXL_DECODER_MAX_ENCODED_IG (Dan)
Signed-off-by: Adam Manzanares <a.manzanares@samsung.com>
---
drivers/cxl/cxl.h | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
index f680450f0b16..3ab81ad9d2e5 100644
--- a/drivers/cxl/cxl.h
+++ b/drivers/cxl/cxl.h
@@ -61,6 +61,10 @@
#define CXL_HDM_DECODER0_SKIP_LOW(i) CXL_HDM_DECODER0_TL_LOW(i)
#define CXL_HDM_DECODER0_SKIP_HIGH(i) CXL_HDM_DECODER0_TL_HIGH(i)
+/* HDM decoder control register constants CXL 3.0 8.2.5.19.7 */
+#define CXL_DECODER_MIN_GRANULARITY 256
+#define CXL_DECODER_MAX_ENCODED_IG 6
+
static inline int cxl_hdm_decoder_count(u32 cap_hdr)
{
int val = FIELD_GET(CXL_HDM_DECODER_COUNT_MASK, cap_hdr);
@@ -71,9 +75,9 @@ static inline int cxl_hdm_decoder_count(u32 cap_hdr)
/* Encode defined in CXL 2.0 8.2.5.12.7 HDM Decoder Control Register */
static inline int cxl_to_granularity(u16 ig, unsigned int *val)
{
- if (ig > 6)
+ if (ig > CXL_DECODER_MAX_ENCODED_IG)
return -EINVAL;
- *val = 256 << ig;
+ *val = CXL_DECODER_MIN_GRANULARITY << ig;
return 0;
}
@@ -96,7 +100,7 @@ static inline int cxl_to_ways(u8 eniw, unsigned int *val)
static inline int granularity_to_cxl(int g, u16 *ig)
{
- if (g > SZ_16K || g < 256 || !is_power_of_2(g))
+ if (g > SZ_16K || g < CXL_DECODER_MIN_GRANULARITY || !is_power_of_2(g))
return -EINVAL;
*ig = ilog2(g) - 8;
return 0;
@@ -248,7 +252,6 @@ enum cxl_decoder_type {
*/
#define CXL_DECODER_MAX_INTERLEAVE 16
-#define CXL_DECODER_MIN_GRANULARITY 256
/**
* struct cxl_decoder - Common CXL HDM Decoder Attributes
--
2.35.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] cxl: Replace HDM decoder granularity magic numbers
2022-08-29 22:03 ` [PATCH v2] cxl: Replace HDM decoder granularity magic numbers Adam Manzanares
@ 2022-09-28 15:45 ` Dave Jiang
2022-10-21 17:52 ` Dan Williams
1 sibling, 0 replies; 3+ messages in thread
From: Dave Jiang @ 2022-09-28 15:45 UTC (permalink / raw)
To: Adam Manzanares, alison.schofield, vishal.l.verma, ira.weiny,
bwidawsk, dan.j.williams, dave, Jonathan.Cameron
Cc: linux-cxl, linux-kernel
On 8/29/2022 3:03 PM, Adam Manzanares wrote:
> When reviewing the CFMWS parsing code that deals with the HDM decoders,
> I noticed a couple of magic numbers. This commit replaces these magic numbers
> with constants defined by the CXL 3.0 specification.
>
> v2:
> - Change references to CXL 3.0 specification (David)
> - CXL_DECODER_MAX_GRANULARITY_ORDER -> CXL_DECODER_MAX_ENCODED_IG (Dan)
>
> Signed-off-by: Adam Manzanares <a.manzanares@samsung.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
> drivers/cxl/cxl.h | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
> index f680450f0b16..3ab81ad9d2e5 100644
> --- a/drivers/cxl/cxl.h
> +++ b/drivers/cxl/cxl.h
> @@ -61,6 +61,10 @@
> #define CXL_HDM_DECODER0_SKIP_LOW(i) CXL_HDM_DECODER0_TL_LOW(i)
> #define CXL_HDM_DECODER0_SKIP_HIGH(i) CXL_HDM_DECODER0_TL_HIGH(i)
>
> +/* HDM decoder control register constants CXL 3.0 8.2.5.19.7 */
> +#define CXL_DECODER_MIN_GRANULARITY 256
> +#define CXL_DECODER_MAX_ENCODED_IG 6
> +
> static inline int cxl_hdm_decoder_count(u32 cap_hdr)
> {
> int val = FIELD_GET(CXL_HDM_DECODER_COUNT_MASK, cap_hdr);
> @@ -71,9 +75,9 @@ static inline int cxl_hdm_decoder_count(u32 cap_hdr)
> /* Encode defined in CXL 2.0 8.2.5.12.7 HDM Decoder Control Register */
> static inline int cxl_to_granularity(u16 ig, unsigned int *val)
> {
> - if (ig > 6)
> + if (ig > CXL_DECODER_MAX_ENCODED_IG)
> return -EINVAL;
> - *val = 256 << ig;
> + *val = CXL_DECODER_MIN_GRANULARITY << ig;
> return 0;
> }
>
> @@ -96,7 +100,7 @@ static inline int cxl_to_ways(u8 eniw, unsigned int *val)
>
> static inline int granularity_to_cxl(int g, u16 *ig)
> {
> - if (g > SZ_16K || g < 256 || !is_power_of_2(g))
> + if (g > SZ_16K || g < CXL_DECODER_MIN_GRANULARITY || !is_power_of_2(g))
> return -EINVAL;
> *ig = ilog2(g) - 8;
> return 0;
> @@ -248,7 +252,6 @@ enum cxl_decoder_type {
> */
> #define CXL_DECODER_MAX_INTERLEAVE 16
>
> -#define CXL_DECODER_MIN_GRANULARITY 256
>
> /**
> * struct cxl_decoder - Common CXL HDM Decoder Attributes
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH v2] cxl: Replace HDM decoder granularity magic numbers
2022-08-29 22:03 ` [PATCH v2] cxl: Replace HDM decoder granularity magic numbers Adam Manzanares
2022-09-28 15:45 ` Dave Jiang
@ 2022-10-21 17:52 ` Dan Williams
1 sibling, 0 replies; 3+ messages in thread
From: Dan Williams @ 2022-10-21 17:52 UTC (permalink / raw)
To: Adam Manzanares, alison.schofield, vishal.l.verma, ira.weiny,
bwidawsk, dan.j.williams, dave, Jonathan.Cameron
Cc: linux-cxl, linux-kernel, Adam Manzanares
Adam Manzanares wrote:
> When reviewing the CFMWS parsing code that deals with the HDM decoders,
> I noticed a couple of magic numbers. This commit replaces these magic numbers
> with constants defined by the CXL 3.0 specification.
>
> v2:
> - Change references to CXL 3.0 specification (David)
> - CXL_DECODER_MAX_GRANULARITY_ORDER -> CXL_DECODER_MAX_ENCODED_IG (Dan)
>
> Signed-off-by: Adam Manzanares <a.manzanares@samsung.com>
Applied for 6.2.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-21 17:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20220829220315uscas1p125d01bdd52a7aa6fd07c26bef7ead825@uscas1p1.samsung.com>
2022-08-29 22:03 ` [PATCH v2] cxl: Replace HDM decoder granularity magic numbers Adam Manzanares
2022-09-28 15:45 ` Dave Jiang
2022-10-21 17:52 ` Dan Williams
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.