Re: [PATCH 03/20] cxl: Move CXL spec defines to public header
From: Dave Jiang
Date: Fri Mar 13 2026 - 13:01:48 EST
On 3/13/26 5:18 AM, Jonathan Cameron wrote:
> On Thu, 12 Mar 2026 02:04:23 +0530
> mhonap@xxxxxxxxxx wrote:
>
>> From: Manish Honap <mhonap@xxxxxxxxxx>
>>
>> HDM decoder capability structure and component reg block size
>> needs to be used by VFIO subsystem. Move the macros from private
>> CXL header to public one.
>>
>> Signed-off-by: Manish Honap <mhonap@xxxxxxxxxx>
>
> Not really related to this patch, but...
>
> Maybe this is the time to think about doing a PCI like
> uapi/linux/cxl_regs.h header?
Sounds reasonable. Maybe makes sense to be in uapi/cxl/? There's already a features.h header in there.
>
> So far we have these duplicated in at least a couple of code
> bases and that is less than ideal!
>
> Move seems fine to me otherwise.
>
>> ---
>> drivers/cxl/cxl.h | 30 ------------------------------
>> include/cxl/cxl.h | 30 ++++++++++++++++++++++++++++++
>> 2 files changed, 30 insertions(+), 30 deletions(-)
>>
>> diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
>> index 10ddab3949ee..7146059e0dae 100644
>> --- a/drivers/cxl/cxl.h
>> +++ b/drivers/cxl/cxl.h
>> @@ -24,9 +24,6 @@ extern const struct nvdimm_security_ops *cxl_security_ops;
>> * (port-driver, region-driver, nvdimm object-drivers... etc).
>> */
>>
>> -/* CXL 2.0 8.2.4 CXL Component Register Layout and Definition */
>> -#define CXL_COMPONENT_REG_BLOCK_SIZE SZ_64K
>> -
>> /* CXL 2.0 8.2.5 CXL.cache and CXL.mem Registers*/
>> #define CXL_CM_OFFSET 0x1000
>> #define CXL_CM_CAP_HDR_OFFSET 0x0
>> @@ -39,33 +36,6 @@ extern const struct nvdimm_security_ops *cxl_security_ops;
>> #define CXL_CM_CAP_HDR_ARRAY_SIZE_MASK GENMASK(31, 24)
>> #define CXL_CM_CAP_PTR_MASK GENMASK(31, 20)
>>
>> -/* HDM decoders CXL 2.0 8.2.5.12 CXL HDM Decoder Capability Structure */
>> -#define CXL_HDM_DECODER_CAP_OFFSET 0x0
>> -#define CXL_HDM_DECODER_COUNT_MASK GENMASK(3, 0)
>> -#define CXL_HDM_DECODER_TARGET_COUNT_MASK GENMASK(7, 4)
>> -#define CXL_HDM_DECODER_INTERLEAVE_11_8 BIT(8)
>> -#define CXL_HDM_DECODER_INTERLEAVE_14_12 BIT(9)
>> -#define CXL_HDM_DECODER_INTERLEAVE_3_6_12_WAY BIT(11)
>> -#define CXL_HDM_DECODER_INTERLEAVE_16_WAY BIT(12)
>> -#define CXL_HDM_DECODER_CTRL_OFFSET 0x4
>> -#define CXL_HDM_DECODER_ENABLE BIT(1)
>> -#define CXL_HDM_DECODER0_BASE_LOW_OFFSET(i) (0x20 * (i) + 0x10)
>> -#define CXL_HDM_DECODER0_BASE_HIGH_OFFSET(i) (0x20 * (i) + 0x14)
>> -#define CXL_HDM_DECODER0_SIZE_LOW_OFFSET(i) (0x20 * (i) + 0x18)
>> -#define CXL_HDM_DECODER0_SIZE_HIGH_OFFSET(i) (0x20 * (i) + 0x1c)
>> -#define CXL_HDM_DECODER0_CTRL_OFFSET(i) (0x20 * (i) + 0x20)
>> -#define CXL_HDM_DECODER0_CTRL_IG_MASK GENMASK(3, 0)
>> -#define CXL_HDM_DECODER0_CTRL_IW_MASK GENMASK(7, 4)
>> -#define CXL_HDM_DECODER0_CTRL_LOCK BIT(8)
>> -#define CXL_HDM_DECODER0_CTRL_COMMIT BIT(9)
>> -#define CXL_HDM_DECODER0_CTRL_COMMITTED BIT(10)
>> -#define CXL_HDM_DECODER0_CTRL_COMMIT_ERROR BIT(11)
>> -#define CXL_HDM_DECODER0_CTRL_HOSTONLY BIT(12)
>> -#define CXL_HDM_DECODER0_TL_LOW(i) (0x20 * (i) + 0x24)
>> -#define CXL_HDM_DECODER0_TL_HIGH(i) (0x20 * (i) + 0x28)
>> -#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
>> diff --git a/include/cxl/cxl.h b/include/cxl/cxl.h
>> index 610711e861d4..27c006fa53c3 100644
>> --- a/include/cxl/cxl.h
>> +++ b/include/cxl/cxl.h
>> @@ -75,6 +75,36 @@ struct cxl_regs {
>> #define CXL_CM_CAP_CAP_ID_HDM 0x5
>> #define CXL_CM_CAP_CAP_HDM_VERSION 1
>>
>> +/* CXL 2.0 8.2.4 CXL Component Register Layout and Definition */
>> +#define CXL_COMPONENT_REG_BLOCK_SIZE SZ_64K
>> +
>> +/* HDM decoders CXL 2.0 8.2.5.12 CXL HDM Decoder Capability Structure */
>> +#define CXL_HDM_DECODER_CAP_OFFSET 0x0
>> +#define CXL_HDM_DECODER_COUNT_MASK GENMASK(3, 0)
>> +#define CXL_HDM_DECODER_TARGET_COUNT_MASK GENMASK(7, 4)
>> +#define CXL_HDM_DECODER_INTERLEAVE_11_8 BIT(8)
>> +#define CXL_HDM_DECODER_INTERLEAVE_14_12 BIT(9)
>> +#define CXL_HDM_DECODER_INTERLEAVE_3_6_12_WAY BIT(11)
>> +#define CXL_HDM_DECODER_INTERLEAVE_16_WAY BIT(12)
>> +#define CXL_HDM_DECODER_CTRL_OFFSET 0x4
>> +#define CXL_HDM_DECODER_ENABLE BIT(1)
>> +#define CXL_HDM_DECODER0_BASE_LOW_OFFSET(i) (0x20 * (i) + 0x10)
>> +#define CXL_HDM_DECODER0_BASE_HIGH_OFFSET(i) (0x20 * (i) + 0x14)
>> +#define CXL_HDM_DECODER0_SIZE_LOW_OFFSET(i) (0x20 * (i) + 0x18)
>> +#define CXL_HDM_DECODER0_SIZE_HIGH_OFFSET(i) (0x20 * (i) + 0x1c)
>> +#define CXL_HDM_DECODER0_CTRL_OFFSET(i) (0x20 * (i) + 0x20)
>> +#define CXL_HDM_DECODER0_CTRL_IG_MASK GENMASK(3, 0)
>> +#define CXL_HDM_DECODER0_CTRL_IW_MASK GENMASK(7, 4)
>> +#define CXL_HDM_DECODER0_CTRL_LOCK BIT(8)
>> +#define CXL_HDM_DECODER0_CTRL_COMMIT BIT(9)
>> +#define CXL_HDM_DECODER0_CTRL_COMMITTED BIT(10)
>> +#define CXL_HDM_DECODER0_CTRL_COMMIT_ERROR BIT(11)
>> +#define CXL_HDM_DECODER0_CTRL_HOSTONLY BIT(12)
>> +#define CXL_HDM_DECODER0_TL_LOW(i) (0x20 * (i) + 0x24)
>> +#define CXL_HDM_DECODER0_TL_HIGH(i) (0x20 * (i) + 0x28)
>> +#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)
>> +
>> struct cxl_reg_map {
>> bool valid;
>> int id;
>
>