Skip to content

Commit 9aa5f62

Browse files
AlisonSchofielddavejiang
authored andcommitted
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: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Alison Schofield <alison.schofield@intel.com> Reviewed-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Robert Richter <rrichter@amd.com> Link: https://patch.msgid.link/452a9b0c525b774c72d9d5851515ffa928750132.1719980933.git.alison.schofield@intel.com Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent 22a40d1 commit 9aa5f62

File tree

4 files changed

+20
-27
lines changed

4 files changed

+20
-27
lines changed

drivers/cxl/core/core.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ int cxl_region_init(void);
2828
void cxl_region_exit(void);
2929
int cxl_get_poison_by_endpoint(struct cxl_port *port);
3030
struct cxl_region *cxl_dpa_to_region(const struct cxl_memdev *cxlmd, u64 dpa);
31-
u64 cxl_trace_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd,
32-
u64 dpa);
31+
u64 cxl_dpa_to_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd,
32+
u64 dpa);
3333

3434
#else
35-
static inline u64
36-
cxl_trace_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd, u64 dpa)
35+
static inline u64 cxl_dpa_to_hpa(struct cxl_region *cxlr,
36+
const struct cxl_memdev *cxlmd, u64 dpa)
3737
{
3838
return ULLONG_MAX;
3939
}

drivers/cxl/core/mbox.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ void cxl_event_trace_record(const struct cxl_memdev *cxlmd,
878878
dpa = le64_to_cpu(evt->common.phys_addr) & CXL_DPA_MASK;
879879
cxlr = cxl_dpa_to_region(cxlmd, dpa);
880880
if (cxlr)
881-
hpa = cxl_trace_hpa(cxlr, cxlmd, dpa);
881+
hpa = cxl_dpa_to_hpa(cxlr, cxlmd, dpa);
882882

883883
if (event_type == CXL_CPER_EVENT_GEN_MEDIA)
884884
trace_cxl_general_media(cxlmd, type, cxlr, hpa,

drivers/cxl/core/region.c

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2749,15 +2749,25 @@ static bool cxl_is_hpa_in_range(u64 hpa, struct cxl_region *cxlr, int pos)
27492749
return false;
27502750
}
27512751

2752-
static u64 cxl_dpa_to_hpa(u64 dpa, struct cxl_region *cxlr,
2753-
struct cxl_endpoint_decoder *cxled)
2752+
u64 cxl_dpa_to_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd,
2753+
u64 dpa)
27542754
{
27552755
u64 dpa_offset, hpa_offset, bits_upper, mask_upper, hpa;
27562756
struct cxl_region_params *p = &cxlr->params;
2757-
int pos = cxled->pos;
2757+
struct cxl_endpoint_decoder *cxled = NULL;
27582758
u16 eig = 0;
27592759
u8 eiw = 0;
2760+
int pos;
2761+
2762+
for (int i = 0; i < p->nr_targets; i++) {
2763+
cxled = p->targets[i];
2764+
if (cxlmd == cxled_to_memdev(cxled))
2765+
break;
2766+
}
2767+
if (!cxled || cxlmd != cxled_to_memdev(cxled))
2768+
return ULLONG_MAX;
27602769

2770+
pos = cxled->pos;
27612771
ways_to_eiw(p->interleave_ways, &eiw);
27622772
granularity_to_eig(p->interleave_granularity, &eig);
27632773

@@ -2797,23 +2807,6 @@ static u64 cxl_dpa_to_hpa(u64 dpa, struct cxl_region *cxlr,
27972807
return hpa;
27982808
}
27992809

2800-
u64 cxl_trace_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd,
2801-
u64 dpa)
2802-
{
2803-
struct cxl_region_params *p = &cxlr->params;
2804-
struct cxl_endpoint_decoder *cxled = NULL;
2805-
2806-
for (int i = 0; i < p->nr_targets; i++) {
2807-
cxled = p->targets[i];
2808-
if (cxlmd == cxled_to_memdev(cxled))
2809-
break;
2810-
}
2811-
if (!cxled || cxlmd != cxled_to_memdev(cxled))
2812-
return ULLONG_MAX;
2813-
2814-
return cxl_dpa_to_hpa(dpa, cxlr, cxled);
2815-
}
2816-
28172810
static struct lock_class_key cxl_pmem_region_key;
28182811

28192812
static int cxl_pmem_region_alloc(struct cxl_region *cxlr)

drivers/cxl/core/trace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,8 @@ TRACE_EVENT(cxl_poison,
704704
if (cxlr) {
705705
__assign_str(region);
706706
memcpy(__entry->uuid, &cxlr->params.uuid, 16);
707-
__entry->hpa = cxl_trace_hpa(cxlr, cxlmd,
708-
__entry->dpa);
707+
__entry->hpa = cxl_dpa_to_hpa(cxlr, cxlmd,
708+
__entry->dpa);
709709
} else {
710710
__assign_str(region);
711711
memset(__entry->uuid, 0, 16);

0 commit comments

Comments
 (0)