Skip to content

Commit 4d75876

Browse files
Robert Richterdjbw
authored andcommitted
cxl/port: Pre-initialize component register mappings
The component registers of a component may not exist and cxl_setup_comp_regs() will fail for that reason. In another case, Software may not use and set those registers up. cxl_setup_comp_regs() is then called with a base address of CXL_RESOURCE_NONE. Both are valid cases, but the function returns without initializing the register map. Now, a missing component register block is not necessarily a reason to fail (feature is optional or its existence checked later). Change cxl_setup_comp_regs() to also use components with the component register block missing. Thus, always initialize struct cxl_register_map with valid values, set @dev and make @resource CXL_RESOURCE_NONE. The change is in preparation of follow-on patches. Signed-off-by: Terry Bowman <terry.bowman@amd.com> Signed-off-by: Robert Richter <rrichter@amd.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Link: https://lore.kernel.org/r/20231018171713.1883517-6-rrichter@amd.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent d8add49 commit 4d75876

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/cxl/core/port.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -694,16 +694,18 @@ static struct cxl_port *cxl_port_alloc(struct device *uport_dev,
694694
static int cxl_setup_comp_regs(struct device *host, struct cxl_register_map *map,
695695
resource_size_t component_reg_phys)
696696
{
697-
if (component_reg_phys == CXL_RESOURCE_NONE)
698-
return 0;
699-
700697
*map = (struct cxl_register_map) {
701698
.host = host,
702-
.reg_type = CXL_REGLOC_RBI_COMPONENT,
699+
.reg_type = CXL_REGLOC_RBI_EMPTY,
703700
.resource = component_reg_phys,
704-
.max_size = CXL_COMPONENT_REG_BLOCK_SIZE,
705701
};
706702

703+
if (component_reg_phys == CXL_RESOURCE_NONE)
704+
return 0;
705+
706+
map->reg_type = CXL_REGLOC_RBI_COMPONENT;
707+
map->max_size = CXL_COMPONENT_REG_BLOCK_SIZE;
708+
707709
return cxl_setup_regs(map);
708710
}
709711

0 commit comments

Comments
 (0)