Skip to content

Commit 8f55ada

Browse files
AlisonSchofielddavejiang
authored andcommitted
cxl: Remove defunct code calculating host bridge target positions
The CXL Spec 3.1 Table 9-22 requires that the BIOS populate the CFMWS target list in interleave target order. This means the calculations the CXL driver added to determine positions when XOR math is in use, along with the entire XOR vs Modulo call back setup is not needed. A prior patch added a common method to verify positions. Remove the now unused code related to the cxl_calc_hb_fn. Signed-off-by: Alison Schofield <alison.schofield@intel.com> Reviewed-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Link: https://patch.msgid.link/2e2c32a2d0f1007e920b58712d15edad2e48d857.1719980933.git.alison.schofield@intel.com Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent 82a3e3a commit 8f55ada

File tree

3 files changed

+4
-84
lines changed

3 files changed

+4
-84
lines changed

drivers/cxl/acpi.c

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -22,57 +22,6 @@ static const guid_t acpi_cxl_qtg_id_guid =
2222
GUID_INIT(0xF365F9A6, 0xA7DE, 0x4071,
2323
0xA6, 0x6A, 0xB4, 0x0C, 0x0B, 0x4F, 0x8E, 0x52);
2424

25-
/*
26-
* Find a targets entry (n) in the host bridge interleave list.
27-
* CXL Specification 3.0 Table 9-22
28-
*/
29-
static int cxl_xor_calc_n(u64 hpa, struct cxl_cxims_data *cximsd, int iw,
30-
int ig)
31-
{
32-
int i = 0, n = 0;
33-
u8 eiw;
34-
35-
/* IW: 2,4,6,8,12,16 begin building 'n' using xormaps */
36-
if (iw != 3) {
37-
for (i = 0; i < cximsd->nr_maps; i++)
38-
n |= (hweight64(hpa & cximsd->xormaps[i]) & 1) << i;
39-
}
40-
/* IW: 3,6,12 add a modulo calculation to 'n' */
41-
if (!is_power_of_2(iw)) {
42-
if (ways_to_eiw(iw, &eiw))
43-
return -1;
44-
hpa &= GENMASK_ULL(51, eiw + ig);
45-
n |= do_div(hpa, 3) << i;
46-
}
47-
return n;
48-
}
49-
50-
static struct cxl_dport *cxl_hb_xor(struct cxl_root_decoder *cxlrd, int pos)
51-
{
52-
struct cxl_cxims_data *cximsd = cxlrd->platform_data;
53-
struct cxl_switch_decoder *cxlsd = &cxlrd->cxlsd;
54-
struct cxl_decoder *cxld = &cxlsd->cxld;
55-
int ig = cxld->interleave_granularity;
56-
int iw = cxld->interleave_ways;
57-
int n = 0;
58-
u64 hpa;
59-
60-
if (dev_WARN_ONCE(&cxld->dev,
61-
cxld->interleave_ways != cxlsd->nr_targets,
62-
"misconfigured root decoder\n"))
63-
return NULL;
64-
65-
hpa = cxlrd->res->start + pos * ig;
66-
67-
/* Entry (n) is 0 for no interleave (iw == 1) */
68-
if (iw != 1)
69-
n = cxl_xor_calc_n(hpa, cximsd, iw, ig);
70-
71-
if (n < 0)
72-
return NULL;
73-
74-
return cxlrd->cxlsd.target[n];
75-
}
7625

7726
static u64 cxl_xor_hpa_to_spa(struct cxl_root_decoder *cxlrd, u64 hpa)
7827
{
@@ -398,7 +347,6 @@ static int __cxl_parse_cfmws(struct acpi_cedt_cfmws *cfmws,
398347
struct cxl_port *root_port = ctx->root_port;
399348
struct cxl_cxims_context cxims_ctx;
400349
struct device *dev = ctx->dev;
401-
cxl_calc_hb_fn cxl_calc_hb;
402350
struct cxl_decoder *cxld;
403351
unsigned int ways, i, ig;
404352
int rc;
@@ -426,13 +374,9 @@ static int __cxl_parse_cfmws(struct acpi_cedt_cfmws *cfmws,
426374
if (rc)
427375
return rc;
428376

429-
if (cfmws->interleave_arithmetic == ACPI_CEDT_CFMWS_ARITHMETIC_MODULO)
430-
cxl_calc_hb = cxl_hb_modulo;
431-
else
432-
cxl_calc_hb = cxl_hb_xor;
433-
434377
struct cxl_root_decoder *cxlrd __free(put_cxlrd) =
435-
cxl_root_decoder_alloc(root_port, ways, cxl_calc_hb);
378+
cxl_root_decoder_alloc(root_port, ways);
379+
436380
if (IS_ERR(cxlrd))
437381
return PTR_ERR(cxlrd);
438382

drivers/cxl/core/port.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,21 +1733,6 @@ static int decoder_populate_targets(struct cxl_switch_decoder *cxlsd,
17331733
return 0;
17341734
}
17351735

1736-
struct cxl_dport *cxl_hb_modulo(struct cxl_root_decoder *cxlrd, int pos)
1737-
{
1738-
struct cxl_switch_decoder *cxlsd = &cxlrd->cxlsd;
1739-
struct cxl_decoder *cxld = &cxlsd->cxld;
1740-
int iw;
1741-
1742-
iw = cxld->interleave_ways;
1743-
if (dev_WARN_ONCE(&cxld->dev, iw != cxlsd->nr_targets,
1744-
"misconfigured root decoder\n"))
1745-
return NULL;
1746-
1747-
return cxlrd->cxlsd.target[pos % iw];
1748-
}
1749-
EXPORT_SYMBOL_NS_GPL(cxl_hb_modulo, CXL);
1750-
17511736
static struct lock_class_key cxl_decoder_key;
17521737

17531738
/**
@@ -1807,16 +1792,14 @@ static int cxl_switch_decoder_init(struct cxl_port *port,
18071792
* cxl_root_decoder_alloc - Allocate a root level decoder
18081793
* @port: owning CXL root of this decoder
18091794
* @nr_targets: static number of downstream targets
1810-
* @calc_hb: which host bridge covers the n'th position by granularity
18111795
*
18121796
* Return: A new cxl decoder to be registered by cxl_decoder_add(). A
18131797
* 'CXL root' decoder is one that decodes from a top-level / static platform
18141798
* firmware description of CXL resources into a CXL standard decode
18151799
* topology.
18161800
*/
18171801
struct cxl_root_decoder *cxl_root_decoder_alloc(struct cxl_port *port,
1818-
unsigned int nr_targets,
1819-
cxl_calc_hb_fn calc_hb)
1802+
unsigned int nr_targets)
18201803
{
18211804
struct cxl_root_decoder *cxlrd;
18221805
struct cxl_switch_decoder *cxlsd;
@@ -1838,7 +1821,6 @@ struct cxl_root_decoder *cxl_root_decoder_alloc(struct cxl_port *port,
18381821
return ERR_PTR(rc);
18391822
}
18401823

1841-
cxlrd->calc_hb = calc_hb;
18421824
mutex_init(&cxlrd->range_lock);
18431825

18441826
cxld = &cxlsd->cxld;

drivers/cxl/cxl.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -432,15 +432,12 @@ struct cxl_switch_decoder {
432432
};
433433

434434
struct cxl_root_decoder;
435-
typedef struct cxl_dport *(*cxl_calc_hb_fn)(struct cxl_root_decoder *cxlrd,
436-
int pos);
437435
typedef u64 (*cxl_hpa_to_spa_fn)(struct cxl_root_decoder *cxlrd, u64 hpa);
438436

439437
/**
440438
* struct cxl_root_decoder - Static platform CXL address decoder
441439
* @res: host / parent resource for region allocations
442440
* @region_id: region id for next region provisioning event
443-
* @calc_hb: which host bridge covers the n'th position by granularity
444441
* @hpa_to_spa: translate CXL host-physical-address to Platform system-physical-address
445442
* @platform_data: platform specific configuration data
446443
* @range_lock: sync region autodiscovery by address range
@@ -450,7 +447,6 @@ typedef u64 (*cxl_hpa_to_spa_fn)(struct cxl_root_decoder *cxlrd, u64 hpa);
450447
struct cxl_root_decoder {
451448
struct resource *res;
452449
atomic_t region_id;
453-
cxl_calc_hb_fn calc_hb;
454450
cxl_hpa_to_spa_fn hpa_to_spa;
455451
void *platform_data;
456452
struct mutex range_lock;
@@ -775,9 +771,7 @@ bool is_root_decoder(struct device *dev);
775771
bool is_switch_decoder(struct device *dev);
776772
bool is_endpoint_decoder(struct device *dev);
777773
struct cxl_root_decoder *cxl_root_decoder_alloc(struct cxl_port *port,
778-
unsigned int nr_targets,
779-
cxl_calc_hb_fn calc_hb);
780-
struct cxl_dport *cxl_hb_modulo(struct cxl_root_decoder *cxlrd, int pos);
774+
unsigned int nr_targets);
781775
struct cxl_switch_decoder *cxl_switch_decoder_alloc(struct cxl_port *port,
782776
unsigned int nr_targets);
783777
int cxl_decoder_add(struct cxl_decoder *cxld, int *target_map);

0 commit comments

Comments
 (0)