drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c- Extension
.c- Size
- 12263 bytes
- Lines
- 441
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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.hamdgpu.hamdgpu_i2c.hsmu_v11_0_i2c.hatom.hamdgpu_fru_eeprom.hamdgpu_eeprom.h
Detected Declarations
function filesfunction IP_VERSIONfunction IP_VERSIONfunction fru_pia_advancefunction fru_pia_copy_fieldfunction amdgpu_fru_get_product_infofunction amdgpu_fru_product_name_showfunction amdgpu_fru_product_number_showfunction amdgpu_fru_serial_number_showfunction amdgpu_fru_id_showfunction amdgpu_fru_manufacturer_name_showfunction amdgpu_fru_sysfs_initfunction amdgpu_fru_sysfs_fini
Annotated Snippet
switch (adev->asic_type) {
case CHIP_VEGA20:
/* D161 and D163 are the VG20 server SKUs */
if (atom_ctx && (strnstr(atom_ctx->vbios_pn, "D161",
sizeof(atom_ctx->vbios_pn)) ||
strnstr(atom_ctx->vbios_pn, "D163",
sizeof(atom_ctx->vbios_pn)))) {
if (fru_addr)
*fru_addr = FRU_EEPROM_MADDR_6;
return true;
} else {
return false;
}
case CHIP_ARCTURUS:
default:
return false;
}
case IP_VERSION(11, 0, 7):
if (atom_ctx && strnstr(atom_ctx->vbios_pn, "D603",
sizeof(atom_ctx->vbios_pn))) {
if (strnstr(atom_ctx->vbios_pn, "D603GLXE",
sizeof(atom_ctx->vbios_pn))) {
return false;
}
if (fru_addr)
*fru_addr = FRU_EEPROM_MADDR_6;
return true;
} else {
return false;
}
case IP_VERSION(13, 0, 2):
/* All Aldebaran SKUs have an FRU */
if (atom_ctx && !strnstr(atom_ctx->vbios_pn, "D673",
sizeof(atom_ctx->vbios_pn)))
if (fru_addr)
*fru_addr = FRU_EEPROM_MADDR_6;
return true;
case IP_VERSION(13, 0, 6):
case IP_VERSION(13, 0, 14):
if (fru_addr)
*fru_addr = FRU_EEPROM_MADDR_8;
return true;
case IP_VERSION(13, 0, 12):
case IP_VERSION(15, 0, 8):
if (fru_addr)
*fru_addr = FRU_EEPROM_MADDR_INV;
return true;
default:
return false;
}
}
/*
* IPMI FRU Product Info Area fields are TLV: one type/length byte
* (low 6 bits = data length) followed by that many data bytes. These
* helpers walk the cursor and copy a single field while bounding all
* accesses to the actual buffer length read from the EEPROM.
*/
#define FRU_FIELD_LEN(p, a) ((p)[a] & 0x3F)
/* Advance cursor past the current TLV. Returns false if no more data. */
static bool fru_pia_advance(u32 *addr, const unsigned char *pia, int len)
{
if (*addr >= (u32)len)
return false;
*addr += 1 + FRU_FIELD_LEN(pia, *addr);
return true;
}
/*
* Copy the current TLV's data into dst (NUL-terminated). Returns false if
* the TLV header or data would read past the end of pia.
*/
static bool fru_pia_copy_field(char *dst, size_t dst_size,
const unsigned char *pia, u32 addr, int len)
{
size_t fl;
if (addr + 1 >= (u32)len)
return false;
fl = min3((size_t)FRU_FIELD_LEN(pia, addr),
dst_size - 1,
(size_t)(len - addr - 1));
memcpy(dst, pia + addr + 1, fl);
dst[fl] = '\0';
return true;
}
Annotation
- Immediate include surface: `linux/pci.h`, `amdgpu.h`, `amdgpu_i2c.h`, `smu_v11_0_i2c.h`, `atom.h`, `amdgpu_fru_eeprom.h`, `amdgpu_eeprom.h`.
- Detected declarations: `function files`, `function IP_VERSION`, `function IP_VERSION`, `function fru_pia_advance`, `function fru_pia_copy_field`, `function amdgpu_fru_get_product_info`, `function amdgpu_fru_product_name_show`, `function amdgpu_fru_product_number_show`, `function amdgpu_fru_serial_number_show`, `function amdgpu_fru_id_show`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source 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.