@@ -780,8 +780,12 @@ static size_t show_targetN(struct cxl_region *cxlr, char *buf, int pos)
static int check_commit_order(struct device *dev, const void *data)
{
- struct cxl_decoder *cxld = to_cxl_decoder(dev);
+ struct cxl_decoder *cxld;
+ if (!is_switch_decoder(dev))
+ return 1;
+
+ cxld = to_cxl_decoder(dev);
/*
* if port->commit_end is not the only free decoder, then out of
* order shutdown has occurred, block further allocations until
@@ -815,7 +819,7 @@ static int match_free_decoder(struct device *dev, void *data)
rc = device_for_each_child_reverse_from(dev->parent, dev, NULL,
check_commit_order);
- if (rc) {
+ if (rc < 0) {
dev_dbg(dev->parent,
"unable to allocate %s due to out of order shutdown\n",
dev_name(dev));
Currently, endpoint port probing helps to enumerate decoders on its ancestor ports. it will impact the sequence of port's device child list. Before that, port's decoders are added to port's device child list firstly, then all ports under the port will be added to the port's device child list. But now, all ports under the port will be added to the port's device child list firstly, then the port's decoders will be added. So when using device_for_each_child_reverse_from() to check decoders commit order, needs to check if the child device is decoder, if not, that means the first decoder was walked. Returning a positive in such case to stop iterator. Signed-off-by: Li Ming <ming.li@zohomail.com> --- drivers/cxl/core/region.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)