All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Matthew Brost <matthew.brost@intel.com>,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: lucas.demarchi@intel.com, tvrtko.ursulin@intel.com
Subject: Re: [Intel-gfx] [PATCH] drm/i915: Drop stealing of bits from i915_sw_fence function pointer
Date: Wed, 22 Sep 2021 14:12:55 +0300	[thread overview]
Message-ID: <877df8n9s8.fsf@intel.com> (raw)
In-Reply-To: <20210922021305.33096-1-matthew.brost@intel.com>

On Tue, 21 Sep 2021, Matthew Brost <matthew.brost@intel.com> wrote:
> Rather than stealing bits from i915_sw_fence function pointer use
> seperate fields for function pointer and flags. If using two different
> fields, the 4 byte alignment for the i915_sw_fence function pointer can
> also be dropped.

Yes, please, thank you.

Acked-by: Jani Nikula <jani.nikula@intel.com>


BR,
Jani.

>
> Signed-off-by: Matthew Brost <matthew.brost@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_display.c  |  2 +-
>  drivers/gpu/drm/i915/gem/i915_gem_context.c   |  2 +-
>  drivers/gpu/drm/i915/i915_request.c           |  4 ++--
>  drivers/gpu/drm/i915/i915_sw_fence.c          |  9 +++-----
>  drivers/gpu/drm/i915/i915_sw_fence.h          | 21 +++++++++----------
>  drivers/gpu/drm/i915/i915_sw_fence_work.c     |  2 +-
>  .../gpu/drm/i915/selftests/i915_sw_fence.c    |  2 +-
>  drivers/gpu/drm/i915/selftests/lib_sw_fence.c |  4 ++--
>  8 files changed, 21 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index a7ca38613f89..6d5bb55ffc82 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -10323,7 +10323,7 @@ static void intel_atomic_commit_work(struct work_struct *work)
>  	intel_atomic_commit_tail(state);
>  }
>  
> -static int __i915_sw_fence_call
> +static int
>  intel_atomic_commit_ready(struct i915_sw_fence *fence,
>  			  enum i915_sw_fence_notify notify)
>  {
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> index c2ab0e22db0a..df5fec5c3da8 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> @@ -800,7 +800,7 @@ static void free_engines_rcu(struct rcu_head *rcu)
>  	free_engines(engines);
>  }
>  
> -static int __i915_sw_fence_call
> +static int
>  engines_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
>  {
>  	struct i915_gem_engines *engines =
> diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
> index ce446716d092..945d3025a0b6 100644
> --- a/drivers/gpu/drm/i915/i915_request.c
> +++ b/drivers/gpu/drm/i915/i915_request.c
> @@ -719,7 +719,7 @@ void i915_request_cancel(struct i915_request *rq, int error)
>  	intel_context_cancel_request(rq->context, rq);
>  }
>  
> -static int __i915_sw_fence_call
> +static int
>  submit_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
>  {
>  	struct i915_request *request =
> @@ -755,7 +755,7 @@ submit_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
>  	return NOTIFY_DONE;
>  }
>  
> -static int __i915_sw_fence_call
> +static int
>  semaphore_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
>  {
>  	struct i915_request *rq = container_of(fence, typeof(*rq), semaphore);
> diff --git a/drivers/gpu/drm/i915/i915_sw_fence.c b/drivers/gpu/drm/i915/i915_sw_fence.c
> index c589a681da77..5cf101cf06d2 100644
> --- a/drivers/gpu/drm/i915/i915_sw_fence.c
> +++ b/drivers/gpu/drm/i915/i915_sw_fence.c
> @@ -34,7 +34,7 @@ enum {
>  
>  static void *i915_sw_fence_debug_hint(void *addr)
>  {
> -	return (void *)(((struct i915_sw_fence *)addr)->flags & I915_SW_FENCE_MASK);
> +	return (void *)(((struct i915_sw_fence *)addr)->fn);
>  }
>  
>  #ifdef CONFIG_DRM_I915_SW_FENCE_DEBUG_OBJECTS
> @@ -126,10 +126,7 @@ static inline void debug_fence_assert(struct i915_sw_fence *fence)
>  static int __i915_sw_fence_notify(struct i915_sw_fence *fence,
>  				  enum i915_sw_fence_notify state)
>  {
> -	i915_sw_fence_notify_t fn;
> -
> -	fn = (i915_sw_fence_notify_t)(fence->flags & I915_SW_FENCE_MASK);
> -	return fn(fence, state);
> +	return fence->fn(fence, state);
>  }
>  
>  #ifdef CONFIG_DRM_I915_SW_FENCE_DEBUG_OBJECTS
> @@ -242,7 +239,7 @@ void __i915_sw_fence_init(struct i915_sw_fence *fence,
>  			  const char *name,
>  			  struct lock_class_key *key)
>  {
> -	BUG_ON(!fn || (unsigned long)fn & ~I915_SW_FENCE_MASK);
> +	BUG_ON(!fn);
>  
>  	__init_waitqueue_head(&fence->wait, name, key);
>  	fence->flags = (unsigned long)fn;
> diff --git a/drivers/gpu/drm/i915/i915_sw_fence.h b/drivers/gpu/drm/i915/i915_sw_fence.h
> index 30a863353ee6..70ba1789aa89 100644
> --- a/drivers/gpu/drm/i915/i915_sw_fence.h
> +++ b/drivers/gpu/drm/i915/i915_sw_fence.h
> @@ -17,26 +17,25 @@
>  
>  struct completion;
>  struct dma_resv;
> +struct i915_sw_fence;
> +
> +enum i915_sw_fence_notify {
> +	FENCE_COMPLETE,
> +	FENCE_FREE
> +};
> +
> +typedef int (*i915_sw_fence_notify_t)(struct i915_sw_fence *,
> +				      enum i915_sw_fence_notify state);
>  
>  struct i915_sw_fence {
>  	wait_queue_head_t wait;
> +	i915_sw_fence_notify_t fn;
>  	unsigned long flags;
>  	atomic_t pending;
>  	int error;
>  };
>  
>  #define I915_SW_FENCE_CHECKED_BIT	0 /* used internally for DAG checking */
> -#define I915_SW_FENCE_PRIVATE_BIT	1 /* available for use by owner */
> -#define I915_SW_FENCE_MASK		(~3)
> -
> -enum i915_sw_fence_notify {
> -	FENCE_COMPLETE,
> -	FENCE_FREE
> -};
> -
> -typedef int (*i915_sw_fence_notify_t)(struct i915_sw_fence *,
> -				      enum i915_sw_fence_notify state);
> -#define __i915_sw_fence_call __aligned(4)
>  
>  void __i915_sw_fence_init(struct i915_sw_fence *fence,
>  			  i915_sw_fence_notify_t fn,
> diff --git a/drivers/gpu/drm/i915/i915_sw_fence_work.c b/drivers/gpu/drm/i915/i915_sw_fence_work.c
> index 5b33ef23d54c..d2e56b387993 100644
> --- a/drivers/gpu/drm/i915/i915_sw_fence_work.c
> +++ b/drivers/gpu/drm/i915/i915_sw_fence_work.c
> @@ -23,7 +23,7 @@ static void fence_work(struct work_struct *work)
>  	dma_fence_put(&f->dma);
>  }
>  
> -static int __i915_sw_fence_call
> +static int
>  fence_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
>  {
>  	struct dma_fence_work *f = container_of(fence, typeof(*f), chain);
> diff --git a/drivers/gpu/drm/i915/selftests/i915_sw_fence.c b/drivers/gpu/drm/i915/selftests/i915_sw_fence.c
> index cbf45d85cbff..daa985e5a19b 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_sw_fence.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_sw_fence.c
> @@ -28,7 +28,7 @@
>  
>  #include "../i915_selftest.h"
>  
> -static int __i915_sw_fence_call
> +static int
>  fence_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
>  {
>  	switch (state) {
> diff --git a/drivers/gpu/drm/i915/selftests/lib_sw_fence.c b/drivers/gpu/drm/i915/selftests/lib_sw_fence.c
> index 080b90b63d16..eb59a41bdb79 100644
> --- a/drivers/gpu/drm/i915/selftests/lib_sw_fence.c
> +++ b/drivers/gpu/drm/i915/selftests/lib_sw_fence.c
> @@ -26,7 +26,7 @@
>  
>  /* Small library of different fence types useful for writing tests */
>  
> -static int __i915_sw_fence_call
> +static int
>  nop_fence_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
>  {
>  	return NOTIFY_DONE;
> @@ -89,7 +89,7 @@ struct heap_fence {
>  	};
>  };
>  
> -static int __i915_sw_fence_call
> +static int
>  heap_fence_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
>  {
>  	struct heap_fence *h = container_of(fence, typeof(*h), fence);

-- 
Jani Nikula, Intel Open Source Graphics Center

WARNING: multiple messages have this Message-ID (diff)
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Matthew Brost <matthew.brost@intel.com>,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: lucas.demarchi@intel.com, tvrtko.ursulin@intel.com
Subject: Re: [PATCH] drm/i915: Drop stealing of bits from i915_sw_fence function pointer
Date: Wed, 22 Sep 2021 14:12:55 +0300	[thread overview]
Message-ID: <877df8n9s8.fsf@intel.com> (raw)
In-Reply-To: <20210922021305.33096-1-matthew.brost@intel.com>

On Tue, 21 Sep 2021, Matthew Brost <matthew.brost@intel.com> wrote:
> Rather than stealing bits from i915_sw_fence function pointer use
> seperate fields for function pointer and flags. If using two different
> fields, the 4 byte alignment for the i915_sw_fence function pointer can
> also be dropped.

Yes, please, thank you.

Acked-by: Jani Nikula <jani.nikula@intel.com>


BR,
Jani.

>
> Signed-off-by: Matthew Brost <matthew.brost@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_display.c  |  2 +-
>  drivers/gpu/drm/i915/gem/i915_gem_context.c   |  2 +-
>  drivers/gpu/drm/i915/i915_request.c           |  4 ++--
>  drivers/gpu/drm/i915/i915_sw_fence.c          |  9 +++-----
>  drivers/gpu/drm/i915/i915_sw_fence.h          | 21 +++++++++----------
>  drivers/gpu/drm/i915/i915_sw_fence_work.c     |  2 +-
>  .../gpu/drm/i915/selftests/i915_sw_fence.c    |  2 +-
>  drivers/gpu/drm/i915/selftests/lib_sw_fence.c |  4 ++--
>  8 files changed, 21 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index a7ca38613f89..6d5bb55ffc82 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -10323,7 +10323,7 @@ static void intel_atomic_commit_work(struct work_struct *work)
>  	intel_atomic_commit_tail(state);
>  }
>  
> -static int __i915_sw_fence_call
> +static int
>  intel_atomic_commit_ready(struct i915_sw_fence *fence,
>  			  enum i915_sw_fence_notify notify)
>  {
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> index c2ab0e22db0a..df5fec5c3da8 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> @@ -800,7 +800,7 @@ static void free_engines_rcu(struct rcu_head *rcu)
>  	free_engines(engines);
>  }
>  
> -static int __i915_sw_fence_call
> +static int
>  engines_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
>  {
>  	struct i915_gem_engines *engines =
> diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
> index ce446716d092..945d3025a0b6 100644
> --- a/drivers/gpu/drm/i915/i915_request.c
> +++ b/drivers/gpu/drm/i915/i915_request.c
> @@ -719,7 +719,7 @@ void i915_request_cancel(struct i915_request *rq, int error)
>  	intel_context_cancel_request(rq->context, rq);
>  }
>  
> -static int __i915_sw_fence_call
> +static int
>  submit_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
>  {
>  	struct i915_request *request =
> @@ -755,7 +755,7 @@ submit_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
>  	return NOTIFY_DONE;
>  }
>  
> -static int __i915_sw_fence_call
> +static int
>  semaphore_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
>  {
>  	struct i915_request *rq = container_of(fence, typeof(*rq), semaphore);
> diff --git a/drivers/gpu/drm/i915/i915_sw_fence.c b/drivers/gpu/drm/i915/i915_sw_fence.c
> index c589a681da77..5cf101cf06d2 100644
> --- a/drivers/gpu/drm/i915/i915_sw_fence.c
> +++ b/drivers/gpu/drm/i915/i915_sw_fence.c
> @@ -34,7 +34,7 @@ enum {
>  
>  static void *i915_sw_fence_debug_hint(void *addr)
>  {
> -	return (void *)(((struct i915_sw_fence *)addr)->flags & I915_SW_FENCE_MASK);
> +	return (void *)(((struct i915_sw_fence *)addr)->fn);
>  }
>  
>  #ifdef CONFIG_DRM_I915_SW_FENCE_DEBUG_OBJECTS
> @@ -126,10 +126,7 @@ static inline void debug_fence_assert(struct i915_sw_fence *fence)
>  static int __i915_sw_fence_notify(struct i915_sw_fence *fence,
>  				  enum i915_sw_fence_notify state)
>  {
> -	i915_sw_fence_notify_t fn;
> -
> -	fn = (i915_sw_fence_notify_t)(fence->flags & I915_SW_FENCE_MASK);
> -	return fn(fence, state);
> +	return fence->fn(fence, state);
>  }
>  
>  #ifdef CONFIG_DRM_I915_SW_FENCE_DEBUG_OBJECTS
> @@ -242,7 +239,7 @@ void __i915_sw_fence_init(struct i915_sw_fence *fence,
>  			  const char *name,
>  			  struct lock_class_key *key)
>  {
> -	BUG_ON(!fn || (unsigned long)fn & ~I915_SW_FENCE_MASK);
> +	BUG_ON(!fn);
>  
>  	__init_waitqueue_head(&fence->wait, name, key);
>  	fence->flags = (unsigned long)fn;
> diff --git a/drivers/gpu/drm/i915/i915_sw_fence.h b/drivers/gpu/drm/i915/i915_sw_fence.h
> index 30a863353ee6..70ba1789aa89 100644
> --- a/drivers/gpu/drm/i915/i915_sw_fence.h
> +++ b/drivers/gpu/drm/i915/i915_sw_fence.h
> @@ -17,26 +17,25 @@
>  
>  struct completion;
>  struct dma_resv;
> +struct i915_sw_fence;
> +
> +enum i915_sw_fence_notify {
> +	FENCE_COMPLETE,
> +	FENCE_FREE
> +};
> +
> +typedef int (*i915_sw_fence_notify_t)(struct i915_sw_fence *,
> +				      enum i915_sw_fence_notify state);
>  
>  struct i915_sw_fence {
>  	wait_queue_head_t wait;
> +	i915_sw_fence_notify_t fn;
>  	unsigned long flags;
>  	atomic_t pending;
>  	int error;
>  };
>  
>  #define I915_SW_FENCE_CHECKED_BIT	0 /* used internally for DAG checking */
> -#define I915_SW_FENCE_PRIVATE_BIT	1 /* available for use by owner */
> -#define I915_SW_FENCE_MASK		(~3)
> -
> -enum i915_sw_fence_notify {
> -	FENCE_COMPLETE,
> -	FENCE_FREE
> -};
> -
> -typedef int (*i915_sw_fence_notify_t)(struct i915_sw_fence *,
> -				      enum i915_sw_fence_notify state);
> -#define __i915_sw_fence_call __aligned(4)
>  
>  void __i915_sw_fence_init(struct i915_sw_fence *fence,
>  			  i915_sw_fence_notify_t fn,
> diff --git a/drivers/gpu/drm/i915/i915_sw_fence_work.c b/drivers/gpu/drm/i915/i915_sw_fence_work.c
> index 5b33ef23d54c..d2e56b387993 100644
> --- a/drivers/gpu/drm/i915/i915_sw_fence_work.c
> +++ b/drivers/gpu/drm/i915/i915_sw_fence_work.c
> @@ -23,7 +23,7 @@ static void fence_work(struct work_struct *work)
>  	dma_fence_put(&f->dma);
>  }
>  
> -static int __i915_sw_fence_call
> +static int
>  fence_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
>  {
>  	struct dma_fence_work *f = container_of(fence, typeof(*f), chain);
> diff --git a/drivers/gpu/drm/i915/selftests/i915_sw_fence.c b/drivers/gpu/drm/i915/selftests/i915_sw_fence.c
> index cbf45d85cbff..daa985e5a19b 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_sw_fence.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_sw_fence.c
> @@ -28,7 +28,7 @@
>  
>  #include "../i915_selftest.h"
>  
> -static int __i915_sw_fence_call
> +static int
>  fence_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
>  {
>  	switch (state) {
> diff --git a/drivers/gpu/drm/i915/selftests/lib_sw_fence.c b/drivers/gpu/drm/i915/selftests/lib_sw_fence.c
> index 080b90b63d16..eb59a41bdb79 100644
> --- a/drivers/gpu/drm/i915/selftests/lib_sw_fence.c
> +++ b/drivers/gpu/drm/i915/selftests/lib_sw_fence.c
> @@ -26,7 +26,7 @@
>  
>  /* Small library of different fence types useful for writing tests */
>  
> -static int __i915_sw_fence_call
> +static int
>  nop_fence_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
>  {
>  	return NOTIFY_DONE;
> @@ -89,7 +89,7 @@ struct heap_fence {
>  	};
>  };
>  
> -static int __i915_sw_fence_call
> +static int
>  heap_fence_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
>  {
>  	struct heap_fence *h = container_of(fence, typeof(*h), fence);

-- 
Jani Nikula, Intel Open Source Graphics Center

  parent reply	other threads:[~2021-09-22 11:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-22  2:13 [Intel-gfx] [PATCH] drm/i915: Drop stealing of bits from i915_sw_fence function pointer Matthew Brost
2021-09-22  2:13 ` Matthew Brost
2021-09-22  2:43 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
2021-09-22  2:59 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2021-09-22 11:12 ` Jani Nikula [this message]
2021-09-22 11:12   ` [PATCH] " Jani Nikula
  -- strict thread matches above, loose matches on Subject: below --
2021-09-22 14:57 [Intel-gfx] " Matthew Brost
2021-09-22 15:21 ` Tvrtko Ursulin
2021-09-22 15:25   ` Tvrtko Ursulin
2021-09-22 15:40     ` Matthew Brost
2021-09-22 15:47 Matthew Brost
2021-11-11 20:18 ` Teres Alexis, Alan Previn
2021-11-11 20:18   ` Teres Alexis, Alan Previn
2021-11-16 19:49 Matthew Brost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877df8n9s8.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=tvrtko.ursulin@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.