mem/cxl_type3: support 3, 6, 12 and 16 interleave ways
PATCH v3 1/1 mem/cxl_type3: support 3, 6, 12 and 16 interleave ways
Since the kernel does not check the interleave capability, a 3-way, 6-way, 12-way or 16-way region can be create normally.
Applications can access the memory of 16-way region normally because qemu can convert hpa to dpa correctly for the power of 2 interleave ways, after kernel implementing the check, this kind of region will not be created any more.
For non power of 2 interleave ways, applications could not access the memory normally and may occur some unexpected behaviors, such as segmentation fault.
So implements this feature is needed.
--- hw/cxl/cxl-component-utils.c | 9 +++++++-- hw/mem/cxl_type3.c | 15 +++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-)
hw/cxl/cxl-component-utils.c +7 -2
@@ -243,8 +243,13 @@ static void hdm_init_common(uint32_t *reg_state, uint32_t *write_msk,ARRAY_FIELD_DP32 (reg_state,CXL_HDM_DECODER_CAPABILITY ,INTERLEAVE_4K ,1 );ARRAY_FIELD_DP32 (reg_state,CXL_HDM_DECODER_CAPABILITY ,POISON_ON_ERR_CAP ,0 ); - ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, 3_6_12_WAY, 0); - ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, 16_WAY, 0); +if (type ==CXL2_TYPE3_DEVICE ) { + ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, 3_6_12_WAY, 1); + ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, 16_WAY, 1); + }else { + ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, 3_6_12_WAY, 0); + ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, 16_WAY, 0); + }ARRAY_FIELD_DP32 (reg_state,CXL_HDM_DECODER_CAPABILITY ,UIO ,0 );ARRAY_FIELD_DP32 (reg_state,CXL_HDM_DECODER_CAPABILITY ,UIO_DECODER_COUNT ,0 );
hw/mem/cxl_type3.c +11 -4
@@ -804,10 +804,17 @@ static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr host_addr, uint64_t *dpa)continue ; } - *dpa = dpa_base + - ((MAKE_64BIT_MASK (0 ,8 + ig) & hpa_offset) | - ((MAKE_64BIT_MASK (8 + ig + iw,64 -8 - ig - iw) & hpa_offset) - >> iw)); +if (iw <8 ) { + *dpa = dpa_base + + ((MAKE_64BIT_MASK (0 ,8 + ig) & hpa_offset) | + ((MAKE_64BIT_MASK (8 + ig + iw,64 -8 - ig - iw) & hpa_offset) + >> iw)); + }else { + *dpa = dpa_base + + ((MAKE_64BIT_MASK (0 ,8 + ig) & hpa_offset) | + ((((MAKE_64BIT_MASK (ig + iw,64 - ig - iw) & hpa_offset) + >> (ig + iw)) /3 ) << (ig +8 ))); + }return true; }
Signature · 1 line
2.37.3
ping.
Quoted 87 lines
-----Original Message-----
From: Yao Xingtao <[email protected]>
Sent: Wednesday, May 8, 2024 8:53 AM
To: [email protected]; [email protected]
Cc: [email protected]; Yao, Xingtao/姚 幸涛 <[email protected]>
Subject: [PATCH v3] mem/cxl_type3: support 3, 6, 12 and 16 interleave waysSince the kernel does not check the interleave capability, a 3-way, 6-way, 12-way or 16-way region can be create normally.
Applications can access the memory of 16-way region normally because qemu can convert hpa to dpa correctly for the power of 2 interleave ways, after kernel implementing the check, this kind of region will not be created any more.
For non power of 2 interleave ways, applications could not access the memory normally and may occur some unexpected behaviors, such as segmentation fault.
So implements this feature is needed.
Link:
https://lore.kernel.org/linux-cxl/3e84b919-7631-d1db-3e1d-33000f3f3868@fujits
u.com/Signed-off-by Yao Xingtao <[email protected]>--- hw/cxl/cxl-component-utils.c | 9 +++++++-- hw/mem/cxl_type3.c | 15 +++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-)hw/cxl/cxl-component-utils.c +0
-2@@ -243,8 +243,13 @@ static void hdm_init_common(uint32_t *reg_state,uint32_t *write_msk,ARRAY_FIELD_DP32 (reg_state ,CXL_HDM_DECODER_CAPABILITY , INTERLEAVE_4K, 1);ARRAY_FIELD_DP32 (reg_state,CXL_HDM_DECODER_CAPABILITY ,POISON_ON_ERR_CAP ,0 ); -ARRAY_FIELD_DP32 (reg_state,CXL_HDM_DECODER_CAPABILITY , 3_6_12_WAY, 0); - ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, 16_WAY,0);
hw/cxl/cxl-component-utils.c +2
-0+if (type ==CXL2_TYPE3_DEVICE ) { + ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY,3_6_12_WAY, 1);
+ ARRAY_FIELD_DP32(reg_state,CXL_HDM_DECODER_CAPABILITY,
16_WAY, 1);hw/cxl/cxl-component-utils.c +2
-0+ }else { + ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY,3_6_12_WAY, 0);
+ ARRAY_FIELD_DP32(reg_state,CXL_HDM_DECODER_CAPABILITY,
16_WAY, 0);hw/cxl/cxl-component-utils.c +1
-0+ }ARRAY_FIELD_DP32 (reg_state,CXL_HDM_DECODER_CAPABILITY ,UIO ,0 );ARRAY_FIELD_DP32 (reg_state,CXL_HDM_DECODER_CAPABILITY ,UIO_DECODER_COUNT ,0 );hw/mem/cxl_type3.c +11
-4@@ -804,10 +804,17 @@ static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr host_addr, uint64_t *dpa)continue ; } - *dpa = dpa_base + - ((MAKE_64BIT_MASK (0 ,8 + ig) & hpa_offset) | - ((MAKE_64BIT_MASK (8 + ig + iw,64 -8 - ig - iw) & hpa_offset) - >> iw)); +if (iw <8 ) { + *dpa = dpa_base + + ((MAKE_64BIT_MASK (0 ,8 + ig) & hpa_offset) | + ((MAKE_64BIT_MASK (8 + ig + iw,64 -8 - ig - iw) & hpa_offset) + >> iw)); + }else { + *dpa = dpa_base + + ((MAKE_64BIT_MASK (0 ,8 + ig) & hpa_offset) | + ((((MAKE_64BIT_MASK (ig + iw,64 - ig - iw) & hpa_offset) + >> (ig + iw)) /3 ) << (ig +8 ))); + }return true;}--
2.37.3
ping again.
Quoted 101 lines
-----Original Message-----
From: Yao, Xingtao/姚 幸涛 <[email protected]>
Sent: Friday, May 24, 2024 5:31 PM
To: Yao, Xingtao/姚 幸涛 <[email protected]>; [email protected]; [email protected]
Cc: [email protected]
Subject: RE: [PATCH v3] mem/cxl_type3: support 3, 6, 12 and 16 interleave waysping.
Quoted 15 lines
-----Original Message-----
From: Yao Xingtao <[email protected]>
Sent: Wednesday, May 8, 2024 8:53 AM
To: [email protected]; [email protected]
Cc: [email protected]; Yao, Xingtao/姚 幸涛 <[email protected]>
Subject: [PATCH v3] mem/cxl_type3: support 3, 6, 12 and 16 interleave waysSince the kernel does not check the interleave capability, a 3-way, 6-way, 12-way or 16-way region can be create normally.
Applications can access the memory of 16-way region normally because qemu can convert hpa to dpa correctly for the power of 2 interleave ways, after kernel implementing the check, this kind of region will not be created any more.
Quoted 8 lines
For non power of 2 interleave ways, applications could not access the memory normally and may occur some unexpected behaviors, such as segmentation fault.
So implements this feature is needed.
Link:
https://lore.kernel.org/linux-cxl/3e84b919-7631-d1db-3e1d-33000f3f3868@fujits
Quoted 12 lines
u.com/
Signed-off-by Yao Xingtao <[email protected]>--- hw/cxl/cxl-component-utils.c | 9 +++++++-- hw/mem/cxl_type3.c | 15 +++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-)hw/cxl/cxl-component-utils.c +0
-0hw/cxl/cxl-component-utils.c static void hdm_init_common(uint32_t *reg_state, · line 250
Quoted 8 lines
hw/cxl/cxl-component-utils.c +0
-2@@ -243,8 +243,13 @@ static void hdm_init_common(uint32_t *reg_state,uint32_t *write_msk,ARRAY_FIELD_DP32 (reg_state ,CXL_HDM_DECODER_CAPABILITY , INTERLEAVE_4K, 1);ARRAY_FIELD_DP32 (reg_state,CXL_HDM_DECODER_CAPABILITY ,POISON_ON_ERR_CAP ,0 ); -ARRAY_FIELD_DP32 (reg_state,CXL_HDM_DECODER_CAPABILITY , 3_6_12_WAY, 0); - ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY,16_WAY,
Quoted 8 lines
0);
hw/cxl/cxl-component-utils.c +2
-0+if (type ==CXL2_TYPE3_DEVICE ) { + ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY,3_6_12_WAY, 1);
+ ARRAY_FIELD_DP32(reg_state,CXL_HDM_DECODER_CAPABILITY,
16_WAY, 1);hw/cxl/cxl-component-utils.c +2
-0+ }else { + ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY,Quoted 5 lines
3_6_12_WAY, 0);
+ ARRAY_FIELD_DP32(reg_state,CXL_HDM_DECODER_CAPABILITY,
16_WAY, 0);
+ }
ARRAY_FIELD_DP32(reg_state,CXL_HDM_DECODER_CAPABILITY, UIO,0);
Quoted 9 lines
ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, UIO_DECODER_COUNT, 0);hw/mem/cxl_type3.c +0
-0@@ -804,10 +804,17 @@ static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr host_addr, uint64_t *dpa)continue ;hw/mem/cxl_type3.c static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr · line 811
Quoted 10 lines
hw/mem/cxl_type3.c +4
-4} - *dpa = dpa_base + - ((MAKE_64BIT_MASK (0 ,8 + ig) & hpa_offset) | - ((MAKE_64BIT_MASK (8 + ig + iw,64 -8 - ig - iw) & hpa_offset) - >> iw)); +if (iw <8 ) { + *dpa = dpa_base + + ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) | + ((MAKE_64BIT_MASK(8 + ig + iw, 64 - 8 - ig - iw) &
hpa_offset)Quoted 12 lines
hw/mem/cxl_type3.c +7
-0+ >> iw)); + }else { + *dpa = dpa_base + + ((MAKE_64BIT_MASK (0 ,8 + ig) & hpa_offset) | + ((((MAKE_64BIT_MASK (ig + iw,64 - ig - iw) & hpa_offset) + >> (ig + iw)) /3 ) << (ig +8 ))); + }return true;}--
2.37.3
Quoted 1 line · On Thu, 6 Jun 2024 08:07:27 +0000 "Xingtao Yao (Fujitsu)"…
ping again.
Sorry for delay - I was waiting for some of the tree I'm carrying to get picked up before applying anything new.
I haven't yet tested this as fully as I'd like for upstreaming, but with that in mind applied to my cxl staging tree.
Thanks,
Jonathan
Quoted 104 lines
Quoted 102 lines
-----Original Message-----
From: Yao, Xingtao/姚 幸涛 <[email protected]>
Sent: Friday, May 24, 2024 5:31 PM
To: Yao, Xingtao/姚 幸涛 <[email protected]>; [email protected]; [email protected]
Cc: [email protected]
Subject: RE: [PATCH v3] mem/cxl_type3: support 3, 6, 12 and 16 interleave waysping.
Quoted 15 lines
-----Original Message-----
From: Yao Xingtao <[email protected]>
Sent: Wednesday, May 8, 2024 8:53 AM
To: [email protected]; [email protected]
Cc: [email protected]; Yao, Xingtao/姚 幸涛 <[email protected]>
Subject: [PATCH v3] mem/cxl_type3: support 3, 6, 12 and 16 interleave waysSince the kernel does not check the interleave capability, a 3-way, 6-way, 12-way or 16-way region can be create normally.
Applications can access the memory of 16-way region normally because qemu can convert hpa to dpa correctly for the power of 2 interleave ways, after kernel implementing the check, this kind of region will not be created any more.
Quoted 8 lines
For non power of 2 interleave ways, applications could not access the memory normally and may occur some unexpected behaviors, such as segmentation fault.
So implements this feature is needed.
Link:
https://lore.kernel.org/linux-cxl/3e84b919-7631-d1db-3e1d-33000f3f3868@fujits
Quoted 12 lines
u.com/
Signed-off-by Yao Xingtao <[email protected]>--- hw/cxl/cxl-component-utils.c | 9 +++++++-- hw/mem/cxl_type3.c | 15 +++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-)hw/cxl/cxl-component-utils.c +0
-0hw/cxl/cxl-component-utils.c static void hdm_init_common(uint32_t *reg_state, · line 250
Quoted 8 lines
hw/cxl/cxl-component-utils.c +0
-2@@ -243,8 +243,13 @@ static void hdm_init_common(uint32_t *reg_state,uint32_t *write_msk,ARRAY_FIELD_DP32 (reg_state ,CXL_HDM_DECODER_CAPABILITY , INTERLEAVE_4K, 1);ARRAY_FIELD_DP32 (reg_state,CXL_HDM_DECODER_CAPABILITY ,POISON_ON_ERR_CAP ,0 ); -ARRAY_FIELD_DP32 (reg_state,CXL_HDM_DECODER_CAPABILITY , 3_6_12_WAY, 0); - ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY,16_WAY,
Quoted 8 lines
0);
hw/cxl/cxl-component-utils.c +2
-0+if (type ==CXL2_TYPE3_DEVICE ) { + ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY,3_6_12_WAY, 1);
+ ARRAY_FIELD_DP32(reg_state,CXL_HDM_DECODER_CAPABILITY,
16_WAY, 1);hw/cxl/cxl-component-utils.c +2
-0+ }else { + ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY,Quoted 5 lines
3_6_12_WAY, 0);
+ ARRAY_FIELD_DP32(reg_state,CXL_HDM_DECODER_CAPABILITY,
16_WAY, 0);
+ }
ARRAY_FIELD_DP32(reg_state,CXL_HDM_DECODER_CAPABILITY, UIO,0);
Quoted 9 lines
ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, UIO_DECODER_COUNT, 0);hw/mem/cxl_type3.c +0
-0@@ -804,10 +804,17 @@ static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr host_addr, uint64_t *dpa)continue ;hw/mem/cxl_type3.c static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr · line 811
Quoted 10 lines
hw/mem/cxl_type3.c +4
-4} - *dpa = dpa_base + - ((MAKE_64BIT_MASK (0 ,8 + ig) & hpa_offset) | - ((MAKE_64BIT_MASK (8 + ig + iw,64 -8 - ig - iw) & hpa_offset) - >> iw)); +if (iw <8 ) { + *dpa = dpa_base + + ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) | + ((MAKE_64BIT_MASK(8 + ig + iw, 64 - 8 - ig - iw) &
hpa_offset)Quoted 12 lines
hw/mem/cxl_type3.c +7
-0+ >> iw)); + }else { + *dpa = dpa_base + + ((MAKE_64BIT_MASK (0 ,8 + ig) & hpa_offset) | + ((((MAKE_64BIT_MASK (ig + iw,64 - ig - iw) & hpa_offset) + >> (ig + iw)) /3 ) << (ig +8 ))); + }return true;}--
2.37.3
Quoted 12 lines
-----Original Message-----
From: Jonathan Cameron <[email protected]>
Sent: Friday, June 21, 2024 11:02 PM
To: Yao, Xingtao/姚 幸涛 <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v3] mem/cxl_type3: support 3, 6, 12 and 16 interleave waysOn Thu, 6 Jun 2024 08:07:27 +0000
"Xingtao Yao (Fujitsu)" <[email protected]> wrote:
Quoted 7 lines
Quoted 1 line
ping again.
Sorry for delay - I was waiting for some of the tree I'm carrying to get picked up before applying anything new.
I haven't yet tested this as fully as I'd like for upstreaming, but with that in mind applied to my cxl staging tree.
many thanks, I can do some test if you need.
Quoted 120 lines
Thanks,
Jonathan
Quoted 8 lines
Quoted 8 lines
-----Original Message-----
From: Yao, Xingtao/姚 幸涛 <[email protected]>
Sent: Friday, May 24, 2024 5:31 PM
To: Yao, Xingtao/姚 幸涛 <[email protected]>; [email protected]; [email protected]
Cc: [email protected]
Subject: RE: [PATCH v3] mem/cxl_type3: support 3, 6, 12 and 16 interleaveways
Quoted 8 lines
Quoted 8 lines
ping.
Quoted 5 lines
-----Original Message-----
From: Yao Xingtao <[email protected]>
Sent: Wednesday, May 8, 2024 8:53 AM
To: [email protected]; [email protected]
Cc: [email protected]; Yao, Xingtao/姚 幸涛Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Subject: [PATCH v3] mem/cxl_type3: support 3, 6, 12 and 16 interleave ways
Since the kernel does not check the interleave capability, a 3-way, 6-way, 12-way or 16-way region can be create normally.
Applications can access the memory of 16-way region normally because qemu can convert hpa to dpa correctly for the power of 2 interleave ways, after kernel implementing the check, this kind of region will not be created any more.
For non power of 2 interleave ways, applications could not access the memory normally and may occur some unexpected behaviors, such as segmentation fault.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
So implements this feature is needed.
Link:
https://lore.kernel.org/linux-cxl/3e84b919-7631-d1db-3e1d-33000f3f3868@fujits
Quoted 21 lines
Quoted 21 lines
Quoted 12 lines
u.com/
Signed-off-by Yao Xingtao <[email protected]>--- hw/cxl/cxl-component-utils.c | 9 +++++++-- hw/mem/cxl_type3.c | 15 +++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-)hw/cxl/cxl-component-utils.c +0
-0hw/cxl/cxl-component-utils.c static void hdm_init_common(uint32_t *reg_state, · line 250
Quoted 8 lines
hw/cxl/cxl-component-utils.c +0
-2@@ -243,8 +243,13 @@ static void hdm_init_common(uint32_t *reg_state,uint32_t *write_msk,ARRAY_FIELD_DP32 (reg_state ,CXL_HDM_DECODER_CAPABILITY , INTERLEAVE_4K, 1);ARRAY_FIELD_DP32 (reg_state,CXL_HDM_DECODER_CAPABILITY ,POISON_ON_ERR_CAP ,0 ); -ARRAY_FIELD_DP32 (reg_state,CXL_HDM_DECODER_CAPABILITY , 3_6_12_WAY, 0); - ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY,16_WAY,
Quoted 3 lines
Quoted 3 lines
hw/cxl/cxl-component-utils.c
Quoted 3 lines
0);
hw/cxl/cxl-component-utils.c +2
-0+if (type ==CXL2_TYPE3_DEVICE ) { + ARRAY_FIELD_DP32(reg_state,
CXL_HDM_DECODER_CAPABILITY,Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
3_6_12_WAY, 1);
+ ARRAY_FIELD_DP32(reg_state,
CXL_HDM_DECODER_CAPABILITY,Quoted 3 lines
Quoted 3 lines
hw/cxl/cxl-component-utils.c
Quoted 3 lines
16_WAY, 1);
hw/cxl/cxl-component-utils.c +2
-0+ }else { + ARRAY_FIELD_DP32(reg_state,
CXL_HDM_DECODER_CAPABILITY,Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
3_6_12_WAY, 0);
+ ARRAY_FIELD_DP32(reg_state,
CXL_HDM_DECODER_CAPABILITY,Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
16_WAY, 0);
+ }
ARRAY_FIELD_DP32(reg_state,CXL_HDM_DECODER_CAPABILITY,UIO,
Quoted 8 lines
Quoted 8 lines
0);
hw/mem/cxl_type3.c static bool cxl_type3_dpa(CXLType3Dev *ct3d,
Quoted 7 lines
ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, UIO_DECODER_COUNT, 0);hw/mem/cxl_type3.c +0
-0@@ -804,10 +804,17 @@ static bool cxl_type3_dpa(CXLType3Dev *ct3d,hwaddr
Quoted 7 lines
Quoted 7 lines
hw/mem/cxl_type3.c static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr host_addr, uint64_t *dpa)
Quoted 7 lines
hw/mem/cxl_type3.c +0
-3host_addr, uint64_t *dpa)continue ; } - *dpa = dpa_base + - ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) | - ((MAKE_64BIT_MASK(8 + ig + iw, 64 - 8 - ig - iw) &
hpa_offset)Quoted 11 lines
Quoted 11 lines
hw/mem/cxl_type3.c static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr host_addr, uint64_t *dpa)
Quoted 5 lines
hw/mem/cxl_type3.c +4
-1- >> iw)); +if (iw <8 ) { + *dpa = dpa_base + + ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) | + ((MAKE_64BIT_MASK(8 + ig + iw, 64 - 8 - ig - iw) &
hpa_offset)Quoted 5 lines
hw/mem/cxl_type3.c +5
-0+ >> iw)); + }else { + *dpa = dpa_base + + ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) | + ((((MAKE_64BIT_MASK(ig + iw, 64 - ig - iw) &
hpa_offset)Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
hw/mem/cxl_type3.c +2
-0+ >> (ig + iw)) / 3) << (ig + 8))); + }return true;}--
2.37.3