Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Gustavo Sousa <gustavo.sousa@intel.com>
To: "Cavitt, Jonathan" <jonathan.cavitt@intel.com>,
	"intel-gfx@lists.freedesktop.org"
	<intel-gfx@lists.freedesktop.org>,
	"intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>
Cc: "Ville Syrjälä" <ville.syrjala@linux.intel.com>,
	"Nikula, Jani" <jani.nikula@intel.com>,
	"Cavitt, Jonathan" <jonathan.cavitt@intel.com>
Subject: RE: [PATCH 3/3] drm/i915/display: Use INTEL_GLOBAL_STATE_DEFAULTS
Date: Fri, 20 Dec 2024 11:08:36 -0300	[thread overview]
Message-ID: <173470371682.2440.15548786677900604945@intel.com> (raw)
In-Reply-To: <CH0PR11MB54444299B8C0FBB73897F3F3E5062@CH0PR11MB5444.namprd11.prod.outlook.com>

Quoting Cavitt, Jonathan (2024-12-19 19:45:15-03:00)
>-----Original Message-----
>From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Gustavo Sousa
>Sent: Thursday, December 19, 2024 1:49 PM
>To: intel-gfx@lists.freedesktop.org; intel-xe@lists.freedesktop.org
>Cc: Ville Syrj�l� <ville.syrjala@linux.intel.com>; Nikula, Jani <jani.nikula@intel.com>
>Subject: [PATCH 3/3] drm/i915/display: Use INTEL_GLOBAL_STATE_DEFAULTS
>> 
>> Reduce global state boilerplate by using INTEL_GLOBAL_STATE_DEFAULTS().
>> The only case that requires customization is for the duplication of
>> CDCLK state, which is resolved by wrapping the generic implementation.
>> 
>> Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
>
>LGTM, though I am a bit curious under what circumstances we expect
>obj->funcs->atomic_destroy_state to return a valid function pointer
>with these changes?  I'm guessing we aren't depreciating/erasing that
>function pointer because we might need it in the future?

I did keep the atomic_destroy_state for completeness (to complement the
"duplicate state" one). It might be that we end up not really needing
any customization for that part for any of the global state instances
that we have or will have. We could revisit this then...

>Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel>

Thanks for the reviews, Jonathan!

--
Gustavo Sousa

