From: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
Subject: pseries/iommu: Ensure TCEs are cleared with non-huge DDW
Git-commit: 71cf1def1ad8384d5fa008f96de94b36668e5460
Patch-mainline: yes
References:  bnc#793678

    There are now two kinds of DMA windows that might be presented by
    PowerVM DDW support -- huge windows (that can map all of system memory
    regardless of the LPAR configuration) and non-huge windows (which
    can't). They are implemented slightly differently in PowerVM, and thus
    have different characteristics. The most obvious is that slot isolate
    doesn't clear the TCEs/window for us with non-huge windows. Thus, when a
    DLPAR operation occurs on a slot using a non-huge window, TCEs are still
    present (the notifier chain doesn't currently remove them explicitly)
    and the DLPAR fails. Fix this by calling remove_ddw() first, which will
    unmap the DDW TCEs.
    
    Note: a corresponding change to drmgr is needed to actually successfully
    DLPAR, such that the device-tree update (which causes the notifier chain
    to fire) occurs before slot isolate.
    
Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Torsten Duwe <duwe@suse.de>

 arch/powerpc/platforms/pseries/iommu.c |   11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff -urpN linux-3.0-ddw1/arch/powerpc/platforms/pseries/iommu.c linux-3.0-ddw2/arch/powerpc/platforms/pseries/iommu.c
--- linux-3.0-ddw1/arch/powerpc/platforms/pseries/iommu.c	2013-01-21 17:19:39.000000000 -0500
+++ linux-3.0-ddw2/arch/powerpc/platforms/pseries/iommu.c	2013-01-21 17:20:53.000000000 -0500
@@ -1220,6 +1220,7 @@ static int iommu_reconfig_notifier(struc
 
 	switch (action) {
 	case PSERIES_RECONFIG_REMOVE:
+		remove_ddw(np);
 		if (pci && pci->iommu_table)
 			iommu_free_table(pci->iommu_table, np->full_name);
 
@@ -1232,16 +1233,6 @@ static int iommu_reconfig_notifier(struc
 			}
 		}
 		spin_unlock(&direct_window_list_lock);
-
-		/*
-		 * Because the notifier runs after isolation of the
-		 * slot, we are guaranteed any DMA window has already
-		 * been revoked and the TCEs have been marked invalid,
-		 * so we don't need a call to remove_ddw(np). However,
-		 * if an additional notifier action is added before the
-		 * isolate call, we should update this code for
-		 * completeness with such a call.
-		 */
 		break;
 	default:
 		err = NOTIFY_DONE;
