diff mbox

nvdimm: fix PHYS_PFN/PFN_PHYS mixup

Message ID 1474280340-6394-1-git-send-email-oohall@gmail.com (mailing list archive)
State Accepted
Commit 480b6837aa57
Headers show

Commit Message

Oliver O'Halloran Sept. 19, 2016, 10:19 a.m. UTC
nd_activate_region() iomaps any hint addresses required when activating
a region. To prevent duplicate mappings it checks the PFN of the hint to
be mapped against the PFNs of the already mapped hints. Unfortunately it
doesn't convert the PFN back into a physical address before passing it
to devm_nvdimm_ioremap(). Instead it applies PHYS_PFN a second time
which ends about as well as you would imagine.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Cc: Dan Williams <dan.j.williams@intel.com>
---
 drivers/nvdimm/region_devs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dan Williams Sept. 19, 2016, 3:56 p.m. UTC | #1
On Mon, Sep 19, 2016 at 3:19 AM, Oliver O'Halloran <oohall@gmail.com> wrote:
> nd_activate_region() iomaps any hint addresses required when activating
> a region. To prevent duplicate mappings it checks the PFN of the hint to
> be mapped against the PFNs of the already mapped hints. Unfortunately it
> doesn't convert the PFN back into a physical address before passing it
> to devm_nvdimm_ioremap(). Instead it applies PHYS_PFN a second time
> which ends about as well as you would imagine.
>
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> ---
>  drivers/nvdimm/region_devs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
> index e8d5ba7b29af..4eef88eb5144 100644
> --- a/drivers/nvdimm/region_devs.c
> +++ b/drivers/nvdimm/region_devs.c
> @@ -57,7 +57,7 @@ static int nvdimm_map_flush(struct device *dev, struct nvdimm *nvdimm, int dimm,
>                                         ndrd->flush_wpq[dimm][j] & PAGE_MASK);
>                 else
>                         flush_page = devm_nvdimm_ioremap(dev,
> -                                       PHYS_PFN(pfn), PAGE_SIZE);
> +                                       PFN_PHYS(pfn), PAGE_SIZE);
>                 if (!flush_page)
>                         return -ENXIO;
>                 ndrd->flush_wpq[dimm][i] = flush_page

Nice catch, I'll push this for 4.8-final.
diff mbox

Patch

diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
index e8d5ba7b29af..4eef88eb5144 100644
--- a/drivers/nvdimm/region_devs.c
+++ b/drivers/nvdimm/region_devs.c
@@ -57,7 +57,7 @@  static int nvdimm_map_flush(struct device *dev, struct nvdimm *nvdimm, int dimm,
 					ndrd->flush_wpq[dimm][j] & PAGE_MASK);
 		else
 			flush_page = devm_nvdimm_ioremap(dev,
-					PHYS_PFN(pfn), PAGE_SIZE);
+					PFN_PHYS(pfn), PAGE_SIZE);
 		if (!flush_page)
 			return -ENXIO;
 		ndrd->flush_wpq[dimm][i] = flush_page