Message ID | 20241202171222.62595-25-alejandro.lucero-palau@amd.com |
---|---|
State | New |
Headers | show |
Series | cxl: add type2 device basic support | expand |
On Mon, 2 Dec 2024 17:12:18 +0000 <alejandro.lucero-palau@amd.com> wrote: LGTM. Reviewed-by: Zhi Wang <zhiw@nvidia.com> > From: Alejandro Lucero <alucerop@amd.com> > > By definition a type2 cxl device will use the host managed memory for > specific functionality, therefore it should not be available to other > uses. However, a dax interface could be just good enough in some cases. > > Add a flag to a cxl region for specifically state to not create a dax > device. Allow a Type2 driver to set that flag at region creation time. > > Signed-off-by: Alejandro Lucero <alucerop@amd.com> > --- > drivers/cxl/core/region.c | 10 +++++++++- > drivers/cxl/cxl.h | 3 +++ > drivers/cxl/cxlmem.h | 3 ++- > include/cxl/cxl.h | 3 ++- > 4 files changed, 16 insertions(+), 3 deletions(-) > > diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c > index 79d5e3a47af3..5cb7991268ce 100644 > --- a/drivers/cxl/core/region.c > +++ b/drivers/cxl/core/region.c > @@ -3553,7 +3553,8 @@ __construct_new_region(struct cxl_root_decoder *cxlrd, > * cxl_region driver. > */ > struct cxl_region *cxl_create_region(struct cxl_root_decoder *cxlrd, > - struct cxl_endpoint_decoder *cxled) > + struct cxl_endpoint_decoder *cxled, > + bool no_dax) > { > struct cxl_region *cxlr; > > @@ -3569,6 +3570,10 @@ struct cxl_region *cxl_create_region(struct cxl_root_decoder *cxlrd, > drop_region(cxlr); > return ERR_PTR(-ENODEV); > } > + > + if (no_dax) > + set_bit(CXL_REGION_F_NO_DAX, &cxlr->flags); > + > return cxlr; > } > EXPORT_SYMBOL_NS_GPL(cxl_create_region, CXL); > @@ -3704,6 +3709,9 @@ static int cxl_region_probe(struct device *dev) > if (rc) > return rc; > > + if (test_bit(CXL_REGION_F_NO_DAX, &cxlr->flags)) > + return 0; > + > switch (cxlr->mode) { > case CXL_DECODER_PMEM: > return devm_cxl_add_pmem_region(cxlr); > diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h > index 57d6dda3fb4a..cc9e3d859fa6 100644 > --- a/drivers/cxl/cxl.h > +++ b/drivers/cxl/cxl.h > @@ -521,6 +521,9 @@ struct cxl_region_params { > */ > #define CXL_REGION_F_NEEDS_RESET 1 > > +/* Allow Type2 drivers to specify if a dax region should not be created. */ > +#define CXL_REGION_F_NO_DAX 2 > + > /** > * struct cxl_region - CXL region > * @dev: This region's device > diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h > index 9d874f1cb3bf..712f25f494e0 100644 > --- a/drivers/cxl/cxlmem.h > +++ b/drivers/cxl/cxlmem.h > @@ -875,5 +875,6 @@ struct seq_file; > struct dentry *cxl_debugfs_create_dir(const char *dir); > void cxl_dpa_debug(struct seq_file *file, struct cxl_dev_state *cxlds); > struct cxl_region *cxl_create_region(struct cxl_root_decoder *cxlrd, > - struct cxl_endpoint_decoder *cxled); > + struct cxl_endpoint_decoder *cxled, > + bool no_dax); > #endif /* __CXL_MEM_H__ */ > diff --git a/include/cxl/cxl.h b/include/cxl/cxl.h > index e0ea5b801a2e..14be26358f9c 100644 > --- a/include/cxl/cxl.h > +++ b/include/cxl/cxl.h > @@ -61,7 +61,8 @@ struct cxl_endpoint_decoder *cxl_request_dpa(struct cxl_memdev *cxlmd, > resource_size_t max); > int cxl_dpa_free(struct cxl_endpoint_decoder *cxled); > struct cxl_region *cxl_create_region(struct cxl_root_decoder *cxlrd, > - struct cxl_endpoint_decoder *cxled); > + struct cxl_endpoint_decoder *cxled, > + bool no_dax); > > int cxl_accel_region_detach(struct cxl_endpoint_decoder *cxled); > #endif
diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 79d5e3a47af3..5cb7991268ce 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3553,7 +3553,8 @@ __construct_new_region(struct cxl_root_decoder *cxlrd, * cxl_region driver. */ struct cxl_region *cxl_create_region(struct cxl_root_decoder *cxlrd, - struct cxl_endpoint_decoder *cxled) + struct cxl_endpoint_decoder *cxled, + bool no_dax) { struct cxl_region *cxlr; @@ -3569,6 +3570,10 @@ struct cxl_region *cxl_create_region(struct cxl_root_decoder *cxlrd, drop_region(cxlr); return ERR_PTR(-ENODEV); } + + if (no_dax) + set_bit(CXL_REGION_F_NO_DAX, &cxlr->flags); + return cxlr; } EXPORT_SYMBOL_NS_GPL(cxl_create_region, CXL); @@ -3704,6 +3709,9 @@ static int cxl_region_probe(struct device *dev) if (rc) return rc; + if (test_bit(CXL_REGION_F_NO_DAX, &cxlr->flags)) + return 0; + switch (cxlr->mode) { case CXL_DECODER_PMEM: return devm_cxl_add_pmem_region(cxlr); diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 57d6dda3fb4a..cc9e3d859fa6 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -521,6 +521,9 @@ struct cxl_region_params { */ #define CXL_REGION_F_NEEDS_RESET 1 +/* Allow Type2 drivers to specify if a dax region should not be created. */ +#define CXL_REGION_F_NO_DAX 2 + /** * struct cxl_region - CXL region * @dev: This region's device diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index 9d874f1cb3bf..712f25f494e0 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -875,5 +875,6 @@ struct seq_file; struct dentry *cxl_debugfs_create_dir(const char *dir); void cxl_dpa_debug(struct seq_file *file, struct cxl_dev_state *cxlds); struct cxl_region *cxl_create_region(struct cxl_root_decoder *cxlrd, - struct cxl_endpoint_decoder *cxled); + struct cxl_endpoint_decoder *cxled, + bool no_dax); #endif /* __CXL_MEM_H__ */ diff --git a/include/cxl/cxl.h b/include/cxl/cxl.h index e0ea5b801a2e..14be26358f9c 100644 --- a/include/cxl/cxl.h +++ b/include/cxl/cxl.h @@ -61,7 +61,8 @@ struct cxl_endpoint_decoder *cxl_request_dpa(struct cxl_memdev *cxlmd, resource_size_t max); int cxl_dpa_free(struct cxl_endpoint_decoder *cxled); struct cxl_region *cxl_create_region(struct cxl_root_decoder *cxlrd, - struct cxl_endpoint_decoder *cxled); + struct cxl_endpoint_decoder *cxled, + bool no_dax); int cxl_accel_region_detach(struct cxl_endpoint_decoder *cxled); #endif