Re: [PATCH kernel 5/6] powerpc/powernv: Rework TCE level allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 08, 2018 at 03:46:32PM +1000, Alexey Kardashevskiy wrote:
> This moves actual pages allocation to a separate function which is going
> to be reused later in on-demand TCE allocation.
> 
> While we are at it, remove unnecessary level size round up as the caller
> does this already.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@xxxxxxxxx>

Reviewed-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>

> ---
>  arch/powerpc/platforms/powernv/pci-ioda-tce.c | 30 +++++++++++++++++----------
>  1 file changed, 19 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda-tce.c b/arch/powerpc/platforms/powernv/pci-ioda-tce.c
> index f14b282..36c2eb0 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda-tce.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda-tce.c
> @@ -31,6 +31,23 @@ void pnv_pci_setup_iommu_table(struct iommu_table *tbl,
>  	tbl->it_type = TCE_PCI;
>  }
>  
> +static __be64 *pnv_alloc_tce_level(int nid, unsigned int shift)
> +{
> +	struct page *tce_mem = NULL;
> +	__be64 *addr;
> +
> +	tce_mem = alloc_pages_node(nid, GFP_KERNEL, shift - PAGE_SHIFT);
> +	if (!tce_mem) {
> +		pr_err("Failed to allocate a TCE memory, level shift=%d\n",
> +				shift);
> +		return NULL;
> +	}
> +	addr = page_address(tce_mem);
> +	memset(addr, 0, 1UL << shift);
> +
> +	return addr;
> +}
> +
>  static __be64 *pnv_tce(struct iommu_table *tbl, bool user, long idx)
>  {
>  	__be64 *tmp = user ? tbl->it_userspace : (__be64 *) tbl->it_base;
> @@ -165,21 +182,12 @@ static __be64 *pnv_pci_ioda2_table_do_alloc_pages(int nid, unsigned int shift,
>  		unsigned int levels, unsigned long limit,
>  		unsigned long *current_offset, unsigned long *total_allocated)
>  {
> -	struct page *tce_mem = NULL;
>  	__be64 *addr, *tmp;
> -	unsigned int order = max_t(unsigned int, shift, PAGE_SHIFT) -
> -			PAGE_SHIFT;
> -	unsigned long allocated = 1UL << (order + PAGE_SHIFT);
> +	unsigned long allocated = 1UL << shift;
>  	unsigned int entries = 1UL << (shift - 3);
>  	long i;
>  
> -	tce_mem = alloc_pages_node(nid, GFP_KERNEL, order);
> -	if (!tce_mem) {
> -		pr_err("Failed to allocate a TCE memory, order=%d\n", order);
> -		return NULL;
> -	}
> -	addr = page_address(tce_mem);
> -	memset(addr, 0, allocated);
> +	addr = pnv_alloc_tce_level(nid, shift);
>  	*total_allocated += allocated;
>  
>  	--levels;

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux