diff mbox

[v1,13/16] powerpc/iommu: Implement put_page() if TCE had non-zero value

Message ID 1405416280-12318-14-git-send-email-aik@ozlabs.ru (mailing list archive)
State Not Applicable
Headers show

Commit Message

Alexey Kardashevskiy July 15, 2014, 9:24 a.m. UTC
Guests might put new TCEs without clearing them first and the PAPR spec
allows that.

This adds put_page() for TCEs which we just replaced.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 arch/powerpc/kernel/iommu.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Alexey Kardashevskiy July 17, 2014, 2:56 a.m. UTC | #1
On 07/15/2014 07:24 PM, Alexey Kardashevskiy wrote:
> Guests might put new TCEs without clearing them first and the PAPR spec
> allows that.
> 
> This adds put_page() for TCEs which we just replaced.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>  arch/powerpc/kernel/iommu.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
> index ae57910..25fda58 100644
> --- a/arch/powerpc/kernel/iommu.c
> +++ b/arch/powerpc/kernel/iommu.c
> @@ -1054,11 +1054,11 @@ int iommu_tce_build(struct iommu_table *tbl, unsigned long entry,
>  
>  	spin_lock(&(pool->lock));
>  
> -	oldtce = ppc_md.tce_get(tbl, entry);
> -	/* Add new entry if it is not busy */
> -	if (!(oldtce & (TCE_PCI_WRITE | TCE_PCI_READ)))
> -		ret = ppc_md.tce_build(tbl, entry, 1, hwaddr, NULL,
> -				direction, NULL);
> +	ret = ppc_md.tce_build(tbl, entry, 1, hwaddr, &oldtce,
> +			direction, NULL);
> +
> +	if (oldtce & (TCE_PCI_WRITE | TCE_PCI_READ))
> +		put_page(pfn_to_page(__pa(oldtce)));


rshift for PAGE_SHIFT is missing here.


>  
>  	spin_unlock(&(pool->lock));
>  
>
diff mbox

Patch

diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index ae57910..25fda58 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -1054,11 +1054,11 @@  int iommu_tce_build(struct iommu_table *tbl, unsigned long entry,
 
 	spin_lock(&(pool->lock));
 
-	oldtce = ppc_md.tce_get(tbl, entry);
-	/* Add new entry if it is not busy */
-	if (!(oldtce & (TCE_PCI_WRITE | TCE_PCI_READ)))
-		ret = ppc_md.tce_build(tbl, entry, 1, hwaddr, NULL,
-				direction, NULL);
+	ret = ppc_md.tce_build(tbl, entry, 1, hwaddr, &oldtce,
+			direction, NULL);
+
+	if (oldtce & (TCE_PCI_WRITE | TCE_PCI_READ))
+		put_page(pfn_to_page(__pa(oldtce)));
 
 	spin_unlock(&(pool->lock));