Skip to content

Commit a6a355a

Browse files
Luben Tuikovalexdeucher
authored andcommitted
drm/amdgpu: Fixes to returning VBIOS RAS EEPROM address
1) Generalize the function--if the user didn't set i2c_address, still return true/false to indicate whether VBIOS contains the RAS EEPROM address. This function shouldn't evaluate whether the user set the i2c_address pointer or not. 2) Don't touch the caller's i2c_address, unless you have to--this function shouldn't have side effects. 3) Correctly set the function comment as a kernel-doc comment. Cc: John Clements <[email protected]> Cc: Hawking Zhang <[email protected]> Cc: Alex Deucher <[email protected]> Signed-off-by: Luben Tuikov <[email protected]> Reviewed-by: Alex Deucher <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent fbd2a60 commit a6a355a

File tree

1 file changed

+33
-17
lines changed

1 file changed

+33
-17
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -468,42 +468,58 @@ bool amdgpu_atomfirmware_dynamic_boot_config_supported(struct amdgpu_device *ade
468468
return (fw_cap & ATOM_FIRMWARE_CAP_DYNAMIC_BOOT_CFG_ENABLE) ? true : false;
469469
}
470470

471-
/*
472-
* Helper function to query RAS EEPROM address
473-
*
474-
* @adev: amdgpu_device pointer
471+
/**
472+
* amdgpu_atomfirmware_ras_rom_addr -- Get the RAS EEPROM addr from VBIOS
473+
* adev: amdgpu_device pointer
474+
* i2c_address: pointer to u8; if not NULL, will contain
475+
* the RAS EEPROM address if the function returns true
475476
*
476-
* Return true if vbios supports ras rom address reporting
477+
* Return true if VBIOS supports RAS EEPROM address reporting,
478+
* else return false. If true and @i2c_address is not NULL,
479+
* will contain the RAS ROM address.
477480
*/
478-
bool amdgpu_atomfirmware_ras_rom_addr(struct amdgpu_device *adev, uint8_t* i2c_address)
481+
bool amdgpu_atomfirmware_ras_rom_addr(struct amdgpu_device *adev,
482+
u8 *i2c_address)
479483
{
480484
struct amdgpu_mode_info *mode_info = &adev->mode_info;
481485
int index;
482486
u16 data_offset, size;
483487
union firmware_info *firmware_info;
484488
u8 frev, crev;
485489

486-
if (i2c_address == NULL)
487-
return false;
488-
489-
*i2c_address = 0;
490-
491490
index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
492-
firmwareinfo);
491+
firmwareinfo);
493492

494493
if (amdgpu_atom_parse_data_header(adev->mode_info.atom_context,
495-
index, &size, &frev, &crev, &data_offset)) {
494+
index, &size, &frev, &crev,
495+
&data_offset)) {
496496
/* support firmware_info 3.4 + */
497497
if ((frev == 3 && crev >=4) || (frev > 3)) {
498498
firmware_info = (union firmware_info *)
499499
(mode_info->atom_context->bios + data_offset);
500-
*i2c_address = firmware_info->v34.ras_rom_i2c_slave_addr;
500+
/* The ras_rom_i2c_slave_addr should ideally
501+
* be a 19-bit EEPROM address, which would be
502+
* used as is by the driver; see top of
503+
* amdgpu_eeprom.c.
504+
*
505+
* When this is the case, 0 is of course a
506+
* valid RAS EEPROM address, in which case,
507+
* we'll drop the first "if (firm...)" and only
508+
* leave the check for the pointer.
509+
*
510+
* The reason this works right now is because
511+
* ras_rom_i2c_slave_addr contains the EEPROM
512+
* device type qualifier 1010b in the top 4
513+
* bits.
514+
*/
515+
if (firmware_info->v34.ras_rom_i2c_slave_addr) {
516+
if (i2c_address)
517+
*i2c_address = firmware_info->v34.ras_rom_i2c_slave_addr;
518+
return true;
519+
}
501520
}
502521
}
503522

504-
if (*i2c_address != 0)
505-
return true;
506-
507523
return false;
508524
}
509525

0 commit comments

Comments
 (0)