Skip to content

Commit a8b773f

Browse files
committed
cxl: Setup exclusive CXL features that are reserved for the kernel
Certain features will be exclusively used by components such as in kernel RAS driver. Setup an exclusion list that can be used to detect if a feature is exclusive to the kernel. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Li Ming <ming.li@zohomail.com> Tested-by: Shiju Jose <shiju.jose@huawei.com> Link: https://patch.msgid.link/20250220194438.2281088-7-dave.jiang@intel.com Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent 14d502c commit a8b773f

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

drivers/cxl/core/features.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,28 @@
77
#include "core.h"
88
#include "cxlmem.h"
99

10+
/* All the features below are exclusive to the kernel */
11+
static const uuid_t cxl_exclusive_feats[] = {
12+
CXL_FEAT_PATROL_SCRUB_UUID,
13+
CXL_FEAT_ECS_UUID,
14+
CXL_FEAT_SPPR_UUID,
15+
CXL_FEAT_HPPR_UUID,
16+
CXL_FEAT_CACHELINE_SPARING_UUID,
17+
CXL_FEAT_ROW_SPARING_UUID,
18+
CXL_FEAT_BANK_SPARING_UUID,
19+
CXL_FEAT_RANK_SPARING_UUID,
20+
};
21+
22+
static bool is_cxl_feature_exclusive(struct cxl_feat_entry *entry)
23+
{
24+
for (int i = 0; i < ARRAY_SIZE(cxl_exclusive_feats); i++) {
25+
if (uuid_equal(&entry->uuid, &cxl_exclusive_feats[i]))
26+
return true;
27+
}
28+
29+
return false;
30+
}
31+
1032
inline struct cxl_features_state *to_cxlfs(struct cxl_dev_state *cxlds)
1133
{
1234
return cxlds->cxlfs;
@@ -47,6 +69,7 @@ get_supported_features(struct cxl_features_state *cxlfs)
4769
struct cxl_mbox_get_sup_feats_in mbox_in;
4870
struct cxl_feat_entry *entry;
4971
struct cxl_mbox_cmd mbox_cmd;
72+
int user_feats = 0;
5073
int count;
5174

5275
count = cxl_get_supported_features_count(cxl_mbox);
@@ -121,6 +144,10 @@ get_supported_features(struct cxl_features_state *cxlfs)
121144
return NULL;
122145

123146
memcpy(entry, mbox_out->ents, retrieved);
147+
for (int i = 0; i < num_entries; i++) {
148+
if (!is_cxl_feature_exclusive(entry + i))
149+
user_feats++;
150+
}
124151
entry += num_entries;
125152
/*
126153
* If the number of output entries is less than expected, add the
@@ -131,6 +158,7 @@ get_supported_features(struct cxl_features_state *cxlfs)
131158
} while (remain_feats);
132159

133160
entries->num_features = count;
161+
entries->num_user_features = user_feats;
134162

135163
return no_free_ptr(entries);
136164
}

include/cxl/features.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,39 @@
55

66
#include <linux/uuid.h>
77

8+
/* Feature UUIDs used by the kernel */
9+
#define CXL_FEAT_PATROL_SCRUB_UUID \
10+
UUID_INIT(0x96dad7d6, 0xfde8, 0x482b, 0xa7, 0x33, 0x75, 0x77, 0x4e, \
11+
0x06, 0xdb, 0x8a)
12+
13+
#define CXL_FEAT_ECS_UUID \
14+
UUID_INIT(0xe5b13f22, 0x2328, 0x4a14, 0xb8, 0xba, 0xb9, 0x69, 0x1e, \
15+
0x89, 0x33, 0x86)
16+
17+
#define CXL_FEAT_SPPR_UUID \
18+
UUID_INIT(0x892ba475, 0xfad8, 0x474e, 0x9d, 0x3e, 0x69, 0x2c, 0x91, \
19+
0x75, 0x68, 0xbb)
20+
21+
#define CXL_FEAT_HPPR_UUID \
22+
UUID_INIT(0x80ea4521, 0x786f, 0x4127, 0xaf, 0xb1, 0xec, 0x74, 0x59, \
23+
0xfb, 0x0e, 0x24)
24+
25+
#define CXL_FEAT_CACHELINE_SPARING_UUID \
26+
UUID_INIT(0x96C33386, 0x91dd, 0x44c7, 0x9e, 0xcb, 0xfd, 0xaf, 0x65, \
27+
0x03, 0xba, 0xc4)
28+
29+
#define CXL_FEAT_ROW_SPARING_UUID \
30+
UUID_INIT(0x450ebf67, 0xb135, 0x4f97, 0xa4, 0x98, 0xc2, 0xd5, 0x7f, \
31+
0x27, 0x9b, 0xed)
32+
33+
#define CXL_FEAT_BANK_SPARING_UUID \
34+
UUID_INIT(0x78b79636, 0x90ac, 0x4b64, 0xa4, 0xef, 0xfa, 0xac, 0x5d, \
35+
0x18, 0xa8, 0x63)
36+
37+
#define CXL_FEAT_RANK_SPARING_UUID \
38+
UUID_INIT(0x34dbaff5, 0x0552, 0x4281, 0x8f, 0x76, 0xda, 0x0b, 0x5e, \
39+
0x7a, 0x76, 0xa7)
40+
841
/* Feature commands capability supported by a device */
942
enum cxl_features_capability {
1043
CXL_FEATURES_NONE = 0,
@@ -134,6 +167,7 @@ struct cxl_features_state {
134167
struct cxl_dev_state *cxlds;
135168
struct cxl_feat_entries {
136169
int num_features;
170+
int num_user_features;
137171
struct cxl_feat_entry ent[] __counted_by(num_features);
138172
} *entries;
139173
};

0 commit comments

Comments
 (0)