From: <dan.j.williams@intel.com>
To: Jonathan Cameron <jonathan.cameron@huawei.com>,
Dan Williams <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 1/9] cxl/port: Cleanup handling of the nr_dports 0 -> 1 transition
Date: Thu, 22 Jan 2026 11:58:56 -0800 [thread overview]
Message-ID: <697281801f449_309510032@dwillia2-mobl4.notmuch> (raw)
In-Reply-To: <20260122113216.00004eb2@huawei.com>
Jonathan Cameron wrote:
> On Wed, 21 Jan 2026 19:33:22 -0800
> Dan Williams <dan.j.williams@intel.com> wrote:
>
> > There are multiple setup actions that can occur for a switch port after it
> > is known that it has at least one active downstream link. That work is
> > currently split between __devm_cxl_add_dport(), the add_dport() helper, and
> > cxl_port_add_dport() where decoder setup occurs.
> >
> > Clean this up by moving all @dport object setup responsibilities into
> > add_dport() and all port effects into cxl_port_add_dport().
> >
> > add_dport() handles taking a reference on @dport->dport_dev, and
> > cxl_port_add_dport() grows the awareness to setup the port component
> > registers. This removes an awkward open-coded xa_erase() from the middle of
> > __devm_cxl_add_dport() and instead tasks cxl_port_add_dport() with calling
> > the common @dport destruction path if anything goes wrong.
> >
> > After this @port->nr_dports is always the count of @dports in the
> > @port->dports xarray, and cxl_dport_remove() is symmetric with add_dport().
> > With ->nr_dports now reliably tracking the number of dports the use of
> > ida_is_empty() can be dropped. Recall that the ida is only cleared on
> > "release" of decoder objects, and release can be arbitrarily delayed past
> > unregistration.
>
> Given we only care about nr_dports going to and and from 0, why do
> we need nr_dports at all? Why not use xa_empty() as the condition.
>
> Does this now guarantee we don't need the extra nr_dports reset in
> cxl_switch_port_probe()? That also made me suspicious of something
> funny going on as the count should have dropped to zero if we
> are in state to rebind.
>
> Other than those this looks good to me and both of those are perhaps
> topics for other patches even if maybe they could be done in here.
True. I had just been assuming that nr_dports was still needed for other
reasons. It turns out that the original need for nr_dports:
e4f6dfa9ef75 cxl/region: Fix 'distance' calculation with passthrough ports
...was obviated here:
711442e29f16 cxl/region: Fix passthrough-decoder detection
So, yes, I would be on board with switching to xa_empty() as a follow-on
cleanup.
next prev parent reply other threads:[~2026-01-22 19:59 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 [this message]
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
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=697281801f449_309510032@dwillia2-mobl4.notmuch \
--to=dan.j.williams@intel.com \
--cc=alison.schofield@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=ira.weiny@intel.com \
--cc=jonathan.cameron@huawei.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