powerpc/pseries/iommu: Remove ddw property when destroying window
authorMilton Miller <miltonm@bga.com>
Wed, 11 May 2011 12:24:58 +0000 (12:24 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Thu, 19 May 2011 07:25:27 +0000 (17:25 +1000)
If we destroy the window, we need to remove the property recording that
we setup the window.  Otherwise the next kernel we kexec will be
confused.

Also we should remove the property if even if we don't find the
ibm,ddw-applicable window or if one of the property sizes is unexpected;
presumably these came from a prior kernel via kexec, and we will not be
maintaining the window with respect to memory hotplug.

Signed-off-by: Milton Miller <miltonm@bga.com>
Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/platforms/pseries/iommu.c

index 05c101e7dcd7821f142a63a9a2e486b1e96eec06..a0421ac46d4e72794b591ad564eb30f44c88ffcf 100644 (file)
@@ -665,9 +665,12 @@ static void remove_ddw(struct device_node *np)
 
        ddr_avail = of_get_property(np, "ibm,ddw-applicable", &len);
        win64 = of_find_property(np, DIRECT64_PROPNAME, NULL);
-       if (!win64 || !ddr_avail || len < 3 * sizeof(u32))
+       if (!win64)
                return;
 
+       if (!ddr_avail || len < 3 * sizeof(u32) || win64->length < sizeof(*dwp))
+               goto delprop;
+
        dwp = win64->value;
        liobn = (u64)be32_to_cpu(dwp->liobn);
 
@@ -690,8 +693,13 @@ static void remove_ddw(struct device_node *np)
                pr_debug("%s: successfully removed direct window: rtas returned "
                        "%d to ibm,remove-pe-dma-window(%x) %llx\n",
                        np->full_name, ret, ddr_avail[2], liobn);
-}
 
+delprop:
+       ret = of_remove_property(np, win64);
+       if (ret)
+               pr_warning("%s: failed to remove direct window property: %d\n"
+                       np->full_name, ret);
+}
 
 static u64 dupe_ddw_if_already_created(struct pci_dev *dev, struct device_node *pdn)
 {
This page took 0.027975 seconds and 5 git commands to generate.