Re: [PATCH v2 6/9] vfio-ccw: Adjust the first IDAW outside of the nested loops

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

 



On Thu,  6 Jun 2019 22:28:28 +0200
Eric Farman <farman@xxxxxxxxxxxxx> wrote:

> Now that pfn_array_table[] is always an array of 1, it seems silly to
> check for the very first entry in an array in the middle of two nested
> loops, since we know it'll only ever happen once.
> 
> Let's move this outside the loops to simplify things, even though
> the "k" variable is still necessary.
> 
> Signed-off-by: Eric Farman <farman@xxxxxxxxxxxxx>
> ---
>  drivers/s390/cio/vfio_ccw_cp.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/s390/cio/vfio_ccw_cp.c b/drivers/s390/cio/vfio_ccw_cp.c
> index 86a0e76ef2b5..ab9f8f0d1b44 100644
> --- a/drivers/s390/cio/vfio_ccw_cp.c
> +++ b/drivers/s390/cio/vfio_ccw_cp.c
> @@ -201,11 +201,12 @@ static inline void pfn_array_table_idal_create_words(
>  		pa = pat->pat_pa + i;
>  		for (j = 0; j < pa->pa_nr; j++) {
>  			idaws[k] = pa->pa_pfn[j] << PAGE_SHIFT;
> -			if (k == 0)
> -				idaws[k] += pa->pa_iova & (PAGE_SIZE - 1);
>  			k++;
>  		}
>  	}
> +
> +	/* Adjust the first IDAW, since it may not start on a page boundary */
> +	idaws[0] += pat->pat_pa->pa_iova & (PAGE_SIZE - 1);
>  }
>  
>  

Also +1 to adding a nice explaining comment :)

Reviewed-by: Cornelia Huck <cohuck@xxxxxxxxxx>



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux