Commit 9aa5f623 authored by Alison Schofield's avatar Alison Schofield Committed by Dave Jiang

cxl/core: Fold cxl_trace_hpa() into cxl_dpa_to_hpa()

Although cxl_trace_hpa() is used to populate TRACE EVENTs with HPA
addresses the work it performs is a DPA to HPA translation not a
trace. Tidy up this naming by moving the minimal work done in
cxl_trace_hpa() into cxl_dpa_to_hpa() and use cxl_dpa_to_hpa()
for trace event callbacks.
Suggested-by: default avatarDan Williams <dan.j.williams@intel.com>
Signed-off-by: default avatarAlison Schofield <alison.schofield@intel.com>
Reviewed-by: default avatarDan Williams <dan.j.williams@intel.com>
Reviewed-by: default avatarRobert Richter <rrichter@amd.com>
Link: https://patch.msgid.link/452a9b0c525b774c72d9d5851515ffa928750132.1719980933.git.alison.schofield@intel.comSigned-off-by: default avatarDave Jiang <dave.jiang@intel.com>
parent 22a40d14
...@@ -28,12 +28,12 @@ int cxl_region_init(void); ...@@ -28,12 +28,12 @@ int cxl_region_init(void);
void cxl_region_exit(void); void cxl_region_exit(void);
int cxl_get_poison_by_endpoint(struct cxl_port *port); int cxl_get_poison_by_endpoint(struct cxl_port *port);
struct cxl_region *cxl_dpa_to_region(const struct cxl_memdev *cxlmd, u64 dpa); struct cxl_region *cxl_dpa_to_region(const struct cxl_memdev *cxlmd, u64 dpa);
u64 cxl_trace_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd, u64 cxl_dpa_to_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd,
u64 dpa); u64 dpa);
#else #else
static inline u64 static inline u64 cxl_dpa_to_hpa(struct cxl_region *cxlr,
cxl_trace_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd, u64 dpa) const struct cxl_memdev *cxlmd, u64 dpa)
{ {
return ULLONG_MAX; return ULLONG_MAX;
} }
......
...@@ -878,7 +878,7 @@ void cxl_event_trace_record(const struct cxl_memdev *cxlmd, ...@@ -878,7 +878,7 @@ void cxl_event_trace_record(const struct cxl_memdev *cxlmd,
dpa = le64_to_cpu(evt->common.phys_addr) & CXL_DPA_MASK; dpa = le64_to_cpu(evt->common.phys_addr) & CXL_DPA_MASK;
cxlr = cxl_dpa_to_region(cxlmd, dpa); cxlr = cxl_dpa_to_region(cxlmd, dpa);
if (cxlr) if (cxlr)
hpa = cxl_trace_hpa(cxlr, cxlmd, dpa); hpa = cxl_dpa_to_hpa(cxlr, cxlmd, dpa);
if (event_type == CXL_CPER_EVENT_GEN_MEDIA) if (event_type == CXL_CPER_EVENT_GEN_MEDIA)
trace_cxl_general_media(cxlmd, type, cxlr, hpa, trace_cxl_general_media(cxlmd, type, cxlr, hpa,
......
...@@ -2749,15 +2749,25 @@ static bool cxl_is_hpa_in_range(u64 hpa, struct cxl_region *cxlr, int pos) ...@@ -2749,15 +2749,25 @@ static bool cxl_is_hpa_in_range(u64 hpa, struct cxl_region *cxlr, int pos)
return false; return false;
} }
static u64 cxl_dpa_to_hpa(u64 dpa, struct cxl_region *cxlr, u64 cxl_dpa_to_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd,
struct cxl_endpoint_decoder *cxled) u64 dpa)
{ {
u64 dpa_offset, hpa_offset, bits_upper, mask_upper, hpa; u64 dpa_offset, hpa_offset, bits_upper, mask_upper, hpa;
struct cxl_region_params *p = &cxlr->params; struct cxl_region_params *p = &cxlr->params;
int pos = cxled->pos; struct cxl_endpoint_decoder *cxled = NULL;
u16 eig = 0; u16 eig = 0;
u8 eiw = 0; u8 eiw = 0;
int pos;
for (int i = 0; i < p->nr_targets; i++) {
cxled = p->targets[i];
if (cxlmd == cxled_to_memdev(cxled))
break;
}
if (!cxled || cxlmd != cxled_to_memdev(cxled))
return ULLONG_MAX;
pos = cxled->pos;
ways_to_eiw(p->interleave_ways, &eiw); ways_to_eiw(p->interleave_ways, &eiw);
granularity_to_eig(p->interleave_granularity, &eig); granularity_to_eig(p->interleave_granularity, &eig);
...@@ -2797,23 +2807,6 @@ static u64 cxl_dpa_to_hpa(u64 dpa, struct cxl_region *cxlr, ...@@ -2797,23 +2807,6 @@ static u64 cxl_dpa_to_hpa(u64 dpa, struct cxl_region *cxlr,
return hpa; return hpa;
} }
u64 cxl_trace_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd,
u64 dpa)
{
struct cxl_region_params *p = &cxlr->params;
struct cxl_endpoint_decoder *cxled = NULL;
for (int i = 0; i < p->nr_targets; i++) {
cxled = p->targets[i];
if (cxlmd == cxled_to_memdev(cxled))
break;
}
if (!cxled || cxlmd != cxled_to_memdev(cxled))
return ULLONG_MAX;
return cxl_dpa_to_hpa(dpa, cxlr, cxled);
}
static struct lock_class_key cxl_pmem_region_key; static struct lock_class_key cxl_pmem_region_key;
static int cxl_pmem_region_alloc(struct cxl_region *cxlr) static int cxl_pmem_region_alloc(struct cxl_region *cxlr)
......
...@@ -704,8 +704,8 @@ TRACE_EVENT(cxl_poison, ...@@ -704,8 +704,8 @@ TRACE_EVENT(cxl_poison,
if (cxlr) { if (cxlr) {
__assign_str(region); __assign_str(region);
memcpy(__entry->uuid, &cxlr->params.uuid, 16); memcpy(__entry->uuid, &cxlr->params.uuid, 16);
__entry->hpa = cxl_trace_hpa(cxlr, cxlmd, __entry->hpa = cxl_dpa_to_hpa(cxlr, cxlmd,
__entry->dpa); __entry->dpa);
} else { } else {
__assign_str(region); __assign_str(region);
memset(__entry->uuid, 0, 16); memset(__entry->uuid, 0, 16);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment