memremap: lift the devmap_enable manipulation into devm_memremap_pages
authorChristoph Hellwig <hch@lst.de>
Wed, 26 Jun 2019 12:27:10 +0000 (14:27 +0200)
committerJason Gunthorpe <jgg@mellanox.com>
Tue, 2 Jul 2019 17:32:44 +0000 (14:32 -0300)
commitf6a55e1a3fe6b3bb294a80a05437fcf86488d819
treec7939245cd5d9437e8bfdc127244b89b8db0b044
parentd8668bb0451c3c45b59dbcde2654e0539aad1d2a
memremap: lift the devmap_enable manipulation into devm_memremap_pages

Just check if there is a ->page_free operation set and take care of the
static key enable, as well as the put using device managed resources.
Also check that a ->page_free is provided for the pgmaps types that
require it, and check for a valid type as well while we are at it.

Note that this also fixes the fact that hmm never called
dev_pagemap_put_ops and thus would leave the slow path enabled forever,
even after a device driver unload or disable.

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>
drivers/nvdimm/pmem.c
include/linux/mm.h
kernel/memremap.c
mm/hmm.c