drivers/misc/ocxl/config.c
Source file repositories/reference/linux-study-clean/drivers/misc/ocxl/config.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/misc/ocxl/config.c- Extension
.c- Size
- 24639 bytes
- Lines
- 938
- Domain
- Driver Families
- Bucket
- drivers/misc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/pci.hasm/pnv-ocxl.hmisc/ocxl-config.hocxl_internal.h
Detected Declarations
function find_dvsecfunction find_dvsec_afu_ctrlfunction get_function_0function read_pasidfunction read_dvsec_tlfunction read_dvsec_functionfunction read_dvsec_afu_infofunction read_dvsec_vendorfunction get_dvsec_vendor0function ocxl_config_get_reset_reloadfunction ocxl_config_set_reset_reloadfunction validate_functionfunction ocxl_config_read_functionfunction read_afu_infofunction read_template_versionfunction ocxl_config_check_afu_indexfunction read_afu_namefunction read_afu_mmiofunction read_afu_controlfunction char_allowedfunction validate_afufunction read_afu_lpc_memory_infofunction ocxl_config_read_afufunction ocxl_config_get_actag_infofunction ocxl_config_set_afu_actagfunction ocxl_config_get_pasid_infofunction ocxl_config_set_afu_pasidfunction ocxl_config_set_afu_statefunction ocxl_config_set_TLfunction ocxl_config_terminate_pasidfunction ocxl_config_set_actagexport ocxl_config_read_functionexport ocxl_config_read_afuexport ocxl_config_get_actag_infoexport ocxl_config_set_afu_actagexport ocxl_config_set_afu_pasidexport ocxl_config_set_afu_stateexport ocxl_config_set_TLexport ocxl_config_terminate_pasidexport ocxl_config_set_actag
Annotated Snippet
if (time_after_eq(jiffies, timeout)) {
dev_err(&dev->dev,
"Timeout while reading AFU info DVSEC (offset=%d)\n",
offset);
return -EBUSY;
}
cpu_relax();
pci_read_config_dword(dev, pos + OCXL_DVSEC_AFU_INFO_OFF, &val);
}
pci_read_config_dword(dev, pos + OCXL_DVSEC_AFU_INFO_DATA, data);
return 0;
}
/**
* read_template_version() - Read the template version from the AFU
* @dev: the device for the AFU
* @fn: the AFU offsets
* @len: outputs the template length
* @version: outputs the major<<8,minor version
*
* Returns 0 on success, negative on failure
*/
static int read_template_version(struct pci_dev *dev, struct ocxl_fn_config *fn,
u16 *len, u16 *version)
{
u32 val32;
u8 major, minor;
int rc;
rc = read_afu_info(dev, fn, OCXL_DVSEC_TEMPL_VERSION, &val32);
if (rc)
return rc;
*len = EXTRACT_BITS(val32, 16, 31);
major = EXTRACT_BITS(val32, 8, 15);
minor = EXTRACT_BITS(val32, 0, 7);
*version = (major << 8) + minor;
return 0;
}
int ocxl_config_check_afu_index(struct pci_dev *dev,
struct ocxl_fn_config *fn, int afu_idx)
{
int rc;
u16 templ_version;
u16 len, expected_len;
pci_write_config_byte(dev,
fn->dvsec_afu_info_pos + OCXL_DVSEC_AFU_INFO_AFU_IDX,
afu_idx);
rc = read_template_version(dev, fn, &len, &templ_version);
if (rc)
return rc;
/* AFU index map can have holes, in which case we read all 0's */
if (!templ_version && !len)
return 0;
dev_dbg(&dev->dev, "AFU descriptor template version %d.%d\n",
templ_version >> 8, templ_version & 0xFF);
switch (templ_version) {
case 0x0005: // v0.5 was used prior to the spec approval
case 0x0100:
expected_len = OCXL_TEMPL_LEN_1_0;
break;
case 0x0101:
expected_len = OCXL_TEMPL_LEN_1_1;
break;
default:
dev_warn(&dev->dev, "Unknown AFU template version %#x\n",
templ_version);
expected_len = len;
}
if (len != expected_len)
dev_warn(&dev->dev,
"Unexpected template length %#x in AFU information, expected %#x for version %#x\n",
len, expected_len, templ_version);
return 1;
}
static int read_afu_name(struct pci_dev *dev, struct ocxl_fn_config *fn,
struct ocxl_afu_config *afu)
{
int i, rc;
u32 val, *ptr;
BUILD_BUG_ON(OCXL_AFU_NAME_SZ < OCXL_TEMPL_NAME_LEN);
for (i = 0; i < OCXL_TEMPL_NAME_LEN; i += 4) {
Annotation
- Immediate include surface: `linux/pci.h`, `asm/pnv-ocxl.h`, `misc/ocxl-config.h`, `ocxl_internal.h`.
- Detected declarations: `function find_dvsec`, `function find_dvsec_afu_ctrl`, `function get_function_0`, `function read_pasid`, `function read_dvsec_tl`, `function read_dvsec_function`, `function read_dvsec_afu_info`, `function read_dvsec_vendor`, `function get_dvsec_vendor0`, `function ocxl_config_get_reset_reload`.
- Atlas domain: Driver Families / drivers/misc.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.