drivers/cxl/cxlmem.h

Source file repositories/reference/linux-study-clean/drivers/cxl/cxlmem.h

File Facts

System
Linux kernel
Corpus path
drivers/cxl/cxlmem.h
Extension
.h
Size
26814 bytes
Lines
877
Domain
Driver Families
Bucket
drivers/cxl
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct cxl_memdev {
	struct device dev;
	struct cdev cdev;
	struct cxl_dev_state *cxlds;
	struct work_struct detach_work;
	struct cxl_nvdimm_bridge *cxl_nvb;
	struct cxl_nvdimm *cxl_nvd;
	struct cxl_port *endpoint;
	const struct cxl_memdev_attach *attach;
	int id;
	int depth;
	u8 scrub_cycle;
	int scrub_region_id;
	struct cxl_mem_err_rec *err_rec_array;
};

static inline struct cxl_memdev *to_cxl_memdev(struct device *dev)
{
	return container_of(dev, struct cxl_memdev, dev);
}

static inline struct cxl_port *cxled_to_port(struct cxl_endpoint_decoder *cxled)
{
	return to_cxl_port(cxled->cxld.dev.parent);
}

static inline struct cxl_port *cxlrd_to_port(struct cxl_root_decoder *cxlrd)
{
	return to_cxl_port(cxlrd->cxlsd.cxld.dev.parent);
}

static inline struct cxl_memdev *
cxled_to_memdev(struct cxl_endpoint_decoder *cxled)
{
	struct cxl_port *port = to_cxl_port(cxled->cxld.dev.parent);

	return to_cxl_memdev(port->uport_dev);
}

bool is_cxl_memdev(const struct device *dev);
static inline bool is_cxl_endpoint(struct cxl_port *port)
{
	return is_cxl_memdev(port->uport_dev);
}

struct cxl_memdev_attach {
	int (*probe)(struct cxl_memdev *cxlmd);
};

/**
 * struct cxl_attach_region - coordinate mapping a region at memdev registration
 * @attach: common core attachment descriptor
 * @hpa_range: physical address range of the region
 *
 * For the common simple case of a CXL device with private (non-general purpose
 * / "accelerator") memory, enumerate firmware instantiated region, or
 * instantiate a region for the device's capacity. Destroy the region on detach.
 */
struct cxl_attach_region {
	struct cxl_memdev_attach attach;
	struct range hpa_range;
};

#ifdef CONFIG_CXL_REGION
int cxl_memdev_attach_region(struct cxl_memdev *cxlmd);
#else
static inline int cxl_memdev_attach_region(struct cxl_memdev *cxlmd)
{
	return -EOPNOTSUPP;
}
#endif

struct cxl_memdev *devm_cxl_add_classdev(struct cxl_dev_state *cxlds);
struct cxl_memdev *__devm_cxl_add_memdev(struct cxl_dev_state *cxlds,
					 const struct cxl_memdev_attach *attach);
int devm_cxl_sanitize_setup_notifier(struct device *host,
				     struct cxl_memdev *cxlmd);
struct cxl_memdev_state;
int devm_cxl_setup_fw_upload(struct device *host, struct cxl_memdev_state *mds);
int devm_cxl_dpa_reserve(struct cxl_endpoint_decoder *cxled,
			 resource_size_t base, resource_size_t len,
			 resource_size_t skipped);

struct cxl_dpa_info {
	u64 size;
	struct cxl_dpa_part_info {
		struct range range;
		enum cxl_partition_mode mode;
	} part[CXL_NR_PARTITIONS_MAX];
	int nr_partitions;

Annotation

Implementation Notes