drm/amdgpu: also track late init state

Submitted by Grazvydas Ignotas on Oct. 2, 2016, 9:06 p.m.

Details

Message ID 1475442406-2096-1-git-send-email-notasas@gmail.com
State New
Headers show
Series "drm/amdgpu: also track late init state" ( rev: 1 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

Grazvydas Ignotas Oct. 2, 2016, 9:06 p.m.
Successful sw_init() and hw_init() states are tracked, but not
late_init(). Various error paths may result in amdgpu_fini() being
called before .late init is done, so late_init needs to be tracked
to avoid unexpected or multiple .late_fini() calls.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++++
 2 files changed, 5 insertions(+)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index b9cc003..4e510092 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1943,6 +1943,7 @@  struct amdgpu_ip_block_status {
 	bool valid;
 	bool sw;
 	bool hw;
+	bool late_initialized;
 	bool hang;
 };
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 9933ab7..0c57898 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1450,6 +1450,7 @@  static int amdgpu_late_init(struct amdgpu_device *adev)
 				DRM_ERROR("late_init of IP block <%s> failed %d\n", adev->ip_blocks[i].funcs->name, r);
 				return r;
 			}
+			adev->ip_block_status[i].late_initialized = true;
 		}
 	}
 
@@ -1495,8 +1496,11 @@  static int amdgpu_fini(struct amdgpu_device *adev)
 	}
 
 	for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
+		if (!adev->ip_block_status[i].late_initialized)
+			continue;
 		if (adev->ip_blocks[i].funcs->late_fini)
 			adev->ip_blocks[i].funcs->late_fini((void *)adev);
+		adev->ip_block_status[i].late_initialized = false;
 	}
 
 	return 0;

Comments

On Sun, Oct 2, 2016 at 5:06 PM, Grazvydas Ignotas <notasas@gmail.com> wrote:
> Successful sw_init() and hw_init() states are tracked, but not
> late_init(). Various error paths may result in amdgpu_fini() being
> called before .late init is done, so late_init needs to be tracked
> to avoid unexpected or multiple .late_fini() calls.
>
> Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>

Applied.  thanks!

Alex

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h        | 1 +
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++++
>  2 files changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index b9cc003..4e510092 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -1943,6 +1943,7 @@ struct amdgpu_ip_block_status {
>         bool valid;
>         bool sw;
>         bool hw;
> +       bool late_initialized;
>         bool hang;
>  };
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 9933ab7..0c57898 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -1450,6 +1450,7 @@ static int amdgpu_late_init(struct amdgpu_device *adev)
>                                 DRM_ERROR("late_init of IP block <%s> failed %d\n", adev->ip_blocks[i].funcs->name, r);
>                                 return r;
>                         }
> +                       adev->ip_block_status[i].late_initialized = true;
>                 }
>         }
>
> @@ -1495,8 +1496,11 @@ static int amdgpu_fini(struct amdgpu_device *adev)
>         }
>
>         for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
> +               if (!adev->ip_block_status[i].late_initialized)
> +                       continue;
>                 if (adev->ip_blocks[i].funcs->late_fini)
>                         adev->ip_blocks[i].funcs->late_fini((void *)adev);
> +               adev->ip_block_status[i].late_initialized = false;
>         }
>
>         return 0;
> --
> 2.7.4
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx