/** * DOC: cxl registers * * CXL device capabilities are enumerated by PCI DVSEC (Designated * Vendor-specific) and / or descriptors provided by platform firmware. * They can be defined as a set like the device and component registers * mandated by CXL Section 8.1.12.2 Memory Device PCIe Capabilities and * Extended Capabilities, or they can be individual capabilities * appended to bridged and endpoint devices. * * Provide common infrastructure for enumerating and mapping these * discrete capabilities.
*/
/** * cxl_probe_component_regs() - Detect CXL Component register blocks * @dev: Host device of the @base mapping * @base: Mapping containing the HDM Decoder Capability Header * @map: Map object describing the register block information found * * See CXL 2.0 8.2.4 Component Register Layout and Definition * See CXL 2.0 8.2.5.5 CXL Device Register Interface * * Probe for component register information and return it in map object.
*/ void cxl_probe_component_regs(struct device *dev, void __iomem *base, struct cxl_component_reg_map *map)
{ int cap, cap_count;
u32 cap_array;
*map = (struct cxl_component_reg_map) { 0 };
/* * CXL.cache and CXL.mem registers are at offset 0x1000 as defined in * CXL 2.0 8.2.4 Table 141.
*/
base += CXL_CM_OFFSET;
cap_array = readl(base + CXL_CM_CAP_HDR_OFFSET);
if (FIELD_GET(CXL_CM_CAP_HDR_ID_MASK, cap_array) != CM_CAP_HDR_CAP_ID) {
dev_dbg(dev, "Couldn't locate the CXL.cache and CXL.mem capability array header.\n"); return;
}
/* It's assumed that future versions will be backward compatible */
cap_count = FIELD_GET(CXL_CM_CAP_HDR_ARRAY_SIZE_MASK, cap_array);
if (!cxl_decode_regblock(pdev, reg_lo, reg_hi, map)) continue;
if (map->reg_type == type) { if (index == instance) return 0;
instance++;
}
}
map->resource = CXL_RESOURCE_NONE; if (index == CXL_INSTANCES_COUNT) return instance;
return -ENODEV;
}
/** * cxl_find_regblock_instance() - Locate a register block by type / index * @pdev: The CXL PCI device to enumerate. * @type: Register Block Indicator id * @map: Enumeration output, clobbered on error * @index: Index into which particular instance of a regblock wanted in the * order found in register locator DVSEC. * * Return: 0 if register block enumerated, negative error code otherwise * * A CXL DVSEC may point to one or more register blocks, search for them * by @type and @index.
*/ int cxl_find_regblock_instance(struct pci_dev *pdev, enum cxl_regloc_type type, struct cxl_register_map *map, unsignedint index)
{ return __cxl_find_regblock_instance(pdev, type, map, index);
}
EXPORT_SYMBOL_NS_GPL(cxl_find_regblock_instance, "CXL");
/** * cxl_find_regblock() - Locate register blocks by type * @pdev: The CXL PCI device to enumerate. * @type: Register Block Indicator id * @map: Enumeration output, clobbered on error * * Return: 0 if register block enumerated, negative error code otherwise * * A CXL DVSEC may point to one or more register blocks, search for them * by @type.
*/ int cxl_find_regblock(struct pci_dev *pdev, enum cxl_regloc_type type, struct cxl_register_map *map)
{ return __cxl_find_regblock_instance(pdev, type, map, 0);
}
EXPORT_SYMBOL_NS_GPL(cxl_find_regblock, "CXL");
/** * cxl_count_regblock() - Count instances of a given regblock type. * @pdev: The CXL PCI device to enumerate. * @type: Register Block Indicator id * * Some regblocks may be repeated. Count how many instances. * * Return: non-negative count of matching regblocks, negative error code otherwise.
*/ int cxl_count_regblock(struct pci_dev *pdev, enum cxl_regloc_type type)
{ struct cxl_register_map map;
/* * Sanity check, see CXL 3.0 Figure 9-8 CXL Device that Does Not * Remap Upstream Port and Component Registers
*/ if (id == U32_MAX) { if (which == CXL_RCRB_DOWNSTREAM)
dev_err(dev, "Failed to access Downstream Port RCRB\n"); return CXL_RESOURCE_NONE;
} /* The RCRB is a Memory Window, and the MEM_TYPE_1M bit is obsolete */ if (bar0 & (PCI_BASE_ADDRESS_MEM_TYPE_1M | PCI_BASE_ADDRESS_SPACE_IO)) return CXL_RESOURCE_NONE;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.