* [PATCH 1/2] drm/amdgpu: Fixes to returning VBIOS RAS EEPROM address
@ 2021-08-25 18:18 Luben Tuikov
2021-08-25 18:18 ` [PATCH 2/2] drm/amdgpu: Process any " Luben Tuikov
0 siblings, 1 reply; 3+ messages in thread
From: Luben Tuikov @ 2021-08-25 18:18 UTC (permalink / raw)
To: amd-gfx; +Cc: Luben Tuikov, John Clements, Hawking Zhang, Alex Deucher
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 use
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 <john.clements@amd.com>
Cc: Hawking Zhang <Hawking.Zhang@amd.com>
Cc: Alex Deucher <Alexander.Deucher@amd.com>
Signed-off-by: Luben Tuikov <luben.tuikov@amd.com>
---
.../gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c | 50 ++++++++++++-------
1 file changed, 33 insertions(+), 17 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
index 8f53837d4d3ee8..97178b307ed6f9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
@@ -468,14 +468,18 @@ bool amdgpu_atomfirmware_dynamic_boot_config_supported(struct amdgpu_device *ade
return (fw_cap & ATOM_FIRMWARE_CAP_DYNAMIC_BOOT_CFG_ENABLE) ? true : false;
}
-/*
- * Helper function to query RAS EEPROM address
- *
- * @adev: amdgpu_device pointer
+/**
+ * amdgpu_atomfirmware_ras_rom_addr -- Get the RAS EEPROM addr from VBIOS
+ * adev: amdgpu_device pointer
+ * i2c_address: pointer to u8; if not NULL, will contain
+ * the RAS EEPROM address if the function returns true
*
- * Return true if vbios supports ras rom address reporting
+ * Return true if VBIOS supports RAS EEPROM address reporting,
+ * else return false. If true and @i2c_address is not NULL,
+ * will contain the RAS ROM address.
*/
-bool amdgpu_atomfirmware_ras_rom_addr(struct amdgpu_device *adev, uint8_t* i2c_address)
+bool amdgpu_atomfirmware_ras_rom_addr(struct amdgpu_device *adev,
+ u8 *i2c_address)
{
struct amdgpu_mode_info *mode_info = &adev->mode_info;
int index;
@@ -483,27 +487,39 @@ bool amdgpu_atomfirmware_ras_rom_addr(struct amdgpu_device *adev, uint8_t* i2c_a
union firmware_info *firmware_info;
u8 frev, crev;
- if (i2c_address == NULL)
- return false;
-
- *i2c_address = 0;
-
index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
- firmwareinfo);
+ firmwareinfo);
if (amdgpu_atom_parse_data_header(adev->mode_info.atom_context,
- index, &size, &frev, &crev, &data_offset)) {
+ index, &size, &frev, &crev,
+ &data_offset)) {
/* support firmware_info 3.4 + */
if ((frev == 3 && crev >=4) || (frev > 3)) {
firmware_info = (union firmware_info *)
(mode_info->atom_context->bios + data_offset);
- *i2c_address = firmware_info->v34.ras_rom_i2c_slave_addr;
+ /* The ras_rom_i2c_slave_addr should ideally
+ * be a 19-bit EEPROM address, which would be
+ * used as is by the driver; see top of
+ * amdgpu_eeprom.c.
+ *
+ * When this is the case, 0 is of course a
+ * valid RAS EEPROM address, in which case,
+ * we'll drop the first "if (firm...)" and only
+ * leave the check for the pointer.
+ *
+ * The reason this works right now is because
+ * ras_rom_i2c_slave_addr contains the EEPROM
+ * device type qualifier 1010b in the top 4
+ * bits.
+ */
+ if (firmware_info->v34.ras_rom_i2c_slave_addr) {
+ if (i2c_address)
+ *i2c_address = firmware_info->v34.ras_rom_i2c_slave_addr;
+ return true;
+ }
}
}
- if (*i2c_address != 0)
- return true;
-
return false;
}
--
2.32.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] drm/amdgpu: Process any VBIOS RAS EEPROM address
2021-08-25 18:18 [PATCH 1/2] drm/amdgpu: Fixes to returning VBIOS RAS EEPROM address Luben Tuikov
@ 2021-08-25 18:18 ` Luben Tuikov
2021-08-26 19:56 ` Alex Deucher
0 siblings, 1 reply; 3+ messages in thread
From: Luben Tuikov @ 2021-08-25 18:18 UTC (permalink / raw)
To: amd-gfx; +Cc: Luben Tuikov, John Clements, Hawking Zhang, Alex Deucher
We can now process any RAS EEPROM address from
VBIOS. Generalize so as to compute the top three
bits of the 19-bit EEPROM address, from any byte
returned as the "i2c address" from VBIOS.
Cc: John Clements <john.clements@amd.com>
Cc: Hawking Zhang <Hawking.Zhang@amd.com>
Cc: Alex Deucher <Alexander.Deucher@amd.com>
Signed-off-by: Luben Tuikov <luben.tuikov@amd.com>
---
.../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 25 ++++++++++---------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
index 194590252bb952..dc44c946a2442a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
@@ -114,21 +114,22 @@ static bool __get_eeprom_i2c_addr_arct(struct amdgpu_device *adev,
static bool __get_eeprom_i2c_addr(struct amdgpu_device *adev,
struct amdgpu_ras_eeprom_control *control)
{
+ u8 i2c_addr;
+
if (!control)
return false;
- control->i2c_address = 0;
-
- if (amdgpu_atomfirmware_ras_rom_addr(adev, (uint8_t*)&control->i2c_address))
- {
- if (control->i2c_address == 0xA0)
- control->i2c_address = 0;
- else if (control->i2c_address == 0xA8)
- control->i2c_address = 0x40000;
- else {
- dev_warn(adev->dev, "RAS EEPROM I2C address not supported");
- return false;
- }
+ if (amdgpu_atomfirmware_ras_rom_addr(adev, &i2c_addr)) {
+ /* The address given by VBIOS is an 8-bit, wire-format
+ * address, i.e. the most significant byte.
+ *
+ * Normalize it to a 19-bit EEPROM address. Remove the
+ * device type identifier and make it a 7-bit address;
+ * then make it a 19-bit EEPROM address. See top of
+ * amdgpu_eeprom.c.
+ */
+ i2c_addr = (i2c_addr & 0x0F) >> 1;
+ control->i2c_address = ((u32) i2c_addr) << 16;
return true;
}
--
2.32.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] drm/amdgpu: Process any VBIOS RAS EEPROM address
2021-08-25 18:18 ` [PATCH 2/2] drm/amdgpu: Process any " Luben Tuikov
@ 2021-08-26 19:56 ` Alex Deucher
0 siblings, 0 replies; 3+ messages in thread
From: Alex Deucher @ 2021-08-26 19:56 UTC (permalink / raw)
To: Luben Tuikov; +Cc: amd-gfx list, John Clements, Hawking Zhang, Alex Deucher
On Wed, Aug 25, 2021 at 2:32 PM Luben Tuikov <luben.tuikov@amd.com> wrote:
>
> We can now process any RAS EEPROM address from
> VBIOS. Generalize so as to compute the top three
> bits of the 19-bit EEPROM address, from any byte
> returned as the "i2c address" from VBIOS.
>
> Cc: John Clements <john.clements@amd.com>
> Cc: Hawking Zhang <Hawking.Zhang@amd.com>
> Cc: Alex Deucher <Alexander.Deucher@amd.com>
> Signed-off-by: Luben Tuikov <luben.tuikov@amd.com>
Series is:
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 25 ++++++++++---------
> 1 file changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
> index 194590252bb952..dc44c946a2442a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
> @@ -114,21 +114,22 @@ static bool __get_eeprom_i2c_addr_arct(struct amdgpu_device *adev,
> static bool __get_eeprom_i2c_addr(struct amdgpu_device *adev,
> struct amdgpu_ras_eeprom_control *control)
> {
> + u8 i2c_addr;
> +
> if (!control)
> return false;
>
> - control->i2c_address = 0;
> -
> - if (amdgpu_atomfirmware_ras_rom_addr(adev, (uint8_t*)&control->i2c_address))
> - {
> - if (control->i2c_address == 0xA0)
> - control->i2c_address = 0;
> - else if (control->i2c_address == 0xA8)
> - control->i2c_address = 0x40000;
> - else {
> - dev_warn(adev->dev, "RAS EEPROM I2C address not supported");
> - return false;
> - }
> + if (amdgpu_atomfirmware_ras_rom_addr(adev, &i2c_addr)) {
> + /* The address given by VBIOS is an 8-bit, wire-format
> + * address, i.e. the most significant byte.
> + *
> + * Normalize it to a 19-bit EEPROM address. Remove the
> + * device type identifier and make it a 7-bit address;
> + * then make it a 19-bit EEPROM address. See top of
> + * amdgpu_eeprom.c.
> + */
> + i2c_addr = (i2c_addr & 0x0F) >> 1;
> + control->i2c_address = ((u32) i2c_addr) << 16;
>
> return true;
> }
> --
> 2.32.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-08-26 19:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-25 18:18 [PATCH 1/2] drm/amdgpu: Fixes to returning VBIOS RAS EEPROM address Luben Tuikov
2021-08-25 18:18 ` [PATCH 2/2] drm/amdgpu: Process any " Luben Tuikov
2021-08-26 19:56 ` Alex Deucher
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.