drm/amdkfd: fix debug watchpoints for logical devices
Subsystems (3)
PATCH 1/1 drm/amdkfd: fix debug watchpoints for logical devices
The number of watchpoints should be set and constrained per logical partition device, not by the socket device.
--- drivers/gpu/drm/amd/amdkfd/kfd_debug.c | 20 ++++++++++---------- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 4 ++-- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_debug.c +10 -10
@@ -365,47 +365,47 @@ static int kfd_dbg_get_dev_watch_id(struct kfd_process_device *pdd, int *watch_i *watch_id =KFD_DEBUGGER_INVALID_WATCH_POINT_ID ; -spin_lock (&pdd->dev->kfd->watch_points_lock); +spin_lock (&pdd->dev->watch_points_lock);for (i =0 ; i <MAX_WATCH_ADDRESSES ; i++) {/* device watchpoint in use so skip */ -if ((pdd->dev->kfd->alloc_watch_ids >> i) &0x1 ) +if ((pdd->dev->alloc_watch_ids >> i) &0x1 )continue ; pdd->alloc_watch_ids |=0x1 << i; - pdd->dev->kfd->alloc_watch_ids |=0x1 << i; + pdd->dev->alloc_watch_ids |=0x1 << i; *watch_id = i; -spin_unlock (&pdd->dev->kfd->watch_points_lock); +spin_unlock (&pdd->dev->watch_points_lock);return 0 ; } -spin_unlock (&pdd->dev->kfd->watch_points_lock); +spin_unlock (&pdd->dev->watch_points_lock);return -ENOMEM ; }static void kfd_dbg_clear_dev_watch_id (struct kfd_process_device *pdd,int watch_id) { -spin_lock (&pdd->dev->kfd->watch_points_lock); +spin_lock (&pdd->dev->watch_points_lock);/* process owns device watch point so safe to clear */ if ((pdd->alloc_watch_ids >> watch_id) &0x1 ) { pdd->alloc_watch_ids &= ~(0x1 << watch_id); - pdd->dev->kfd->alloc_watch_ids &= ~(0x1 << watch_id); + pdd->dev->alloc_watch_ids &= ~(0x1 << watch_id); } -spin_unlock (&pdd->dev->kfd->watch_points_lock); +spin_unlock (&pdd->dev->watch_points_lock); }static bool kfd_dbg_owns_dev_watch_id (struct kfd_process_device *pdd,int watch_id) {bool owns_watch_id = false; -spin_lock (&pdd->dev->kfd->watch_points_lock); +spin_lock (&pdd->dev->watch_points_lock); owns_watch_id = watch_id <MAX_WATCH_ADDRESSES && ((pdd->alloc_watch_ids >> watch_id) &0x1 ); -spin_unlock (&pdd->dev->kfd->watch_points_lock); +spin_unlock (&pdd->dev->watch_points_lock);return owns_watch_id; }
drivers/gpu/drm/amd/amdkfd/kfd_device.c +2 -2
@@ -885,12 +885,12 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd, goto node_init_error; } kfd->nodes[i] = node; + +spin_lock_init (&kfd->nodes[i]->watch_points_lock); }svm_range_set_max_pages (kfd->adev); -spin_lock_init (&kfd->watch_points_lock); - kfd->init_complete = true;dev_info (kfd_device,"added device %x:%x\n" , kfd->adev->pdev->vendor, kfd->adev->pdev->device);
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +4 -4
@@ -310,6 +310,10 @@ struct kfd_node {struct kfd_local_mem_info local_mem_info;struct kfd_dev *kfd; + +/* Track per device allocated watch points */ +uint32_t alloc_watch_ids; +spinlock_t watch_points_lock; };struct kfd_dev {
@@ -362,10 +366,6 @@ struct kfd_dev {struct kfd_node *nodes[MAX_KFD_NODES ];unsigned int num_nodes; -/* Track per device allocated watch points */ -uint32_t alloc_watch_ids; -spinlock_t watch_points_lock; -/* Kernel doorbells for KFD device */ struct amdgpu_bo *doorbells;
Signature · 1 line
2.34.1
[Public]
Ping on review.
Thanks,
Jon
Quoted 134 lines
-----Original Message-----
From: Kim, Jonathan <[email protected]>
Sent: Monday, July 22, 2024 2:57 PM
To: [email protected]
Cc: Kim, Jonathan <[email protected]>; Kim, Jonathan <[email protected]>
Subject: [PATCH] drm/amdkfd: fix debug watchpoints for logical devicesThe number of watchpoints should be set and constrained per logical partition device, not by the socket device.
Signed-off-by Jonathan Kim <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_debug.c | 20 ++++++++++---------- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 4 ++-- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_debug.c +0
-0@@ -365,47 +365,47 @@ static int kfd_dbg_get_dev_watch_id(struct
kfd_process_device*pdd, int*watch_i*watch_id = KFD_DEBUGGER_INVALID_WATCH_POINT_ID;drivers/gpu/drm/amd/amdkfd/kfd_debug.c +5
-5-spin_lock (&pdd->dev->kfd->watch_points_lock); +spin_lock (&pdd->dev->watch_points_lock);for (i =0 ; i <MAX_WATCH_ADDRESSES ; i++) {/* device watchpoint in use so skip */ -if ((pdd->dev->kfd->alloc_watch_ids >> i) &0x1 ) +if ((pdd->dev->alloc_watch_ids >> i) &0x1 )continue ; pdd->alloc_watch_ids |=0x1 << i; - pdd->dev->kfd->alloc_watch_ids |=0x1 << i; + pdd->dev->alloc_watch_ids |=0x1 << i; *watch_id = i; -spin_unlock (&pdd->dev->kfd->watch_points_lock); +spin_unlock (&pdd->dev->watch_points_lock);return 0 ; } -spin_unlock (&pdd->dev->kfd->watch_points_lock); +spin_unlock (&pdd->dev->watch_points_lock);return -ENOMEM ; } static void kfd_dbg_clear_dev_watch_id(struct kfd_process_device *pdd, int
watch_id)
{drivers/gpu/drm/amd/amdkfd/kfd_debug.c +3
-3-spin_lock (&pdd->dev->kfd->watch_points_lock); +spin_lock (&pdd->dev->watch_points_lock);/* process owns device watch point so safe to clear */ if ((pdd->alloc_watch_ids >> watch_id) &0x1 ) { pdd->alloc_watch_ids &= ~(0x1 << watch_id); - pdd->dev->kfd->alloc_watch_ids &= ~(0x1 << watch_id); + pdd->dev->alloc_watch_ids &= ~(0x1 << watch_id); } -spin_unlock (&pdd->dev->kfd->watch_points_lock); +spin_unlock (&pdd->dev->watch_points_lock); } static bool kfd_dbg_owns_dev_watch_id(struct kfd_process_device *pdd, int
watch_id){ bool owns_watch_id = false;drivers/gpu/drm/amd/amdkfd/kfd_debug.c +2
-2-spin_lock (&pdd->dev->kfd->watch_points_lock); +spin_lock (&pdd->dev->watch_points_lock); owns_watch_id = watch_id <MAX_WATCH_ADDRESSES && ((pdd->alloc_watch_ids >> watch_id) &0x1 ); -spin_unlock (&pdd->dev->kfd->watch_points_lock); +spin_unlock (&pdd->dev->watch_points_lock);return owns_watch_id; }drivers/gpu/drm/amd/amdkfd/kfd_device.c +2
-2@@ -885,12 +885,12 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd, goto node_init_error; } kfd->nodes[i] = node; + +spin_lock_init (&kfd->nodes[i]->watch_points_lock); }svm_range_set_max_pages (kfd->adev); -spin_lock_init (&kfd->watch_points_lock); - kfd->init_complete = true; dev_info(kfd_device, "added device %x:%x\n", kfd->adev->pdev- >vendor,kfd->adev->pdev->device);drivers/gpu/drm/amd/amdkfd/kfd_priv.h +4
-5@@ -310,6 +310,10 @@ struct kfd_node {struct kfd_local_mem_info local_mem_info;struct kfd_dev *kfd; + +/* Track per device allocated watch points */ +uint32_t alloc_watch_ids; +spinlock_t watch_points_lock; };struct kfd_dev {@@ -362,10 +366,6 @@ struct kfd_dev {struct kfd_node *nodes[MAX_KFD_NODES ];unsigned int num_nodes; -/* Track per device allocated watch points */ -uint32_t alloc_watch_ids; -spinlock_t watch_points_lock; -/* Kernel doorbells for KFD device */ struct amdgpu_bo *doorbells; --2.34.1
[AMD Official Use Only - AMD Internal Distribution Only]
One minor comment b. Either way Reviewed-by: Harish Kasiviswanathan <[email protected]>
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Jonathan Kim
Sent: Monday, July 22, 2024 2:57 PM
To: [email protected]
Cc: Kim, Jonathan <[email protected]>; Kim, Jonathan <[email protected]>
Subject: [PATCH] drm/amdkfd: fix debug watchpoints for logical devices
The number of watchpoints should be set and constrained per logical partition device, not by the socket device.
--- drivers/gpu/drm/amd/amdkfd/kfd_debug.c | 20 ++++++++++---------- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 4 ++-- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_debug.c +10 -10
@@ -365,47 +365,47 @@ static int kfd_dbg_get_dev_watch_id(struct kfd_process_device *pdd, int *watch_i *watch_id =KFD_DEBUGGER_INVALID_WATCH_POINT_ID ; -spin_lock (&pdd->dev->kfd->watch_points_lock); +spin_lock (&pdd->dev->watch_points_lock);for (i =0 ; i <MAX_WATCH_ADDRESSES ; i++) {/* device watchpoint in use so skip */ -if ((pdd->dev->kfd->alloc_watch_ids >> i) &0x1 ) +if ((pdd->dev->alloc_watch_ids >> i) &0x1 )continue ; pdd->alloc_watch_ids |=0x1 << i; - pdd->dev->kfd->alloc_watch_ids |=0x1 << i; + pdd->dev->alloc_watch_ids |=0x1 << i; *watch_id = i; -spin_unlock (&pdd->dev->kfd->watch_points_lock); +spin_unlock (&pdd->dev->watch_points_lock);return 0 ; } -spin_unlock (&pdd->dev->kfd->watch_points_lock); +spin_unlock (&pdd->dev->watch_points_lock);return -ENOMEM ; }static void kfd_dbg_clear_dev_watch_id (struct kfd_process_device *pdd,int watch_id) { -spin_lock (&pdd->dev->kfd->watch_points_lock); +spin_lock (&pdd->dev->watch_points_lock);/* process owns device watch point so safe to clear */ if ((pdd->alloc_watch_ids >> watch_id) &0x1 ) { pdd->alloc_watch_ids &= ~(0x1 << watch_id); - pdd->dev->kfd->alloc_watch_ids &= ~(0x1 << watch_id); + pdd->dev->alloc_watch_ids &= ~(0x1 << watch_id); } -spin_unlock (&pdd->dev->kfd->watch_points_lock); +spin_unlock (&pdd->dev->watch_points_lock); }static bool kfd_dbg_owns_dev_watch_id (struct kfd_process_device *pdd,int watch_id) {bool owns_watch_id = false; -spin_lock (&pdd->dev->kfd->watch_points_lock); +spin_lock (&pdd->dev->watch_points_lock); owns_watch_id = watch_id <MAX_WATCH_ADDRESSES && ((pdd->alloc_watch_ids >> watch_id) &0x1 ); -spin_unlock (&pdd->dev->kfd->watch_points_lock); +spin_unlock (&pdd->dev->watch_points_lock);return owns_watch_id; }
drivers/gpu/drm/amd/amdkfd/kfd_device.c +0 -0
@@ -885,12 +885,12 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd, goto node_init_error; }
Wouldn't it better to initialize node->watch_points_lock here. spin_lock_init(&node->watch_points_lock);
kfd->nodes[i] = node;
+
+ spin_lock_init(&kfd->nodes[i]->watch_points_lock);
}
svm_range_set_max_pages(kfd->adev);- spin_lock_init(&kfd->watch_points_lock);
-
kfd->init_complete = true;
dev_info(kfd_device, "added device %x:%x\n", kfd->adev->pdev->vendor,
kfd->adev->pdev->device);drivers/gpu/drm/amd/amdkfd/kfd_priv.h +4 -4
@@ -310,6 +310,10 @@ struct kfd_node {struct kfd_local_mem_info local_mem_info;struct kfd_dev *kfd; + +/* Track per device allocated watch points */ +uint32_t alloc_watch_ids; +spinlock_t watch_points_lock; };struct kfd_dev {
@@ -362,10 +366,6 @@ struct kfd_dev {struct kfd_node *nodes[MAX_KFD_NODES ];unsigned int num_nodes; -/* Track per device allocated watch points */ -uint32_t alloc_watch_ids; -spinlock_t watch_points_lock; -/* Kernel doorbells for KFD device */ struct amdgpu_bo *doorbells;
--
2.34.1
[Public]
Quoted 107 lines
-----Original Message-----
From: Kasiviswanathan, Harish <[email protected]>
Sent: Tuesday, July 30, 2024 12:23 PM
To: Kim, Jonathan <[email protected]>; [email protected]
Cc: Kim, Jonathan <[email protected]>; Kim, Jonathan <[email protected]>
Subject: RE: [PATCH] drm/amdkfd: fix debug watchpoints for logical devices[AMD Official Use Only - AMD Internal Distribution Only]
One minor comment b. Either way Reviewed-by: Harish Kasiviswanathan <[email protected]>
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Jonathan Kim
Sent: Monday, July 22, 2024 2:57 PM
To: [email protected]
Cc: Kim, Jonathan <[email protected]>; Kim, Jonathan <[email protected]>
Subject: [PATCH] drm/amdkfd: fix debug watchpoints for logical devicesThe number of watchpoints should be set and constrained per logical partition device, not by the socket device.
Signed-off-by Jonathan Kim <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_debug.c | 20 ++++++++++---------- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 4 ++-- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_debug.c +0
-0@@ -365,47 +365,47 @@ static int kfd_dbg_get_dev_watch_id(struct
kfd_process_device*pdd, int*watch_i*watch_id = KFD_DEBUGGER_INVALID_WATCH_POINT_ID;drivers/gpu/drm/amd/amdkfd/kfd_debug.c +5
-5-spin_lock (&pdd->dev->kfd->watch_points_lock); +spin_lock (&pdd->dev->watch_points_lock);for (i =0 ; i <MAX_WATCH_ADDRESSES ; i++) {/* device watchpoint in use so skip */ -if ((pdd->dev->kfd->alloc_watch_ids >> i) &0x1 ) +if ((pdd->dev->alloc_watch_ids >> i) &0x1 )continue ; pdd->alloc_watch_ids |=0x1 << i; - pdd->dev->kfd->alloc_watch_ids |=0x1 << i; + pdd->dev->alloc_watch_ids |=0x1 << i; *watch_id = i; -spin_unlock (&pdd->dev->kfd->watch_points_lock); +spin_unlock (&pdd->dev->watch_points_lock);return 0 ; } -spin_unlock (&pdd->dev->kfd->watch_points_lock); +spin_unlock (&pdd->dev->watch_points_lock);return -ENOMEM ; } static void kfd_dbg_clear_dev_watch_id(struct kfd_process_device *pdd, int
watch_id)
{drivers/gpu/drm/amd/amdkfd/kfd_debug.c +3
-3-spin_lock (&pdd->dev->kfd->watch_points_lock); +spin_lock (&pdd->dev->watch_points_lock);/* process owns device watch point so safe to clear */ if ((pdd->alloc_watch_ids >> watch_id) &0x1 ) { pdd->alloc_watch_ids &= ~(0x1 << watch_id); - pdd->dev->kfd->alloc_watch_ids &= ~(0x1 << watch_id); + pdd->dev->alloc_watch_ids &= ~(0x1 << watch_id); } -spin_unlock (&pdd->dev->kfd->watch_points_lock); +spin_unlock (&pdd->dev->watch_points_lock); } static bool kfd_dbg_owns_dev_watch_id(struct kfd_process_device *pdd, int
watch_id){ bool owns_watch_id = false;drivers/gpu/drm/amd/amdkfd/kfd_debug.c +2
-2-spin_lock (&pdd->dev->kfd->watch_points_lock); +spin_lock (&pdd->dev->watch_points_lock); owns_watch_id = watch_id <MAX_WATCH_ADDRESSES && ((pdd->alloc_watch_ids >> watch_id) &0x1 ); -spin_unlock (&pdd->dev->kfd->watch_points_lock); +spin_unlock (&pdd->dev->watch_points_lock);return owns_watch_id; }drivers/gpu/drm/amd/amdkfd/kfd_device.c +0
-0@@ -885,12 +885,12 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd, goto node_init_error; }
Quoted 2 lines
Wouldn't it better to initialize
node->watch_points_lockhere.spin_lock_init(&node->watch_points_lock);
Done. Thanks for the review.
Jon
Quoted 43 lines
kfd->nodes[i] = node;drivers/gpu/drm/amd/amdkfd/kfd_device.c +2
-2+ +spin_lock_init (&kfd->nodes[i]->watch_points_lock); }svm_range_set_max_pages (kfd->adev); -spin_lock_init (&kfd->watch_points_lock); - kfd->init_complete = true;dev_info (kfd_device,"added device %x:%x\n" , kfd->adev->pdev->vendor, kfd->adev->pdev->device);drivers/gpu/drm/amd/amdkfd/kfd_priv.h +4
-5@@ -310,6 +310,10 @@ struct kfd_node {struct kfd_local_mem_info local_mem_info;struct kfd_dev *kfd; + +/* Track per device allocated watch points */ +uint32_t alloc_watch_ids; +spinlock_t watch_points_lock; };struct kfd_dev {@@ -362,10 +366,6 @@ struct kfd_dev {struct kfd_node *nodes[MAX_KFD_NODES ];unsigned int num_nodes; -/* Track per device allocated watch points */ -uint32_t alloc_watch_ids; -spinlock_t watch_points_lock; -/* Kernel doorbells for KFD device */ struct amdgpu_bo *doorbells; --2.34.1