Re: [PATCH i-g-t 8/8] tests: Use BIT macro instead of (1<<x)

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

 



On Wed, Feb 08, 2017 at 06:18:28PM -0800, Michel Thierry wrote:
> Mostly done with coccinelle,
> @@
> expression x;
> @@
> (
> - (1<<x)
> + BIT(x)
> |
> - (1 << x)
> + BIT(x)
> |
> - 1 << x
> + BIT(x)
> |
> - (1UL<<x)
> + BIT(x)
> |
> - (1UL << x)
> + BIT(x)
> |
> - 1UL << x
> + BIT(x)
> |
> - (1ULL<<x)
> + BIT_ULL(x)
> |
> - (1ULL << x)
> + BIT_ULL(x)
> |
> - 1ULL << x
> + BIT_ULL(x)
> )
> 
> Signed-off-by: Michel Thierry <michel.thierry@xxxxxxxxx>
> ---
>  tests/drm_vma_limiter_cached.c      |  2 +-
>  tests/drv_missed_irq.c              |  4 +-
>  tests/drv_module_reload.c           |  4 +-
>  tests/eviction_common.c             |  8 ++--
>  tests/gem_bad_address.c             |  2 +-
>  tests/gem_bad_reloc.c               |  6 +--
>  tests/gem_busy.c                    | 24 ++++++------
>  tests/gem_close_race.c              |  8 ++--
>  tests/gem_concurrent_all.c          |  2 +-
>  tests/gem_cpu_reloc.c               |  4 +-
>  tests/gem_create.c                  |  2 +-
>  tests/gem_cs_prefetch.c             |  2 +-
>  tests/gem_cs_tlb.c                  |  2 +-
>  tests/gem_ctx_switch.c              |  4 +-
>  tests/gem_ctx_thrash.c              |  2 +-
>  tests/gem_double_irq_loop.c         |  4 +-
>  tests/gem_exec_alignment.c          |  6 +--
>  tests/gem_exec_async.c              |  8 ++--
>  tests/gem_exec_blt.c                | 20 +++++-----
>  tests/gem_exec_create.c             |  4 +-
>  tests/gem_exec_faulting_reloc.c     | 14 +++----
>  tests/gem_exec_fence.c              | 14 +++----
>  tests/gem_exec_flush.c              | 10 ++---
>  tests/gem_exec_gttfill.c            |  4 +-
>  tests/gem_exec_latency.c            |  8 ++--
>  tests/gem_exec_lut_handle.c         |  4 +-
>  tests/gem_exec_nop.c                |  4 +-
>  tests/gem_exec_parallel.c           |  6 +--
>  tests/gem_exec_params.c             |  8 ++--
>  tests/gem_exec_parse.c              |  4 +-
>  tests/gem_exec_reloc.c              |  8 ++--
>  tests/gem_exec_reuse.c              |  4 +-
>  tests/gem_exec_schedule.c           |  6 +--
>  tests/gem_exec_store.c              |  4 +-
>  tests/gem_exec_suspend.c            |  6 +--
>  tests/gem_exec_whisper.c            | 10 ++---
>  tests/gem_fence_upload.c            |  4 +-
>  tests/gem_fenced_exec_thrash.c      |  4 +-
>  tests/gem_gtt_hog.c                 |  4 +-
>  tests/gem_lut_handle.c              |  2 +-
>  tests/gem_persistent_relocs.c       | 10 ++---
>  tests/gem_pin.c                     |  6 +--
>  tests/gem_pipe_control_store_loop.c | 18 ++++-----
>  tests/gem_pwrite.c                  |  8 ++--
>  tests/gem_pwrite_pread.c            | 12 +++---
>  tests/gem_reloc_vs_gpu.c            | 12 +++---
>  tests/gem_reset_stats.c             |  6 +--
>  tests/gem_ringfill.c                |  6 +--
>  tests/gem_shrink.c                  |  4 +-
>  tests/gem_softpin.c                 | 12 +++---
>  tests/gem_storedw_batches_loop.c    |  2 +-
>  tests/gem_streaming_writes.c        | 10 ++---
>  tests/gem_stress.c                  |  8 ++--
>  tests/gem_sync.c                    | 10 ++---
>  tests/gem_tiled_pread_basic.c       |  2 +-
>  tests/gem_tiled_wb.c                |  2 +-
>  tests/gem_tiled_wc.c                |  2 +-
>  tests/gem_write_read_ring_switch.c  |  4 +-
>  tests/gen3_mixed_blits.c            |  6 +--
>  tests/gen3_render_linear_blits.c    |  6 +--
>  tests/gen3_render_mixed_blits.c     |  6 +--
>  tests/gen3_render_tiledx_blits.c    |  6 +--
>  tests/gen3_render_tiledy_blits.c    |  6 +--
>  tests/gen7_forcewake_mt.c           |  2 +-
>  tests/kms_atomic.c                  |  6 +--
>  tests/kms_atomic_transition.c       | 20 +++++-----
>  tests/kms_ccs.c                     |  8 ++--
>  tests/kms_cursor_crc.c              |  4 +-
>  tests/kms_cursor_legacy.c           |  4 +-
>  tests/kms_fbc_crc.c                 |  2 +-
>  tests/kms_flip.c                    | 74 ++++++++++++++++++-------------------
>  tests/kms_frontbuffer_tracking.c    | 26 ++++++-------
>  tests/kms_pipe_color.c              |  6 +--
>  tests/kms_pipe_crc_basic.c          |  4 +-
>  tests/kms_plane.c                   | 10 ++---
>  tests/kms_psr_sink_crc.c            |  2 +-
>  tests/kms_render.c                  |  2 +-
>  tests/kms_setmode.c                 | 11 +++---
>  tests/perf.c                        | 52 +++++++++++++-------------
>  tests/pm_rpm.c                      |  8 ++--
>  tests/pm_rps.c                      |  4 +-
>  tests/pm_sseu.c                     |  4 +-
>  tests/prime_busy.c                  |  6 +--
>  tests/prime_nv_pcopy.c              |  4 +-
>  tests/prime_vgem.c                  |  8 ++--
>  tests/sw_sync.c                     |  8 ++--
>  tests/testdisplay.c                 |  2 +-
>  tests/vgem_basic.c                  |  8 ++--
>  88 files changed, 347 insertions(+), 348 deletions(-)
> 
> diff --git a/tests/drm_vma_limiter_cached.c b/tests/drm_vma_limiter_cached.c
> index a47c7970..d248217c 100644
> --- a/tests/drm_vma_limiter_cached.c
> +++ b/tests/drm_vma_limiter_cached.c
> @@ -110,7 +110,7 @@ igt_simple_main
>  			OUT_BATCH((3 << 24) | /* 32 bits */
>  				  128);
>  			OUT_BATCH(0); /* dst x1,y1 */
> -			OUT_BATCH((1 << 16) | 1);
> +			OUT_BATCH(BIT(16) | 1);

Not this one, this is y << Y_SHIFT.

> diff --git a/tests/gem_bad_reloc.c b/tests/gem_bad_reloc.c
> index 2351ce91..a3b07bb7 100644
> --- a/tests/gem_bad_reloc.c
> +++ b/tests/gem_bad_reloc.c
> @@ -42,7 +42,7 @@
>  IGT_TEST_DESCRIPTION("Simulates SNA behaviour using negative self-relocations"
>  		     " for STATE_BASE_ADDRESS command packets.");
>  
> -#define USE_LUT (1 << 12)
> +#define USE_LUT BIT(12)
>  #define BIAS (256*1024)
>  
>  /* Simulates SNA behaviour using negative self-relocations for
> @@ -137,8 +137,8 @@ static void negative_reloc_blt(int fd)
>  		*b++ = XY_COLOR_BLT_CMD_NOLEN |
>  			((gen >= 8) ? 5 : 4) |
>  			COLOR_BLT_WRITE_ALPHA | XY_COLOR_BLT_WRITE_RGB;
> -		*b++ = 0xf0 << 16 | 1 << 25 | 1 << 24 | 4096;
> -		*b++ = 1 << 16 | 0;
> +		*b++ = 0xf0 << 16 | BIT(25) | BIT(24) | 4096;

Ok.

> +		*b++ = BIT(16) | 0;

Keep as a shift (y << Y_SHIFT).

>  		*b++ = 2 << 16 | 1024;
>  		*b++ = ~0;
>  		if (gen >= 8)

> diff --git a/tests/gem_close_race.c b/tests/gem_close_race.c
> index 05e95547..1ef94d61 100644
> --- a/tests/gem_close_race.c
> +++ b/tests/gem_close_race.c
> @@ -45,8 +45,8 @@
>  #define OBJECT_SIZE (256 * 1024)
>  
>  #define COPY_BLT_CMD		(2<<29|0x53<<22|0x6)
> -#define BLT_WRITE_ALPHA		(1<<21)
> -#define BLT_WRITE_RGB		(1<<20)
> +#define BLT_WRITE_ALPHA		BIT(21)
> +#define BLT_WRITE_RGB		BIT(20)
>  
>  static uint32_t devid;
>  static bool has_64bit_relocations;
> @@ -69,9 +69,9 @@ static void selfcopy(int fd, uint32_t handle, int loops)
>  	if (has_64bit_relocations)
>  		*b += 2;
>  	b++;
> -	*b++ = 0xcc << 16 | 1 << 25 | 1 << 24 | (4*1024);
> +	*b++ = 0xcc << 16 | BIT(25) | BIT(24) | (4*1024);

Ok.

>  	*b++ = 0;
> -	*b++ = 1 << 16 | 1024;
> +	*b++ = BIT(16) | 1024;

Keep the shift.

>  
>  	reloc[0].offset = (b - buf) * sizeof(*b);
>  	reloc[0].target_handle = handle;

> diff --git a/tests/gem_cpu_reloc.c b/tests/gem_cpu_reloc.c
> index 4e4458d2..e73fd417 100644
> --- a/tests/gem_cpu_reloc.c
> +++ b/tests/gem_cpu_reloc.c
> @@ -125,7 +125,7 @@ uint32_t gen6_batch[] = {
>  	 0xcc << 16 | /* copy ROP */
>  	 4096),
>  	0 << 16 | 0, /* dst x1, y1 */
> -	1 << 16 | 2,
> +	BIT(16) | 2,

Keep.

>  	0, /* dst relocation */
>  	0 << 16 | 0, /* src x1, y1 */
>  	4096,
> @@ -141,7 +141,7 @@ uint32_t gen8_batch[] = {
>  	 0xcc << 16 | /* copy ROP */
>  	 4096),
>  	0 << 16 | 0, /* dst x1, y1 */
> -	1 << 16 | 2,
> +	BIT(16) | 2,

Keep.

>  	0, /* dst relocation */
>  	0, /* FIXME */
>  	0 << 16 | 0, /* src x1, y1 */

Those were the only ones that I spotted that I wanted to keep.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux