Skip to content

Commit a76b625

Browse files
committed
cxl/port: Fix cxl_test register enumeration regression
The cxl_test unit test environment models a CXL topology for sysfs/user-ABI regression testing. It uses interface mocking via the "--wrap=" linker option to redirect cxl_core routines that parse hardware registers with versions that just publish objects, like devm_cxl_enumerate_decoders(). Starting with: Commit 19ab69a ("cxl/port: Store the port's Component Register mappings in struct cxl_port") ...port register enumeration is moved into devm_cxl_add_port(). This conflicts with the "cxl_test avoids emulating registers stance" so either the port code needs to be refactored (too violent), or modified so that register enumeration is skipped on "fake" cxl_test ports (annoying, but straightforward). This conflict has happened previously and the "check for platform device" workaround to avoid instrusive refactoring was deployed in those scenarios. In general, refactoring should only benefit production code, test code needs to remain minimally instrusive to the greatest extent possible. This was missed previously because it may sometimes just cause warning messages to be emitted, but it can also cause test failures. The backport to -stable is only nice to have for clean cxl_test runs. Fixes: 19ab69a ("cxl/port: Store the port's Component Register mappings in struct cxl_port") Cc: [email protected] Reported-by: Alison Schofield <[email protected]> Reviewed-by: Dave Jiang <[email protected]> Tested-by: Dave Jiang <[email protected]> Link: https://lore.kernel.org/r/169476525052.1013896.6235102957693675187.stgit@dwillia2-xfh.jf.intel.com Signed-off-by: Dan Williams <[email protected]>
1 parent 18f35dc commit a76b625

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

drivers/cxl/core/port.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/* Copyright(c) 2020 Intel Corporation. All rights reserved. */
3+
#include <linux/platform_device.h>
34
#include <linux/memregion.h>
45
#include <linux/workqueue.h>
56
#include <linux/debugfs.h>
@@ -706,16 +707,20 @@ static int cxl_setup_comp_regs(struct device *dev, struct cxl_register_map *map,
706707
return cxl_setup_regs(map);
707708
}
708709

709-
static inline int cxl_port_setup_regs(struct cxl_port *port,
710-
resource_size_t component_reg_phys)
710+
static int cxl_port_setup_regs(struct cxl_port *port,
711+
resource_size_t component_reg_phys)
711712
{
713+
if (dev_is_platform(port->uport_dev))
714+
return 0;
712715
return cxl_setup_comp_regs(&port->dev, &port->comp_map,
713716
component_reg_phys);
714717
}
715718

716-
static inline int cxl_dport_setup_regs(struct cxl_dport *dport,
717-
resource_size_t component_reg_phys)
719+
static int cxl_dport_setup_regs(struct cxl_dport *dport,
720+
resource_size_t component_reg_phys)
718721
{
722+
if (dev_is_platform(dport->dport_dev))
723+
return 0;
719724
return cxl_setup_comp_regs(dport->dport_dev, &dport->comp_map,
720725
component_reg_phys);
721726
}

0 commit comments

Comments
 (0)