Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/amdgpu: Add vbios build number interface

Fetch VBIOS build number from atom rom image. Add a sysfs interface to
read the build number.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Lijo Lazar and committed by
Alex Deucher
d6fa8026 c5f4fb40

+54 -3
+30 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
··· 1816 1816 return sysfs_emit(buf, "%s\n", ctx->vbios_pn); 1817 1817 } 1818 1818 1819 + static ssize_t amdgpu_atombios_get_vbios_build(struct device *dev, 1820 + struct device_attribute *attr, 1821 + char *buf) 1822 + { 1823 + struct drm_device *ddev = dev_get_drvdata(dev); 1824 + struct amdgpu_device *adev = drm_to_adev(ddev); 1825 + struct atom_context *ctx = adev->mode_info.atom_context; 1826 + 1827 + return sysfs_emit(buf, "%s\n", ctx->build_num); 1828 + } 1829 + 1819 1830 static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version, 1820 1831 NULL); 1832 + static DEVICE_ATTR(vbios_build, 0444, amdgpu_atombios_get_vbios_build, NULL); 1821 1833 1822 1834 static struct attribute *amdgpu_vbios_version_attrs[] = { 1823 - &dev_attr_vbios_version.attr, 1824 - NULL 1835 + &dev_attr_vbios_version.attr, &dev_attr_vbios_build.attr, NULL 1825 1836 }; 1826 1837 1838 + static umode_t amdgpu_vbios_version_attrs_is_visible(struct kobject *kobj, 1839 + struct attribute *attr, 1840 + int index) 1841 + { 1842 + struct device *dev = kobj_to_dev(kobj); 1843 + struct drm_device *ddev = dev_get_drvdata(dev); 1844 + struct amdgpu_device *adev = drm_to_adev(ddev); 1845 + struct atom_context *ctx = adev->mode_info.atom_context; 1846 + 1847 + if (attr == &dev_attr_vbios_build.attr && !strlen(ctx->build_num)) 1848 + return 0; 1849 + 1850 + return attr->mode; 1851 + } 1852 + 1827 1853 const struct attribute_group amdgpu_vbios_version_attr_group = { 1828 - .attrs = amdgpu_vbios_version_attrs 1854 + .attrs = amdgpu_vbios_version_attrs, 1855 + .is_visible = amdgpu_vbios_version_attrs_is_visible, 1829 1856 }; 1830 1857 1831 1858 int amdgpu_atombios_sysfs_init(struct amdgpu_device *adev)
+22
drivers/gpu/drm/amd/amdgpu/atom.c
··· 1494 1494 } 1495 1495 } 1496 1496 1497 + static void atom_get_vbios_build(struct atom_context *ctx) 1498 + { 1499 + unsigned char *atom_rom_hdr; 1500 + unsigned char *str; 1501 + uint16_t base; 1502 + 1503 + base = CU16(ATOM_ROM_TABLE_PTR); 1504 + atom_rom_hdr = CSTR(base); 1505 + 1506 + str = CSTR(CU16(base + ATOM_ROM_CFG_PTR)); 1507 + /* Skip config string */ 1508 + while (str < atom_rom_hdr && *str++) 1509 + ; 1510 + /* Skip change list string */ 1511 + while (str < atom_rom_hdr && *str++) 1512 + ; 1513 + 1514 + if ((str + STRLEN_NORMAL) < atom_rom_hdr) 1515 + strscpy(ctx->build_num, str, STRLEN_NORMAL); 1516 + } 1517 + 1497 1518 struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios) 1498 1519 { 1499 1520 int base; ··· 1575 1554 atom_get_vbios_pn(ctx); 1576 1555 atom_get_vbios_date(ctx); 1577 1556 atom_get_vbios_version(ctx); 1557 + atom_get_vbios_build(ctx); 1578 1558 1579 1559 return ctx; 1580 1560 }
+2
drivers/gpu/drm/amd/amdgpu/atom.h
··· 37 37 #define ATOM_ROM_MAGIC "ATOM" 38 38 #define ATOM_ROM_MAGIC_PTR 4 39 39 40 + #define ATOM_ROM_CFG_PTR 0xC 40 41 #define ATOM_ROM_MSG_PTR 0x10 41 42 #define ATOM_ROM_CMD_PTR 0x1E 42 43 #define ATOM_ROM_DATA_PTR 0x20 ··· 152 151 uint32_t version; 153 152 uint8_t vbios_ver_str[STRLEN_NORMAL]; 154 153 uint8_t date[STRLEN_NORMAL]; 154 + uint8_t build_num[STRLEN_NORMAL]; 155 155 }; 156 156 157 157 extern int amdgpu_atom_debug;