>-Jonathan Cavitt
>
>> ---
>>  drivers/gpu/drm/i915/display/intel_bw.c       | 21 +------------------
>>  drivers/gpu/drm/i915/display/intel_cdclk.c    | 18 +++++++---------
>>  drivers/gpu/drm/i915/display/intel_pmdemand.c | 21 +------------------
>>  drivers/gpu/drm/i915/display/skl_watermark.c  | 20 +-----------------
>>  4 files changed, 10 insertions(+), 70 deletions(-)
>> 
>> diff --git a/drivers/gpu/drm/i915/display/intel_bw.c b/drivers/gpu/drm/i915/display/intel_bw.c
>> index 30236010e0ed..f040dfa70fd9 100644
>> --- a/drivers/gpu/drm/i915/display/intel_bw.c
>> +++ b/drivers/gpu/drm/i915/display/intel_bw.c
>> @@ -1422,27 +1422,8 @@ int intel_bw_atomic_check(struct intel_atomic_state *state)
>>          return 0;
>>  }
>>  
>> -static struct intel_global_state *
>> -intel_bw_duplicate_state(struct intel_global_obj *obj)
>> -{
>> -        struct intel_bw_state *state = to_intel_bw_state(obj->state);
>> -
>> -        state = kmemdup(state, sizeof(*state), GFP_KERNEL);
>> -        if (!state)
>> -                return NULL;
>> -
>> -        return &state->base;
>> -}
>> -
>> -static void intel_bw_destroy_state(struct intel_global_obj *obj,
>> -                                   struct intel_global_state *state)
>> -{
>> -        kfree(state);
>> -}
>> -
>>  static const struct intel_global_state_funcs intel_bw_funcs = {
>> -        .atomic_duplicate_state = intel_bw_duplicate_state,
>> -        .atomic_destroy_state = intel_bw_destroy_state,
>> +        INTEL_GLOBAL_STATE_DEFAULTS(struct intel_bw_state, base),
>>  };
>>  
>>  int intel_bw_init(struct drm_i915_private *i915)
>> diff --git a/drivers/gpu/drm/i915/display/intel_cdclk.c b/drivers/gpu/drm/i915/display/intel_cdclk.c
>> index fc084e2a4c6a..a9dfbd53e812 100644
>> --- a/drivers/gpu/drm/i915/display/intel_cdclk.c
>> +++ b/drivers/gpu/drm/i915/display/intel_cdclk.c
>> @@ -3130,27 +3130,23 @@ static int fixed_modeset_calc_cdclk(struct intel_atomic_state *state)
>>  
>>  static struct intel_global_state *intel_cdclk_duplicate_state(struct intel_global_obj *obj)
>>  {
>> -        struct intel_cdclk_state *cdclk_state = to_intel_cdclk_state(obj->state);
>> +        struct intel_global_state *obj_state;
>> +        struct intel_cdclk_state *cdclk_state;
>>  
>> -        cdclk_state = kmemdup(cdclk_state, sizeof(*cdclk_state), GFP_KERNEL);
>> -        if (!cdclk_state)
>> +        obj_state = intel_atomic_global_duplicate_state_common(obj);
>> +        if (!obj_state)
>>                  return NULL;
>>  
>> +        cdclk_state = to_intel_cdclk_state(obj_state);
>>          cdclk_state->pipe = INVALID_PIPE;
>>          cdclk_state->disable_pipes = false;
>>  
>> -        return &cdclk_state->base;
>> -}
>> -
>> -static void intel_cdclk_destroy_state(struct intel_global_obj *obj,
>> -                                      struct intel_global_state *state)
>> -{
>> -        kfree(state);
>> +        return obj_state;
>>  }
>>  
>>  static const struct intel_global_state_funcs intel_cdclk_funcs = {
>> +        INTEL_GLOBAL_STATE_DEFAULTS(struct intel_cdclk_state, base),
>>          .atomic_duplicate_state = intel_cdclk_duplicate_state,
>> -        .atomic_destroy_state = intel_cdclk_destroy_state,
>>  };
>>  
>>  struct intel_cdclk_state *
>> diff --git a/drivers/gpu/drm/i915/display/intel_pmdemand.c b/drivers/gpu/drm/i915/display/intel_pmdemand.c
>> index 1f71efb7d04d..5bf245a9ac8d 100644
>> --- a/drivers/gpu/drm/i915/display/intel_pmdemand.c
>> +++ b/drivers/gpu/drm/i915/display/intel_pmdemand.c
>> @@ -15,27 +15,8 @@
>>  #include "intel_pmdemand.h"
>>  #include "skl_watermark.h"
>>  
>> -static struct intel_global_state *
>> -intel_pmdemand_duplicate_state(struct intel_global_obj *obj)
>> -{
>> -        struct intel_pmdemand_state *pmdemand_state = to_intel_pmdemand_state(obj->state);
>> -
>> -        pmdemand_state = kmemdup(pmdemand_state, sizeof(*pmdemand_state), GFP_KERNEL);
>> -        if (!pmdemand_state)
>> -                return NULL;
>> -
>> -        return &pmdemand_state->base;
>> -}
>> -
>> -static void intel_pmdemand_destroy_state(struct intel_global_obj *obj,
>> -                                         struct intel_global_state *state)
>> -{
>> -        kfree(state);
>> -}
>> -
>>  static const struct intel_global_state_funcs intel_pmdemand_funcs = {
>> -        .atomic_duplicate_state = intel_pmdemand_duplicate_state,
>> -        .atomic_destroy_state = intel_pmdemand_destroy_state,
>> +        INTEL_GLOBAL_STATE_DEFAULTS(struct intel_pmdemand_state, base),
>>  };
>>  
>>  static struct intel_pmdemand_state *
>> diff --git a/drivers/gpu/drm/i915/display/skl_watermark.c b/drivers/gpu/drm/i915/display/skl_watermark.c
>> index b3d38e09df5a..8aa041be8277 100644
>> --- a/drivers/gpu/drm/i915/display/skl_watermark.c
>> +++ b/drivers/gpu/drm/i915/display/skl_watermark.c
>> @@ -3289,26 +3289,8 @@ static void skl_setup_wm_latency(struct drm_i915_private *i915)
>>          intel_print_wm_latency(i915, "Gen9 Plane", display->wm.skl_latency);
>>  }
>>  
>> -static struct intel_global_state *intel_dbuf_duplicate_state(struct intel_global_obj *obj)
>> -{
>> -        struct intel_dbuf_state *dbuf_state = to_intel_dbuf_state(obj->state);
>> -
>> -        dbuf_state = kmemdup(dbuf_state, sizeof(*dbuf_state), GFP_KERNEL);
>> -        if (!dbuf_state)
>> -                return NULL;
>> -
>> -        return &dbuf_state->base;
>> -}
>> -
>> -static void intel_dbuf_destroy_state(struct intel_global_obj *obj,
>> -                                     struct intel_global_state *state)
>> -{
>> -        kfree(state);
>> -}
>> -
>>  static const struct intel_global_state_funcs intel_dbuf_funcs = {
>> -        .atomic_duplicate_state = intel_dbuf_duplicate_state,
>> -        .atomic_destroy_state = intel_dbuf_destroy_state,
>> +        INTEL_GLOBAL_STATE_DEFAULTS(struct intel_dbuf_state, base),
>>  };
>>  
>>  struct intel_dbuf_state *
>> -- 
>> 2.47.1
>> 
>>

  reply	other threads:[~2024-12-20 14:08 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-19 21:48 [PATCH 0/3] drm/i915/display: Reduce global state funcs boilerplate Gustavo Sousa
2024-12-19 21:48 ` [PATCH 1/3] drm/i915/display: Do not assume zero offset when duplicating global state Gustavo Sousa
2024-12-19 22:43   ` Cavitt, Jonathan
2024-12-20  9:11   ` Ville Syrjälä
2024-12-20 13:37     ` Gustavo Sousa
2024-12-19 21:48 ` [PATCH 2/3] drm/i915/display: Add infra to reduce global state funcs boilerplate Gustavo Sousa
2024-12-19 22:44   ` Cavitt, Jonathan
2024-12-20 13:43     ` Gustavo Sousa
2024-12-20  8:50   ` Jani Nikula
2024-12-20 13:54     ` Gustavo Sousa
2024-12-20  8:51   ` Jani Nikula
2024-12-20 13:56     ` Gustavo Sousa
2024-12-20  9:23   ` Ville Syrjälä
2024-12-20 14:02     ` Gustavo Sousa
2024-12-19 21:48 ` [PATCH 3/3] drm/i915/display: Use INTEL_GLOBAL_STATE_DEFAULTS Gustavo Sousa
2024-12-19 22:45   ` Cavitt, Jonathan
2024-12-20 14:08     ` Gustavo Sousa [this message]
2024-12-19 22:51 ` ✓ CI.Patch_applied: success for drm/i915/display: Reduce global state funcs boilerplate Patchwork
2024-12-19 22:51 ` ✗ CI.checkpatch: warning " Patchwork
2024-12-19 22:53 ` ✓ CI.KUnit: success " Patchwork
2024-12-19 23:13 ` ✓ CI.Build: " Patchwork
2024-12-19 23:15 ` ✓ CI.Hooks: " Patchwork
2024-12-19 23:17 ` ✗ CI.checksparse: warning " Patchwork
2024-12-19 23:52 ` ✓ Xe.CI.BAT: success " Patchwork
2024-12-20 22:48 ` ✗ Xe.CI.Full: failure " Patchwork

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=173470371682.2440.15548786677900604945@intel.com \
    --to=gustavo.sousa@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jani.nikula@intel.com \
    --cc=jonathan.cavitt@intel.com \
    --cc=ville.syrjala@linux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox