* [PATCH v6] drm/xe: Add a null pointer check
@ 2024-03-25 14:12 Karthik Poosa
2024-03-25 14:45 ` Michal Wajdeczko
2024-03-25 17:58 ` Matt Roper
0 siblings, 2 replies; 4+ messages in thread
From: Karthik Poosa @ 2024-03-25 14:12 UTC (permalink / raw)
To: intel-xe
Cc: anshuman.gupta, badal.nilawar, riana.tauro, jani.nikula,
Karthik Poosa
Add a missing 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)
v6: Update commit message. (Jani)
Fixes: 09d88e3beb64 ("drm/xe/pm: Init pcode and restore vram on power lost")
Signed-off-by: Karthik Poosa <karthik.poosa@intel.com>
Reviewed-by: Riana Tauro <riana.tauro@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)) {
+ err = -ENXIO;
+ goto out;
+ }
+
xe->d3cold.power_lost = xe_guc_in_reset(>->uc.guc);
if (xe->d3cold.allowed && xe->d3cold.power_lost) {
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v6] drm/xe: Add a null pointer check
2024-03-25 14:12 [PATCH v6] drm/xe: Add a null pointer check Karthik Poosa
@ 2024-03-25 14:45 ` Michal Wajdeczko
2024-03-25 17:58 ` Matt Roper
1 sibling, 0 replies; 4+ messages in thread
From: Michal Wajdeczko @ 2024-03-25 14:45 UTC (permalink / raw)
To: Karthik Poosa, intel-xe
Cc: anshuman.gupta, badal.nilawar, riana.tauro, jani.nikula
On 25.03.2024 15:12, Karthik Poosa wrote:
> Add a missing 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)
>
> v6: Update commit message. (Jani)
>
> Fixes: 09d88e3beb64 ("drm/xe/pm: Init pcode and restore vram on power lost")
> Signed-off-by: Karthik Poosa <karthik.poosa@intel.com>
> Reviewed-by: Riana Tauro <riana.tauro@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);
maybe easier way to silence the tool is to use:
gt = xe_root_mmio_gt(xe);
that don't have a path with NULL as return
> + if (XE_WARN_ON(!gt)) {
but if you still want to add the WARN for the impossible case then as we
have xe it is better to use drm_WARN_ON()
> + err = -ENXIO;
> + goto out;
> + }
> +
> xe->d3cold.power_lost = xe_guc_in_reset(>->uc.guc);
>
> if (xe->d3cold.allowed && xe->d3cold.power_lost) {
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v6] drm/xe: Add a null pointer check
2024-03-25 14:12 [PATCH v6] drm/xe: Add a null pointer check Karthik Poosa
2024-03-25 14:45 ` Michal Wajdeczko
@ 2024-03-25 17:58 ` Matt Roper
2024-03-26 15:23 ` Poosa, Karthik
1 sibling, 1 reply; 4+ messages in thread
From: Matt Roper @ 2024-03-25 17:58 UTC (permalink / raw)
To: Karthik Poosa
Cc: intel-xe, anshuman.gupta, badal.nilawar, riana.tauro, jani.nikula
On Mon, Mar 25, 2024 at 07:42:23PM +0530, Karthik Poosa wrote:
> Add a missing null pointer check.
You have so many versions of this patch that I've lost track of which is
which, but as I commented on an earlier version, this whole patch seems
unnecessary. All Intel devices will have at least one GT, and we can
never "resume from runtime PM" before those GT(s) get initialized. So a
NULL return here is impossible. If you want to be paranoid, you can add
an assert to make that invariant clear and it will get compiled out of
production releases.
Matt
>
> 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)
>
> v6: Update commit message. (Jani)
>
> Fixes: 09d88e3beb64 ("drm/xe/pm: Init pcode and restore vram on power lost")
> Signed-off-by: Karthik Poosa <karthik.poosa@intel.com>
> Reviewed-by: Riana Tauro <riana.tauro@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)) {
> + err = -ENXIO;
> + goto out;
> + }
> +
> xe->d3cold.power_lost = xe_guc_in_reset(>->uc.guc);
>
> if (xe->d3cold.allowed && xe->d3cold.power_lost) {
> --
> 2.25.1
>
--
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v6] drm/xe: Add a null pointer check
2024-03-25 17:58 ` Matt Roper
@ 2024-03-26 15:23 ` Poosa, Karthik
0 siblings, 0 replies; 4+ messages in thread
From: Poosa, Karthik @ 2024-03-26 15:23 UTC (permalink / raw)
To: Matt Roper
Cc: intel-xe, anshuman.gupta, badal.nilawar, riana.tauro, jani.nikula
On 25-03-2024 23:28, Matt Roper wrote:
> On Mon, Mar 25, 2024 at 07:42:23PM +0530, Karthik Poosa wrote:
>> Add a missing null pointer check.
> You have so many versions of this patch that I've lost track of which is
> which, but as I commented on an earlier version, this whole patch seems
> unnecessary. All Intel devices will have at least one GT, and we can
> never "resume from runtime PM" before those GT(s) get initialized. So a
> NULL return here is impossible. If you want to be paranoid, you can add
> an assert to make that invariant clear and it will get compiled out of
> production releases.
>
>
> Matt
Unfortunately, I missed your comment on earlier version (v2). Will drop
this patch.
>
>> 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)
>>
>> v6: Update commit message. (Jani)
>>
>> Fixes: 09d88e3beb64 ("drm/xe/pm: Init pcode and restore vram on power lost")
>> Signed-off-by: Karthik Poosa <karthik.poosa@intel.com>
>> Reviewed-by: Riana Tauro <riana.tauro@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)) {
>> + err = -ENXIO;
>> + goto out;
>> + }
>> +
>> xe->d3cold.power_lost = xe_guc_in_reset(>->uc.guc);
>>
>> if (xe->d3cold.allowed && xe->d3cold.power_lost) {
>> --
>> 2.25.1
>>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-03-26 15:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-25 14:12 [PATCH v6] drm/xe: Add a null pointer check Karthik Poosa
2024-03-25 14:45 ` Michal Wajdeczko
2024-03-25 17:58 ` Matt Roper
2024-03-26 15:23 ` Poosa, Karthik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox