Skip to content
/ linux Public

Commit 17e9478

Browse files
jokim-amdSasha Levin
authored andcommitted
drm/amdkfd: fix debug watchpoints for logical devices
[ Upstream commit b41a382 ] The number of watchpoints should be set and constrained per logical partition device, not by the socket device. Signed-off-by: Jonathan Kim <jonathan.kim@amd.com> Reviewed-by: Harish Kasiviswanathan <harish.kasiviswanathan@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Stable-dep-of: 5a19302 ("drm/amdkfd: Fix watch_id bounds checking in debug address watch v2") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e975148 commit 17e9478

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

drivers/gpu/drm/amd/amdkfd/kfd_debug.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -381,47 +381,47 @@ static int kfd_dbg_get_dev_watch_id(struct kfd_process_device *pdd, int *watch_i
381381

382382
*watch_id = KFD_DEBUGGER_INVALID_WATCH_POINT_ID;
383383

384-
spin_lock(&pdd->dev->kfd->watch_points_lock);
384+
spin_lock(&pdd->dev->watch_points_lock);
385385

386386
for (i = 0; i < MAX_WATCH_ADDRESSES; i++) {
387387
/* device watchpoint in use so skip */
388-
if ((pdd->dev->kfd->alloc_watch_ids >> i) & 0x1)
388+
if ((pdd->dev->alloc_watch_ids >> i) & 0x1)
389389
continue;
390390

391391
pdd->alloc_watch_ids |= 0x1 << i;
392-
pdd->dev->kfd->alloc_watch_ids |= 0x1 << i;
392+
pdd->dev->alloc_watch_ids |= 0x1 << i;
393393
*watch_id = i;
394-
spin_unlock(&pdd->dev->kfd->watch_points_lock);
394+
spin_unlock(&pdd->dev->watch_points_lock);
395395
return 0;
396396
}
397397

398-
spin_unlock(&pdd->dev->kfd->watch_points_lock);
398+
spin_unlock(&pdd->dev->watch_points_lock);
399399

400400
return -ENOMEM;
401401
}
402402

403403
static void kfd_dbg_clear_dev_watch_id(struct kfd_process_device *pdd, int watch_id)
404404
{
405-
spin_lock(&pdd->dev->kfd->watch_points_lock);
405+
spin_lock(&pdd->dev->watch_points_lock);
406406

407407
/* process owns device watch point so safe to clear */
408408
if ((pdd->alloc_watch_ids >> watch_id) & 0x1) {
409409
pdd->alloc_watch_ids &= ~(0x1 << watch_id);
410-
pdd->dev->kfd->alloc_watch_ids &= ~(0x1 << watch_id);
410+
pdd->dev->alloc_watch_ids &= ~(0x1 << watch_id);
411411
}
412412

413-
spin_unlock(&pdd->dev->kfd->watch_points_lock);
413+
spin_unlock(&pdd->dev->watch_points_lock);
414414
}
415415

416416
static bool kfd_dbg_owns_dev_watch_id(struct kfd_process_device *pdd, int watch_id)
417417
{
418418
bool owns_watch_id = false;
419419

420-
spin_lock(&pdd->dev->kfd->watch_points_lock);
420+
spin_lock(&pdd->dev->watch_points_lock);
421421
owns_watch_id = watch_id < MAX_WATCH_ADDRESSES &&
422422
((pdd->alloc_watch_ids >> watch_id) & 0x1);
423423

424-
spin_unlock(&pdd->dev->kfd->watch_points_lock);
424+
spin_unlock(&pdd->dev->watch_points_lock);
425425

426426
return owns_watch_id;
427427
}

drivers/gpu/drm/amd/amdkfd/kfd_device.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,13 +815,14 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
815815
dev_err(kfd_device, "Error initializing KFD node\n");
816816
goto node_init_error;
817817
}
818+
819+
spin_lock_init(&node->watch_points_lock);
820+
818821
kfd->nodes[i] = node;
819822
}
820823

821824
svm_range_set_max_pages(kfd->adev);
822825

823-
spin_lock_init(&kfd->watch_points_lock);
824-
825826
kfd->init_complete = true;
826827
dev_info(kfd_device, "added device %x:%x\n", kfd->adev->pdev->vendor,
827828
kfd->adev->pdev->device);

drivers/gpu/drm/amd/amdkfd/kfd_priv.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,10 @@ struct kfd_node {
316316
struct kfd_local_mem_info local_mem_info;
317317

318318
struct kfd_dev *kfd;
319+
320+
/* Track per device allocated watch points */
321+
uint32_t alloc_watch_ids;
322+
spinlock_t watch_points_lock;
319323
};
320324

321325
struct kfd_dev {
@@ -368,10 +372,6 @@ struct kfd_dev {
368372
struct kfd_node *nodes[MAX_KFD_NODES];
369373
unsigned int num_nodes;
370374

371-
/* Track per device allocated watch points */
372-
uint32_t alloc_watch_ids;
373-
spinlock_t watch_points_lock;
374-
375375
/* Kernel doorbells for KFD device */
376376
struct amdgpu_bo *doorbells;
377377

0 commit comments

Comments
 (0)