Commit 5e2411ae authored by Ira Weiny's avatar Ira Weiny Committed by Dan Williams

cxl/memdev: Change cxl_mem to a more descriptive name

The 'struct cxl_mem' object actually represents the state of a CXL
device within the driver. Comments indicating that 'struct cxl_mem' is a
device itself are incorrect. It is data layered on top of a CXL Memory
Expander class device. Rename it 'struct cxl_dev_state'. The 'struct'
cxl_memdev' structure represents a Linux CXL memory device object, and
it uses services and information provided by 'struct cxl_dev_state'.

Update the structure name, function names, and the kdocs to reflect the
real uses of this structure.

Some helper functions that were previously prefixed "cxl_mem_" are
renamed to just "cxl_".
Acked-by: default avatarBen Widawsky <ben.widawsky@intel.com>
Signed-off-by: default avatarIra Weiny <ira.weiny@intel.com>
Link: https://lore.kernel.org/r/20211102202901.3675568-3-ira.weiny@intel.comSigned-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 888e034a
This diff is collapsed.
...@@ -37,9 +37,9 @@ static ssize_t firmware_version_show(struct device *dev, ...@@ -37,9 +37,9 @@ static ssize_t firmware_version_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct cxl_memdev *cxlmd = to_cxl_memdev(dev); struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
struct cxl_mem *cxlm = cxlmd->cxlm; struct cxl_dev_state *cxlds = cxlmd->cxlds;
return sysfs_emit(buf, "%.16s\n", cxlm->firmware_version); return sysfs_emit(buf, "%.16s\n", cxlds->firmware_version);
} }
static DEVICE_ATTR_RO(firmware_version); static DEVICE_ATTR_RO(firmware_version);
...@@ -47,9 +47,9 @@ static ssize_t payload_max_show(struct device *dev, ...@@ -47,9 +47,9 @@ static ssize_t payload_max_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct cxl_memdev *cxlmd = to_cxl_memdev(dev); struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
struct cxl_mem *cxlm = cxlmd->cxlm; struct cxl_dev_state *cxlds = cxlmd->cxlds;
return sysfs_emit(buf, "%zu\n", cxlm->payload_size); return sysfs_emit(buf, "%zu\n", cxlds->payload_size);
} }
static DEVICE_ATTR_RO(payload_max); static DEVICE_ATTR_RO(payload_max);
...@@ -57,9 +57,9 @@ static ssize_t label_storage_size_show(struct device *dev, ...@@ -57,9 +57,9 @@ static ssize_t label_storage_size_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct cxl_memdev *cxlmd = to_cxl_memdev(dev); struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
struct cxl_mem *cxlm = cxlmd->cxlm; struct cxl_dev_state *cxlds = cxlmd->cxlds;
return sysfs_emit(buf, "%zu\n", cxlm->lsa_size); return sysfs_emit(buf, "%zu\n", cxlds->lsa_size);
} }
static DEVICE_ATTR_RO(label_storage_size); static DEVICE_ATTR_RO(label_storage_size);
...@@ -67,8 +67,8 @@ static ssize_t ram_size_show(struct device *dev, struct device_attribute *attr, ...@@ -67,8 +67,8 @@ static ssize_t ram_size_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct cxl_memdev *cxlmd = to_cxl_memdev(dev); struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
struct cxl_mem *cxlm = cxlmd->cxlm; struct cxl_dev_state *cxlds = cxlmd->cxlds;
unsigned long long len = range_len(&cxlm->ram_range); unsigned long long len = range_len(&cxlds->ram_range);
return sysfs_emit(buf, "%#llx\n", len); return sysfs_emit(buf, "%#llx\n", len);
} }
...@@ -80,8 +80,8 @@ static ssize_t pmem_size_show(struct device *dev, struct device_attribute *attr, ...@@ -80,8 +80,8 @@ static ssize_t pmem_size_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct cxl_memdev *cxlmd = to_cxl_memdev(dev); struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
struct cxl_mem *cxlm = cxlmd->cxlm; struct cxl_dev_state *cxlds = cxlmd->cxlds;
unsigned long long len = range_len(&cxlm->pmem_range); unsigned long long len = range_len(&cxlds->pmem_range);
return sysfs_emit(buf, "%#llx\n", len); return sysfs_emit(buf, "%#llx\n", len);
} }
...@@ -136,17 +136,17 @@ static const struct device_type cxl_memdev_type = { ...@@ -136,17 +136,17 @@ static const struct device_type cxl_memdev_type = {
/** /**
* set_exclusive_cxl_commands() - atomically disable user cxl commands * set_exclusive_cxl_commands() - atomically disable user cxl commands
* @cxlm: cxl_mem instance to modify * @cxlds: The device state to operate on
* @cmds: bitmap of commands to mark exclusive * @cmds: bitmap of commands to mark exclusive
* *
* Grab the cxl_memdev_rwsem in write mode to flush in-flight * Grab the cxl_memdev_rwsem in write mode to flush in-flight
* invocations of the ioctl path and then disable future execution of * invocations of the ioctl path and then disable future execution of
* commands with the command ids set in @cmds. * commands with the command ids set in @cmds.
*/ */
void set_exclusive_cxl_commands(struct cxl_mem *cxlm, unsigned long *cmds) void set_exclusive_cxl_commands(struct cxl_dev_state *cxlds, unsigned long *cmds)
{ {
down_write(&cxl_memdev_rwsem); down_write(&cxl_memdev_rwsem);
bitmap_or(cxlm->exclusive_cmds, cxlm->exclusive_cmds, cmds, bitmap_or(cxlds->exclusive_cmds, cxlds->exclusive_cmds, cmds,
CXL_MEM_COMMAND_ID_MAX); CXL_MEM_COMMAND_ID_MAX);
up_write(&cxl_memdev_rwsem); up_write(&cxl_memdev_rwsem);
} }
...@@ -154,13 +154,13 @@ EXPORT_SYMBOL_GPL(set_exclusive_cxl_commands); ...@@ -154,13 +154,13 @@ EXPORT_SYMBOL_GPL(set_exclusive_cxl_commands);
/** /**
* clear_exclusive_cxl_commands() - atomically enable user cxl commands * clear_exclusive_cxl_commands() - atomically enable user cxl commands
* @cxlm: cxl_mem instance to modify * @cxlds: The device state to modify
* @cmds: bitmap of commands to mark available for userspace * @cmds: bitmap of commands to mark available for userspace
*/ */
void clear_exclusive_cxl_commands(struct cxl_mem *cxlm, unsigned long *cmds) void clear_exclusive_cxl_commands(struct cxl_dev_state *cxlds, unsigned long *cmds)
{ {
down_write(&cxl_memdev_rwsem); down_write(&cxl_memdev_rwsem);
bitmap_andnot(cxlm->exclusive_cmds, cxlm->exclusive_cmds, cmds, bitmap_andnot(cxlds->exclusive_cmds, cxlds->exclusive_cmds, cmds,
CXL_MEM_COMMAND_ID_MAX); CXL_MEM_COMMAND_ID_MAX);
up_write(&cxl_memdev_rwsem); up_write(&cxl_memdev_rwsem);
} }
...@@ -171,7 +171,7 @@ static void cxl_memdev_shutdown(struct device *dev) ...@@ -171,7 +171,7 @@ static void cxl_memdev_shutdown(struct device *dev)
struct cxl_memdev *cxlmd = to_cxl_memdev(dev); struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
down_write(&cxl_memdev_rwsem); down_write(&cxl_memdev_rwsem);
cxlmd->cxlm = NULL; cxlmd->cxlds = NULL;
up_write(&cxl_memdev_rwsem); up_write(&cxl_memdev_rwsem);
} }
...@@ -185,7 +185,7 @@ static void cxl_memdev_unregister(void *_cxlmd) ...@@ -185,7 +185,7 @@ static void cxl_memdev_unregister(void *_cxlmd)
put_device(dev); put_device(dev);
} }
static struct cxl_memdev *cxl_memdev_alloc(struct cxl_mem *cxlm, static struct cxl_memdev *cxl_memdev_alloc(struct cxl_dev_state *cxlds,
const struct file_operations *fops) const struct file_operations *fops)
{ {
struct cxl_memdev *cxlmd; struct cxl_memdev *cxlmd;
...@@ -204,7 +204,7 @@ static struct cxl_memdev *cxl_memdev_alloc(struct cxl_mem *cxlm, ...@@ -204,7 +204,7 @@ static struct cxl_memdev *cxl_memdev_alloc(struct cxl_mem *cxlm,
dev = &cxlmd->dev; dev = &cxlmd->dev;
device_initialize(dev); device_initialize(dev);
dev->parent = cxlm->dev; dev->parent = cxlds->dev;
dev->bus = &cxl_bus_type; dev->bus = &cxl_bus_type;
dev->devt = MKDEV(cxl_mem_major, cxlmd->id); dev->devt = MKDEV(cxl_mem_major, cxlmd->id);
dev->type = &cxl_memdev_type; dev->type = &cxl_memdev_type;
...@@ -239,7 +239,7 @@ static long cxl_memdev_ioctl(struct file *file, unsigned int cmd, ...@@ -239,7 +239,7 @@ static long cxl_memdev_ioctl(struct file *file, unsigned int cmd,
int rc = -ENXIO; int rc = -ENXIO;
down_read(&cxl_memdev_rwsem); down_read(&cxl_memdev_rwsem);
if (cxlmd->cxlm) if (cxlmd->cxlds)
rc = __cxl_memdev_ioctl(cxlmd, cmd, arg); rc = __cxl_memdev_ioctl(cxlmd, cmd, arg);
up_read(&cxl_memdev_rwsem); up_read(&cxl_memdev_rwsem);
...@@ -276,15 +276,14 @@ static const struct file_operations cxl_memdev_fops = { ...@@ -276,15 +276,14 @@ static const struct file_operations cxl_memdev_fops = {
.llseek = noop_llseek, .llseek = noop_llseek,
}; };
struct cxl_memdev * struct cxl_memdev *devm_cxl_add_memdev(struct cxl_dev_state *cxlds)
devm_cxl_add_memdev(struct cxl_mem *cxlm)
{ {
struct cxl_memdev *cxlmd; struct cxl_memdev *cxlmd;
struct device *dev; struct device *dev;
struct cdev *cdev; struct cdev *cdev;
int rc; int rc;
cxlmd = cxl_memdev_alloc(cxlm, &cxl_memdev_fops); cxlmd = cxl_memdev_alloc(cxlds, &cxl_memdev_fops);
if (IS_ERR(cxlmd)) if (IS_ERR(cxlmd))
return cxlmd; return cxlmd;
...@@ -297,14 +296,14 @@ devm_cxl_add_memdev(struct cxl_mem *cxlm) ...@@ -297,14 +296,14 @@ devm_cxl_add_memdev(struct cxl_mem *cxlm)
* Activate ioctl operations, no cxl_memdev_rwsem manipulation * Activate ioctl operations, no cxl_memdev_rwsem manipulation
* needed as this is ordered with cdev_add() publishing the device. * needed as this is ordered with cdev_add() publishing the device.
*/ */
cxlmd->cxlm = cxlm; cxlmd->cxlds = cxlds;
cdev = &cxlmd->cdev; cdev = &cxlmd->cdev;
rc = cdev_device_add(cdev, dev); rc = cdev_device_add(cdev, dev);
if (rc) if (rc)
goto err; goto err;
rc = devm_add_action_or_reset(cxlm->dev, cxl_memdev_unregister, cxlmd); rc = devm_add_action_or_reset(cxlds->dev, cxl_memdev_unregister, cxlmd);
if (rc) if (rc)
return ERR_PTR(rc); return ERR_PTR(rc);
return cxlmd; return cxlmd;
......
...@@ -33,13 +33,13 @@ ...@@ -33,13 +33,13 @@
* struct cxl_memdev - CXL bus object representing a Type-3 Memory Device * struct cxl_memdev - CXL bus object representing a Type-3 Memory Device
* @dev: driver core device object * @dev: driver core device object
* @cdev: char dev core object for ioctl operations * @cdev: char dev core object for ioctl operations
* @cxlm: pointer to the parent device driver data * @cxlds: The device state backing this device
* @id: id number of this memdev instance. * @id: id number of this memdev instance.
*/ */
struct cxl_memdev { struct cxl_memdev {
struct device dev; struct device dev;
struct cdev cdev; struct cdev cdev;
struct cxl_mem *cxlm; struct cxl_dev_state *cxlds;
int id; int id;
}; };
...@@ -48,7 +48,7 @@ static inline struct cxl_memdev *to_cxl_memdev(struct device *dev) ...@@ -48,7 +48,7 @@ static inline struct cxl_memdev *to_cxl_memdev(struct device *dev)
return container_of(dev, struct cxl_memdev, dev); return container_of(dev, struct cxl_memdev, dev);
} }
struct cxl_memdev *devm_cxl_add_memdev(struct cxl_mem *cxlm); struct cxl_memdev *devm_cxl_add_memdev(struct cxl_dev_state *cxlds);
/** /**
* struct cxl_mbox_cmd - A command to be submitted to hardware. * struct cxl_mbox_cmd - A command to be submitted to hardware.
...@@ -90,8 +90,13 @@ struct cxl_mbox_cmd { ...@@ -90,8 +90,13 @@ struct cxl_mbox_cmd {
#define CXL_CAPACITY_MULTIPLIER SZ_256M #define CXL_CAPACITY_MULTIPLIER SZ_256M
/** /**
* struct cxl_mem - A CXL memory device * struct cxl_dev_state - The driver device state
* @dev: The device associated with this CXL device. *
* cxl_dev_state represents the CXL driver/device state. It provides an
* interface to mailbox commands as well as some cached data about the device.
* Currently only memory devices are represented.
*
* @dev: The device associated with this CXL state
* @cxlmd: Logical memory device chardev / interface * @cxlmd: Logical memory device chardev / interface
* @regs: Parsed register blocks * @regs: Parsed register blocks
* @payload_size: Size of space for payload * @payload_size: Size of space for payload
...@@ -117,7 +122,7 @@ struct cxl_mbox_cmd { ...@@ -117,7 +122,7 @@ struct cxl_mbox_cmd {
* See section 8.2.9.5.2 Capacity Configuration and Label Storage for * See section 8.2.9.5.2 Capacity Configuration and Label Storage for
* details on capacity parameters. * details on capacity parameters.
*/ */
struct cxl_mem { struct cxl_dev_state {
struct device *dev; struct device *dev;
struct cxl_memdev *cxlmd; struct cxl_memdev *cxlmd;
...@@ -142,7 +147,7 @@ struct cxl_mem { ...@@ -142,7 +147,7 @@ struct cxl_mem {
u64 next_volatile_bytes; u64 next_volatile_bytes;
u64 next_persistent_bytes; u64 next_persistent_bytes;
int (*mbox_send)(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd); int (*mbox_send)(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd);
}; };
enum cxl_opcode { enum cxl_opcode {
...@@ -253,12 +258,12 @@ struct cxl_mem_command { ...@@ -253,12 +258,12 @@ struct cxl_mem_command {
#define CXL_CMD_FLAG_FORCE_ENABLE BIT(0) #define CXL_CMD_FLAG_FORCE_ENABLE BIT(0)
}; };
int cxl_mem_mbox_send_cmd(struct cxl_mem *cxlm, u16 opcode, void *in, int cxl_mbox_send_cmd(struct cxl_dev_state *cxlds, u16 opcode, void *in,
size_t in_size, void *out, size_t out_size); size_t in_size, void *out, size_t out_size);
int cxl_mem_identify(struct cxl_mem *cxlm); int cxl_dev_state_identify(struct cxl_dev_state *cxlds);
int cxl_mem_enumerate_cmds(struct cxl_mem *cxlm); int cxl_enumerate_cmds(struct cxl_dev_state *cxlds);
int cxl_mem_create_range_info(struct cxl_mem *cxlm); int cxl_mem_create_range_info(struct cxl_dev_state *cxlds);
struct cxl_mem *cxl_mem_create(struct device *dev); struct cxl_dev_state *cxl_dev_state_create(struct device *dev);
void set_exclusive_cxl_commands(struct cxl_mem *cxlm, unsigned long *cmds); void set_exclusive_cxl_commands(struct cxl_dev_state *cxlds, unsigned long *cmds);
void clear_exclusive_cxl_commands(struct cxl_mem *cxlm, unsigned long *cmds); void clear_exclusive_cxl_commands(struct cxl_dev_state *cxlds, unsigned long *cmds);
#endif /* __CXL_MEM_H__ */ #endif /* __CXL_MEM_H__ */
This diff is collapsed.
...@@ -19,9 +19,9 @@ static struct workqueue_struct *cxl_pmem_wq; ...@@ -19,9 +19,9 @@ static struct workqueue_struct *cxl_pmem_wq;
static __read_mostly DECLARE_BITMAP(exclusive_cmds, CXL_MEM_COMMAND_ID_MAX); static __read_mostly DECLARE_BITMAP(exclusive_cmds, CXL_MEM_COMMAND_ID_MAX);
static void clear_exclusive(void *cxlm) static void clear_exclusive(void *cxlds)
{ {
clear_exclusive_cxl_commands(cxlm, exclusive_cmds); clear_exclusive_cxl_commands(cxlds, exclusive_cmds);
} }
static void unregister_nvdimm(void *nvdimm) static void unregister_nvdimm(void *nvdimm)
...@@ -34,7 +34,7 @@ static int cxl_nvdimm_probe(struct device *dev) ...@@ -34,7 +34,7 @@ static int cxl_nvdimm_probe(struct device *dev)
struct cxl_nvdimm *cxl_nvd = to_cxl_nvdimm(dev); struct cxl_nvdimm *cxl_nvd = to_cxl_nvdimm(dev);
struct cxl_memdev *cxlmd = cxl_nvd->cxlmd; struct cxl_memdev *cxlmd = cxl_nvd->cxlmd;
unsigned long flags = 0, cmd_mask = 0; unsigned long flags = 0, cmd_mask = 0;
struct cxl_mem *cxlm = cxlmd->cxlm; struct cxl_dev_state *cxlds = cxlmd->cxlds;
struct cxl_nvdimm_bridge *cxl_nvb; struct cxl_nvdimm_bridge *cxl_nvb;
struct nvdimm *nvdimm; struct nvdimm *nvdimm;
int rc; int rc;
...@@ -49,8 +49,8 @@ static int cxl_nvdimm_probe(struct device *dev) ...@@ -49,8 +49,8 @@ static int cxl_nvdimm_probe(struct device *dev)
goto out; goto out;
} }
set_exclusive_cxl_commands(cxlm, exclusive_cmds); set_exclusive_cxl_commands(cxlds, exclusive_cmds);
rc = devm_add_action_or_reset(dev, clear_exclusive, cxlm); rc = devm_add_action_or_reset(dev, clear_exclusive, cxlds);
if (rc) if (rc)
goto out; goto out;
...@@ -80,7 +80,7 @@ static struct cxl_driver cxl_nvdimm_driver = { ...@@ -80,7 +80,7 @@ static struct cxl_driver cxl_nvdimm_driver = {
.id = CXL_DEVICE_NVDIMM, .id = CXL_DEVICE_NVDIMM,
}; };
static int cxl_pmem_get_config_size(struct cxl_mem *cxlm, static int cxl_pmem_get_config_size(struct cxl_dev_state *cxlds,
struct nd_cmd_get_config_size *cmd, struct nd_cmd_get_config_size *cmd,
unsigned int buf_len) unsigned int buf_len)
{ {
...@@ -88,14 +88,14 @@ static int cxl_pmem_get_config_size(struct cxl_mem *cxlm, ...@@ -88,14 +88,14 @@ static int cxl_pmem_get_config_size(struct cxl_mem *cxlm,
return -EINVAL; return -EINVAL;
*cmd = (struct nd_cmd_get_config_size) { *cmd = (struct nd_cmd_get_config_size) {
.config_size = cxlm->lsa_size, .config_size = cxlds->lsa_size,
.max_xfer = cxlm->payload_size, .max_xfer = cxlds->payload_size,
}; };
return 0; return 0;
} }
static int cxl_pmem_get_config_data(struct cxl_mem *cxlm, static int cxl_pmem_get_config_data(struct cxl_dev_state *cxlds,
struct nd_cmd_get_config_data_hdr *cmd, struct nd_cmd_get_config_data_hdr *cmd,
unsigned int buf_len) unsigned int buf_len)
{ {
...@@ -112,15 +112,14 @@ static int cxl_pmem_get_config_data(struct cxl_mem *cxlm, ...@@ -112,15 +112,14 @@ static int cxl_pmem_get_config_data(struct cxl_mem *cxlm,
.length = cmd->in_length, .length = cmd->in_length,
}; };
rc = cxl_mem_mbox_send_cmd(cxlm, CXL_MBOX_OP_GET_LSA, &get_lsa, rc = cxl_mbox_send_cmd(cxlds, CXL_MBOX_OP_GET_LSA, &get_lsa,
sizeof(get_lsa), cmd->out_buf, sizeof(get_lsa), cmd->out_buf, cmd->in_length);
cmd->in_length);
cmd->status = 0; cmd->status = 0;
return rc; return rc;
} }
static int cxl_pmem_set_config_data(struct cxl_mem *cxlm, static int cxl_pmem_set_config_data(struct cxl_dev_state *cxlds,
struct nd_cmd_set_config_hdr *cmd, struct nd_cmd_set_config_hdr *cmd,
unsigned int buf_len) unsigned int buf_len)
{ {
...@@ -144,9 +143,9 @@ static int cxl_pmem_set_config_data(struct cxl_mem *cxlm, ...@@ -144,9 +143,9 @@ static int cxl_pmem_set_config_data(struct cxl_mem *cxlm,
}; };
memcpy(set_lsa->data, cmd->in_buf, cmd->in_length); memcpy(set_lsa->data, cmd->in_buf, cmd->in_length);
rc = cxl_mem_mbox_send_cmd(cxlm, CXL_MBOX_OP_SET_LSA, set_lsa, rc = cxl_mbox_send_cmd(cxlds, CXL_MBOX_OP_SET_LSA, set_lsa,
struct_size(set_lsa, data, cmd->in_length), struct_size(set_lsa, data, cmd->in_length),
NULL, 0); NULL, 0);
/* /*
* Set "firmware" status (4-packed bytes at the end of the input * Set "firmware" status (4-packed bytes at the end of the input
...@@ -164,18 +163,18 @@ static int cxl_pmem_nvdimm_ctl(struct nvdimm *nvdimm, unsigned int cmd, ...@@ -164,18 +163,18 @@ static int cxl_pmem_nvdimm_ctl(struct nvdimm *nvdimm, unsigned int cmd,
struct cxl_nvdimm *cxl_nvd = nvdimm_provider_data(nvdimm); struct cxl_nvdimm *cxl_nvd = nvdimm_provider_data(nvdimm);
unsigned long cmd_mask = nvdimm_cmd_mask(nvdimm); unsigned long cmd_mask = nvdimm_cmd_mask(nvdimm);
struct cxl_memdev *cxlmd = cxl_nvd->cxlmd; struct cxl_memdev *cxlmd = cxl_nvd->cxlmd;
struct cxl_mem *cxlm = cxlmd->cxlm; struct cxl_dev_state *cxlds = cxlmd->cxlds;
if (!test_bit(cmd, &cmd_mask)) if (!test_bit(cmd, &cmd_mask))
return -ENOTTY; return -ENOTTY;
switch (cmd) { switch (cmd) {
case ND_CMD_GET_CONFIG_SIZE: case ND_CMD_GET_CONFIG_SIZE:
return cxl_pmem_get_config_size(cxlm, buf, buf_len); return cxl_pmem_get_config_size(cxlds, buf, buf_len);
case ND_CMD_GET_CONFIG_DATA: case ND_CMD_GET_CONFIG_DATA:
return cxl_pmem_get_config_data(cxlm, buf, buf_len); return cxl_pmem_get_config_data(cxlds, buf, buf_len);
case ND_CMD_SET_CONFIG_DATA: case ND_CMD_SET_CONFIG_DATA:
return cxl_pmem_set_config_data(cxlm, buf, buf_len); return cxl_pmem_set_config_data(cxlds, buf, buf_len);
default: default:
return -ENOTTY; return -ENOTTY;
} }
......
...@@ -54,7 +54,7 @@ static int mock_gsl(struct cxl_mbox_cmd *cmd) ...@@ -54,7 +54,7 @@ static int mock_gsl(struct cxl_mbox_cmd *cmd)
return 0; return 0;
} }
static int mock_get_log(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd) static int mock_get_log(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd)
{ {
struct cxl_mbox_get_log *gl = cmd->payload_in; struct cxl_mbox_get_log *gl = cmd->payload_in;
u32 offset = le32_to_cpu(gl->offset); u32 offset = le32_to_cpu(gl->offset);
...@@ -64,7 +64,7 @@ static int mock_get_log(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd) ...@@ -64,7 +64,7 @@ static int mock_get_log(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd)
if (cmd->size_in < sizeof(*gl)) if (cmd->size_in < sizeof(*gl))
return -EINVAL; return -EINVAL;
if (length > cxlm->payload_size) if (length > cxlds->payload_size)
return -EINVAL; return -EINVAL;
if (offset + length > sizeof(mock_cel)) if (offset + length > sizeof(mock_cel))
return -EINVAL; return -EINVAL;
...@@ -78,9 +78,9 @@ static int mock_get_log(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd) ...@@ -78,9 +78,9 @@ static int mock_get_log(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd)
return 0; return 0;
} }
static int mock_id(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd) static int mock_id(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd)
{ {
struct platform_device *pdev = to_platform_device(cxlm->dev); struct platform_device *pdev = to_platform_device(cxlds->dev);
struct cxl_mbox_identify id = { struct cxl_mbox_identify id = {
.fw_revision = { "mock fw v1 " }, .fw_revision = { "mock fw v1 " },
.lsa_size = cpu_to_le32(LSA_SIZE), .lsa_size = cpu_to_le32(LSA_SIZE),
...@@ -120,10 +120,10 @@ static int mock_id(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd) ...@@ -120,10 +120,10 @@ static int mock_id(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd)
return 0; return 0;
} }
static int mock_get_lsa(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd) static int mock_get_lsa(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd)
{ {
struct cxl_mbox_get_lsa *get_lsa = cmd->payload_in; struct cxl_mbox_get_lsa *get_lsa = cmd->payload_in;
void *lsa = dev_get_drvdata(cxlm->dev); void *lsa = dev_get_drvdata(cxlds->dev);
u32 offset, length; u32 offset, length;
if (sizeof(*get_lsa) > cmd->size_in) if (sizeof(*get_lsa) > cmd->size_in)
...@@ -139,10 +139,10 @@ static int mock_get_lsa(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd) ...@@ -139,10 +139,10 @@ static int mock_get_lsa(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd)
return 0; return 0;
} }
static int mock_set_lsa(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd) static int mock_set_lsa(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd)
{ {
struct cxl_mbox_set_lsa *set_lsa = cmd->payload_in; struct cxl_mbox_set_lsa *set_lsa = cmd->payload_in;
void *lsa = dev_get_drvdata(cxlm->dev); void *lsa = dev_get_drvdata(cxlds->dev);
u32 offset, length; u32 offset, length;
if (sizeof(*set_lsa) > cmd->size_in) if (sizeof(*set_lsa) > cmd->size_in)
...@@ -156,9 +156,9 @@ static int mock_set_lsa(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd) ...@@ -156,9 +156,9 @@ static int mock_set_lsa(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd)
return 0; return 0;
} }
static int cxl_mock_mbox_send(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd) static int cxl_mock_mbox_send(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd)
{ {
struct device *dev = cxlm->dev; struct device *dev = cxlds->dev;
int rc = -EIO; int rc = -EIO;
switch (cmd->opcode) { switch (cmd->opcode) {
...@@ -166,16 +166,16 @@ static int cxl_mock_mbox_send(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd) ...@@ -166,16 +166,16 @@ static int cxl_mock_mbox_send(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd)
rc = mock_gsl(cmd); rc = mock_gsl(cmd);
break; break;
case CXL_MBOX_OP_GET_LOG: case CXL_MBOX_OP_GET_LOG:
rc = mock_get_log(cxlm, cmd); rc = mock_get_log(cxlds, cmd);
break; break;
case CXL_MBOX_OP_IDENTIFY: case CXL_MBOX_OP_IDENTIFY:
rc = mock_id(cxlm, cmd); rc = mock_id(cxlds, cmd);
break; break;
case CXL_MBOX_OP_GET_LSA: case CXL_MBOX_OP_GET_LSA:
rc = mock_get_lsa(cxlm, cmd); rc = mock_get_lsa(cxlds, cmd);
break; break;
case CXL_MBOX_OP_SET_LSA: case CXL_MBOX_OP_SET_LSA:
rc = mock_set_lsa(cxlm, cmd); rc = mock_set_lsa(cxlds, cmd);
break; break;
default: default:
break; break;
...@@ -196,7 +196,7 @@ static int cxl_mock_mem_probe(struct platform_device *pdev) ...@@ -196,7 +196,7 @@ static int cxl_mock_mem_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct cxl_memdev *cxlmd; struct cxl_memdev *cxlmd;
struct cxl_mem *cxlm; struct cxl_dev_state *cxlds;
void *lsa; void *lsa;
int rc; int rc;
...@@ -208,30 +208,30 @@ static int cxl_mock_mem_probe(struct platform_device *pdev) ...@@ -208,30 +208,30 @@ static int cxl_mock_mem_probe(struct platform_device *pdev)
return rc; return rc;
dev_set_drvdata(dev, lsa); dev_set_drvdata(dev, lsa);
cxlm = cxl_mem_create(dev); cxlds = cxl_dev_state_create(dev);
if (IS_ERR(cxlm)) if (IS_ERR(cxlds))
return PTR_ERR(cxlm); return PTR_ERR(cxlds);
cxlm->mbox_send = cxl_mock_mbox_send; cxlds->mbox_send = cxl_mock_mbox_send;
cxlm->payload_size = SZ_4K; cxlds->payload_size = SZ_4K;
rc = cxl_mem_enumerate_cmds(cxlm); rc = cxl_enumerate_cmds(cxlds);
if (rc) if (rc)
return rc; return rc;
rc = cxl_mem_identify(cxlm); rc = cxl_dev_state_identify(cxlds);
if (rc) if (rc)
return rc; return rc;
rc = cxl_mem_create_range_info(cxlm); rc = cxl_mem_create_range_info(cxlds);
if (rc) if (rc)
return rc; return rc;
cxlmd = devm_cxl_add_memdev(cxlm); cxlmd = devm_cxl_add_memdev(cxlds);
if (IS_ERR(cxlmd)) if (IS_ERR(cxlmd))
return PTR_ERR(cxlmd); return PTR_ERR(cxlmd);
if (range_len(&cxlm->pmem_range) && IS_ENABLED(CONFIG_CXL_PMEM)) if (range_len(&cxlds->pmem_range) && IS_ENABLED(CONFIG_CXL_PMEM))
rc = devm_cxl_add_nvdimm(dev, cxlmd); rc = devm_cxl_add_nvdimm(dev, cxlmd);
return 0; return 0;
......
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