From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Jani Nikula <jani.nikula@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH v3 5/6] drm/i915/audio: clean up LPE audio init/cleanup calls
Date: Fri, 5 Nov 2021 12:21:14 +0200 [thread overview]
Message-ID: <YYUFmkGqEIDpkH8N@intel.com> (raw)
In-Reply-To: <20211104161858.21786-5-jani.nikula@intel.com>
On Thu, Nov 04, 2021 at 06:18:57PM +0200, Jani Nikula wrote:
> Unify audio init/cleanup paths wrt LPE audio, and base the logic on the
> return values from LPE audio calls. Move the platform device check on
> cleanup to intel_lpe_audio.c, thereby limiting all audio.lpe substruct
> access to that file.
>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
> drivers/gpu/drm/i915/display/intel_audio.c | 14 ++++++++------
> drivers/gpu/drm/i915/display/intel_lpe_audio.c | 6 ++++--
> drivers/gpu/drm/i915/display/intel_lpe_audio.h | 4 ++--
> 3 files changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_audio.c b/drivers/gpu/drm/i915/display/intel_audio.c
> index 24e76657d561..aa7037021376 100644
> --- a/drivers/gpu/drm/i915/display/intel_audio.c
> +++ b/drivers/gpu/drm/i915/display/intel_audio.c
> @@ -1403,8 +1403,10 @@ static void i915_audio_component_cleanup(struct drm_i915_private *dev_priv)
> */
> void intel_audio_init(struct drm_i915_private *dev_priv)
> {
> - if (intel_lpe_audio_init(dev_priv) < 0)
> - i915_audio_component_init(dev_priv);
> + if (!intel_lpe_audio_init(dev_priv))
> + return;
> +
> + i915_audio_component_init(dev_priv);
The logic here is already a bit funky. Technically we should not
init the component stuff except when LPE audio is not present.
Ie. we should only do it when intel_lpe_audio_init() returns
-ENODEV.
> }
>
> /**
> @@ -1414,8 +1416,8 @@ void intel_audio_init(struct drm_i915_private *dev_priv)
> */
> void intel_audio_deinit(struct drm_i915_private *dev_priv)
> {
> - if ((dev_priv)->audio.lpe.platdev != NULL)
> - intel_lpe_audio_teardown(dev_priv);
> - else
> - i915_audio_component_cleanup(dev_priv);
> + if (!intel_lpe_audio_teardown(dev_priv))
> + return;
> +
> + i915_audio_component_cleanup(dev_priv);
Here it would probably make more sense to just call both
unconditionally so we don't have to care what happened during
init.
> }
> diff --git a/drivers/gpu/drm/i915/display/intel_lpe_audio.c b/drivers/gpu/drm/i915/display/intel_lpe_audio.c
> index 4970bf146c4a..a2984718d136 100644
> --- a/drivers/gpu/drm/i915/display/intel_lpe_audio.c
> +++ b/drivers/gpu/drm/i915/display/intel_lpe_audio.c
> @@ -296,10 +296,10 @@ int intel_lpe_audio_init(struct drm_i915_private *dev_priv)
> *
> * release all the resources for LPE audio <-> i915 bridge.
> */
> -void intel_lpe_audio_teardown(struct drm_i915_private *dev_priv)
> +int intel_lpe_audio_teardown(struct drm_i915_private *dev_priv)
> {
> if (!HAS_LPE_AUDIO(dev_priv))
> - return;
> + return -ENODEV;
>
> lpe_audio_platdev_destroy(dev_priv);
>
> @@ -307,6 +307,8 @@ void intel_lpe_audio_teardown(struct drm_i915_private *dev_priv)
>
> dev_priv->audio.lpe.irq = -1;
> dev_priv->audio.lpe.platdev = NULL;
> +
> + return 0;
> }
>
> /**
> diff --git a/drivers/gpu/drm/i915/display/intel_lpe_audio.h b/drivers/gpu/drm/i915/display/intel_lpe_audio.h
> index f848c5038714..030874623872 100644
> --- a/drivers/gpu/drm/i915/display/intel_lpe_audio.h
> +++ b/drivers/gpu/drm/i915/display/intel_lpe_audio.h
> @@ -12,8 +12,8 @@ enum pipe;
> enum port;
> struct drm_i915_private;
>
> -int intel_lpe_audio_init(struct drm_i915_private *dev_priv);
> -void intel_lpe_audio_teardown(struct drm_i915_private *dev_priv);
> +int intel_lpe_audio_init(struct drm_i915_private *dev_priv);
> +int intel_lpe_audio_teardown(struct drm_i915_private *dev_priv);
> void intel_lpe_audio_irq_handler(struct drm_i915_private *dev_priv);
> void intel_lpe_audio_notify(struct drm_i915_private *dev_priv,
> enum pipe pipe, enum port port,
> --
> 2.30.2
--
Ville Syrjälä
Intel
next prev parent reply other threads:[~2021-11-05 10:21 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-04 16:18 [Intel-gfx] [PATCH v3 1/6] drm/i915/audio: group audio under anonymous struct in drm_i915_private Jani Nikula
2021-11-04 16:18 ` [Intel-gfx] [PATCH v3 2/6] drm/i915/audio: name the audio sub-struct " Jani Nikula
2021-11-04 16:18 ` [Intel-gfx] [PATCH v3 3/6] drm/i915/audio: define the audio struct separately from drm_i915_private Jani Nikula
2021-11-04 16:18 ` [Intel-gfx] [PATCH v3 4/6] drm/i915/audio: move intel_audio_funcs internal to intel_audio.c Jani Nikula
2021-11-04 16:18 ` [Intel-gfx] [PATCH v3 5/6] drm/i915/audio: clean up LPE audio init/cleanup calls Jani Nikula
2021-11-05 10:21 ` Ville Syrjälä [this message]
2021-11-05 11:29 ` Jani Nikula
2021-11-04 16:18 ` [Intel-gfx] [PATCH v3 6/6] drm/i915/audio: rename intel_init_audio_hooks to intel_audio_hooks_init Jani Nikula
2021-11-05 10:21 ` Ville Syrjälä
2021-11-04 19:22 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [v3,1/6] drm/i915/audio: group audio under anonymous struct in drm_i915_private Patchwork
2021-11-04 19:23 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-11-04 19:54 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-11-04 23:32 ` [Intel-gfx] ✓ Fi.CI.IGT: " 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=YYUFmkGqEIDpkH8N@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@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