Message ID | 20240715172835.24757-15-alejandro.lucero-palau@amd.com |
---|---|
State | Superseded |
Headers | show |
Series | cxl: add Type2 device support | expand |
On Mon, 15 Jul 2024 18:28:34 +0100 <alejandro.lucero-palau@amd.com> wrote: > From: Alejandro Lucero <alucerop@amd.com> > > A CXL region struct contains the physical address to work with. > > Add a function for given a opaque cxl region struct returns the params > to be used for mapping such memory range. > > Signed-off-by: Alejandro Lucero <alucerop@amd.com> > --- > drivers/cxl/core/region.c | 16 ++++++++++++++++ > drivers/cxl/cxl.h | 3 +++ > include/linux/cxl_accel_mem.h | 2 ++ > 3 files changed, 21 insertions(+) > > diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c > index c8fc14ac437e..9ff10923e9fc 100644 > --- a/drivers/cxl/core/region.c > +++ b/drivers/cxl/core/region.c > @@ -3345,6 +3345,22 @@ static int devm_cxl_add_dax_region(struct > cxl_region *cxlr) return rc; > } > > +int cxl_accel_get_region_params(struct cxl_region *region, > + resource_size_t *start, > resource_size_t *end) +{ > + if (!region) > + return -ENODEV; > + > + if (!region->params.res) { > + return -ENODEV; > + } Remove the extra {} > + *start = region->params.res->start; > + *end = region->params.res->end; > + > + return 0; > +} > +EXPORT_SYMBOL_NS_GPL(cxl_accel_get_region_params, CXL); > + > static int match_root_decoder_by_range(struct device *dev, void > *data) { > struct range *r1, *r2 = data; > diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h > index 1bf3b74ff959..b4c4c4455ef1 100644 > --- a/drivers/cxl/cxl.h > +++ b/drivers/cxl/cxl.h > @@ -906,6 +906,9 @@ void cxl_coordinates_combine(struct > access_coordinate *out, bool > cxl_endpoint_decoder_reset_detected(struct cxl_port *port); > int cxl_region_detach(struct cxl_endpoint_decoder *cxled); > + > +int cxl_accel_get_region_params(struct cxl_region *region, > + resource_size_t *start, > resource_size_t *end); /* > * Unit test builds overrides this to __weak, find the 'strong' > version > * of these symbols in tools/testing/cxl/. > diff --git a/include/linux/cxl_accel_mem.h > b/include/linux/cxl_accel_mem.h index a5f9ffc24509..5d715eea6e91 > 100644 --- a/include/linux/cxl_accel_mem.h > +++ b/include/linux/cxl_accel_mem.h > @@ -53,4 +53,6 @@ struct cxl_region *cxl_create_region(struct > cxl_root_decoder *cxlrd, int ways); > > int cxl_region_detach(struct cxl_endpoint_decoder *cxled); > +int cxl_accel_get_region_params(struct cxl_region *region, > + resource_size_t *start, > resource_size_t *end); #endif
On 8/9/24 16:24, Zhi Wang wrote: > On Mon, 15 Jul 2024 18:28:34 +0100 > <alejandro.lucero-palau@amd.com> wrote: > >> From: Alejandro Lucero <alucerop@amd.com> >> >> A CXL region struct contains the physical address to work with. >> >> Add a function for given a opaque cxl region struct returns the params >> to be used for mapping such memory range. >> >> Signed-off-by: Alejandro Lucero <alucerop@amd.com> >> --- >> drivers/cxl/core/region.c | 16 ++++++++++++++++ >> drivers/cxl/cxl.h | 3 +++ >> include/linux/cxl_accel_mem.h | 2 ++ >> 3 files changed, 21 insertions(+) >> >> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c >> index c8fc14ac437e..9ff10923e9fc 100644 >> --- a/drivers/cxl/core/region.c >> +++ b/drivers/cxl/core/region.c >> @@ -3345,6 +3345,22 @@ static int devm_cxl_add_dax_region(struct >> cxl_region *cxlr) return rc; >> } >> >> +int cxl_accel_get_region_params(struct cxl_region *region, >> + resource_size_t *start, >> resource_size_t *end) +{ >> + if (!region) >> + return -ENODEV; >> + >> + if (!region->params.res) { >> + return -ENODEV; >> + } > Remove the extra {} > Sure. Thanks! >> + *start = region->params.res->start; >> + *end = region->params.res->end; >> + >> + return 0; >> +} >> +EXPORT_SYMBOL_NS_GPL(cxl_accel_get_region_params, CXL); >> + >> static int match_root_decoder_by_range(struct device *dev, void >> *data) { >> struct range *r1, *r2 = data; >> diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h >> index 1bf3b74ff959..b4c4c4455ef1 100644 >> --- a/drivers/cxl/cxl.h >> +++ b/drivers/cxl/cxl.h >> @@ -906,6 +906,9 @@ void cxl_coordinates_combine(struct >> access_coordinate *out, bool >> cxl_endpoint_decoder_reset_detected(struct cxl_port *port); >> int cxl_region_detach(struct cxl_endpoint_decoder *cxled); >> + >> +int cxl_accel_get_region_params(struct cxl_region *region, >> + resource_size_t *start, >> resource_size_t *end); /* >> * Unit test builds overrides this to __weak, find the 'strong' >> version >> * of these symbols in tools/testing/cxl/. >> diff --git a/include/linux/cxl_accel_mem.h >> b/include/linux/cxl_accel_mem.h index a5f9ffc24509..5d715eea6e91 >> 100644 --- a/include/linux/cxl_accel_mem.h >> +++ b/include/linux/cxl_accel_mem.h >> @@ -53,4 +53,6 @@ struct cxl_region *cxl_create_region(struct >> cxl_root_decoder *cxlrd, int ways); >> >> int cxl_region_detach(struct cxl_endpoint_decoder *cxled); >> +int cxl_accel_get_region_params(struct cxl_region *region, >> + resource_size_t *start, >> resource_size_t *end); #endif
diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index c8fc14ac437e..9ff10923e9fc 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3345,6 +3345,22 @@ static int devm_cxl_add_dax_region(struct cxl_region *cxlr) return rc; } +int cxl_accel_get_region_params(struct cxl_region *region, + resource_size_t *start, resource_size_t *end) +{ + if (!region) + return -ENODEV; + + if (!region->params.res) { + return -ENODEV; + } + *start = region->params.res->start; + *end = region->params.res->end; + + return 0; +} +EXPORT_SYMBOL_NS_GPL(cxl_accel_get_region_params, CXL); + static int match_root_decoder_by_range(struct device *dev, void *data) { struct range *r1, *r2 = data; diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 1bf3b74ff959..b4c4c4455ef1 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -906,6 +906,9 @@ void cxl_coordinates_combine(struct access_coordinate *out, bool cxl_endpoint_decoder_reset_detected(struct cxl_port *port); int cxl_region_detach(struct cxl_endpoint_decoder *cxled); + +int cxl_accel_get_region_params(struct cxl_region *region, + resource_size_t *start, resource_size_t *end); /* * Unit test builds overrides this to __weak, find the 'strong' version * of these symbols in tools/testing/cxl/. diff --git a/include/linux/cxl_accel_mem.h b/include/linux/cxl_accel_mem.h index a5f9ffc24509..5d715eea6e91 100644 --- a/include/linux/cxl_accel_mem.h +++ b/include/linux/cxl_accel_mem.h @@ -53,4 +53,6 @@ struct cxl_region *cxl_create_region(struct cxl_root_decoder *cxlrd, int ways); int cxl_region_detach(struct cxl_endpoint_decoder *cxled); +int cxl_accel_get_region_params(struct cxl_region *region, + resource_size_t *start, resource_size_t *end); #endif