Re: [Intel-gfx] [igt-dev] [PATCH i-g-t 1/7] lib/i915/gem_mman: add FIXED mmap mode

Dixit, Ashutosh
2021-07-28T02:08:17Z

On Mon, 26 Jul 2021 05:03:04 -0700, Matthew Auld wrote:
>
> diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
> index 4b4f2114..e2514f0c 100644
> --- a/lib/i915/gem_mman.c
> +++ b/lib/i915/gem_mman.c
> @@ -497,6 +497,43 @@ void *gem_mmap_offset__cpu(int fd, uint32_t handle, uint64_t offset,
> return ptr;
> }
>
> +#define LOCAL_I915_MMAP_OFFSET_FIXED 4

Cc: @Petri Latvala

This use of LOCAL declarations is more related to the methodology we follow
in IGT rather than this patch. We have seen in the past that such LOCAL's
linger on in the code for months and years till someone decides to clean
them so the question is can we prevent these LOCAL's from getting
introduced in the first place.

One reason for these is that we sync IGT headers with drm-next whereas IGT
is used to test drm-tip. So the delta between the two results in such
LOCAL's as in this case.

My proposal is that even if we don't start sync'ing IGT headers with
drm-tip (instead of drm-next) we allow direct modification of the headers
when needed to avoid introducing such LOCAL's. So in the above case we
would add:

#define I915_MMAP_OFFSET_FIXED 4

to i915_drm.h as part of this patch and then just use
I915_MMAP_OFFSET_FIXED. If another sync happens from drm-next before this
#define has appeared there, the compile will break and whoever syncs will
need to add this again to i915_drm.h.

What do people think about a scheme such as this? The other, perhaps
better, option of course is to sync the headers directly with drm-tip
(whenever and as often as needed). But the goal in both cases is to avoid
LOCAL's, or other things like #ifndef's distributed throughout multiple
source files which we also do in such cases. A centralized internal header
to contain such declarations might not be so bad. Thanks.