On 2021-06-11 9:05 a.m., Hawking Zhang wrote: > PSP will dump various boot up information into a > portion of local frame buffer, called runtime database. > The helper function is used for driver to query those > shared information. > > v2: init ret and check !ret to exit loop as soon as > found the entry > > Signed-off-by: Hawking Zhang <Hawking.Zhang@xxxxxxx> > Reviewed-by: John Clements <john.clements@xxxxxxx> > Reviewed-by: Lijo Lazar <lijo.lazar@xxxxxxx> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 68 +++++++++++++++++++++++++ > 1 file changed, 68 insertions(+) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c > index ab4e89186186..dc786c91ec9d 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c > @@ -164,6 +164,74 @@ static int psp_memory_training_init(struct psp_context *psp) > return ret; > } > > +/* > + * Helper funciton to query psp runtime database entry > + * > + * @adev: amdgpu_device pointer > + * @entry_type: the type of psp runtime database entry > + * @db_entry: runtime database entry pointer > + * > + * Return false if runtime database doesn't exit or entry is invalid > + * or true if the specific database entry is found, and copy to @db_entry > + */ > +static bool psp_get_runtime_db_entry(struct amdgpu_device *adev, > + enum psp_runtime_entry_type entry_type, > + void *db_entry) > +{ > + uint64_t db_header_pos, db_dir_pos; > + struct psp_runtime_data_header db_header = {0}; > + struct psp_runtime_data_directory db_dir = {0}; > + bool ret = false; > + int i; > + > + db_header_pos = adev->gmc.mc_vram_size - PSP_RUNTIME_DB_OFFSET; > + db_dir_pos = db_header_pos + sizeof(struct psp_runtime_data_header); > + > + /* read runtime db header from vram */ > + amdgpu_device_vram_access(adev, db_header_pos, (uint32_t *)&db_header, > + sizeof(struct psp_runtime_data_header), false); > + > + if (db_header.cookie != PSP_RUNTIME_DB_COOKIE_ID) { > + /* runtime db doesn't exist, exit */ > + dev_warn(adev->dev, "PSP runtime database doesn't exist\n"); > + return false; > + } I just noticed this message in the output of dmesg -l emerg,alert,crit,err,warn I wonder if these messages really need to be printed by default at all, let alone at warning level. Do they indicate an issue which needs to be addressed? > + /* read runtime database entry from vram */ > + amdgpu_device_vram_access(adev, db_dir_pos, (uint32_t *)&db_dir, > + sizeof(struct psp_runtime_data_directory), false); > + > + if (db_dir.entry_count >= PSP_RUNTIME_DB_DIAG_ENTRY_MAX_COUNT) { > + /* invalid db entry count, exit */ > + dev_warn(adev->dev, "Invalid PSP runtime database entry count\n"); > + return false; > + } -- Earthling Michel Dänzer | https://redhat.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list amd-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/amd-gfx