[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251001153412.000073bc@huawei.com>
Date: Wed, 1 Oct 2025 15:34:12 +0100
From: Jonathan Cameron <jonathan.cameron@...wei.com>
To: Li Ming <ming.li@...omail.com>
CC: <dave@...olabs.net>, <dave.jiang@...el.com>, <alison.schofield@...el.com>,
<vishal.l.verma@...el.com>, <ira.weiny@...el.com>,
<dan.j.williams@...el.com>, <shiju.jose@...wei.com>,
<linux-cxl@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3 1/1] cxl/port: Avoid missing port component registers
setup
On Wed, 1 Oct 2025 14:03:37 +0800
Li Ming <ming.li@...omail.com> wrote:
> port->nr_dports is used to represent how many dports added to the cxl
> port, it will increase in add_dport() when a new dport is being added to
> the cxl port, but it will not be reduced when a dport is removed from
> the cxl port.
>
> Currently, when the first dport is added to a cxl port, it will trigger
> component registers setup on the cxl port, the implementation is using
> port->nr_dports to confirm if the dport is the first dport.
>
> A corner case here is that adding dport could fail after port->nr_dports
> updating and before checking port->nr_dports for component registers
> setup. If the failure happens during the first dport attaching, it will
> cause that CXL subsystem has not chance to execute component registers
> setup for the cxl port. the failure flow like below:
>
> port->nr_dports = 0
> dport 1 adding to the port:
> add_dport() # port->nr_dports: 1
> failed on devm_add_action_or_reset() or sysfs_create_link()
> return error # port->nr_dports: 1
> dport 2 adding to the port:
> add_dport() # port->nr_dports: 2
> no failure
> skip component registers setup because of port->nr_dports is 2
>
> The solution here is that moving component registers setup closer to
> add_dport(), so if add_dport() is executed correctly for the first
> dport, component registers setup on the port will be executed
> immediately after that.
>
> Fixes: f6ee24913de2 ("cxl: Move port register setup to when first dport appear")
> Signed-off-by: Li Ming <ming.li@...omail.com>
> Reviewed-by: Dave Jiang <dave.jiang@...el.com>
> Reviewed-by: Davidlohr Bueso <dave@...olabs.net>
Seems reasonable. Alternative would have been to carry a 'it went horribly wrong'
flag and fail the later additions as well (on basis a failure in the relevant calls
is very unlikely). This seems simpler.
Reviewed-by: Jonathan Cameron <jonathan.cameron@...wei.com>
Thanks,
J
Powered by blists - more mailing lists