Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: "Usyskin, Alexander" <alexander.usyskin@intel.com>,
	"Vivi, Rodrigo" <rodrigo.vivi@intel.com>,
	"Teres Alexis, Alan Previn" <alan.previn.teres.alexis@intel.com>
Cc: "dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"intel-gfx@lists.freedesktop.org"
	<intel-gfx@lists.freedesktop.org>,
	"Winkler, Tomas" <tomas.winkler@intel.com>,
	"Vivi@freedesktop.org" <Vivi@freedesktop.org>
Subject: Re: [Intel-gfx] [PATCH v5 2/6] drm/i915/pxp: add device link between i915 and mei_pxp
Date: Mon, 23 Jan 2023 14:43:33 +0200	[thread overview]
Message-ID: <874jsh8lqi.fsf@intel.com> (raw)
In-Reply-To: <CY5PR11MB63660409E141F1D0E65A9B95EDCB9@CY5PR11MB6366.namprd11.prod.outlook.com>

On Sun, 22 Jan 2023, "Usyskin, Alexander" <alexander.usyskin@intel.com> wrote:
>> > diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c
>> b/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c
>> > index d50354bfb993..bef6d7f8ac55 100644
>> > --- a/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c
>> > +++ b/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c
>> > @@ -127,6 +127,10 @@ static int i915_pxp_tee_component_bind(struct
>> device *i915_kdev,
>> >  	intel_wakeref_t wakeref;
>> >  	int ret = 0;
>> >
>> > +	if (!HAS_HECI_PXP(i915) &&
>> > +	    drm_WARN_ON(&i915->drm, !device_link_add(i915_kdev,
>> tee_kdev,
>> 
>> I don't like the action here hidden behind the drm_WARN_ON.
>> Please notice that almost every use of this and other helpers like
>> this expect the param as a failure. Not an actual action. So,
>> most of lazy readers like me might ignore that the main function
>> is actually a param inside  this warn condition.
>> 
> Honestly, copy-pasted from drivers/gpu/drm/i915/display/intel_audio.c +1266
> I don't have deep knowledge of drm macros, so thought this should be ok.
> Can make it any other form that acceptable in drm tree...

Unfortunately, some pattern being present in the driver does not mean
it's a good example to be emulated. If we copy a bad pattern, it seems
more acceptable, and even more people will copy it.


BR,
Jani.

>
>> We should probably stash the link as well...
>> 
>> pxp->dev_link = device_link_add(i915_kdev, tee_kdev,...);
>> 
>> so in the end below, instead of checking the HAS_HECI_PXP again
>> and use the remove version you check the dev_link and use the del
>> function.
>> 
>> something like:
>> 
>> if (pxp->dev_link)
>>    device_link_del(pxp->dev_link);
>> 
> Not sure that this simplification warrants additional clutter in struct.
>
>> Also, do you really need the WARN to see the stack when this happens
>> or you already know the callers?
>> Why not a simple drm_error msg?
>> 
>> if (!HAS_HECI_PXP(i915) {
>> 	pxp->dev_link = device_link_add(i915_kdev, tee_kdev,...);
>> 	if (!pxp->dev_link) {
>> 	   drm_error();
>> 	   return -ESOMETHING;
>> 
>> >  DL_FLAG_STATELESS)))
>> 
>> do we need the RPM in sync as well?
>> I mean:
>> 
>> DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME)))
>> 
>> ?
>
> No, the mei device should not be active all the time when i915 is active, only when pxp requires it.
>
>> 
>> > +		return -ENOMEM;
>> 
>> why ENOMEM?
> Copy-paste from i915 audio.
>
>> 
>> > +
>> >  	mutex_lock(&pxp->tee_mutex);
>> >  	pxp->pxp_component = data;
>> >  	pxp->pxp_component->tee_dev = tee_kdev;
>> > @@ -169,6 +173,9 @@ static void i915_pxp_tee_component_unbind(struct
>> device *i915_kdev,
>> >  	mutex_lock(&pxp->tee_mutex);
>> >  	pxp->pxp_component = NULL;
>> >  	mutex_unlock(&pxp->tee_mutex);
>> > +
>> > +	if (!HAS_HECI_PXP(i915))
>> > +		device_link_remove(i915_kdev, tee_kdev);
>> >  }
>> >
>> >  static const struct component_ops i915_pxp_tee_component_ops = {
>> > --
>> > 2.39.0
>> >

-- 
Jani Nikula, Intel Open Source Graphics Center

  reply	other threads:[~2023-01-23 12:43 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-13  1:18 [Intel-gfx] [PATCH v5 0/6] drm/i915/pxp: Add missing cleanup steps for PXP global-teardown Alan Previn
2023-01-13  1:18 ` [Intel-gfx] [PATCH v5 1/6] mei: mei-me: resume device in prepare Alan Previn
2023-01-18 11:42   ` Winkler, Tomas
2023-01-13  1:18 ` [Intel-gfx] [PATCH v5 2/6] drm/i915/pxp: add device link between i915 and mei_pxp Alan Previn
2023-01-19 19:25   ` Rodrigo Vivi
2023-01-19 23:01     ` Teres Alexis, Alan Previn
2023-01-22  6:57     ` Usyskin, Alexander
2023-01-23 12:43       ` Jani Nikula [this message]
2023-01-23 14:31       ` Rodrigo Vivi
2023-01-24  1:53         ` Teres Alexis, Alan Previn
2023-01-13  1:18 ` [Intel-gfx] [PATCH v5 3/6] mei: clean pending read with vtag on bus Alan Previn
2023-01-18 11:43   ` Winkler, Tomas
2023-01-13  1:18 ` [Intel-gfx] [PATCH v5 4/6] drm/i915/pxp: Invalidate all PXP fw sessions during teardown Alan Previn
2023-01-19 19:28   ` Rodrigo Vivi
2023-01-19 22:00     ` Teres Alexis, Alan Previn
2023-01-13  1:18 ` [Intel-gfx] [PATCH v5 5/6] drm/i915/pxp: Trigger the global teardown for before suspending Alan Previn
2023-01-19 19:35   ` Rodrigo Vivi
2023-01-19 22:31     ` Teres Alexis, Alan Previn
2023-01-13  1:18 ` [Intel-gfx] [PATCH v5 6/6] drm/i915/pxp: Pxp hw init should be in resume_complete Alan Previn
2023-01-19 19:10   ` Ceraolo Spurio, Daniele
2023-01-19 19:40     ` Rodrigo Vivi
2023-01-13  2:10 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm/i915/pxp: Add missing cleanup steps for PXP global-teardown Patchwork
2023-01-13  2:38 ` [Intel-gfx] ✗ Fi.CI.BAT: 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=874jsh8lqi.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=Vivi@freedesktop.org \
    --cc=alan.previn.teres.alexis@intel.com \
    --cc=alexander.usyskin@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=rodrigo.vivi@intel.com \
    --cc=tomas.winkler@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