[igt-dev] [PATCH i-g-t] i915/gem_tiled_w[bc]: Tighten computation of upper bound

Antonio Argenziano antonio.argenziano at intel.com
Thu Mar 14 21:24:32 UTC 2019



On 14/03/19 10:49, Chris Wilson wrote:
> Fix the off-by-one in computing the last page that caused us to try and
> mmap the page beyond the end of the object.

Ah, that explains the failures.

Reviewed-by: Antonio Argenziano <antonio.argenziano at intel.com>

> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>   tests/i915/gem_tiled_wb.c | 4 ++--
>   tests/i915/gem_tiled_wc.c | 4 ++--
>   2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/i915/gem_tiled_wb.c b/tests/i915/gem_tiled_wb.c
> index 67d54bd30..827c2d9d6 100644
> --- a/tests/i915/gem_tiled_wb.c
> +++ b/tests/i915/gem_tiled_wb.c
> @@ -174,8 +174,8 @@ igt_simple_main
>   			len = size;
>   		}
>   
> -		first_page = offset & ~(PAGE_SIZE-1);
> -		last_page = (offset + len + PAGE_SIZE) & ~(PAGE_SIZE-1);
> +		first_page = offset & -PAGE_SIZE;
> +		last_page = (offset + len + PAGE_SIZE - 1) & -PAGE_SIZE;
>   		offset -= first_page;
>   
>   		linear = gem_mmap__cpu(fd, handle, first_page, last_page - first_page, PROT_READ);
> diff --git a/tests/i915/gem_tiled_wc.c b/tests/i915/gem_tiled_wc.c
> index 21390729d..67ebbc940 100644
> --- a/tests/i915/gem_tiled_wc.c
> +++ b/tests/i915/gem_tiled_wc.c
> @@ -149,8 +149,8 @@ igt_simple_main
>   			len = size;
>   		}
>   
> -		first_page = offset & ~(PAGE_SIZE-1);
> -		last_page = (offset + len + PAGE_SIZE) & ~(PAGE_SIZE-1);
> +		first_page = offset & -PAGE_SIZE;
> +		last_page = (offset + len + PAGE_SIZE - 1) & -PAGE_SIZE;
>   
>   		linear = gem_mmap__wc(fd, handle, first_page, last_page - first_page, PROT_READ);
>   
> 


More information about the igt-dev mailing list