> 
alan: [snip]
> [Severity: Medium]
> Can the first else branch inside if (survive_err) ever be reached, and does
> the second else branch log a misleading message on unsupported platforms?
> 
> In drivers/gpu/drm/xe/xe_survivability_mode.c,
> xe_survivability_mode_boot_enable() immediately re-checks
> xe_survivability_mode_is_requested(xe) and returns 0 when it is false:
> 
> int xe_survivability_mode_boot_enable(struct xe_device *xe)
> {
>       struct xe_survivability *survivability = &xe->survivability;
>       struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
> 
>       if (!xe_survivability_mode_is_requested(xe))
>               return 0;
> 
> And xe_survivability_mode_is_requested() returns false both when
> survivability is not requested and when the platform or VF does not support
> survivability mode:
> 
> bool xe_survivability_mode_is_requested(struct xe_device *xe)
> {
>       ...
>       if (!IS_DGFX(xe) || IS_SRIOV_VF(xe) || xe->info.platform < 
> XE_BATTLEMAGE)
>               return false;
> 
> Because xe_survivability_mode_boot_enable() returns 0 whenever
> xe_survivability_mode_is_requested() is false:
> 
> 1. In xe_device_probe_early(), when pcode_err is non-zero and
>    survival_requested is false, survive_err will be 0 (unless the redundant
>    second call to xe_survivability_mode_is_requested() reads a changed
>    configfs or PCODE_SCRATCH(0) state, in which case survivability was
>    actually requested). That makes the "Early pcode err(%pe), survivability
>    not requested and unavailable(%pe)" branch unreachable under normal
>    execution.
> 
> 2. On integrated GPUs, SR-IOV VFs, or dGPUs prior to XE_BATTLEMAGE where
>    survivability mode is unsupported (and where xe_config_device_is_visible()
>    in drivers/gpu/drm/xe/xe_configfs.c hides attr_survivability_mode), an
>    early pcode failure will have survive_err == 0 and survival_requested ==
>    false, falling through to log "Consider xe_configfs" even though the
>    survivability_mode configfs attribute is not available on that device.
> 
> Should xe_survivability_mode_boot_enable() or its helper distinguish between
> "unsupported" and "not requested", and avoid calling
> xe_survivability_mode_is_requested() twice?
> 
> 

alan: Shasiko's points are valid. i dont want to refactor the original code and 
change the flow, so i'll only limit
the messages so its never reflecting an invalid case.

Reply via email to