From: Andi Shyti <andi.shyti@intel.com>
To: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: Intel GFX <intel-gfx@lists.freedesktop.org>
Subject: Re: [Intel-gfx] [PATCH v5] drm/i915/gt: make a gt sysfs group and move power management files
Date: Tue, 25 Feb 2020 14:29:53 +0200 [thread overview]
Message-ID: <20200225122953.GA5050@intel.intel> (raw)
In-Reply-To: <2b7d426d-a8e9-40f9-fb1c-184f0f9b0dfd@linux.intel.com>
> > > > > > +void intel_gt_sysfs_register(struct intel_gt *gt)
> > > > > > +{
> > > > > > + struct kobject *parent = kobject_get(gt_get_parent_obj(gt));
> > > > > > + int ret;
> > > > > > +
> >
> > and if I need to call kobject_put at the end. If for some reason
> > the files have failed to be initialized, I would have an
> > unbalanced put and a warning would be printed.
> >
> > I'll summarize in pseudo code:
> >
> > intel_gt_sysfs_register()
> > {
> > kobject_init_and_add(sysfs_root...); /* which calls kobject_get() inside */
> > if (fails)
> > kobject_put(sysfs_root); /* reference goes to '0' */
> > }
> >
> > intel_gt_sysfs_unregister()
> > {
> > option1: I don't call kobject_put(), I have an unbalanced
> > situation as you reviewed in patch 1.
> >
> > option2: I call kobject_put(), if it did fail during init
> > there is an unbalanced situation, which is
> > handled but an annoying WARN() is issued.
> >
> > option3: I check if "state_initialized" which I suppose
> > has been properly initialised during declaration
> > (maybe too paranoic?) and call _put()
> > accordingly
> > }
>
> Yes you are right, I confused the two parents again. :I
this little things are good for jambling the brain up :)
> Okay then, is the extra kobject_get/put on the parent
> (kobject_get(gt_get_parent_obj(gt) - this one) needed?
I do not see any strong reason for calling kobject_get, I do it
only because I am creating files in there and I don't want anyone
to free those without my permission. Otherwise, the creation and
the destruction of the son object would take care of the
refcount.
Will it ever happen that parent will be destroyed before I have
time to release the files? I don't think so, but I do it more for
the form than for the use. In the sense that "I have stuff in
there and I declare I have stuff in there and I declare when I
won't need them anymore".
Andi
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2020-02-25 12:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-19 19:02 [Intel-gfx] [PATCH v4] drm/i915/gt: make a gt sysfs group and move power management files Andi Shyti
2020-02-19 19:25 ` Andi Shyti
2020-02-19 19:30 ` [Intel-gfx] [PATCH v5] " Andi Shyti
2020-02-20 10:52 ` Jani Nikula
2020-02-24 14:53 ` Tvrtko Ursulin
2020-02-24 16:30 ` Andi Shyti
2020-02-24 16:46 ` Tvrtko Ursulin
2020-02-25 1:35 ` Andi Shyti
2020-02-25 8:39 ` Tvrtko Ursulin
2020-02-25 12:29 ` Andi Shyti [this message]
2020-02-19 20:32 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/gt: make a gt sysfs group and move power management files (rev5) Patchwork
2020-02-19 20:33 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2020-02-19 20:55 ` [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=20200225122953.GA5050@intel.intel \
--to=andi.shyti@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=tvrtko.ursulin@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 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.