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>

authored by Alison Schofield and committed by Dave Jiang 8f55ada7 82a3e3a2

+4 -84
+2 -58
drivers/cxl/acpi.c
··· 22 GUID_INIT(0xF365F9A6, 0xA7DE, 0x4071, 23 0xA6, 0x6A, 0xB4, 0x0C, 0x0B, 0x4F, 0x8E, 0x52); 24 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 - } 76 77 static u64 cxl_xor_hpa_to_spa(struct cxl_root_decoder *cxlrd, u64 hpa) 78 { ··· 347 struct cxl_port *root_port = ctx->root_port; 348 struct cxl_cxims_context cxims_ctx; 349 struct device *dev = ctx->dev; 350 - cxl_calc_hb_fn cxl_calc_hb; 351 struct cxl_decoder *cxld; 352 unsigned int ways, i, ig; 353 int rc; ··· 374 if (rc) 375 return rc; 376 377 - if (cfmws->interleave_arithmetic == ACPI_CEDT_CFMWS_ARITHMETIC_MODULO) 378 - cxl_calc_hb = cxl_hb_modulo; 379 - else 380 - cxl_calc_hb = cxl_hb_xor; 381 - 382 struct cxl_root_decoder *cxlrd __free(put_cxlrd) = 383 - cxl_root_decoder_alloc(root_port, ways, cxl_calc_hb); 384 if (IS_ERR(cxlrd)) 385 return PTR_ERR(cxlrd); 386
··· 22 GUID_INIT(0xF365F9A6, 0xA7DE, 0x4071, 23 0xA6, 0x6A, 0xB4, 0x0C, 0x0B, 0x4F, 0x8E, 0x52); 24 25 26 static u64 cxl_xor_hpa_to_spa(struct cxl_root_decoder *cxlrd, u64 hpa) 27 { ··· 398 struct cxl_port *root_port = ctx->root_port; 399 struct cxl_cxims_context cxims_ctx; 400 struct device *dev = ctx->dev; 401 struct cxl_decoder *cxld; 402 unsigned int ways, i, ig; 403 int rc; ··· 426 if (rc) 427 return rc; 428 429 struct cxl_root_decoder *cxlrd __free(put_cxlrd) = 430 + cxl_root_decoder_alloc(root_port, ways); 431 + 432 if (IS_ERR(cxlrd)) 433 return PTR_ERR(cxlrd); 434
+1 -19
drivers/cxl/core/port.c
··· 1733 return 0; 1734 } 1735 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 - 1751 static struct lock_class_key cxl_decoder_key; 1752 1753 /** ··· 1792 * cxl_root_decoder_alloc - Allocate a root level decoder 1793 * @port: owning CXL root of this decoder 1794 * @nr_targets: static number of downstream targets 1795 - * @calc_hb: which host bridge covers the n'th position by granularity 1796 * 1797 * Return: A new cxl decoder to be registered by cxl_decoder_add(). A 1798 * 'CXL root' decoder is one that decodes from a top-level / static platform ··· 1799 * topology. 1800 */ 1801 struct cxl_root_decoder *cxl_root_decoder_alloc(struct cxl_port *port, 1802 - unsigned int nr_targets, 1803 - cxl_calc_hb_fn calc_hb) 1804 { 1805 struct cxl_root_decoder *cxlrd; 1806 struct cxl_switch_decoder *cxlsd; ··· 1821 return ERR_PTR(rc); 1822 } 1823 1824 - cxlrd->calc_hb = calc_hb; 1825 mutex_init(&cxlrd->range_lock); 1826 1827 cxld = &cxlsd->cxld;
··· 1733 return 0; 1734 } 1735 1736 static struct lock_class_key cxl_decoder_key; 1737 1738 /** ··· 1807 * cxl_root_decoder_alloc - Allocate a root level decoder 1808 * @port: owning CXL root of this decoder 1809 * @nr_targets: static number of downstream targets 1810 * 1811 * Return: A new cxl decoder to be registered by cxl_decoder_add(). A 1812 * 'CXL root' decoder is one that decodes from a top-level / static platform ··· 1815 * topology. 1816 */ 1817 struct cxl_root_decoder *cxl_root_decoder_alloc(struct cxl_port *port, 1818 + unsigned int nr_targets) 1819 { 1820 struct cxl_root_decoder *cxlrd; 1821 struct cxl_switch_decoder *cxlsd; ··· 1838 return ERR_PTR(rc); 1839 } 1840 1841 mutex_init(&cxlrd->range_lock); 1842 1843 cxld = &cxlsd->cxld;
+1 -7
drivers/cxl/cxl.h
··· 432 }; 433 434 struct cxl_root_decoder; 435 - typedef struct cxl_dport *(*cxl_calc_hb_fn)(struct cxl_root_decoder *cxlrd, 436 - int pos); 437 typedef u64 (*cxl_hpa_to_spa_fn)(struct cxl_root_decoder *cxlrd, u64 hpa); 438 439 /** 440 * struct cxl_root_decoder - Static platform CXL address decoder 441 * @res: host / parent resource for region allocations 442 * @region_id: region id for next region provisioning event 443 - * @calc_hb: which host bridge covers the n'th position by granularity 444 * @hpa_to_spa: translate CXL host-physical-address to Platform system-physical-address 445 * @platform_data: platform specific configuration data 446 * @range_lock: sync region autodiscovery by address range ··· 447 struct cxl_root_decoder { 448 struct resource *res; 449 atomic_t region_id; 450 - cxl_calc_hb_fn calc_hb; 451 cxl_hpa_to_spa_fn hpa_to_spa; 452 void *platform_data; 453 struct mutex range_lock; ··· 771 bool is_switch_decoder(struct device *dev); 772 bool is_endpoint_decoder(struct device *dev); 773 struct cxl_root_decoder *cxl_root_decoder_alloc(struct cxl_port *port, 774 - unsigned int nr_targets, 775 - cxl_calc_hb_fn calc_hb); 776 - struct cxl_dport *cxl_hb_modulo(struct cxl_root_decoder *cxlrd, int pos); 777 struct cxl_switch_decoder *cxl_switch_decoder_alloc(struct cxl_port *port, 778 unsigned int nr_targets); 779 int cxl_decoder_add(struct cxl_decoder *cxld, int *target_map);
··· 432 }; 433 434 struct cxl_root_decoder; 435 typedef u64 (*cxl_hpa_to_spa_fn)(struct cxl_root_decoder *cxlrd, u64 hpa); 436 437 /** 438 * struct cxl_root_decoder - Static platform CXL address decoder 439 * @res: host / parent resource for region allocations 440 * @region_id: region id for next region provisioning event 441 * @hpa_to_spa: translate CXL host-physical-address to Platform system-physical-address 442 * @platform_data: platform specific configuration data 443 * @range_lock: sync region autodiscovery by address range ··· 450 struct cxl_root_decoder { 451 struct resource *res; 452 atomic_t region_id; 453 cxl_hpa_to_spa_fn hpa_to_spa; 454 void *platform_data; 455 struct mutex range_lock; ··· 775 bool is_switch_decoder(struct device *dev); 776 bool is_endpoint_decoder(struct device *dev); 777 struct cxl_root_decoder *cxl_root_decoder_alloc(struct cxl_port *port, 778 + unsigned int nr_targets); 779 struct cxl_switch_decoder *cxl_switch_decoder_alloc(struct cxl_port *port, 780 unsigned int nr_targets); 781 int cxl_decoder_add(struct cxl_decoder *cxld, int *target_map);