a5ab0de0eb
The current bandwidth calculation aggregates all the targets. This simple method does not take into account where multiple targets sharing under a switch or a root port where the aggregated bandwidth can be greater than the upstream link of the switch. To accurately account for the shared upstream uplink cases, a new update function is introduced by walking from the leaves to the root of the hierarchy and clamp the bandwidth in the process as needed. This process is done when all the targets for a region are present but before the final values are send to the HMAT handling code cached access_coordinate targets. The original perf calculation path was kept to calculate the latency performance data that does not require the shared link consideration. The shared upstream link calculation is done as a second pass when all the endpoints have arrived. Testing is done via qemu with CXL hierarchy. run_qemu[1] is modified to support several CXL hierarchy layouts. The following layouts are tested: HB: Host Bridge RP: Root Port SW: Switch EP: End Point 2 HB 2 RP 2 EP: resulting bandwidth: 624 1 HB 2 RP 2 EP: resulting bandwidth: 624 2 HB 2 RP 2 SW 4 EP: resulting bandwidth: 624 Current testing, perf number from SRAT/HMAT is hacked into the kernel code. However with new QEMU support of Generic Target Port that's incoming, the perf data injection is no longer needed. [1]: https://github.com/pmem/run_qemu Suggested-by: Jonathan Cameron <jonathan.cameron@huawei.com> Link: https://lore.kernel.org/linux-cxl/20240501152503.00002e60@Huawei.com/ Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Alison Schofield <alison.schofield@intel.com> Acked-by: Dan Williams <dan.j.williams@intel.com> Link: https://patch.msgid.link/20240904001316.1688225-3-dave.jiang@intel.com Signed-off-by: Dave Jiang <dave.jiang@intel.com>
114 lines
3.7 KiB
C
114 lines
3.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/* Copyright(c) 2020 Intel Corporation. */
|
|
|
|
#ifndef __CXL_CORE_H__
|
|
#define __CXL_CORE_H__
|
|
|
|
extern const struct device_type cxl_nvdimm_bridge_type;
|
|
extern const struct device_type cxl_nvdimm_type;
|
|
extern const struct device_type cxl_pmu_type;
|
|
|
|
extern struct attribute_group cxl_base_attribute_group;
|
|
|
|
#ifdef CONFIG_CXL_REGION
|
|
extern struct device_attribute dev_attr_create_pmem_region;
|
|
extern struct device_attribute dev_attr_create_ram_region;
|
|
extern struct device_attribute dev_attr_delete_region;
|
|
extern struct device_attribute dev_attr_region;
|
|
extern const struct device_type cxl_pmem_region_type;
|
|
extern const struct device_type cxl_dax_region_type;
|
|
extern const struct device_type cxl_region_type;
|
|
void cxl_decoder_kill_region(struct cxl_endpoint_decoder *cxled);
|
|
#define CXL_REGION_ATTR(x) (&dev_attr_##x.attr)
|
|
#define CXL_REGION_TYPE(x) (&cxl_region_type)
|
|
#define SET_CXL_REGION_ATTR(x) (&dev_attr_##x.attr),
|
|
#define CXL_PMEM_REGION_TYPE(x) (&cxl_pmem_region_type)
|
|
#define CXL_DAX_REGION_TYPE(x) (&cxl_dax_region_type)
|
|
int cxl_region_init(void);
|
|
void cxl_region_exit(void);
|
|
int cxl_get_poison_by_endpoint(struct cxl_port *port);
|
|
struct cxl_region *cxl_dpa_to_region(const struct cxl_memdev *cxlmd, u64 dpa);
|
|
u64 cxl_dpa_to_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd,
|
|
u64 dpa);
|
|
|
|
#else
|
|
static inline u64 cxl_dpa_to_hpa(struct cxl_region *cxlr,
|
|
const struct cxl_memdev *cxlmd, u64 dpa)
|
|
{
|
|
return ULLONG_MAX;
|
|
}
|
|
static inline
|
|
struct cxl_region *cxl_dpa_to_region(const struct cxl_memdev *cxlmd, u64 dpa)
|
|
{
|
|
return NULL;
|
|
}
|
|
static inline int cxl_get_poison_by_endpoint(struct cxl_port *port)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline void cxl_decoder_kill_region(struct cxl_endpoint_decoder *cxled)
|
|
{
|
|
}
|
|
static inline int cxl_region_init(void)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline void cxl_region_exit(void)
|
|
{
|
|
}
|
|
#define CXL_REGION_ATTR(x) NULL
|
|
#define CXL_REGION_TYPE(x) NULL
|
|
#define SET_CXL_REGION_ATTR(x)
|
|
#define CXL_PMEM_REGION_TYPE(x) NULL
|
|
#define CXL_DAX_REGION_TYPE(x) NULL
|
|
#endif
|
|
|
|
struct cxl_send_command;
|
|
struct cxl_mem_query_commands;
|
|
int cxl_query_cmd(struct cxl_memdev *cxlmd,
|
|
struct cxl_mem_query_commands __user *q);
|
|
int cxl_send_cmd(struct cxl_memdev *cxlmd, struct cxl_send_command __user *s);
|
|
void __iomem *devm_cxl_iomap_block(struct device *dev, resource_size_t addr,
|
|
resource_size_t length);
|
|
|
|
struct dentry *cxl_debugfs_create_dir(const char *dir);
|
|
int cxl_dpa_set_mode(struct cxl_endpoint_decoder *cxled,
|
|
enum cxl_decoder_mode mode);
|
|
int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, unsigned long long size);
|
|
int cxl_dpa_free(struct cxl_endpoint_decoder *cxled);
|
|
resource_size_t cxl_dpa_size(struct cxl_endpoint_decoder *cxled);
|
|
resource_size_t cxl_dpa_resource_start(struct cxl_endpoint_decoder *cxled);
|
|
|
|
enum cxl_rcrb {
|
|
CXL_RCRB_DOWNSTREAM,
|
|
CXL_RCRB_UPSTREAM,
|
|
};
|
|
struct cxl_rcrb_info;
|
|
resource_size_t __rcrb_to_component(struct device *dev,
|
|
struct cxl_rcrb_info *ri,
|
|
enum cxl_rcrb which);
|
|
u16 cxl_rcrb_to_aer(struct device *dev, resource_size_t rcrb);
|
|
|
|
extern struct rw_semaphore cxl_dpa_rwsem;
|
|
extern struct rw_semaphore cxl_region_rwsem;
|
|
|
|
int cxl_memdev_init(void);
|
|
void cxl_memdev_exit(void);
|
|
void cxl_mbox_init(void);
|
|
|
|
enum cxl_poison_trace_type {
|
|
CXL_POISON_TRACE_LIST,
|
|
CXL_POISON_TRACE_INJECT,
|
|
CXL_POISON_TRACE_CLEAR,
|
|
};
|
|
|
|
long cxl_pci_get_latency(struct pci_dev *pdev);
|
|
int cxl_pci_get_bandwidth(struct pci_dev *pdev, struct access_coordinate *c);
|
|
int cxl_update_hmat_access_coordinates(int nid, struct cxl_region *cxlr,
|
|
enum access_coordinate_class access);
|
|
bool cxl_need_node_perf_attrs_update(int nid);
|
|
int cxl_port_get_switch_dport_bandwidth(struct cxl_port *port,
|
|
struct access_coordinate *c);
|
|
|
|
#endif /* __CXL_CORE_H__ */
|