Re: [PATCH 8/9] tools/testing/libnvdimm: cleanup mock resource lookup
From: Dan Williams
Date: Tue Dec 15 2015 - 02:11:58 EST
On Mon, Dec 14, 2015 at 6:15 PM, Dan Williams <dan.j.williams@xxxxxxxxx> wrote:
> Push the locking around get_nfit_res() into get_nfit_res().
>
> Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx>
> ---
> tools/testing/nvdimm/test/iomap.c | 86 +++++++++++++++++--------------------
> 1 file changed, 39 insertions(+), 47 deletions(-)
>
> diff --git a/tools/testing/nvdimm/test/iomap.c b/tools/testing/nvdimm/test/iomap.c
> index 802d3a173ccf..d9c6c5af67e8 100644
> --- a/tools/testing/nvdimm/test/iomap.c
> +++ b/tools/testing/nvdimm/test/iomap.c
[..]
> @@ -83,55 +89,55 @@ EXPORT_SYMBOL(__wrap_devm_ioremap_nocache);
> void *__wrap_devm_memremap(struct device *dev, resource_size_t offset,
> size_t size, unsigned long flags)
> {
> - struct nfit_test_resource *nfit_res;
> + struct nfit_test_resource *nfit_res = get_nfit_res(offset);
>
> - rcu_read_lock();
> - nfit_res = get_nfit_res(offset);
> - rcu_read_unlock();
> if (nfit_res)
> return nfit_res->buf + offset - nfit_res->res->start;
> return devm_memremap(dev, offset, size, flags);
> }
> EXPORT_SYMBOL(__wrap_devm_memremap);
>
> -void *__wrap_devm_memremap_pages(struct device *dev, struct resource *res)
> +#ifdef PFN_MAP
> +void *__wrap_devm_memremap_pages(struct device *dev, struct resource *res,
> + struct percpu_ref *ref, struct vmem_altmap *altmap)
> {
> - struct nfit_test_resource *nfit_res;
> resource_size_t offset = res->start;
> + struct nfit_test_resource *nfit_res = get_nfit_res(offset);
>
> - rcu_read_lock();
> - nfit_res = get_nfit_res(offset);
> - rcu_read_unlock();
> if (nfit_res)
> return nfit_res->buf + offset - nfit_res->res->start;
> - return devm_memremap_pages(dev, res);
> + return devm_memremap_pages(dev, res, ref, altmap);
> }
> EXPORT_SYMBOL(__wrap_devm_memremap_pages);
>
> -#ifdef PFN_MAP
> pfn_t __wrap_phys_to_pfn_t(dma_addr_t addr, unsigned long flags)
> {
> - struct nfit_test_resource *nfit_res;
> -
> - rcu_read_lock();
> - nfit_res = get_nfit_res(offset);
> - rcu_read_unlock();
> + struct nfit_test_resource *nfit_res = get_nfit_res(addr);
>
> if (nfit_res)
> flags &= ~PFN_MAP;
> - return phys_to_pfn_t(addr >> PAGE_SHIFT, flags);
> + return phys_to_pfn_t(addr, flags);
> }
> EXPORT_SYMBOL(__wrap_phys_to_pfn_t);
> +#else
> +/* to be removed post 4.5-rc1 */
> +void *__wrap_devm_memremap_pages(struct device *dev, struct resource *res)
> +{
> + resource_size_t offset = res->start;
> + struct nfit_test_resource *nfit_res = get_nfit_res(offset);
> +
> + if (nfit_res)
> + return nfit_res->buf + offset - nfit_res->res->start;
> + return devm_memremap_pages(dev, res);
> +}
> +EXPORT_SYMBOL(__wrap_devm_memremap_pages);
> #endif
Whoops, the above hunk was meant to be folded into [PATCH 6/9]
libnvdimm, pfn: enable pfn sysfs interface unit testing
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/