linux/drivers/dax/bus.c

// SPDX-License-Identifier: GPL-2.0
/* Copyright(c) 2017-2018 Intel Corporation. All rights reserved. */
#include <linux/memremap.h>
#include <linux/device.h>
#include <linux/mutex.h>
#include <linux/list.h>
#include <linux/slab.h>
#include <linux/dax.h>
#include <linux/io.h>
#include "dax-private.h"
#include "bus.h"

static DEFINE_MUTEX(dax_bus_lock);

/*
 * All changes to the dax region configuration occur with this lock held
 * for write.
 */
DECLARE_RWSEM();

/*
 * All changes to the dax device configuration occur with this lock held
 * for write.
 */
DECLARE_RWSEM();

#define DAX_NAME_LEN
struct dax_id {};

static int dax_bus_uevent(const struct device *dev, struct kobj_uevent_env *env)
{}

#define to_dax_drv(__drv)

static struct dax_id *__dax_match_id(const struct dax_device_driver *dax_drv,
		const char *dev_name)
{}

static int dax_match_id(const struct dax_device_driver *dax_drv, struct device *dev)
{}

static int dax_match_type(const struct dax_device_driver *dax_drv, struct device *dev)
{}

enum id_action {};

static ssize_t do_id_store(struct device_driver *drv, const char *buf,
		size_t count, enum id_action action)
{}

static ssize_t new_id_store(struct device_driver *drv, const char *buf,
		size_t count)
{}
static DRIVER_ATTR_WO(new_id);

static ssize_t remove_id_store(struct device_driver *drv, const char *buf,
		size_t count)
{}
static DRIVER_ATTR_WO(remove_id);

static struct attribute *dax_drv_attrs[] =;
ATTRIBUTE_GROUPS();

static int dax_bus_match(struct device *dev, const struct device_driver *drv);

/*
 * Static dax regions are regions created by an external subsystem
 * nvdimm where a single range is assigned. Its boundaries are by the external
 * subsystem and are usually limited to one physical memory range. For example,
 * for PMEM it is usually defined by NVDIMM Namespace boundaries (i.e. a
 * single contiguous range)
 *
 * On dynamic dax regions, the assigned region can be partitioned by dax core
 * into multiple subdivisions. A subdivision is represented into one
 * /dev/daxN.M device composed by one or more potentially discontiguous ranges.
 *
 * When allocating a dax region, drivers must set whether it's static
 * (IORESOURCE_DAX_STATIC).  On static dax devices, the @pgmap is pre-assigned
 * to dax core when calling devm_create_dev_dax(), whereas in dynamic dax
 * devices it is NULL but afterwards allocated by dax core on device ->probe().
 * Care is needed to make sure that dynamic dax devices are torn down with a
 * cleared @pgmap field (see kill_dev_dax()).
 */
static bool is_static(struct dax_region *dax_region)
{}

bool static_dev_dax(struct dev_dax *dev_dax)
{}
EXPORT_SYMBOL_GPL();

static u64 dev_dax_size(struct dev_dax *dev_dax)
{}

static int dax_bus_probe(struct device *dev)
{}

static void dax_bus_remove(struct device *dev)
{}

static const struct bus_type dax_bus_type =;

static int dax_bus_match(struct device *dev, const struct device_driver *drv)
{}

/*
 * Rely on the fact that drvdata is set before the attributes are
 * registered, and that the attributes are unregistered before drvdata
 * is cleared to assume that drvdata is always valid.
 */
static ssize_t id_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(id);

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

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

#define for_each_dax_region_resource(dax_region, res)

static unsigned long long dax_region_avail_size(struct dax_region *dax_region)
{}

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

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

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

static struct dev_dax *__devm_create_dev_dax(struct dev_dax_data *data);

static ssize_t create_store(struct device *dev, struct device_attribute *attr,
		const char *buf, size_t len)
{}
static DEVICE_ATTR_RW(create);

void kill_dev_dax(struct dev_dax *dev_dax)
{}
EXPORT_SYMBOL_GPL();

static void trim_dev_dax_range(struct dev_dax *dev_dax)
{}

static void free_dev_dax_ranges(struct dev_dax *dev_dax)
{}

static void unregister_dev_dax(void *dev)
{}

static void dax_region_free(struct kref *kref)
{}

static void dax_region_put(struct dax_region *dax_region)
{}

/* a return value >= 0 indicates this invocation invalidated the id */
static int __free_dev_dax_id(struct dev_dax *dev_dax)
{}

static int free_dev_dax_id(struct dev_dax *dev_dax)
{}

static int alloc_dev_dax_id(struct dev_dax *dev_dax)
{}

static ssize_t delete_store(struct device *dev, struct device_attribute *attr,
		const char *buf, size_t len)
{}
static DEVICE_ATTR_WO(delete);

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

static struct attribute *dax_region_attributes[] =;

static const struct attribute_group dax_region_attribute_group =;

static const struct attribute_group *dax_region_attribute_groups[] =;

static void dax_region_unregister(void *region)
{}

struct dax_region *alloc_dax_region(struct device *parent, int region_id,
		struct range *range, int target_node, unsigned int align,
		unsigned long flags)
{}
EXPORT_SYMBOL_GPL();

static void dax_mapping_release(struct device *dev)
{}

static void unregister_dax_mapping(void *data)
{}

static struct dev_dax_range *get_dax_range(struct device *dev)
{}

static void put_dax_range(void)
{}

static ssize_t start_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR(start, 0400, start_show, NULL);

static ssize_t end_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR(end, 0400, end_show, NULL);

static ssize_t pgoff_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR(page_offset, 0400, pgoff_show, NULL);

static struct attribute *dax_mapping_attributes[] =;

static const struct attribute_group dax_mapping_attribute_group =;

static const struct attribute_group *dax_mapping_attribute_groups[] =;

static const struct device_type dax_mapping_type =;

static int devm_register_dax_mapping(struct dev_dax *dev_dax, int range_id)
{}

static int alloc_dev_dax_range(struct dev_dax *dev_dax, u64 start,
		resource_size_t size)
{}

static int adjust_dev_dax_range(struct dev_dax *dev_dax, struct resource *res, resource_size_t size)
{}

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

static bool alloc_is_aligned(struct dev_dax *dev_dax, resource_size_t size)
{}

static int dev_dax_shrink(struct dev_dax *dev_dax, resource_size_t size)
{}

/*
 * Only allow adjustments that preserve the relative pgoff of existing
 * allocations. I.e. the dev_dax->ranges array is ordered by increasing pgoff.
 */
static bool adjust_ok(struct dev_dax *dev_dax, struct resource *res)
{}

static ssize_t dev_dax_resize(struct dax_region *dax_region,
		struct dev_dax *dev_dax, resource_size_t size)
{}

static ssize_t size_store(struct device *dev, struct device_attribute *attr,
		const char *buf, size_t len)
{}
static DEVICE_ATTR_RW(size);

static ssize_t range_parse(const char *opt, size_t len, struct range *range)
{}

static ssize_t mapping_store(struct device *dev, struct device_attribute *attr,
		const char *buf, size_t len)
{}
static DEVICE_ATTR_WO(mapping);

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

static ssize_t dev_dax_validate_align(struct dev_dax *dev_dax)
{}

static ssize_t align_store(struct device *dev, struct device_attribute *attr,
		const char *buf, size_t len)
{}
static DEVICE_ATTR_RW(align);

static int dev_dax_target_node(struct dev_dax *dev_dax)
{}

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

static ssize_t resource_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR(resource, 0400, resource_show, NULL);

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

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

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

static ssize_t memmap_on_memory_store(struct device *dev,
				      struct device_attribute *attr,
				      const char *buf, size_t len)
{}
static DEVICE_ATTR_RW(memmap_on_memory);

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

static struct attribute *dev_dax_attributes[] =;

static const struct attribute_group dev_dax_attribute_group =;

static const struct attribute_group *dax_attribute_groups[] =;

static void dev_dax_release(struct device *dev)
{}

static const struct device_type dev_dax_type =;

static struct dev_dax *__devm_create_dev_dax(struct dev_dax_data *data)
{}

struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data)
{}
EXPORT_SYMBOL_GPL();

int __dax_driver_register(struct dax_device_driver *dax_drv,
		struct module *module, const char *mod_name)
{}
EXPORT_SYMBOL_GPL();

void dax_driver_unregister(struct dax_device_driver *dax_drv)
{}
EXPORT_SYMBOL_GPL();

int __init dax_bus_init(void)
{}

void __exit dax_bus_exit(void)
{}