RE: [PATCH v12 07/20] cxl/hdm: Use stored Component Register mappings to map HDM decoder capability

From: Dan Williams
Date: Fri Oct 27 2023 - 17:51:52 EST


Robert Richter wrote:
> Now, that the Component Register mappings are stored, use them to
> enable and map the HDM decoder capabilities. The Component Registers
> do not need to be probed again for this, remove probing code.
>
> The HDM capability applies to Endpoints, USPs and VH Host Bridges. The
> Endpoint's component register mappings are located in the cxlds and
> else in the port's structure. Duplicate the cxlds->reg_map in
> port->reg_map for endpoint ports.
>
> Signed-off-by: Terry Bowman <terry.bowman@xxxxxxx>
> Signed-off-by: Robert Richter <rrichter@xxxxxxx>
> Reviewed-by: Dave Jiang <dave.jiang@xxxxxxxxx>
> [rework to drop cxl_port_get_comp_map()]
> Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx>
[..]
> @@ -164,19 +144,30 @@ struct cxl_hdm *devm_cxl_setup_hdm(struct cxl_port *port,
> cxlhdm->port = port;
> dev_set_drvdata(dev, cxlhdm);
>
> - crb = ioremap(port->component_reg_phys, CXL_COMPONENT_REG_BLOCK_SIZE);
> - if (!crb && info && info->mem_enabled) {
> + /* Memory devices can configure device HDM using DVSEC range regs. */
> + if (reg_map->resource == CXL_RESOURCE_NONE) {
> + if (!info && !info->mem_enabled) {
> + WARN_ON(1);

This new WARN() is not documented in the changelog, it needs to be
justified as a valid reason to panic the kernel in case panic_on_warn
conservatism is being applied. Even if it could be justified on those
grounds it should be combined with the following error message as a
dev_WARN(). For now, I'll delete it.

> + dev_err(dev, "No component registers mapped\n");
> + return ERR_PTR(-ENXIO);
> + }
> +