staticbool is_fru_eeprom_supported(struct amdgpu_device *adev, u32 *fru_addr)
{ /* Only server cards have the FRU EEPROM *TODO:Seeifwecanfigurethisoutdynamicallyinsteadof *havingtoparseVBIOSversions.
*/ struct atom_context *atom_ctx = adev->mode_info.atom_context;
/* The i2c access is blocked on VF *TODO:Needotherwaytogettheinfo *Also,FRUnotvalidforAPUdevices.
*/ if (amdgpu_sriov_vf(adev) || (adev->flags & AMD_IS_APU)) returnfalse;
/* The default I2C EEPROM address of the FRU.
*/ if (fru_addr)
*fru_addr = FRU_EEPROM_MADDR_8;
/* VBIOS is of the format ###-DXXXYYYY-##. For SKU identification, *wecanusejustthe"DXXX"portion.Ifthereweremoremodels,we *couldconvertthe3characterstoahexintegeranduseaswitch *forease/speed/readability.Fornow,2stringcomparisonsare *reasonableandnottooexpensive
*/ switch (amdgpu_ip_version(adev, MP1_HWIP, 0)) { case IP_VERSION(11, 0, 2): 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; returntrue;
} else { returnfalse;
} case CHIP_ARCTURUS: default: returnfalse;
} 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))) { returnfalse;
}
if (fru_addr)
*fru_addr = FRU_EEPROM_MADDR_6; returntrue;
} else { returnfalse;
} 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; returntrue; case IP_VERSION(13, 0, 6): case IP_VERSION(13, 0, 14): if (fru_addr)
*fru_addr = FRU_EEPROM_MADDR_8; returntrue; case IP_VERSION(13, 0, 12): if (fru_addr)
*fru_addr = FRU_EEPROM_MADDR_INV; returntrue; default: returnfalse;
}
}
int amdgpu_fru_get_product_info(struct amdgpu_device *adev)
{ struct amdgpu_fru_info *fru_info; unsignedchar buf[8], *pia;
u32 addr, fru_addr; int size, len;
u8 csum;
if (!is_fru_eeprom_supported(adev, &fru_addr)) return0;
/* FRU data avaialble, but no direct EEPROM access */ if (fru_addr == FRU_EEPROM_MADDR_INV) return0;
if (!adev->fru_info) {
adev->fru_info = kzalloc(sizeof(*adev->fru_info), GFP_KERNEL); if (!adev->fru_info) return -ENOMEM;
}
fru_info = adev->fru_info; /* For Arcturus-and-later, default value of serial_number is unique_id *soconvertittoa16-digitHEXstringforconvenienceand *backwards-compatibility.
*/
sprintf(fru_info->serial, "%llx", adev->unique_id);
/* If algo exists, it means that the i2c_adapter's initialized */ if (!adev->pm.fru_eeprom_i2c_bus || !adev->pm.fru_eeprom_i2c_bus->algo) {
dev_warn(adev->dev, "Cannot access FRU, EEPROM accessor not initialized"); return -ENODEV;
}
/* Read the IPMI Common header */
len = amdgpu_eeprom_read(adev->pm.fru_eeprom_i2c_bus, fru_addr, buf, sizeof(buf)); if (len != 8) {
dev_err(adev->dev, "Couldn't read the IPMI Common Header: %d",
len); return len < 0 ? len : -EIO;
}
if (buf[0] != 1) {
dev_err(adev->dev, "Bad IPMI Common Header version: 0x%02x",
buf[0]); return -EIO;
}
for (csum = 0; len > 0; len--)
csum += buf[len - 1]; if (csum) {
dev_err(adev->dev, "Bad IPMI Common Header checksum: 0x%02x",
csum); return -EIO;
}
/* Get the offset to the Product Info Area (PIA). */
addr = buf[4] * 8; if (!addr) return0;
/* Get the absolute address to the PIA. */
addr += fru_addr;
/* Read the header of the PIA. */
len = amdgpu_eeprom_read(adev->pm.fru_eeprom_i2c_bus, addr, buf, 3); if (len != 3) {
dev_err(adev->dev, "Couldn't read the Product Info Area header: %d", len); return len < 0 ? len : -EIO;
}
if (buf[0] != 1) {
dev_err(adev->dev, "Bad IPMI Product Info Area version: 0x%02x",
buf[0]); return -EIO;
}
size = buf[1] * 8;
pia = kzalloc(size, GFP_KERNEL); if (!pia) return -ENOMEM;
/* Read the whole PIA. */
len = amdgpu_eeprom_read(adev->pm.fru_eeprom_i2c_bus, addr, pia, size); if (len != size) {
kfree(pia);
dev_err(adev->dev, "Couldn't read the Product Info Area: %d",
len); return len < 0 ? len : -EIO;
}
for (csum = 0; size > 0; size--)
csum += pia[size - 1]; if (csum) {
dev_err(adev->dev, "Bad Product Info Area checksum: 0x%02x",
csum);
kfree(pia); return -EIO;
}
/* Now extract useful information from the PIA. * *ReadManufacturerNamefieldwhoselengthis[3].
*/
addr = 3; if (addr + 1 >= len) goto Out;
memcpy(fru_info->manufacturer_name, pia + addr + 1,
min_t(size_t, sizeof(fru_info->manufacturer_name),
pia[addr] & 0x3F));
fru_info->manufacturer_name[sizeof(fru_info->manufacturer_name) - 1] = '\0';
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.