Skip to content

Commit

Permalink
device-dax: use the dev_pagemap internal refcount
Browse files Browse the repository at this point in the history
The functionality is identical to the one currently open coded in
device-dax.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
  • Loading branch information
Christoph Hellwig authored and jgunthorpe committed Jul 2, 2019
1 parent 24917f6 commit ea31d58
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 47 deletions.
4 changes: 0 additions & 4 deletions drivers/dax/dax-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,13 @@ struct dax_region {
* @target_node: effective numa node if dev_dax memory range is onlined
* @dev - device core
* @pgmap - pgmap for memmap setup / lifetime (driver owned)
* @ref: pgmap reference count (driver owned)
* @cmp: @ref final put completion (driver owned)
*/
struct dev_dax {
struct dax_region *region;
struct dax_device *dax_dev;
int target_node;
struct device dev;
struct dev_pagemap pgmap;
struct percpu_ref ref;
struct completion cmp;
};

static inline struct dev_dax *to_dev_dax(struct device *dev)
Expand Down
43 changes: 0 additions & 43 deletions drivers/dax/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,6 @@
#include "dax-private.h"
#include "bus.h"

static struct dev_dax *ref_to_dev_dax(struct percpu_ref *ref)
{
return container_of(ref, struct dev_dax, ref);
}

static void dev_dax_percpu_release(struct percpu_ref *ref)
{
struct dev_dax *dev_dax = ref_to_dev_dax(ref);

dev_dbg(&dev_dax->dev, "%s\n", __func__);
complete(&dev_dax->cmp);
}

static void dev_dax_percpu_exit(struct dev_pagemap *pgmap)
{
struct dev_dax *dev_dax = container_of(pgmap, struct dev_dax, pgmap);

dev_dbg(&dev_dax->dev, "%s\n", __func__);
wait_for_completion(&dev_dax->cmp);
percpu_ref_exit(pgmap->ref);
}

static void dev_dax_percpu_kill(struct dev_pagemap *pgmap)
{
struct dev_dax *dev_dax = container_of(pgmap, struct dev_dax, pgmap);

dev_dbg(&dev_dax->dev, "%s\n", __func__);
percpu_ref_kill(pgmap->ref);
}

static int check_vma(struct dev_dax *dev_dax, struct vm_area_struct *vma,
const char *func)
{
Expand Down Expand Up @@ -441,11 +411,6 @@ static void dev_dax_kill(void *dev_dax)
kill_dev_dax(dev_dax);
}

static const struct dev_pagemap_ops dev_dax_pagemap_ops = {
.kill = dev_dax_percpu_kill,
.cleanup = dev_dax_percpu_exit,
};

int dev_dax_probe(struct device *dev)
{
struct dev_dax *dev_dax = to_dev_dax(dev);
Expand All @@ -463,15 +428,7 @@ int dev_dax_probe(struct device *dev)
return -EBUSY;
}

init_completion(&dev_dax->cmp);
rc = percpu_ref_init(&dev_dax->ref, dev_dax_percpu_release, 0,
GFP_KERNEL);
if (rc)
return rc;

dev_dax->pgmap.ref = &dev_dax->ref;
dev_dax->pgmap.type = MEMORY_DEVICE_DEVDAX;
dev_dax->pgmap.ops = &dev_dax_pagemap_ops;
addr = devm_memremap_pages(dev, &dev_dax->pgmap);
if (IS_ERR(addr))
return PTR_ERR(addr);
Expand Down

0 comments on commit ea31d58

Please sign in to comment.