drm/amdgpu: fix gpu reset issue
Subsystems (2)
PATCH 3/3 drm/amdgpu: fix gpu reset issue
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c | 7 ++++++- 4 files changed, 31 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +6 -0
@@ -1526,6 +1526,7 @@ struct amdgpu_device {atomic64_t num_bytes_moved;atomic64_t num_evictions;atomic_t gpu_reset_counter; +atomic_t gpu_reset_state;/* data for buffer migration throttling */ struct {
@@ -1851,6 +1852,11 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)#define amdgpu_psp_check_fw_loading_status (adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i))/* Common functions */ +static inline int amdgpu_device_is_reset (struct amdgpu_device *adev) +{ +return atomic_read (&adev->gpu_reset_state); +} +int amdgpu_gpu_reset (struct amdgpu_device *adev);bool amdgpu_need_backup (struct amdgpu_device *adev);void amdgpu_pci_config_reset (struct amdgpu_device *adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +15 -1
@@ -1894,6 +1894,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->grbm_idx_mutex);mutex_init (&adev->mn_lock);hash_init (adev->mn_hash); +atomic_set (&adev->gpu_reset_state,0 );amdgpu_check_arguments (adev);
@@ -2655,6 +2656,18 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, bool voluntary) }/** +* amdgpu_device_set_reset_state - set gpu reset state +* +* @adev: amdgpu device pointer +* @state: true when start to reset gpu; false: reset done +*/ +static inline void amdgpu_device_set_reset_state (struct amdgpu_device *adev, +bool state) +{ +atomic_set (&adev->gpu_reset_state, state); +} + +/** * amdgpu_gpu_reset - reset the asic * * @adev: amdgpu device pointer
@@ -2678,7 +2691,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) }atomic_inc (&adev->gpu_reset_counter); - +amdgpu_device_set_reset_state (adev, true);/* block TTM */ resched =ttm_bo_lock_delayed_workqueue (&adev->mman.bdev);/* store modesetting */
@@ -2811,6 +2824,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)dev_info (adev->dev,"GPU reset failed\n" ); } +amdgpu_device_set_reset_state (adev, false);return r; }
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4 -0
@@ -679,11 +679,15 @@ long amdgpu_drm_ioctl(struct file *filp,struct drm_file *file_priv = filp->private_data;struct drm_device *dev;long ret; + dev = file_priv->minor->dev; ret =pm_runtime_get_sync (dev->dev);if (ret <0 )return ret; +while (amdgpu_device_is_reset (dev->dev_private)) +msleep (100 ); + ret =drm_ioctl (filp, cmd, arg);pm_runtime_mark_last_busy (dev->dev);
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +6 -1
@@ -36,10 +36,15 @@long amdgpu_kms_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {unsigned int nr =DRM_IOCTL_NR (cmd); +struct drm_file *file_priv = filp->private_data; +struct amdgpu_device *adev = file_priv->minor->dev->dev_private;int ret; -if (nr <DRM_COMMAND_BASE ) +if (nr <DRM_COMMAND_BASE ) { +while (amdgpu_device_is_reset (adev)) +msleep (100 );return drm_compat_ioctl (filp, cmd, arg); + } ret =amdgpu_drm_ioctl (filp, cmd, arg);
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1492758490-12631-1-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org
Quoted 2 lines · Roger.He
Change-Id Ib77d33a09f348ebf2e3a9d7861411f4b951ebf7cSigned-off-by Roger.He <[email protected]>
Please add more explaination in comment, like "prevent ioctl during gpu reset, otherwise many un-expected behaviour happen."
Regards,
David Zhou
Quoted 110 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c | 7 ++++++- 4 files changed, 31 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +6
-0@@ -1526,6 +1526,7 @@ struct amdgpu_device {atomic64_t num_bytes_moved;atomic64_t num_evictions;atomic_t gpu_reset_counter; +atomic_t gpu_reset_state;/* data for buffer migration throttling */ struct {@@ -1851,6 +1852,11 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)#define amdgpu_psp_check_fw_loading_status (adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i))/* Common functions */ +static inline int amdgpu_device_is_reset (struct amdgpu_device *adev) +{ +return atomic_read (&adev->gpu_reset_state); +} +int amdgpu_gpu_reset (struct amdgpu_device *adev);bool amdgpu_need_backup (struct amdgpu_device *adev);void amdgpu_pci_config_reset (struct amdgpu_device *adev);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +15
-1@@ -1894,6 +1894,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->grbm_idx_mutex);mutex_init (&adev->mn_lock);hash_init (adev->mn_hash); +atomic_set (&adev->gpu_reset_state,0 );amdgpu_check_arguments (adev);@@ -2655,6 +2656,18 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, bool voluntary) }/** +* amdgpu_device_set_reset_state - set gpu reset state +* +* @adev: amdgpu device pointer +* @state: true when start to reset gpu; false: reset done +*/ +static inline void amdgpu_device_set_reset_state (struct amdgpu_device *adev, +bool state) +{ +atomic_set (&adev->gpu_reset_state, state); +} + +/** * amdgpu_gpu_reset - reset the asic * * @adev: amdgpu device pointer @@ -2678,7 +2691,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) }atomic_inc (&adev->gpu_reset_counter); - +amdgpu_device_set_reset_state (adev, true);/* block TTM */ resched =ttm_bo_lock_delayed_workqueue (&adev->mman.bdev);/* store modesetting */ @@ -2811,6 +2824,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)dev_info (adev->dev,"GPU reset failed\n" ); } +amdgpu_device_set_reset_state (adev, false);return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4
-0@@ -679,11 +679,15 @@ long amdgpu_drm_ioctl(struct file *filp,struct drm_file *file_priv = filp->private_data;struct drm_device *dev;long ret; + dev = file_priv->minor->dev; ret =pm_runtime_get_sync (dev->dev);if (ret <0 )return ret; +while (amdgpu_device_is_reset (dev->dev_private)) +msleep (100 ); + ret =drm_ioctl (filp, cmd, arg);pm_runtime_mark_last_busy (dev->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +2
-0@@ -36,10 +36,15 @@long amdgpu_kms_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {unsigned int nr =DRM_IOCTL_NR (cmd); +struct drm_file *file_priv = filp->private_data; +struct amdgpu_device *adev = file_priv->minor->dev->dev_private;int ret;
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c line 50
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +4
-1-if (nr <DRM_COMMAND_BASE ) +if (nr <DRM_COMMAND_BASE ) { +while (amdgpu_device_is_reset (adev)) +msleep (100 );return drm_compat_ioctl (filp, cmd, arg); + } ret =amdgpu_drm_ioctl (filp, cmd, arg);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
First of all, Your patch will impact on SR-IOV case, because "gpu_reset_state" will be referenced by two place:
1) IOCTL; 2)GPU-RESET ,
SRIOV use srio_gpu_reset, but SRIOV use the same IOCTL routines, that way the gpu_reset_state is not consistent for SR-IOV case
I suggest you firstly unify this gpu_reset_state for both SRIOV and bare-metal case
For sriov, we have "adev->gfx.in_reset " and you now have "adev->gpu_reset_state", I suggest you replace all "adev->gfx.in_reset" with "adev->gpu_reset_state",
BR Monk
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of zhoucm1
Sent: Friday, April 21, 2017 3:18 PM
To: He, Hongbo <[email protected]>; [email protected]
Subject: Re: [PATCH 3/3] drm/amdgpu: fix gpu reset issue
Quoted 2 lines · Roger.He
Change-Id Ib77d33a09f348ebf2e3a9d7861411f4b951ebf7cSigned-off-by Roger.He <[email protected]>
Please add more explaination in comment, like "prevent ioctl during gpu reset, otherwise many un-expected behaviour happen."
Regards,
David Zhou
Quoted 113 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c | 7 ++++++- 4 files changed, 31 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +6
-0@@ -1526,6 +1526,7 @@ struct amdgpu_device {atomic64_t num_bytes_moved;atomic64_t num_evictions;atomic_t gpu_reset_counter; +atomic_t gpu_reset_state;/* data for buffer migration throttling */ struct {@@ -1851,6 +1852,11 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)#define amdgpu_psp_check_fw_loading_status (adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i))/* Common functions */ +static inline int amdgpu_device_is_reset (struct amdgpu_device *adev) +{ +return atomic_read (&adev->gpu_reset_state); +} +int amdgpu_gpu_reset (struct amdgpu_device *adev);bool amdgpu_need_backup (struct amdgpu_device *adev);void
amdgpu_pci_config_reset(struct amdgpu_device *adev); diff --gita/drivers/gpu/drm/amd/amdgpu/amdgpu_device.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index f882496..0fb4716 100644drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +13
-1@@ -1894,6 +1894,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->grbm_idx_mutex);mutex_init (&adev->mn_lock);hash_init (adev->mn_hash); +atomic_set (&adev->gpu_reset_state,0 );amdgpu_check_arguments (adev);@@ -2655,6 +2656,18 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, bool voluntary) }/** +* amdgpu_device_set_reset_state - set gpu reset state +* +* @adev: amdgpu device pointer +* @state: true when start to reset gpu; false: reset done */ static +inline void amdgpu_device_set_reset_state (struct amdgpu_device *adev, +bool state) +{ +atomic_set (&adev->gpu_reset_state, state); } + +/** * amdgpu_gpu_reset - reset the asic * * @adev: amdgpu device pointer @@ -2678,7 +2691,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) }atomic_inc (&adev->gpu_reset_counter); - +amdgpu_device_set_reset_state (adev, true);/* block TTM */ resched =ttm_bo_lock_delayed_workqueue (&adev->mman.bdev);/* store modesetting */ @@ -2811,6 +2824,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)dev_info (adev->dev,"GPU reset failed\n" ); } +amdgpu_device_set_reset_state (adev, false);return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4
-0@@ -679,11 +679,15 @@ long amdgpu_drm_ioctl(struct file *filp,struct drm_file *file_priv = filp->private_data;struct drm_device *dev;long ret; + dev = file_priv->minor->dev; ret =pm_runtime_get_sync (dev->dev);if (ret <0 )return ret; +while (amdgpu_device_is_reset (dev->dev_private)) +msleep (100 ); + ret =drm_ioctl (filp, cmd, arg);pm_runtime_mark_last_busy (dev->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +2
-0@@ -36,10 +36,15 @@long amdgpu_kms_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {unsigned int nr =DRM_IOCTL_NR (cmd); +struct drm_file *file_priv = filp->private_data; +struct amdgpu_device *adev = file_priv->minor->dev->dev_private;int ret;
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c line 50
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +4
-1-if (nr <DRM_COMMAND_BASE ) +if (nr <DRM_COMMAND_BASE ) { +while (amdgpu_device_is_reset (adev)) +msleep (100 );return drm_compat_ioctl (filp, cmd, arg); + } ret =amdgpu_drm_ioctl (filp, cmd, arg);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): DM5PR12MB161079A7788AC1D9E4CD5D6284EA0-2J9CzHegvk++jCVTvoAFKAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Quoted 1 line
I suggest you firstly unify this
gpu_reset_statefor both SRIOV and bare-metal case
Yeah, that sounds like a good idea to me as well.
I suggest to have a function which covers things necessary for both cases, e.g. stopping the scheduler and blocking TTM.
And inside that one we call specific functions for bare metal and SRIOV for the special handling.
Regards,
Christian.
Am 04.05.2017 um 12:42 schrieb Liu, Monk:
Quoted 149 lines
First of all, Your patch will impact on SR-IOV case, because "
gpu_reset_state" will be referenced by two place:
1) IOCTL; 2)GPU-RESET ,
SRIOV usesrio_gpu_reset, but SRIOV use the same IOCTL routines, that way thegpu_reset_stateis not consistent for SR-IOV caseI suggest you firstly unify this
gpu_reset_statefor both SRIOV and bare-metal caseFor sriov, we have "
adev->gfx.in_reset" and you now have "adev->gpu_reset_state", I suggest you replace all "adev->gfx.in_reset" with "adev->gpu_reset_state",BR Monk
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of zhoucm1
Sent: Friday, April 21, 2017 3:18 PM
To: He, Hongbo <[email protected]>; [email protected]
Subject: Re: [PATCH 3/3] drm/amdgpu: fix gpu reset issueQuoted 2 lines · Roger.He
Change-Id Ib77d33a09f348ebf2e3a9d7861411f4b951ebf7cSigned-off-by Roger.He <[email protected]>Please add more explaination in comment, like "prevent ioctl during gpu reset, otherwise many un-expected behaviour happen."
Regards,
David ZhouQuoted 121 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c | 7 ++++++- 4 files changed, 31 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +6
-0@@ -1526,6 +1526,7 @@ struct amdgpu_device {atomic64_t num_bytes_moved;atomic64_t num_evictions;atomic_t gpu_reset_counter; +atomic_t gpu_reset_state;/* data for buffer migration throttling */ struct {@@ -1851,6 +1852,11 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)#define amdgpu_psp_check_fw_loading_status (adev, i) (adev)->firmware.funcs->check_fw_loading_status ((adev), (i)) /* Common functions */ +static inline int amdgpu_device_is_reset (struct amdgpu_device *adev) +{ +return atomic_read (&adev->gpu_reset_state); +} +int amdgpu_gpu_reset (struct amdgpu_device *adev);bool amdgpu_need_backup (struct amdgpu_device *adev);void amdgpu_pci_config_reset(struct amdgpu_device *adev); diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index f882496..0fb4716 100644drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +13
-1@@ -1894,6 +1894,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->grbm_idx_mutex);mutex_init (&adev->mn_lock);hash_init (adev->mn_hash); +atomic_set (&adev->gpu_reset_state,0 );amdgpu_check_arguments (adev);@@ -2655,6 +2656,18 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, bool voluntary) }/** +* amdgpu_device_set_reset_state - set gpu reset state +* +* @adev: amdgpu device pointer +* @state: true when start to reset gpu; false: reset done */ static +inline void amdgpu_device_set_reset_state (struct amdgpu_device *adev, +bool state) +{ +atomic_set (&adev->gpu_reset_state, state); } + +/** * amdgpu_gpu_reset - reset the asic * * @adev: amdgpu device pointer @@ -2678,7 +2691,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) }atomic_inc (&adev->gpu_reset_counter); - +amdgpu_device_set_reset_state (adev, true);/* block TTM */ resched =ttm_bo_lock_delayed_workqueue (&adev->mman.bdev);/* store modesetting */ @@ -2811,6 +2824,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)dev_info (adev->dev,"GPU reset failed\n" ); } +amdgpu_device_set_reset_state (adev, false);return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4
-0@@ -679,11 +679,15 @@ long amdgpu_drm_ioctl(struct file *filp,struct drm_file *file_priv = filp->private_data;struct drm_device *dev;long ret; + dev = file_priv->minor->dev; ret =pm_runtime_get_sync (dev->dev);if (ret <0 )return ret; +while (amdgpu_device_is_reset (dev->dev_private)) +msleep (100 ); + ret =drm_ioctl (filp, cmd, arg);pm_runtime_mark_last_busy (dev->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +6
-1@@ -36,10 +36,15 @@long amdgpu_kms_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {unsigned int nr =DRM_IOCTL_NR (cmd); +struct drm_file *file_priv = filp->private_data; +struct amdgpu_device *adev = file_priv->minor->dev->dev_private;int ret; -if (nr <DRM_COMMAND_BASE ) +if (nr <DRM_COMMAND_BASE ) { +while (amdgpu_device_is_reset (adev)) +msleep (100 );return drm_compat_ioctl (filp, cmd, arg); + }
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c line 50
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +0
-0ret =amdgpu_drm_ioctl (filp, cmd, arg);_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): c88049b2-2440-142e-129a-542c136b8d61-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
I still want to keep different police and design for bare-metal and sr-iov on gpu reset e.g. what I designed is per sched reset, not that like current bare-metal's reset all sched, etc...
after we all make this feature stable, we can consider merge most part into one
BR Monk
-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, May 04, 2017 7:30 PM
To: Liu, Monk <[email protected]>; Zhou, David(ChunMing) <[email protected]>; He, Hongbo <[email protected]>; [email protected]
Subject: Re: [PATCH 3/3] drm/amdgpu: fix gpu reset issue
Quoted 2 lines
I suggest you firstly unify this
gpu_reset_statefor both SRIOV and bare-metal case
Yeah, that sounds like a good idea to me as well.
I suggest to have a function which covers things necessary for both cases, e.g. stopping the scheduler and blocking TTM.
And inside that one we call specific functions for bare metal and SRIOV for the special handling.
Regards,
Christian.
Am 04.05.2017 um 12:42 schrieb Liu, Monk:
Quoted 153 lines
First of all, Your patch will impact on SR-IOV case, because "
gpu_reset_state" will be referenced by two place:
1) IOCTL; 2)GPU-RESET ,
SRIOV usesrio_gpu_reset, but SRIOV use the same IOCTL routines, that
way thegpu_reset_stateis not consistent for SR-IOV caseI suggest you firstly unify this
gpu_reset_statefor both SRIOV and bare-metal caseFor sriov, we have "
adev->gfx.in_reset" and you now have "adev->gpu_reset_state", I suggest you replace all "adev->gfx.in_reset" with "adev->gpu_reset_state",BR Monk
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of zhoucm1
Sent: Friday, April 21, 2017 3:18 PM
To: He, Hongbo <[email protected]>; [email protected]
Subject: Re: [PATCH 3/3] drm/amdgpu: fix gpu reset issueQuoted 2 lines · Roger.He
Change-Id Ib77d33a09f348ebf2e3a9d7861411f4b951ebf7cSigned-off-by Roger.He <[email protected]>Please add more explaination in comment, like "prevent ioctl during gpu reset, otherwise many un-expected behaviour happen."
Regards,
David ZhouQuoted 121 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c | 7 ++++++- 4 files changed, 31 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +6
-0@@ -1526,6 +1526,7 @@ struct amdgpu_device {atomic64_t num_bytes_moved;atomic64_t num_evictions;atomic_t gpu_reset_counter; +atomic_t gpu_reset_state;/* data for buffer migration throttling */ struct {@@ -1851,6 +1852,11 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)#define amdgpu_psp_check_fw_loading_status (adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i))/* Common functions */ +static inline int amdgpu_device_is_reset (struct amdgpu_device *adev) +{ +return atomic_read (&adev->gpu_reset_state); +} +int amdgpu_gpu_reset (struct amdgpu_device *adev);bool amdgpu_need_backup (struct amdgpu_device *adev);void
amdgpu_pci_config_reset(struct amdgpu_device *adev); diff
--gita/drivers/gpu/drm/amd/amdgpu/amdgpu_device.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index f882496..0fb4716 100644drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +13
-1@@ -1894,6 +1894,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->grbm_idx_mutex);mutex_init (&adev->mn_lock);hash_init (adev->mn_hash); +atomic_set (&adev->gpu_reset_state,0 );amdgpu_check_arguments (adev);@@ -2655,6 +2656,18 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, bool voluntary) }/** +* amdgpu_device_set_reset_state - set gpu reset state +* +* @adev: amdgpu device pointer +* @state: true when start to reset gpu; false: reset done */ +static inline void amdgpu_device_set_reset_state (struct amdgpu_device *adev, +bool state) +{ +atomic_set (&adev->gpu_reset_state, state); } + +/** * amdgpu_gpu_reset - reset the asic * * @adev: amdgpu device pointer @@ -2678,7 +2691,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) }atomic_inc (&adev->gpu_reset_counter); - +amdgpu_device_set_reset_state (adev, true);/* block TTM */ resched =ttm_bo_lock_delayed_workqueue (&adev->mman.bdev);/* store modesetting */ @@ -2811,6 +2824,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)dev_info (adev->dev,"GPU reset failed\n" ); } +amdgpu_device_set_reset_state (adev, false);return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4
-0@@ -679,11 +679,15 @@ long amdgpu_drm_ioctl(struct file *filp,struct drm_file *file_priv = filp->private_data;struct drm_device *dev;long ret; + dev = file_priv->minor->dev; ret =pm_runtime_get_sync (dev->dev);if (ret <0 )return ret; +while (amdgpu_device_is_reset (dev->dev_private)) +msleep (100 ); + ret =drm_ioctl (filp, cmd, arg);pm_runtime_mark_last_busy (dev->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +6
-1@@ -36,10 +36,15 @@long amdgpu_kms_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {unsigned int nr =DRM_IOCTL_NR (cmd); +struct drm_file *file_priv = filp->private_data; +struct amdgpu_device *adev = file_priv->minor->dev->dev_private;int ret; -if (nr <DRM_COMMAND_BASE ) +if (nr <DRM_COMMAND_BASE ) { +while (amdgpu_device_is_reset (adev)) +msleep (100 );return drm_compat_ioctl (filp, cmd, arg); + }
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c line 50
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +0
-0ret =amdgpu_drm_ioctl (filp, cmd, arg);_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 13 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Liu, Monk
Sent: Thursday, May 04, 2017 6:42 AM
To: Zhou, David(ChunMing); He, Hongbo; [email protected]
Subject: RE: [PATCH 3/3] drm/amdgpu: fix gpu reset issueFirst of all, Your patch will impact on SR-IOV case, because "
gpu_reset_state" will be referenced by two place:
1) IOCTL; 2)GPU-RESET ,
SRIOV usesrio_gpu_reset, but SRIOV use the same IOCTL routines, that way thegpu_reset_stateis not consistent for SR-IOV case
Quoted 6 lines
I suggest you firstly unify this
gpu_reset_statefor both SRIOV and bare- metal caseFor sriov, we have "
adev->gfx.in_reset" and you now have "adev-Quoted 1 line
gpu_reset_state",I suggest you replace all "
adev->gfx.in_reset" with "adev->gpu_reset_state",
Yes, I agree. Please unify these.
Alex
Quoted 151 lines
BR Monk
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of zhoucm1
Sent: Friday, April 21, 2017 3:18 PM
To: He, Hongbo <[email protected]>; [email protected]
Subject: Re: [PATCH 3/3] drm/amdgpu: fix gpu reset issueQuoted 2 lines · Roger.He
Change-Id Ib77d33a09f348ebf2e3a9d7861411f4b951ebf7cSigned-off-by Roger.He <[email protected]>Please add more explaination in comment, like "prevent ioctl during gpu reset, otherwise many un-expected behaviour happen."
Regards,
David ZhouQuoted 3 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16+++++++++++++++-
drivers/gpu/drm/amd/amdgpu/amdgpu.h amdgpu_get_sdma_instance(struct
Quoted 18 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c | 7 ++++++- 4 files changed, 31 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -1526,6 +1526,7 @@ struct amdgpu_device {atomic64_t num_bytes_moved;atomic64_t num_evictions;atomic_t gpu_reset_counter; +atomic_t gpu_reset_state;/* data for buffer migration throttling */ struct {@@ -1851,6 +1852,11 @@ amdgpu_get_sdma_instance(struct
amdgpu_ring*ring)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device
Quoted 18 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +5
-0#define amdgpu_psp_check_fw_loading_status (adev, i) (adev)->firmware.funcs->check_fw_loading_status ((adev), (i)) /* Common functions */ +static inline int amdgpu_device_is_reset (struct amdgpu_device *adev) +{ +return atomic_read (&adev->gpu_reset_state); +} +int amdgpu_gpu_reset (struct amdgpu_device *adev);bool amdgpu_need_backup (struct amdgpu_device *adev);void
amdgpu_pci_config_reset(struct amdgpu_device *adev); diff --gita/drivers/gpu/drm/amd/amdgpu/amdgpu_device.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index f882496..0fb4716 100644drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -1894,6 +1894,7 @@ int amdgpu_device_init(struct amdgpu_device*adev,
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_sriov_gpu_reset(struct
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0mutex_init (&adev->grbm_idx_mutex);mutex_init (&adev->mn_lock);hash_init (adev->mn_hash); +atomic_set (&adev->gpu_reset_state,0 );amdgpu_check_arguments (adev);@@ -2655,6 +2656,18 @@ int amdgpu_sriov_gpu_reset(struct
amdgpu_device*adev, bool voluntary)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, bool voluntary)
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5
-0}/** +* amdgpu_device_set_reset_state - set gpu reset state +* +* @adev: amdgpu device pointer +* @state: true when start to reset gpu; false: reset done */ static +inline void amdgpu_device_set_reset_state(struct amdgpu_device*adev,
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_gpu_reset(struct amdgpu_device
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5
-0+ bool state) +{ +atomic_set (&adev->gpu_reset_state, state); } + +/** * amdgpu_gpu_reset - reset the asic * * @adev: amdgpu device pointer @@ -2678,7 +2691,7 @@ int amdgpu_gpu_reset(struct amdgpu_device*adev)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_gpu_reset(struct amdgpu_device
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1}atomic_inc (&adev->gpu_reset_counter); - +amdgpu_device_set_reset_state (adev, true);/* block TTM */ resched =ttm_bo_lock_delayed_workqueue (&adev->mman.bdev);/* store modesetting */ @@ -2811,6 +2824,7 @@ int amdgpu_gpu_reset(struct amdgpu_device*adev)
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0dev_info (adev->dev,"GPU reset failed\n" ); } +amdgpu_device_set_reset_state (adev, false);return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4
-0@@ -679,11 +679,15 @@ long amdgpu_drm_ioctl(struct file *filp,struct drm_file *file_priv = filp->private_data;struct drm_device *dev;long ret; + dev = file_priv->minor->dev; ret =pm_runtime_get_sync (dev->dev);if (ret <0 )return ret; +while (amdgpu_device_is_reset (dev->dev_private)) +msleep (100 ); + ret =drm_ioctl (filp, cmd, arg);pm_runtime_mark_last_busy (dev->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c line 36
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +0
-0@@ -36,10 +36,15 @@ long amdgpu_kms_compat_ioctl(struct file *filp, unsigned int cmd,unsigned long arg)
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +6
-1{unsigned int nr =DRM_IOCTL_NR (cmd); +struct drm_file *file_priv = filp->private_data; +struct amdgpu_device *adev = file_priv->minor->dev->dev_private;int ret; -if (nr <DRM_COMMAND_BASE ) +if (nr <DRM_COMMAND_BASE ) { +while (amdgpu_device_is_reset (adev)) +msleep (100 );return drm_compat_ioctl (filp, cmd, arg); + }
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c line 50
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +0
-0ret =amdgpu_drm_ioctl (filp, cmd, arg);_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
NAKNAK, that is exactly what we wanted to avoid.
We used to have an exclusive lock for this and it cause a whole bunch of problems.
Please elaborate why that should be necessary.
Regards,
Christian.
Am 21.04.2017 um 09:08 schrieb Roger.He:
Quoted 112 lines
Change-Id Ib77d33a09f348ebf2e3a9d7861411f4b951ebf7cSigned-off-by Roger.He <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c | 7 ++++++- 4 files changed, 31 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +6
-0@@ -1526,6 +1526,7 @@ struct amdgpu_device {atomic64_t num_bytes_moved;atomic64_t num_evictions;atomic_t gpu_reset_counter; +atomic_t gpu_reset_state;/* data for buffer migration throttling */ struct {@@ -1851,6 +1852,11 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)#define amdgpu_psp_check_fw_loading_status (adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i))/* Common functions */ +static inline int amdgpu_device_is_reset (struct amdgpu_device *adev) +{ +return atomic_read (&adev->gpu_reset_state); +} +int amdgpu_gpu_reset (struct amdgpu_device *adev);bool amdgpu_need_backup (struct amdgpu_device *adev);void amdgpu_pci_config_reset (struct amdgpu_device *adev);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +15
-1@@ -1894,6 +1894,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->grbm_idx_mutex);mutex_init (&adev->mn_lock);hash_init (adev->mn_hash); +atomic_set (&adev->gpu_reset_state,0 );amdgpu_check_arguments (adev);@@ -2655,6 +2656,18 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, bool voluntary) }/** +* amdgpu_device_set_reset_state - set gpu reset state +* +* @adev: amdgpu device pointer +* @state: true when start to reset gpu; false: reset done +*/ +static inline void amdgpu_device_set_reset_state (struct amdgpu_device *adev, +bool state) +{ +atomic_set (&adev->gpu_reset_state, state); +} + +/** * amdgpu_gpu_reset - reset the asic * * @adev: amdgpu device pointer @@ -2678,7 +2691,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) }atomic_inc (&adev->gpu_reset_counter); - +amdgpu_device_set_reset_state (adev, true);/* block TTM */ resched =ttm_bo_lock_delayed_workqueue (&adev->mman.bdev);/* store modesetting */ @@ -2811,6 +2824,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)dev_info (adev->dev,"GPU reset failed\n" ); } +amdgpu_device_set_reset_state (adev, false);return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4
-0@@ -679,11 +679,15 @@ long amdgpu_drm_ioctl(struct file *filp,struct drm_file *file_priv = filp->private_data;struct drm_device *dev;long ret; + dev = file_priv->minor->dev; ret =pm_runtime_get_sync (dev->dev);if (ret <0 )return ret; +while (amdgpu_device_is_reset (dev->dev_private)) +msleep (100 ); + ret =drm_ioctl (filp, cmd, arg);pm_runtime_mark_last_busy (dev->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +2
-0@@ -36,10 +36,15 @@long amdgpu_kms_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {unsigned int nr =DRM_IOCTL_NR (cmd); +struct drm_file *file_priv = filp->private_data; +struct amdgpu_device *adev = file_priv->minor->dev->dev_private;int ret;
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c line 50
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +4
-1-if (nr <DRM_COMMAND_BASE ) +if (nr <DRM_COMMAND_BASE ) { +while (amdgpu_device_is_reset (adev)) +msleep (100 );return drm_compat_ioctl (filp, cmd, arg); + } ret =amdgpu_drm_ioctl (filp, cmd, arg);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): ef2c40cd-bb55-5921-9318-e0147f1b4719-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Hi Roger,
Could you try to move 'id->current_gpu_reset_count = atomic_read(&adev->gpu_reset_counter);' in amdgpu_vm_grab_id to no_flush_needed label.
Regards,
David Zhou
Quoted 117 lines · Christian König
NAK, that is exactly what we wanted to avoid.
We used to have an exclusive lock for this and it cause a whole bunch of problems.
Please elaborate why that should be necessary.
Regards,
Christian.Am 21.04.2017 um 09:08 schrieb Roger.He:
Quoted 107 lines
Change-Id Ib77d33a09f348ebf2e3a9d7861411f4b951ebf7cSigned-off-by Roger.He <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c | 7 ++++++- 4 files changed, 31 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +6
-0@@ -1526,6 +1526,7 @@ struct amdgpu_device {atomic64_t num_bytes_moved;atomic64_t num_evictions;atomic_t gpu_reset_counter; +atomic_t gpu_reset_state;/* data for buffer migration throttling */ struct {@@ -1851,6 +1852,11 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)#define amdgpu_psp_check_fw_loading_status (adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i))/* Common functions */ +static inline int amdgpu_device_is_reset (struct amdgpu_device *adev) +{ +return atomic_read (&adev->gpu_reset_state); +} +int amdgpu_gpu_reset (struct amdgpu_device *adev);bool amdgpu_need_backup (struct amdgpu_device *adev);void amdgpu_pci_config_reset(struct amdgpu_device *adev);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0@@ -1894,6 +1894,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->grbm_idx_mutex);mutex_init (&adev->mn_lock);hash_init (adev->mn_hash); +atomic_set (&adev->gpu_reset_state,0 );amdgpu_check_arguments (adev); @@ -2655,6 +2656,18 @@ int amdgpu_sriov_gpu_reset(structamdgpu_device *adev,bool voluntary)}
/**+ *
amdgpu_device_set_reset_state- set gpu reset state
+ *
+ * @adev: amdgpu device pointer
+ * @state: true when start to reset gpu; false: reset done
+ */
+static inline void amdgpu_device_set_reset_state(structamdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-1+ bool state) +{ +atomic_set (&adev->gpu_reset_state, state); +} + +/** * amdgpu_gpu_reset - reset the asic * * @adev: amdgpu device pointer @@ -2678,7 +2691,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) }atomic_inc (&adev->gpu_reset_counter); - +amdgpu_device_set_reset_state (adev, true);/* block TTM */ resched =ttm_bo_lock_delayed_workqueue (&adev->mman.bdev);/* store modesetting */ @@ -2811,6 +2824,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)dev_info (adev->dev,"GPU reset failed\n" ); } +amdgpu_device_set_reset_state (adev, false);return r; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index ead00d7..8cc14af 100644drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3
-0@@ -679,11 +679,15 @@ long amdgpu_drm_ioctl(struct file *filp,struct drm_file *file_priv = filp->private_data;struct drm_device *dev;long ret; + dev = file_priv->minor->dev; ret =pm_runtime_get_sync (dev->dev);if (ret <0 )return ret; + while (amdgpu_device_is_reset(dev->dev_private)) +msleep (100 ); + ret =drm_ioctl (filp, cmd, arg);pm_runtime_mark_last_busy (dev->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +2
-0@@ -36,10 +36,15 @@long amdgpu_kms_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {unsigned int nr =DRM_IOCTL_NR (cmd); +struct drm_file *file_priv = filp->private_data; +struct amdgpu_device *adev = file_priv->minor->dev->dev_private;
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c line 49
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +4
-0int ret; - if (nr < DRM_COMMAND_BASE) +if (nr <DRM_COMMAND_BASE ) { +while (amdgpu_device_is_reset (adev)) +msleep (100 );return drm_compat_ioctl (filp, cmd, arg); + } ret =amdgpu_drm_ioctl (filp, cmd, arg);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
He, Hongbo
NAKHi Christian:
During GPU reset, IOCTL still submit command to GPU.
That will result in lots of strange problems when we test this feature.
I have no better idea to handle this case. At that time, I have tried with return error directly rather than waiting GPU reset completion. But that doesn't work and it lead to other problems.
Thanks
Roger(Hongbo.He)
-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Friday, April 21, 2017 4:27 PM
To: He, Hongbo; [email protected]
Cc: Zhou, David(ChunMing)
Subject: Re: [PATCH 3/3] drm/amdgpu: fix gpu reset issue
NAK, that is exactly what we wanted to avoid.
We used to have an exclusive lock for this and it cause a whole bunch of problems.
Please elaborate why that should be necessary.
Regards,
Christian.
Am 21.04.2017 um 09:08 schrieb Roger.He:
Quoted 115 lines
Change-Id Ib77d33a09f348ebf2e3a9d7861411f4b951ebf7cSigned-off-by Roger.He <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c | 7 ++++++- 4 files changed, 31 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +6
-0@@ -1526,6 +1526,7 @@ struct amdgpu_device {atomic64_t num_bytes_moved;atomic64_t num_evictions;atomic_t gpu_reset_counter; +atomic_t gpu_reset_state;/* data for buffer migration throttling */ struct {@@ -1851,6 +1852,11 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)#define amdgpu_psp_check_fw_loading_status (adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i))/* Common functions */ +static inline int amdgpu_device_is_reset (struct amdgpu_device *adev) +{ +return atomic_read (&adev->gpu_reset_state); +} +int amdgpu_gpu_reset (struct amdgpu_device *adev);bool amdgpu_need_backup (struct amdgpu_device *adev);void
amdgpu_pci_config_reset(struct amdgpu_device *adev); diff --gita/drivers/gpu/drm/amd/amdgpu/amdgpu_device.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index f882496..0fb4716 100644drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +13
-1@@ -1894,6 +1894,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->grbm_idx_mutex);mutex_init (&adev->mn_lock);hash_init (adev->mn_hash); +atomic_set (&adev->gpu_reset_state,0 );amdgpu_check_arguments (adev);@@ -2655,6 +2656,18 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, bool voluntary) }/** +* amdgpu_device_set_reset_state - set gpu reset state +* +* @adev: amdgpu device pointer +* @state: true when start to reset gpu; false: reset done */ static +inline void amdgpu_device_set_reset_state (struct amdgpu_device *adev, +bool state) +{ +atomic_set (&adev->gpu_reset_state, state); } + +/** * amdgpu_gpu_reset - reset the asic * * @adev: amdgpu device pointer @@ -2678,7 +2691,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) }atomic_inc (&adev->gpu_reset_counter); - +amdgpu_device_set_reset_state (adev, true);/* block TTM */ resched =ttm_bo_lock_delayed_workqueue (&adev->mman.bdev);/* store modesetting */ @@ -2811,6 +2824,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)dev_info (adev->dev,"GPU reset failed\n" ); } +amdgpu_device_set_reset_state (adev, false);return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4
-0@@ -679,11 +679,15 @@ long amdgpu_drm_ioctl(struct file *filp,struct drm_file *file_priv = filp->private_data;struct drm_device *dev;long ret; + dev = file_priv->minor->dev; ret =pm_runtime_get_sync (dev->dev);if (ret <0 )return ret; +while (amdgpu_device_is_reset (dev->dev_private)) +msleep (100 ); + ret =drm_ioctl (filp, cmd, arg);pm_runtime_mark_last_busy (dev->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +2
-0@@ -36,10 +36,15 @@long amdgpu_kms_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {unsigned int nr =DRM_IOCTL_NR (cmd); +struct drm_file *file_priv = filp->private_data; +struct amdgpu_device *adev = file_priv->minor->dev->dev_private;int ret;
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c line 50
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +4
-1-if (nr <DRM_COMMAND_BASE ) +if (nr <DRM_COMMAND_BASE ) { +while (amdgpu_device_is_reset (adev)) +msleep (100 );return drm_compat_ioctl (filp, cmd, arg); + } ret =amdgpu_drm_ioctl (filp, cmd, arg);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): MWHPR1201MB01272142B19FFEB9EAD281F3FD1A0-3iK1xFAIwjq9imrIu4W8xGrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/[email protected]
Quoted 1 line
During GPU reset, IOCTL still submit command to GPU.
No it won't. We disable the GPU scheduler during GPU reset, so that isn't an issue.
Do you have a concrete problem (e.g. dmesg?) you ran into?
Regards,
Christian.
Am 21.04.2017 um 11:00 schrieb He, Hongbo:
Quoted 151 lines
Hi Christian:
During GPU reset, IOCTL still submit command to GPU.
That will result in lots of strange problems when we test this feature.I have no better idea to handle this case. At that time, I have tried with return error directly rather than waiting GPU reset completion. But that doesn't work and it lead to other problems.
Thanks
Roger(Hongbo.He)-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Friday, April 21, 2017 4:27 PM
To: He, Hongbo; [email protected]
Cc: Zhou, David(ChunMing)
Subject: Re: [PATCH 3/3] drm/amdgpu: fix gpu reset issueNAK, that is exactly what we wanted to avoid.
We used to have an exclusive lock for this and it cause a whole bunch of problems.
Please elaborate why that should be necessary.
Regards,
Christian.Am 21.04.2017 um 09:08 schrieb Roger.He:
Quoted 123 lines
Change-Id Ib77d33a09f348ebf2e3a9d7861411f4b951ebf7cSigned-off-by Roger.He <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c | 7 ++++++- 4 files changed, 31 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +6
-0@@ -1526,6 +1526,7 @@ struct amdgpu_device {atomic64_t num_bytes_moved;atomic64_t num_evictions;atomic_t gpu_reset_counter; +atomic_t gpu_reset_state;/* data for buffer migration throttling */ struct {@@ -1851,6 +1852,11 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)#define amdgpu_psp_check_fw_loading_status (adev, i) (adev)->firmware.funcs->check_fw_loading_status ((adev), (i)) /* Common functions */ +static inline int amdgpu_device_is_reset (struct amdgpu_device *adev) +{ +return atomic_read (&adev->gpu_reset_state); +} +int amdgpu_gpu_reset (struct amdgpu_device *adev);bool amdgpu_need_backup (struct amdgpu_device *adev);void amdgpu_pci_config_reset(struct amdgpu_device *adev); diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index f882496..0fb4716 100644drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +13
-1@@ -1894,6 +1894,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->grbm_idx_mutex);mutex_init (&adev->mn_lock);hash_init (adev->mn_hash); +atomic_set (&adev->gpu_reset_state,0 );amdgpu_check_arguments (adev);@@ -2655,6 +2656,18 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, bool voluntary) }/** +* amdgpu_device_set_reset_state - set gpu reset state +* +* @adev: amdgpu device pointer +* @state: true when start to reset gpu; false: reset done */ static +inline void amdgpu_device_set_reset_state (struct amdgpu_device *adev, +bool state) +{ +atomic_set (&adev->gpu_reset_state, state); } + +/** * amdgpu_gpu_reset - reset the asic * * @adev: amdgpu device pointer @@ -2678,7 +2691,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) }atomic_inc (&adev->gpu_reset_counter); - +amdgpu_device_set_reset_state (adev, true);/* block TTM */ resched =ttm_bo_lock_delayed_workqueue (&adev->mman.bdev);/* store modesetting */ @@ -2811,6 +2824,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)dev_info (adev->dev,"GPU reset failed\n" ); } +amdgpu_device_set_reset_state (adev, false);return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4
-0@@ -679,11 +679,15 @@ long amdgpu_drm_ioctl(struct file *filp,struct drm_file *file_priv = filp->private_data;struct drm_device *dev;long ret; + dev = file_priv->minor->dev; ret =pm_runtime_get_sync (dev->dev);if (ret <0 )return ret; +while (amdgpu_device_is_reset (dev->dev_private)) +msleep (100 ); + ret =drm_ioctl (filp, cmd, arg);pm_runtime_mark_last_busy (dev->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +6
-1@@ -36,10 +36,15 @@long amdgpu_kms_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {unsigned int nr =DRM_IOCTL_NR (cmd); +struct drm_file *file_priv = filp->private_data; +struct amdgpu_device *adev = file_priv->minor->dev->dev_private;int ret; -if (nr <DRM_COMMAND_BASE ) +if (nr <DRM_COMMAND_BASE ) { +while (amdgpu_device_is_reset (adev)) +msleep (100 );return drm_compat_ioctl (filp, cmd, arg); + }
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c line 50
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +0
-0ret =amdgpu_drm_ioctl (filp, cmd, arg);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 05b9d783-75ab-9924-6881-472540fc77d1-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Quoted 1 line
During GPU reset, IOCTL still submit command to GPU.
No it won't. We disable the GPU scheduler during GPU reset, so that isn't an issue.
Could you point out the related code? Thanks.
Thanks
Roger(Hongbo.He)
-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Friday, April 21, 2017 5:16 PM
To: He, Hongbo; [email protected]
Cc: Zhou, David(ChunMing)
Subject: Re: [PATCH 3/3] drm/amdgpu: fix gpu reset issue
Quoted 1 line
During GPU reset, IOCTL still submit command to GPU.
No it won't. We disable the GPU scheduler during GPU reset, so that isn't an issue.
Do you have a concrete problem (e.g. dmesg?) you ran into?
Regards,
Christian.
Am 21.04.2017 um 11:00 schrieb He, Hongbo:
Quoted 151 lines
Hi Christian:
During GPU reset, IOCTL still submit command to GPU.
That will result in lots of strange problems when we test this feature.I have no better idea to handle this case. At that time, I have tried with return error directly rather than waiting GPU reset completion. But that doesn't work and it lead to other problems.
Thanks
Roger(Hongbo.He)-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Friday, April 21, 2017 4:27 PM
To: He, Hongbo; [email protected]
Cc: Zhou, David(ChunMing)
Subject: Re: [PATCH 3/3] drm/amdgpu: fix gpu reset issueNAK, that is exactly what we wanted to avoid.
We used to have an exclusive lock for this and it cause a whole bunch of problems.
Please elaborate why that should be necessary.
Regards,
Christian.Am 21.04.2017 um 09:08 schrieb Roger.He:
Quoted 123 lines
Change-Id Ib77d33a09f348ebf2e3a9d7861411f4b951ebf7cSigned-off-by Roger.He <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c | 7 ++++++- 4 files changed, 31 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +6
-0@@ -1526,6 +1526,7 @@ struct amdgpu_device {atomic64_t num_bytes_moved;atomic64_t num_evictions;atomic_t gpu_reset_counter; +atomic_t gpu_reset_state;/* data for buffer migration throttling */ struct {@@ -1851,6 +1852,11 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)#define amdgpu_psp_check_fw_loading_status (adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i))/* Common functions */ +static inline int amdgpu_device_is_reset (struct amdgpu_device *adev) +{ +return atomic_read (&adev->gpu_reset_state); +} +int amdgpu_gpu_reset (struct amdgpu_device *adev);bool amdgpu_need_backup (struct amdgpu_device *adev);void
amdgpu_pci_config_reset(struct amdgpu_device *adev); diff
--gita/drivers/gpu/drm/amd/amdgpu/amdgpu_device.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index f882496..0fb4716 100644drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +13
-1@@ -1894,6 +1894,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->grbm_idx_mutex);mutex_init (&adev->mn_lock);hash_init (adev->mn_hash); +atomic_set (&adev->gpu_reset_state,0 );amdgpu_check_arguments (adev);@@ -2655,6 +2656,18 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, bool voluntary) }/** +* amdgpu_device_set_reset_state - set gpu reset state +* +* @adev: amdgpu device pointer +* @state: true when start to reset gpu; false: reset done */ +static inline void amdgpu_device_set_reset_state (struct amdgpu_device *adev, +bool state) +{ +atomic_set (&adev->gpu_reset_state, state); } + +/** * amdgpu_gpu_reset - reset the asic * * @adev: amdgpu device pointer @@ -2678,7 +2691,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) }atomic_inc (&adev->gpu_reset_counter); - +amdgpu_device_set_reset_state (adev, true);/* block TTM */ resched =ttm_bo_lock_delayed_workqueue (&adev->mman.bdev);/* store modesetting */ @@ -2811,6 +2824,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)dev_info (adev->dev,"GPU reset failed\n" ); } +amdgpu_device_set_reset_state (adev, false);return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4
-0@@ -679,11 +679,15 @@ long amdgpu_drm_ioctl(struct file *filp,struct drm_file *file_priv = filp->private_data;struct drm_device *dev;long ret; + dev = file_priv->minor->dev; ret =pm_runtime_get_sync (dev->dev);if (ret <0 )return ret; +while (amdgpu_device_is_reset (dev->dev_private)) +msleep (100 ); + ret =drm_ioctl (filp, cmd, arg);pm_runtime_mark_last_busy (dev->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +6
-1@@ -36,10 +36,15 @@long amdgpu_kms_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {unsigned int nr =DRM_IOCTL_NR (cmd); +struct drm_file *file_priv = filp->private_data; +struct amdgpu_device *adev = file_priv->minor->dev->dev_private;int ret; -if (nr <DRM_COMMAND_BASE ) +if (nr <DRM_COMMAND_BASE ) { +while (amdgpu_device_is_reset (adev)) +msleep (100 );return drm_compat_ioctl (filp, cmd, arg); + }
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c line 50
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +0
-0ret =amdgpu_drm_ioctl (filp, cmd, arg);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): MWHPR1201MB0127A593761702A7A179855EFD1A0-3iK1xFAIwjq9imrIu4W8xGrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/[email protected]
See amdgpu_gpu_reset():
Quoted 9 lines
/* block scheduler */
for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
struct amdgpu_ring *ring = adev->rings[i];
if (!ring)
continue;
kthread_park(ring->sched.thread);
amd_sched_hw_job_reset(&ring->sched);
}and
Quoted 8 lines
for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { struct amdgpu_ring *ring = adev->rings[i]; if (!ring) continue;amd_sched_job_recovery(&ring->sched); kthread_unpark(ring->sched.thread); }
Regards,
Christian.
Am 21.04.2017 um 11:54 schrieb He, Hongbo:
Quoted 175 lines
Quoted 1 line
During GPU reset, IOCTL still submit command to GPU.
No it won't. We disable the GPU scheduler during GPU reset, so that isn't an issue.
Could you point out the related code? Thanks.Thanks
Roger(Hongbo.He)-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Friday, April 21, 2017 5:16 PM
To: He, Hongbo; [email protected]
Cc: Zhou, David(ChunMing)
Subject: Re: [PATCH 3/3] drm/amdgpu: fix gpu reset issueQuoted 1 line
During GPU reset, IOCTL still submit command to GPU.
No it won't. We disable the GPU scheduler during GPU reset, so that isn't an issue.
Do you have a concrete problem (e.g. dmesg?) you ran into?
Regards,
Christian.Am 21.04.2017 um 11:00 schrieb He, Hongbo:
Quoted 151 lines
Hi Christian:
During GPU reset, IOCTL still submit command to GPU.
That will result in lots of strange problems when we test this feature.I have no better idea to handle this case. At that time, I have tried with return error directly rather than waiting GPU reset completion. But that doesn't work and it lead to other problems.
Thanks
Roger(Hongbo.He)-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Friday, April 21, 2017 4:27 PM
To: He, Hongbo; [email protected]
Cc: Zhou, David(ChunMing)
Subject: Re: [PATCH 3/3] drm/amdgpu: fix gpu reset issueNAK, that is exactly what we wanted to avoid.
We used to have an exclusive lock for this and it cause a whole bunch of problems.
Please elaborate why that should be necessary.
Regards,
Christian.Am 21.04.2017 um 09:08 schrieb Roger.He:
Quoted 123 lines
Change-Id Ib77d33a09f348ebf2e3a9d7861411f4b951ebf7cSigned-off-by Roger.He <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c | 7 ++++++- 4 files changed, 31 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +6
-0@@ -1526,6 +1526,7 @@ struct amdgpu_device {atomic64_t num_bytes_moved;atomic64_t num_evictions;atomic_t gpu_reset_counter; +atomic_t gpu_reset_state;/* data for buffer migration throttling */ struct {@@ -1851,6 +1852,11 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)#define amdgpu_psp_check_fw_loading_status (adev, i) (adev)->firmware.funcs->check_fw_loading_status ((adev), (i)) /* Common functions */ +static inline int amdgpu_device_is_reset (struct amdgpu_device *adev) +{ +return atomic_read (&adev->gpu_reset_state); +} +int amdgpu_gpu_reset (struct amdgpu_device *adev);bool amdgpu_need_backup (struct amdgpu_device *adev);void
amdgpu_pci_config_reset(struct amdgpu_device *adev); diff
--gita/drivers/gpu/drm/amd/amdgpu/amdgpu_device.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index f882496..0fb4716 100644drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +13
-1@@ -1894,6 +1894,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->grbm_idx_mutex);mutex_init (&adev->mn_lock);hash_init (adev->mn_hash); +atomic_set (&adev->gpu_reset_state,0 );amdgpu_check_arguments (adev);@@ -2655,6 +2656,18 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, bool voluntary) }/** +* amdgpu_device_set_reset_state - set gpu reset state +* +* @adev: amdgpu device pointer +* @state: true when start to reset gpu; false: reset done */ +static inline void amdgpu_device_set_reset_state (struct amdgpu_device *adev, +bool state) +{ +atomic_set (&adev->gpu_reset_state, state); } + +/** * amdgpu_gpu_reset - reset the asic * * @adev: amdgpu device pointer @@ -2678,7 +2691,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) }atomic_inc (&adev->gpu_reset_counter); - +amdgpu_device_set_reset_state (adev, true);/* block TTM */ resched =ttm_bo_lock_delayed_workqueue (&adev->mman.bdev);/* store modesetting */ @@ -2811,6 +2824,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)dev_info (adev->dev,"GPU reset failed\n" ); } +amdgpu_device_set_reset_state (adev, false);return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4
-0@@ -679,11 +679,15 @@ long amdgpu_drm_ioctl(struct file *filp,struct drm_file *file_priv = filp->private_data;struct drm_device *dev;long ret; + dev = file_priv->minor->dev; ret =pm_runtime_get_sync (dev->dev);if (ret <0 )return ret; +while (amdgpu_device_is_reset (dev->dev_private)) +msleep (100 ); + ret =drm_ioctl (filp, cmd, arg);pm_runtime_mark_last_busy (dev->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +6
-1@@ -36,10 +36,15 @@long amdgpu_kms_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {unsigned int nr =DRM_IOCTL_NR (cmd); +struct drm_file *file_priv = filp->private_data; +struct amdgpu_device *adev = file_priv->minor->dev->dev_private;int ret; -if (nr <DRM_COMMAND_BASE ) +if (nr <DRM_COMMAND_BASE ) { +while (amdgpu_device_is_reset (adev)) +msleep (100 );return drm_compat_ioctl (filp, cmd, arg); + }
Quoted 6 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c line 50
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +0
-0ret =amdgpu_drm_ioctl (filp, cmd, arg);_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): eeb3931b-ef67-8645-a3bc-bc7f3db4002e-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Thank you!
-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Friday, April 21, 2017 7:47 PM
To: He, Hongbo; [email protected]
Cc: Zhou, David(ChunMing)
Subject: Re: [PATCH 3/3] drm/amdgpu: fix gpu reset issue
See amdgpu_gpu_reset():
Quoted 9 lines
/* block scheduler */
for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
struct amdgpu_ring *ring = adev->rings[i];
if (!ring)
continue;
kthread_park(ring->sched.thread);
amd_sched_hw_job_reset(&ring->sched);
}and
Quoted 8 lines
for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { struct amdgpu_ring *ring = adev->rings[i]; if (!ring) continue;amd_sched_job_recovery(&ring->sched); kthread_unpark(ring->sched.thread); }
Regards,
Christian.
Am 21.04.2017 um 11:54 schrieb He, Hongbo:
Quoted 175 lines
Quoted 1 line
During GPU reset, IOCTL still submit command to GPU.
No it won't. We disable the GPU scheduler during GPU reset, so that isn't an issue.
Could you point out the related code? Thanks.Thanks
Roger(Hongbo.He)-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Friday, April 21, 2017 5:16 PM
To: He, Hongbo; [email protected]
Cc: Zhou, David(ChunMing)
Subject: Re: [PATCH 3/3] drm/amdgpu: fix gpu reset issueQuoted 1 line
During GPU reset, IOCTL still submit command to GPU.
No it won't. We disable the GPU scheduler during GPU reset, so that isn't an issue.
Do you have a concrete problem (e.g. dmesg?) you ran into?
Regards,
Christian.Am 21.04.2017 um 11:00 schrieb He, Hongbo:
Quoted 151 lines
Hi Christian:
During GPU reset, IOCTL still submit command to GPU.
That will result in lots of strange problems when we test this feature.I have no better idea to handle this case. At that time, I have tried with return error directly rather than waiting GPU reset completion. But that doesn't work and it lead to other problems.
Thanks
Roger(Hongbo.He)-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Friday, April 21, 2017 4:27 PM
To: He, Hongbo; [email protected]
Cc: Zhou, David(ChunMing)
Subject: Re: [PATCH 3/3] drm/amdgpu: fix gpu reset issueNAK, that is exactly what we wanted to avoid.
We used to have an exclusive lock for this and it cause a whole bunch of problems.
Please elaborate why that should be necessary.
Regards,
Christian.Am 21.04.2017 um 09:08 schrieb Roger.He:
Quoted 123 lines
Change-Id Ib77d33a09f348ebf2e3a9d7861411f4b951ebf7cSigned-off-by Roger.He <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c | 7 ++++++- 4 files changed, 31 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +6
-0@@ -1526,6 +1526,7 @@ struct amdgpu_device {atomic64_t num_bytes_moved;atomic64_t num_evictions;atomic_t gpu_reset_counter; +atomic_t gpu_reset_state;/* data for buffer migration throttling */ struct {@@ -1851,6 +1852,11 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)#define amdgpu_psp_check_fw_loading_status (adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i))/* Common functions */ +static inline int amdgpu_device_is_reset (struct amdgpu_device +*adev) { +return atomic_read (&adev->gpu_reset_state); +} +int amdgpu_gpu_reset (struct amdgpu_device *adev);bool amdgpu_need_backup (struct amdgpu_device *adev);void
amdgpu_pci_config_reset(struct amdgpu_device *adev); diff
--gita/drivers/gpu/drm/amd/amdgpu/amdgpu_device.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index f882496..0fb4716 100644drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +13
-1@@ -1894,6 +1894,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->grbm_idx_mutex);mutex_init (&adev->mn_lock);hash_init (adev->mn_hash); +atomic_set (&adev->gpu_reset_state,0 );amdgpu_check_arguments (adev);@@ -2655,6 +2656,18 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, bool voluntary) }/** +* amdgpu_device_set_reset_state - set gpu reset state +* +* @adev: amdgpu device pointer +* @state: true when start to reset gpu; false: reset done */ +static inline void amdgpu_device_set_reset_state (struct amdgpu_device *adev, +bool state) +{ +atomic_set (&adev->gpu_reset_state, state); } + +/** * amdgpu_gpu_reset - reset the asic * * @adev: amdgpu device pointer @@ -2678,7 +2691,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) }atomic_inc (&adev->gpu_reset_counter); - +amdgpu_device_set_reset_state (adev, true);/* block TTM */ resched =ttm_bo_lock_delayed_workqueue (&adev->mman.bdev);/* store modesetting */ @@ -2811,6 +2824,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)dev_info (adev->dev,"GPU reset failed\n" ); } +amdgpu_device_set_reset_state (adev, false);return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4
-0@@ -679,11 +679,15 @@ long amdgpu_drm_ioctl(struct file *filp,struct drm_file *file_priv = filp->private_data;struct drm_device *dev;long ret; + dev = file_priv->minor->dev; ret =pm_runtime_get_sync (dev->dev);if (ret <0 )return ret; +while (amdgpu_device_is_reset (dev->dev_private)) +msleep (100 ); + ret =drm_ioctl (filp, cmd, arg);pm_runtime_mark_last_busy (dev->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +6
-1@@ -36,10 +36,15 @@long amdgpu_kms_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {unsigned int nr =DRM_IOCTL_NR (cmd); +struct drm_file *file_priv = filp->private_data; +struct amdgpu_device *adev = file_priv->minor->dev->dev_private;int ret; -if (nr <DRM_COMMAND_BASE ) +if (nr <DRM_COMMAND_BASE ) { +while (amdgpu_device_is_reset (adev)) +msleep (100 );return drm_compat_ioctl (filp, cmd, arg); + }
Quoted 6 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c line 50
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +0
-0ret =amdgpu_drm_ioctl (filp, cmd, arg);_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Hi Christian,
We possibly must re-consider this patch, the direct issue is VM FAULT after gpu reset. one obvious bug is we could bind gtt to gart during GPU reset, binding gtt to gart needs to fill gart table and tlb flush, which is parallel with gpu reset thread.
Regards,
David Zhou
Quoted 117 lines · Christian König
NAK, that is exactly what we wanted to avoid.
We used to have an exclusive lock for this and it cause a whole bunch of problems.
Please elaborate why that should be necessary.
Regards,
Christian.Am 21.04.2017 um 09:08 schrieb Roger.He:
Quoted 107 lines
Change-Id Ib77d33a09f348ebf2e3a9d7861411f4b951ebf7cSigned-off-by Roger.He <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c | 7 ++++++- 4 files changed, 31 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +6
-0@@ -1526,6 +1526,7 @@ struct amdgpu_device {atomic64_t num_bytes_moved;atomic64_t num_evictions;atomic_t gpu_reset_counter; +atomic_t gpu_reset_state;/* data for buffer migration throttling */ struct {@@ -1851,6 +1852,11 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)#define amdgpu_psp_check_fw_loading_status (adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i))/* Common functions */ +static inline int amdgpu_device_is_reset (struct amdgpu_device *adev) +{ +return atomic_read (&adev->gpu_reset_state); +} +int amdgpu_gpu_reset (struct amdgpu_device *adev);bool amdgpu_need_backup (struct amdgpu_device *adev);void amdgpu_pci_config_reset(struct amdgpu_device *adev);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0@@ -1894,6 +1894,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->grbm_idx_mutex);mutex_init (&adev->mn_lock);hash_init (adev->mn_hash); +atomic_set (&adev->gpu_reset_state,0 );amdgpu_check_arguments (adev); @@ -2655,6 +2656,18 @@ int amdgpu_sriov_gpu_reset(structamdgpu_device *adev,bool voluntary)}
/**+ *
amdgpu_device_set_reset_state- set gpu reset state
+ *
+ * @adev: amdgpu device pointer
+ * @state: true when start to reset gpu; false: reset done
+ */
+static inline void amdgpu_device_set_reset_state(structamdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-1+ bool state) +{ +atomic_set (&adev->gpu_reset_state, state); +} + +/** * amdgpu_gpu_reset - reset the asic * * @adev: amdgpu device pointer @@ -2678,7 +2691,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) }atomic_inc (&adev->gpu_reset_counter); - +amdgpu_device_set_reset_state (adev, true);/* block TTM */ resched =ttm_bo_lock_delayed_workqueue (&adev->mman.bdev);/* store modesetting */ @@ -2811,6 +2824,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)dev_info (adev->dev,"GPU reset failed\n" ); } +amdgpu_device_set_reset_state (adev, false);return r; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index ead00d7..8cc14af 100644drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3
-0@@ -679,11 +679,15 @@ long amdgpu_drm_ioctl(struct file *filp,struct drm_file *file_priv = filp->private_data;struct drm_device *dev;long ret; + dev = file_priv->minor->dev; ret =pm_runtime_get_sync (dev->dev);if (ret <0 )return ret; + while (amdgpu_device_is_reset(dev->dev_private)) +msleep (100 ); + ret =drm_ioctl (filp, cmd, arg);pm_runtime_mark_last_busy (dev->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +2
-0@@ -36,10 +36,15 @@long amdgpu_kms_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {unsigned int nr =DRM_IOCTL_NR (cmd); +struct drm_file *file_priv = filp->private_data; +struct amdgpu_device *adev = file_priv->minor->dev->dev_private;
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c line 49
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +4
-0int ret; - if (nr < DRM_COMMAND_BASE) +if (nr <DRM_COMMAND_BASE ) { +while (amdgpu_device_is_reset (adev)) +msleep (100 );return drm_compat_ioctl (filp, cmd, arg); + } ret =amdgpu_drm_ioctl (filp, cmd, arg);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
But that should be harmless because we rebuild the GART table after GPU reset, don't we?
Apart from that I'm fine with having a lock or locks to prevent concurrent things from happening while we do the reset.
But we should NOT do the mistake again and try to prevent everything is one big global lock. That was rather bad idea and using an atomic isn't better in any way.
Regards,
Christian.
Am 04.05.2017 um 12:31 schrieb zhoucm1:
Quoted 137 lines
Hi Christian,
We possibly must re-consider this patch, the direct issue is VM FAULT after gpu reset. one obvious bug is we could bind gtt to gart during GPU reset, binding gtt to gart needs to fill gart table and tlb flush, which is parallel with gpu reset thread.
Regards,
David ZhouQuoted 118 lines · Christian König
NAK, that is exactly what we wanted to avoid.
We used to have an exclusive lock for this and it cause a whole bunch of problems.
Please elaborate why that should be necessary.
Regards,
Christian.Am 21.04.2017 um 09:08 schrieb Roger.He:
Quoted 108 lines
Change-Id Ib77d33a09f348ebf2e3a9d7861411f4b951ebf7cSigned-off-by Roger.He <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c | 7 ++++++- 4 files changed, 31 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +6
-0@@ -1526,6 +1526,7 @@ struct amdgpu_device {atomic64_t num_bytes_moved;atomic64_t num_evictions;atomic_t gpu_reset_counter; +atomic_t gpu_reset_state;/* data for buffer migration throttling */ struct {@@ -1851,6 +1852,11 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)#define amdgpu_psp_check_fw_loading_status (adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i))/* Common functions */ +static inline int amdgpu_device_is_reset (struct amdgpu_device *adev) +{ +return atomic_read (&adev->gpu_reset_state); +} +int amdgpu_gpu_reset (struct amdgpu_device *adev);bool amdgpu_need_backup (struct amdgpu_device *adev);void amdgpu_pci_config_reset(struct amdgpu_device *adev);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0@@ -1894,6 +1894,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->grbm_idx_mutex);mutex_init (&adev->mn_lock);hash_init (adev->mn_hash); +atomic_set (&adev->gpu_reset_state,0 );amdgpu_check_arguments (adev); @@ -2655,6 +2656,18 @@ int amdgpu_sriov_gpu_reset(struct
amdgpu_device*adev, bool voluntary)
}/**+ *
amdgpu_device_set_reset_state- set gpu reset state
+ *
+ * @adev: amdgpu device pointer
+ * @state: true when start to reset gpu; false: reset done
+ */
+static inline void amdgpu_device_set_reset_state(structamdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-1+ bool state) +{ +atomic_set (&adev->gpu_reset_state, state); +} + +/** * amdgpu_gpu_reset - reset the asic * * @adev: amdgpu device pointer @@ -2678,7 +2691,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) }atomic_inc (&adev->gpu_reset_counter); - +amdgpu_device_set_reset_state (adev, true);/* block TTM */ resched =ttm_bo_lock_delayed_workqueue (&adev->mman.bdev);/* store modesetting */ @@ -2811,6 +2824,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)dev_info (adev->dev,"GPU reset failed\n" ); } +amdgpu_device_set_reset_state (adev, false);return r; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index ead00d7..8cc14af 100644drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3
-0@@ -679,11 +679,15 @@ long amdgpu_drm_ioctl(struct file *filp,struct drm_file *file_priv = filp->private_data;struct drm_device *dev;long ret; + dev = file_priv->minor->dev; ret =pm_runtime_get_sync (dev->dev);if (ret <0 )return ret; + while (amdgpu_device_is_reset(dev->dev_private)) +msleep (100 ); + ret =drm_ioctl (filp, cmd, arg);pm_runtime_mark_last_busy (dev->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +2
-0@@ -36,10 +36,15 @@long amdgpu_kms_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {unsigned int nr =DRM_IOCTL_NR (cmd); +struct drm_file *file_priv = filp->private_data; +struct amdgpu_device *adev = file_priv->minor->dev->dev_private;Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c line 49
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +4
-0int ret; - if (nr < DRM_COMMAND_BASE) +if (nr <DRM_COMMAND_BASE ) { +while (amdgpu_device_is_reset (adev)) +msleep (100 );return drm_compat_ioctl (filp, cmd, arg); + } ret =amdgpu_drm_ioctl (filp, cmd, arg);
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): f2c6a892-5929-8644-ca34-09f89e6359a4-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Christian
Why not use rw lock ? that way only gpu reset will make those iOCTL blocked, and in usual case the performance is still the same
BR Monk
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
Sent: Thursday, May 04, 2017 7:21 PM
To: Zhou, David(ChunMing) <[email protected]>; He, Hongbo <[email protected]>; [email protected]
Subject: Re: [PATCH 3/3] drm/amdgpu: fix gpu reset issue
But that should be harmless because we rebuild the GART table after GPU reset, don't we?
Apart from that I'm fine with having a lock or locks to prevent concurrent things from happening while we do the reset.
But we should NOT do the mistake again and try to prevent everything is one big global lock. That was rather bad idea and using an atomic isn't better in any way.
Regards,
Christian.
Am 04.05.2017 um 12:31 schrieb zhoucm1:
Quoted 142 lines
Hi Christian,
We possibly must re-consider this patch, the direct issue is VM FAULT after gpu reset. one obvious bug is we could bind gtt to gart during GPU reset, binding gtt to gart needs to fill gart table and tlb flush, which is parallel with gpu reset thread.
Regards,
David ZhouQuoted 120 lines · Christian König
NAK, that is exactly what we wanted to avoid.
We used to have an exclusive lock for this and it cause a whole bunch of problems.
Please elaborate why that should be necessary.
Regards,
Christian.Am 21.04.2017 um 09:08 schrieb Roger.He:
Quoted 109 lines
Change-Id Ib77d33a09f348ebf2e3a9d7861411f4b951ebf7cSigned-off-by Roger.He <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c | 7 ++++++- 4 files changed, 31 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +6
-0@@ -1526,6 +1526,7 @@ struct amdgpu_device {atomic64_t num_bytes_moved;atomic64_t num_evictions;atomic_t gpu_reset_counter; +atomic_t gpu_reset_state;/* data for buffer migration throttling */ struct {@@ -1851,6 +1852,11 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)#define amdgpu_psp_check_fw_loading_status (adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i))/* Common functions */ +static inline int amdgpu_device_is_reset (struct amdgpu_device +*adev) { +return atomic_read (&adev->gpu_reset_state); +} +int amdgpu_gpu_reset (struct amdgpu_device *adev);bool amdgpu_need_backup (struct amdgpu_device *adev);void
amdgpu_pci_config_reset(struct amdgpu_device *adev); diff
--gita/drivers/gpu/drm/amd/amdgpu/amdgpu_device.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index f882496..0fb4716 100644drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0@@ -1894,6 +1894,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->grbm_idx_mutex);mutex_init (&adev->mn_lock);hash_init (adev->mn_hash); +atomic_set (&adev->gpu_reset_state,0 );amdgpu_check_arguments (adev); @@ -2655,6 +2656,18 @@ int amdgpu_sriov_gpu_reset(struct
amdgpu_device*adev, bool voluntary)
}/**+ *
amdgpu_device_set_reset_state- set gpu reset state
+ *
+ * @adev: amdgpu device pointer
+ * @state: true when start to reset gpu; false: reset done */ +static inline void amdgpu_device_set_reset_state(structamdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5
-1+ bool state) { +atomic_set (&adev->gpu_reset_state, state); } + +/** * amdgpu_gpu_reset - reset the asic * * @adev: amdgpu device pointer @@ -2678,7 +2691,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) }atomic_inc (&adev->gpu_reset_counter); - +amdgpu_device_set_reset_state (adev, true);/* block TTM */ resched =ttm_bo_lock_delayed_workqueue (&adev->mman.bdev);/* store modesetting */ @@ -2811,6 +2824,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)dev_info (adev->dev,"GPU reset failed\n" ); } +amdgpu_device_set_reset_state (adev, false);return r; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index ead00d7..8cc14af 100644drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3
-0@@ -679,11 +679,15 @@ long amdgpu_drm_ioctl(struct file *filp,struct drm_file *file_priv = filp->private_data;struct drm_device *dev;long ret; + dev = file_priv->minor->dev; ret =pm_runtime_get_sync (dev->dev);if (ret <0 )return ret; + while (amdgpu_device_is_reset(dev->dev_private)) +msleep (100 ); + ret =drm_ioctl (filp, cmd, arg);pm_runtime_mark_last_busy (dev->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +3
-0@@ -36,10 +36,15 @@long amdgpu_kms_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {unsigned int nr =DRM_IOCTL_NR (cmd); +struct drm_file *file_priv = filp->private_data; +struct amdgpu_device *adev = + file_priv->minor->dev->dev_private;Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c line 50
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +4
-0int ret; - if (nr < DRM_COMMAND_BASE) +if (nr <DRM_COMMAND_BASE ) { +while (amdgpu_device_is_reset (adev)) +msleep (100 );return drm_compat_ioctl (filp, cmd, arg); + } ret =amdgpu_drm_ioctl (filp, cmd, arg);
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): DM5PR12MB1610FEFA4B2654FF67B2F1B684EA0-2J9CzHegvk++jCVTvoAFKAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
That's what we used to have with the exclusive lock.
The issue is not what kind of lock or locking or not locking at all, but rather where to place it.
Having a rw lock called something like "in_reset" is ok to me, but we shouldn't take it in the IOCTL path.
Instead we should block for example the GART TLB flush while being inside a reset etc...
Otherwise we run into the same problems (lock inversions for example) as we had before.
Regards,
Christian.
Am 04.05.2017 um 13:28 schrieb Liu, Monk:
Quoted 168 lines
Christian
Why not use rw lock ? that way only gpu reset will make those iOCTL blocked, and in usual case the performance is still the same
BR Monk
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
Sent: Thursday, May 04, 2017 7:21 PM
To: Zhou, David(ChunMing) <[email protected]>; He, Hongbo <[email protected]>; [email protected]
Subject: Re: [PATCH 3/3] drm/amdgpu: fix gpu reset issueBut that should be harmless because we rebuild the GART table after GPU reset, don't we?
Apart from that I'm fine with having a lock or locks to prevent concurrent things from happening while we do the reset.
But we should NOT do the mistake again and try to prevent everything is one big global lock. That was rather bad idea and using an atomic isn't better in any way.
Regards,
Christian.Am 04.05.2017 um 12:31 schrieb zhoucm1:
Quoted 140 lines
Hi Christian,
We possibly must re-consider this patch, the direct issue is VM FAULT after gpu reset. one obvious bug is we could bind gtt to gart during GPU reset, binding gtt to gart needs to fill gart table and tlb flush, which is parallel with gpu reset thread.
Regards,
David ZhouQuoted 120 lines · Christian König
NAK, that is exactly what we wanted to avoid.
We used to have an exclusive lock for this and it cause a whole bunch of problems.
Please elaborate why that should be necessary.
Regards,
Christian.Am 21.04.2017 um 09:08 schrieb Roger.He:
Quoted 109 lines
Change-Id Ib77d33a09f348ebf2e3a9d7861411f4b951ebf7cSigned-off-by Roger.He <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c | 7 ++++++- 4 files changed, 31 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +6
-0@@ -1526,6 +1526,7 @@ struct amdgpu_device {atomic64_t num_bytes_moved;atomic64_t num_evictions;atomic_t gpu_reset_counter; +atomic_t gpu_reset_state;/* data for buffer migration throttling */ struct {@@ -1851,6 +1852,11 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring) #define amdgpu_psp_check_fw_loading_status(adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i))/* Common functions */ +static inline int amdgpu_device_is_reset (struct amdgpu_device +*adev) { +return atomic_read (&adev->gpu_reset_state); +} +int amdgpu_gpu_reset (struct amdgpu_device *adev);bool amdgpu_need_backup (struct amdgpu_device *adev);void
amdgpu_pci_config_reset(struct amdgpu_device *adev); diff
--gita/drivers/gpu/drm/amd/amdgpu/amdgpu_device.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index f882496..0fb4716 100644drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0@@ -1894,6 +1894,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->grbm_idx_mutex);mutex_init (&adev->mn_lock);hash_init (adev->mn_hash); +atomic_set (&adev->gpu_reset_state,0 );amdgpu_check_arguments (adev); @@ -2655,6 +2656,18 @@ int amdgpu_sriov_gpu_reset(struct
amdgpu_device*adev, bool voluntary)
}/**+ *
amdgpu_device_set_reset_state- set gpu reset state
+ *
+ * @adev: amdgpu device pointer
+ * @state: true when start to reset gpu; false: reset done */ +static inline void amdgpu_device_set_reset_state(structamdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5
-1+ bool state) { +atomic_set (&adev->gpu_reset_state, state); } + +/** * amdgpu_gpu_reset - reset the asic * * @adev: amdgpu device pointer @@ -2678,7 +2691,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) }atomic_inc (&adev->gpu_reset_counter); - +amdgpu_device_set_reset_state (adev, true);/* block TTM */ resched =ttm_bo_lock_delayed_workqueue (&adev->mman.bdev);/* store modesetting */ @@ -2811,6 +2824,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)dev_info (adev->dev,"GPU reset failed\n" ); } +amdgpu_device_set_reset_state (adev, false);return r; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index ead00d7..8cc14af 100644drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3
-0@@ -679,11 +679,15 @@ long amdgpu_drm_ioctl(struct file *filp,struct drm_file *file_priv = filp->private_data;struct drm_device *dev;long ret; + dev = file_priv->minor->dev; ret =pm_runtime_get_sync (dev->dev);if (ret <0 )return ret; + while (amdgpu_device_is_reset(dev->dev_private)) +msleep (100 ); + ret =drm_ioctl (filp, cmd, arg);pm_runtime_mark_last_busy (dev->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +3
-0@@ -36,10 +36,15 @@long amdgpu_kms_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {unsigned int nr =DRM_IOCTL_NR (cmd); +struct drm_file *file_priv = filp->private_data; +struct amdgpu_device *adev = + file_priv->minor->dev->dev_private;Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c line 50
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +4
-0int ret; - if (nr < DRM_COMMAND_BASE) +if (nr <DRM_COMMAND_BASE ) { +while (amdgpu_device_is_reset (adev)) +msleep (100 );return drm_compat_ioctl (filp, cmd, arg); + } ret =amdgpu_drm_ioctl (filp, cmd, arg);Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 6321c998-f337-39af-3d64-070341e5fbe4-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Agreed.
We can put rw lock in the place that accessing hardware or pde/pte,
But I'm not sure this is safe enough, maybe one IOCTL access hw at top and bottom, and need consistence access, If gpu reset happens maybe the consistence is broken .... just my worry
But we can do from your approach to try first
BR Monk
-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, May 04, 2017 7:33 PM
To: Liu, Monk <[email protected]>; Zhou, David(ChunMing) <[email protected]>; He, Hongbo <[email protected]>; [email protected]
Subject: Re: [PATCH 3/3] drm/amdgpu: fix gpu reset issue
That's what we used to have with the exclusive lock.
The issue is not what kind of lock or locking or not locking at all, but rather where to place it.
Having a rw lock called something like "in_reset" is ok to me, but we shouldn't take it in the IOCTL path.
Instead we should block for example the GART TLB flush while being inside a reset etc...
Otherwise we run into the same problems (lock inversions for example) as we had before.
Regards,
Christian.
Am 04.05.2017 um 13:28 schrieb Liu, Monk:
Quoted 170 lines
Christian
Why not use rw lock ? that way only gpu reset will make those iOCTL blocked, and in usual case the performance is still the same
BR Monk
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
Sent: Thursday, May 04, 2017 7:21 PM
To: Zhou, David(ChunMing) <[email protected]>; He, Hongbo <[email protected]>; [email protected]
Subject: Re: [PATCH 3/3] drm/amdgpu: fix gpu reset issueBut that should be harmless because we rebuild the GART table after GPU reset, don't we?
Apart from that I'm fine with having a lock or locks to prevent concurrent things from happening while we do the reset.
But we should NOT do the mistake again and try to prevent everything is one big global lock. That was rather bad idea and using an atomic isn't better in any way.
Regards,
Christian.Am 04.05.2017 um 12:31 schrieb zhoucm1:
Quoted 140 lines
Hi Christian,
We possibly must re-consider this patch, the direct issue is VM FAULT after gpu reset. one obvious bug is we could bind gtt to gart during GPU reset, binding gtt to gart needs to fill gart table and tlb flush, which is parallel with gpu reset thread.
Regards,
David ZhouQuoted 120 lines · Christian König
NAK, that is exactly what we wanted to avoid.
We used to have an exclusive lock for this and it cause a whole bunch of problems.
Please elaborate why that should be necessary.
Regards,
Christian.Am 21.04.2017 um 09:08 schrieb Roger.He:
Quoted 109 lines
Change-Id Ib77d33a09f348ebf2e3a9d7861411f4b951ebf7cSigned-off-by Roger.He <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c | 7 ++++++- 4 files changed, 31 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +6
-0@@ -1526,6 +1526,7 @@ struct amdgpu_device {atomic64_t num_bytes_moved;atomic64_t num_evictions;atomic_t gpu_reset_counter; +atomic_t gpu_reset_state;/* data for buffer migration throttling */ struct {@@ -1851,6 +1852,11 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)#define amdgpu_psp_check_fw_loading_status (adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i))/* Common functions */ +static inline int amdgpu_device_is_reset (struct amdgpu_device +*adev) { +return atomic_read (&adev->gpu_reset_state); +} +int amdgpu_gpu_reset (struct amdgpu_device *adev);bool amdgpu_need_backup (struct amdgpu_device *adev);void
amdgpu_pci_config_reset(struct amdgpu_device *adev); diff
--gita/drivers/gpu/drm/amd/amdgpu/amdgpu_device.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index f882496..0fb4716 100644drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0@@ -1894,6 +1894,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->grbm_idx_mutex);mutex_init (&adev->mn_lock);hash_init (adev->mn_hash); +atomic_set (&adev->gpu_reset_state,0 );amdgpu_check_arguments (adev); @@ -2655,6 +2656,18 @@ int amdgpu_sriov_gpu_reset(struct
amdgpu_device*adev, bool voluntary)
}/**+ *
amdgpu_device_set_reset_state- set gpu reset state
+ *
+ * @adev: amdgpu device pointer
+ * @state: true when start to reset gpu; false: reset done */ +static inline void amdgpu_device_set_reset_state(structamdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5
-1+ bool state) { +atomic_set (&adev->gpu_reset_state, state); } + +/** * amdgpu_gpu_reset - reset the asic * * @adev: amdgpu device pointer @@ -2678,7 +2691,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) }atomic_inc (&adev->gpu_reset_counter); - +amdgpu_device_set_reset_state (adev, true);/* block TTM */ resched =ttm_bo_lock_delayed_workqueue (&adev->mman.bdev);/* store modesetting */ @@ -2811,6 +2824,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)dev_info (adev->dev,"GPU reset failed\n" ); } +amdgpu_device_set_reset_state (adev, false);return r; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index ead00d7..8cc14af 100644drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3
-0@@ -679,11 +679,15 @@ long amdgpu_drm_ioctl(struct file *filp,struct drm_file *file_priv = filp->private_data;struct drm_device *dev;long ret; + dev = file_priv->minor->dev; ret =pm_runtime_get_sync (dev->dev);if (ret <0 )return ret; + while (amdgpu_device_is_reset(dev->dev_private)) +msleep (100 ); + ret =drm_ioctl (filp, cmd, arg);pm_runtime_mark_last_busy (dev->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +3
-0@@ -36,10 +36,15 @@long amdgpu_kms_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {unsigned int nr =DRM_IOCTL_NR (cmd); +struct drm_file *file_priv = filp->private_data; +struct amdgpu_device *adev = + file_priv->minor->dev->dev_private;Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c line 50
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +4
-0int ret; - if (nr < DRM_COMMAND_BASE) +if (nr <DRM_COMMAND_BASE ) { +while (amdgpu_device_is_reset (adev)) +msleep (100 );return drm_compat_ioctl (filp, cmd, arg); + } ret =amdgpu_drm_ioctl (filp, cmd, arg);Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx