device-dax: Remove multi-resource infrastructure
The multi-resource implementation anticipated discontiguous sub-division support. That has not yet materialized, delete the infrastructure and related code. Signed-off-by: Dan Williams <dan.j.williams@intel.com>hifive-unleashed-5.1
parent
93694f9630
commit
753a0850e7
|
@ -39,14 +39,10 @@ struct dax_region {
|
||||||
* @region - parent region
|
* @region - parent region
|
||||||
* @dax_dev - core dax functionality
|
* @dax_dev - core dax functionality
|
||||||
* @dev - device core
|
* @dev - device core
|
||||||
* @num_resources - number of physical address extents in this device
|
|
||||||
* @res - array of physical address ranges
|
|
||||||
*/
|
*/
|
||||||
struct dev_dax {
|
struct dev_dax {
|
||||||
struct dax_region *region;
|
struct dax_region *region;
|
||||||
struct dax_device *dax_dev;
|
struct dax_device *dax_dev;
|
||||||
struct device dev;
|
struct device dev;
|
||||||
int num_resources;
|
|
||||||
struct resource res[0];
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,6 +19,5 @@ struct dax_region;
|
||||||
void dax_region_put(struct dax_region *dax_region);
|
void dax_region_put(struct dax_region *dax_region);
|
||||||
struct dax_region *alloc_dax_region(struct device *parent, int region_id,
|
struct dax_region *alloc_dax_region(struct device *parent, int region_id,
|
||||||
struct resource *res, unsigned int align, unsigned long flags);
|
struct resource *res, unsigned int align, unsigned long flags);
|
||||||
struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region,
|
struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, int id);
|
||||||
int id, struct resource *res, int count);
|
|
||||||
#endif /* __DEVICE_DAX_H__ */
|
#endif /* __DEVICE_DAX_H__ */
|
||||||
|
|
|
@ -151,11 +151,7 @@ static ssize_t size_show(struct device *dev,
|
||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
struct dev_dax *dev_dax = to_dev_dax(dev);
|
struct dev_dax *dev_dax = to_dev_dax(dev);
|
||||||
unsigned long long size = 0;
|
unsigned long long size = resource_size(&dev_dax->region->res);
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < dev_dax->num_resources; i++)
|
|
||||||
size += resource_size(&dev_dax->res[i]);
|
|
||||||
|
|
||||||
return sprintf(buf, "%llu\n", size);
|
return sprintf(buf, "%llu\n", size);
|
||||||
}
|
}
|
||||||
|
@ -224,21 +220,11 @@ static int check_vma(struct dev_dax *dev_dax, struct vm_area_struct *vma,
|
||||||
__weak phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff,
|
__weak phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff,
|
||||||
unsigned long size)
|
unsigned long size)
|
||||||
{
|
{
|
||||||
struct resource *res;
|
struct resource *res = &dev_dax->region->res;
|
||||||
/* gcc-4.6.3-nolibc for i386 complains that this is uninitialized */
|
phys_addr_t phys;
|
||||||
phys_addr_t uninitialized_var(phys);
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < dev_dax->num_resources; i++) {
|
phys = pgoff * PAGE_SIZE + res->start;
|
||||||
res = &dev_dax->res[i];
|
if (phys >= res->start && phys <= res->end) {
|
||||||
phys = pgoff * PAGE_SIZE + res->start;
|
|
||||||
if (phys >= res->start && phys <= res->end)
|
|
||||||
break;
|
|
||||||
pgoff -= PHYS_PFN(resource_size(res));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i < dev_dax->num_resources) {
|
|
||||||
res = &dev_dax->res[i];
|
|
||||||
if (phys + size - 1 <= res->end)
|
if (phys + size - 1 <= res->end)
|
||||||
return phys;
|
return phys;
|
||||||
}
|
}
|
||||||
|
@ -608,8 +594,7 @@ static void unregister_dev_dax(void *dev)
|
||||||
put_device(dev);
|
put_device(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region,
|
struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, int id)
|
||||||
int id, struct resource *res, int count)
|
|
||||||
{
|
{
|
||||||
struct device *parent = dax_region->dev;
|
struct device *parent = dax_region->dev;
|
||||||
struct dax_device *dax_dev;
|
struct dax_device *dax_dev;
|
||||||
|
@ -617,29 +602,12 @@ struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region,
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct cdev *cdev;
|
struct cdev *cdev;
|
||||||
int rc, i;
|
int rc;
|
||||||
|
|
||||||
if (!count)
|
dev_dax = kzalloc(sizeof(*dev_dax), GFP_KERNEL);
|
||||||
return ERR_PTR(-EINVAL);
|
|
||||||
|
|
||||||
dev_dax = kzalloc(struct_size(dev_dax, res, count), GFP_KERNEL);
|
|
||||||
if (!dev_dax)
|
if (!dev_dax)
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
|
||||||
if (!IS_ALIGNED(res[i].start, dax_region->align)
|
|
||||||
|| !IS_ALIGNED(resource_size(&res[i]),
|
|
||||||
dax_region->align)) {
|
|
||||||
rc = -EINVAL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
dev_dax->res[i].start = res[i].start;
|
|
||||||
dev_dax->res[i].end = res[i].end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i < count)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* No 'host' or dax_operations since there is no access to this
|
* No 'host' or dax_operations since there is no access to this
|
||||||
* device outside of mmap of the resulting character device.
|
* device outside of mmap of the resulting character device.
|
||||||
|
@ -659,7 +627,6 @@ struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region,
|
||||||
cdev_init(cdev, &dax_fops);
|
cdev_init(cdev, &dax_fops);
|
||||||
cdev->owner = parent->driver->owner;
|
cdev->owner = parent->driver->owner;
|
||||||
|
|
||||||
dev_dax->num_resources = count;
|
|
||||||
dev_dax->dax_dev = dax_dev;
|
dev_dax->dax_dev = dax_dev;
|
||||||
dev_dax->region = dax_region;
|
dev_dax->region = dax_region;
|
||||||
kref_get(&dax_region->kref);
|
kref_get(&dax_region->kref);
|
||||||
|
|
|
@ -129,8 +129,7 @@ static int dax_pmem_probe(struct device *dev)
|
||||||
if (!dax_region)
|
if (!dax_region)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
/* TODO: support for subdividing a dax region... */
|
dev_dax = devm_create_dev_dax(dax_region, id);
|
||||||
dev_dax = devm_create_dev_dax(dax_region, id, &res, 1);
|
|
||||||
|
|
||||||
/* child dev_dax instances now own the lifetime of the dax_region */
|
/* child dev_dax instances now own the lifetime of the dax_region */
|
||||||
dax_region_put(dax_region);
|
dax_region_put(dax_region);
|
||||||
|
|
|
@ -17,20 +17,11 @@
|
||||||
phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff,
|
phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff,
|
||||||
unsigned long size)
|
unsigned long size)
|
||||||
{
|
{
|
||||||
struct resource *res;
|
struct resource *res = &dev_dax->region->res;
|
||||||
phys_addr_t addr;
|
phys_addr_t addr;
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < dev_dax->num_resources; i++) {
|
addr = pgoff * PAGE_SIZE + res->start;
|
||||||
res = &dev_dax->res[i];
|
if (addr >= res->start && addr <= res->end) {
|
||||||
addr = pgoff * PAGE_SIZE + res->start;
|
|
||||||
if (addr >= res->start && addr <= res->end)
|
|
||||||
break;
|
|
||||||
pgoff -= PHYS_PFN(resource_size(res));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i < dev_dax->num_resources) {
|
|
||||||
res = &dev_dax->res[i];
|
|
||||||
if (addr + size - 1 <= res->end) {
|
if (addr + size - 1 <= res->end) {
|
||||||
if (get_nfit_res(addr)) {
|
if (get_nfit_res(addr)) {
|
||||||
struct page *page;
|
struct page *page;
|
||||||
|
@ -44,6 +35,5 @@ phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff,
|
||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue