linux/drivers/cxl/core/memdev.c

// SPDX-License-Identifier: GPL-2.0-only
/* Copyright(c) 2020 Intel Corporation. */

#include <linux/io-64-nonatomic-lo-hi.h>
#include <linux/firmware.h>
#include <linux/device.h>
#include <linux/slab.h>
#include <linux/idr.h>
#include <linux/pci.h>
#include <cxlmem.h>
#include "trace.h"
#include "core.h"

static DECLARE_RWSEM(cxl_memdev_rwsem);

/*
 * An entire PCI topology full of devices should be enough for any
 * config
 */
#define CXL_MEM_MAX_DEVS

static int cxl_mem_major;
static DEFINE_IDA(cxl_memdev_ida);

static void cxl_memdev_release(struct device *dev)
{}

static char *cxl_memdev_devnode(const struct device *dev, umode_t *mode, kuid_t *uid,
				kgid_t *gid)
{}

static ssize_t firmware_version_show(struct device *dev,
				     struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(firmware_version);

static ssize_t payload_max_show(struct device *dev,
				struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(payload_max);

static ssize_t label_storage_size_show(struct device *dev,
				       struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(label_storage_size);

static ssize_t ram_size_show(struct device *dev, struct device_attribute *attr,
			     char *buf)
{}

static struct device_attribute dev_attr_ram_size =;

static ssize_t pmem_size_show(struct device *dev, struct device_attribute *attr,
			      char *buf)
{}

static struct device_attribute dev_attr_pmem_size =;

static ssize_t serial_show(struct device *dev, struct device_attribute *attr,
			   char *buf)
{}
static DEVICE_ATTR_RO(serial);

static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr,
			      char *buf)
{}
static DEVICE_ATTR_RO(numa_node);

static ssize_t security_state_show(struct device *dev,
				   struct device_attribute *attr,
				   char *buf)
{}
static struct device_attribute dev_attr_security_state =;

static ssize_t security_sanitize_store(struct device *dev,
				       struct device_attribute *attr,
				       const char *buf, size_t len)
{}
static struct device_attribute dev_attr_security_sanitize =;

static ssize_t security_erase_store(struct device *dev,
				    struct device_attribute *attr,
				    const char *buf, size_t len)
{}
static struct device_attribute dev_attr_security_erase =;

static int cxl_get_poison_by_memdev(struct cxl_memdev *cxlmd)
{}

int cxl_trigger_poison_list(struct cxl_memdev *cxlmd)
{}
EXPORT_SYMBOL_NS_GPL();

static int cxl_validate_poison_dpa(struct cxl_memdev *cxlmd, u64 dpa)
{}

int cxl_inject_poison(struct cxl_memdev *cxlmd, u64 dpa)
{}
EXPORT_SYMBOL_NS_GPL();

int cxl_clear_poison(struct cxl_memdev *cxlmd, u64 dpa)
{}
EXPORT_SYMBOL_NS_GPL();

static struct attribute *cxl_memdev_attributes[] =;

static ssize_t pmem_qos_class_show(struct device *dev,
				   struct device_attribute *attr, char *buf)
{}

static struct device_attribute dev_attr_pmem_qos_class =;

static struct attribute *cxl_memdev_pmem_attributes[] =;

static ssize_t ram_qos_class_show(struct device *dev,
				  struct device_attribute *attr, char *buf)
{}

static struct device_attribute dev_attr_ram_qos_class =;

static struct attribute *cxl_memdev_ram_attributes[] =;

static struct attribute *cxl_memdev_security_attributes[] =;

static umode_t cxl_memdev_visible(struct kobject *kobj, struct attribute *a,
				  int n)
{}

static struct attribute_group cxl_memdev_attribute_group =;

static umode_t cxl_ram_visible(struct kobject *kobj, struct attribute *a, int n)
{}

static struct attribute_group cxl_memdev_ram_attribute_group =;

static umode_t cxl_pmem_visible(struct kobject *kobj, struct attribute *a, int n)
{}

static struct attribute_group cxl_memdev_pmem_attribute_group =;

static umode_t cxl_memdev_security_visible(struct kobject *kobj,
					   struct attribute *a, int n)
{}

static struct attribute_group cxl_memdev_security_attribute_group =;

static const struct attribute_group *cxl_memdev_attribute_groups[] =;

void cxl_memdev_update_perf(struct cxl_memdev *cxlmd)
{}
EXPORT_SYMBOL_NS_GPL();

static const struct device_type cxl_memdev_type =;

bool is_cxl_memdev(const struct device *dev)
{}
EXPORT_SYMBOL_NS_GPL();

/**
 * set_exclusive_cxl_commands() - atomically disable user cxl commands
 * @mds: The device state to operate on
 * @cmds: bitmap of commands to mark exclusive
 *
 * Grab the cxl_memdev_rwsem in write mode to flush in-flight
 * invocations of the ioctl path and then disable future execution of
 * commands with the command ids set in @cmds.
 */
void set_exclusive_cxl_commands(struct cxl_memdev_state *mds,
				unsigned long *cmds)
{}
EXPORT_SYMBOL_NS_GPL();

/**
 * clear_exclusive_cxl_commands() - atomically enable user cxl commands
 * @mds: The device state to modify
 * @cmds: bitmap of commands to mark available for userspace
 */
void clear_exclusive_cxl_commands(struct cxl_memdev_state *mds,
				  unsigned long *cmds)
{}
EXPORT_SYMBOL_NS_GPL();

static void cxl_memdev_shutdown(struct device *dev)
{}

static void cxl_memdev_unregister(void *_cxlmd)
{}

static void detach_memdev(struct work_struct *work)
{}

static struct lock_class_key cxl_memdev_key;

static struct cxl_memdev *cxl_memdev_alloc(struct cxl_dev_state *cxlds,
					   const struct file_operations *fops)
{}

static long __cxl_memdev_ioctl(struct cxl_memdev *cxlmd, unsigned int cmd,
			       unsigned long arg)
{}

static long cxl_memdev_ioctl(struct file *file, unsigned int cmd,
			     unsigned long arg)
{}

static int cxl_memdev_open(struct inode *inode, struct file *file)
{}

static int cxl_memdev_release_file(struct inode *inode, struct file *file)
{}

/**
 * cxl_mem_get_fw_info - Get Firmware info
 * @mds: The device data for the operation
 *
 * Retrieve firmware info for the device specified.
 *
 * Return: 0 if no error: or the result of the mailbox command.
 *
 * See CXL-3.0 8.2.9.3.1 Get FW Info
 */
static int cxl_mem_get_fw_info(struct cxl_memdev_state *mds)
{}

/**
 * cxl_mem_activate_fw - Activate Firmware
 * @mds: The device data for the operation
 * @slot: slot number to activate
 *
 * Activate firmware in a given slot for the device specified.
 *
 * Return: 0 if no error: or the result of the mailbox command.
 *
 * See CXL-3.0 8.2.9.3.3 Activate FW
 */
static int cxl_mem_activate_fw(struct cxl_memdev_state *mds, int slot)
{}

/**
 * cxl_mem_abort_fw_xfer - Abort an in-progress FW transfer
 * @mds: The device data for the operation
 *
 * Abort an in-progress firmware transfer for the device specified.
 *
 * Return: 0 if no error: or the result of the mailbox command.
 *
 * See CXL-3.0 8.2.9.3.2 Transfer FW
 */
static int cxl_mem_abort_fw_xfer(struct cxl_memdev_state *mds)
{}

static void cxl_fw_cleanup(struct fw_upload *fwl)
{}

static int cxl_fw_do_cancel(struct fw_upload *fwl)
{}

static enum fw_upload_err cxl_fw_prepare(struct fw_upload *fwl, const u8 *data,
					 u32 size)
{}

static enum fw_upload_err cxl_fw_write(struct fw_upload *fwl, const u8 *data,
				       u32 offset, u32 size, u32 *written)
{}

static enum fw_upload_err cxl_fw_poll_complete(struct fw_upload *fwl)
{}

static void cxl_fw_cancel(struct fw_upload *fwl)
{}

static const struct fw_upload_ops cxl_memdev_fw_ops =;

static void cxl_remove_fw_upload(void *fwl)
{}

int devm_cxl_setup_fw_upload(struct device *host, struct cxl_memdev_state *mds)
{}
EXPORT_SYMBOL_NS_GPL();

static const struct file_operations cxl_memdev_fops =;

struct cxl_memdev *devm_cxl_add_memdev(struct device *host,
				       struct cxl_dev_state *cxlds)
{}
EXPORT_SYMBOL_NS_GPL();

static void sanitize_teardown_notifier(void *data)
{}

int devm_cxl_sanitize_setup_notifier(struct device *host,
				     struct cxl_memdev *cxlmd)
{}
EXPORT_SYMBOL_NS_GPL();

__init int cxl_memdev_init(void)
{}

void cxl_memdev_exit(void)
{}