Linux CXL
 help / color / mirror / Atom feed
From: Jonathan Cameron <jonathan.cameron@huawei.com>
To: <dan.j.williams@intel.com>
Cc: <linux-cxl@vger.kernel.org>, <dave@stgolabs.net>,
	<dave.jiang@intel.com>, <alison.schofield@intel.com>,
	<ira.weiny@intel.com>, <terry.bowman@amd.com>
Subject: Re: [PATCH 3/9] cxl/port: Cleanup dport removal with a devres group
Date: Fri, 23 Jan 2026 12:14:41 +0000	[thread overview]
Message-ID: <20260123121441.0000240b@huawei.com> (raw)
In-Reply-To: <69728bf84936_309510070@dwillia2-mobl4.notmuch>

On Thu, 22 Jan 2026 12:43:36 -0800
dan.j.williams@intel.com wrote:

> Jonathan Cameron wrote:
> > On Wed, 21 Jan 2026 19:33:24 -0800
> > Dan Williams <dan.j.williams@intel.com> wrote:
> >   
> > > In preparation for adding more setup actions like RAS register mapping,
> > > introduce a devres group to collect all the dport creation / registration
> > > actions. This replaces the maintenance tedium of open coding several
> > > devm_release_action() calls in del_dport().
> > > 
> > > Signed-off-by: Dan Williams <dan.j.williams@intel.com>  
> > Whilst nice, there is some logic buried deep enough that it might surprise
> > anyone trying to grasp flow in __devm_cxl_add_dport.
> > 
> > I like the cleanup.h stuff but here I'm wondering if it is appropriate.
> > Maybe just use a goto in __devm_cxl_add_dport()
> >   
> 
> It is several gotos, I have a hard time ever writing goto again.
> 
> Maybe if you can clarify your "inappropriate" feeling. To be clear I
> have heard this from other maintainers that are not ready to let go of
> goto, but I feel this is rapidly approaching the reverse-xmas-tree level
> of local maintainer preferences.

I'm an enthusiast for the cleanup.h stuff. This was very much specific
to this case. I thought I wrote more on this in original mail, but seems
I deleted the comments before sending!  Sorry about that.

Main thing I was a bit dubious about in this very specific case was about
overlapping semantic meaning of the group and the the dport (which are
the same address, but we only pretend that in some paths).

That is necessary so there is 'one' thing for:

DEFINE_FREE(cxl_dport_release_group, void *,
	    if (_T) devres_release_group(dport_to_host(_T), _T))

Which is fine but then the meaning is broken out in
static void cxl_dport_close_group(struct cxl_dport *dport, void *group)

+ I'd have preferred we were explicit in the group being temporary and
hence passed NULL as ID which we can't do if group and dport need
to be the same pointer.

That in combination made me think perhaps it wasn't worth applying here.

> 
> [..]
> > > + * Upon return either a group is established with one action (free_dport()), or
> > > + * no group established and @dport is freed.
> > > + */
> > > +static void *cxl_dport_open_group_or_free(struct cxl_dport *dport)  
> > 
> > Can we put something in the name to hint this is devres stuff?
> > Group could mean too many things :( Even
> > cxl_dport_open_dr_group_or_free() avoids sounding too generic.  
> 
> I was on the fence with making it more clear it was devres, was just
> waiting for a tie breaking shove. Shove received, "dr_group" it is.
> 
> > > +{
> > > +	int rc;
> > > +	struct device *host = dport_to_host(dport);
> > > +	void *group = devres_open_group(host, dport, GFP_KERNEL);
> > > +
> > > +	if (!group) {
> > > +		kfree(dport);
> > > +		return NULL;
> > > +	}
> > > +
> > > +	rc = devm_add_action_or_reset(host, free_dport, dport);
> > > +	if (rc) {
> > > +		devres_release_group(host, group);
> > > +		return NULL;
> > > +	}
> > > +
> > > +	return group;
> > > +}
> > > +
> > > +static void cxl_dport_close_group(struct cxl_dport *dport, void *group)
> > > +{
> > > +	devres_close_group(dport_to_host(dport), group);
> > > +}
> > > +
> > > +/* The dport group id is the dport */
> > > +DEFINE_FREE(cxl_dport_release_group, void *,
> > > +	    if (_T) devres_release_group(dport_to_host(_T), _T))  
> > 
> > Reorder so this can use the typed del_dport()?  
> 
> Yeah, that is cleaner.
> 


  reply	other threads:[~2026-01-23 12:14 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-22  3:33 [PATCH 0/9] cxl/port: Unify RAS setup across port types Dan Williams
2026-01-22  3:33 ` [PATCH 1/9] cxl/port: Cleanup handling of the nr_dports 0 -> 1 transition Dan Williams
2026-01-22 11:32   ` Jonathan Cameron
2026-01-22 19:58     ` dan.j.williams
2026-01-22 16:45   ` Dave Jiang
2026-01-22  3:33 ` [PATCH 2/9] cxl/port: Reduce number of @dport variables in cxl_port_add_dport() Dan Williams
2026-01-22 11:39   ` Jonathan Cameron
2026-01-22 20:02     ` dan.j.williams
2026-01-22 16:54   ` Dave Jiang
2026-01-22  3:33 ` [PATCH 3/9] cxl/port: Cleanup dport removal with a devres group Dan Williams
2026-01-22 11:59   ` Jonathan Cameron
2026-01-22 20:43     ` dan.j.williams
2026-01-23 12:14       ` Jonathan Cameron [this message]
2026-01-23 12:24         ` Jonathan Cameron
2026-01-30 23:58         ` dan.j.williams
2026-01-22  3:33 ` [PATCH 4/9] cxl/port: Move decoder setup before dport creation Dan Williams
2026-01-22 13:07   ` Jonathan Cameron
2026-01-22 21:42     ` dan.j.williams
2026-01-22 20:38   ` Dave Jiang
2026-01-22  3:33 ` [PATCH 5/9] cxl/port: Move dport probe operations to a driver event Dan Williams
2026-01-22 14:44   ` Jonathan Cameron
2026-01-22 21:53     ` dan.j.williams
2026-01-22  3:33 ` [PATCH 6/9] cxl/port: Move dport RAS setup to dport add time Dan Williams
2026-01-22 15:00   ` Jonathan Cameron
2026-01-22 21:56     ` dan.j.williams
2026-01-22 21:06   ` Dave Jiang
2026-01-22  3:33 ` [PATCH 7/9] cxl/port: Map CXL Endpoint Port and CXL Switch Port RAS registers Dan Williams
2026-01-22 15:25   ` Jonathan Cameron
2026-01-22 22:11     ` dan.j.williams
2026-01-22  3:33 ` [PATCH 8/9] cxl/port: Move endpoint component register management to cxl_port Dan Williams
2026-01-22 15:27   ` Jonathan Cameron
2026-01-22 21:24   ` Dave Jiang
2026-01-22  3:33 ` [PATCH 9/9] cxl/port: Unify endpoint and switch port lookup Dan Williams
2026-01-22 15:32   ` Jonathan Cameron
2026-01-22 21:24   ` Dave Jiang
2026-01-22 21:42 ` [PATCH 0/9] cxl/port: Unify RAS setup across port types Bowman, Terry

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=20260123121441.0000240b@huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=terry.bowman@amd.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