[PATCH] drm/xe: Fix static analysis tool reported errors
Poosa, Karthik
karthik.poosa at intel.com
Mon Mar 25 13:55:05 UTC 2024
It checks but still returns NULL if gt is NULL, instead of XE_WARN_ON.
Should that check be added there.
static inline struct xe_gt *xe_device_get_gt(struct xe_device *xe, u8 gt_id)
{
struct xe_tile *root_tile = xe_device_get_root_tile(xe);
struct xe_gt *gt;
/*
* FIXME: This only works for now because multi-tile and standalone
* media are mutually exclusive on the platforms we have today.
*
* id => GT mapping may change once we settle on how we want to
handle
* our UAPI.
*/
if (MEDIA_VER(xe) >= 13) {
gt = xe_tile_get_gt(root_tile, gt_id);
} else {
if (drm_WARN_ON(&xe->drm, gt_id >=
XE_MAX_TILES_PER_DEVICE))
gt_id = 0;
gt = xe->tiles[gt_id].primary_gt;
}
if (!gt)
return NULL;
On 25-03-2024 19:09, Poosa, Karthik wrote:
> This check is not needed, already xe_device_get_gt internally checks
> gt for NULL.
>
> On 25-03-2024 18:59, Nilawar, Badal wrote:
>>
>>
>> On 25-03-2024 13:35, Karthik Poosa wrote:
>>> Add a NULL pointer check.
>>>
>>> v2: Release resources before returning error. (Riana)
>>>
>>> v3: Update commit message. (Badal)
>>>
>>> v4: Change drm_err to XE_WARN_ON. (Anshuman)
>>>
>>> v5: Fix XE_WARN_ON check. (Riana)
>>>
>>> Fixes: 09d88e3beb64 ("drm/xe/pm: Init pcode and restore vram on
>>> power lost")
>>> Signed-off-by: Karthik Poosa <karthik.poosa at intel.com>
>>> ---
>>> drivers/gpu/drm/xe/xe_pm.c | 5 +++++
>>> 1 file changed, 5 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
>>> index cc650a92c2fc..f6837bd6f9a3 100644
>>> --- a/drivers/gpu/drm/xe/xe_pm.c
>>> +++ b/drivers/gpu/drm/xe/xe_pm.c
>>> @@ -383,6 +383,11 @@ int xe_pm_runtime_resume(struct xe_device *xe)
>>> * really lost power. Detecting primary Gt power is sufficient.
>>> */
>>> gt = xe_device_get_gt(xe, 0);
>>> + if (XE_WARN_ON(!gt)) {
>> Is this check really needed? xe_pm_ops will get installed when driver
>> probe is successful and driver probe successful means root tile
>> primary_gt exists.
>>
>> Regards,
>> Badal
>>> + err = -ENXIO;
>>> + goto out;
>>> + }
>>> +
>>> xe->d3cold.power_lost = xe_guc_in_reset(>->uc.guc);
>>> if (xe->d3cold.allowed && xe->d3cold.power_lost) {
More information about the Intel-xe
mailing list