Subject: Re: [rfc] powerpc/npu: Cleanup MMIO ATSD flushing

From: "Aneesh Kumar K.V" <[email-masked]>
Date: Mon, 30 Oct 2017 21:33:46 +0530

On 10/30/2017 06:08 PM, Balbir Singh wrote:
> +
> +static void pnv_npu2_invalidate_helper(struct npu_context *npu_context,
> +		struct mm_struct *mm, unsigned long start,
> +		unsigned long end, bool flush)
> +{
> +	unsigned long address;
> +	bool is_thp;
> +	unsigned int hshift, shift;
> +
> +	address = start;
> +	do {
> +		local_irq_disable();
> +		find_linux_pte(mm->pgd, address, &is_thp, &hshift);
> +		if (!is_thp)
> +			shift = PAGE_SHIFT;
> +		else
> +			shift = hshift;

Is that correct? if is_thp is 0 can we derive shift from hshift? IIUC we 
set hshift only
if it is a hugepage.

> +		mmio_invalidate(npu_context, address > 0, address, flush,
> +				shift);
> +		local_irq_enable();
> +		address += (1ull << shift);
> +	} while (address < end);
>   }
>   
>

-aneesh