diff options
author | Chunming Zhou <David1.Zhou@amd.com> | 2016-08-30 04:13:10 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2016-08-31 15:21:12 -0400 |
commit | 5c1354bd30c118326236e13cfdc49db03d2b5855 (patch) | |
tree | cbcbcabc509367914f3224167c6aa2fa12e5b487 /drivers/gpu/drm/amd/amdgpu | |
parent | 78fbb6859b739f7f67c820ab8c9e7a25add977b5 (diff) |
drm/amdgpu: link all gtt when binding them V2
V2:
spin lock instead of mutex for gtt list
Signed-off-by: Chunming Zhou <David1.Zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 9 |
3 files changed, 17 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 86762cd74f6d..829b0b4eb838 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -2121,6 +2121,10 @@ struct amdgpu_device { | |||
2121 | /* link all shadow bo */ | 2121 | /* link all shadow bo */ |
2122 | struct list_head shadow_list; | 2122 | struct list_head shadow_list; |
2123 | struct mutex shadow_list_lock; | 2123 | struct mutex shadow_list_lock; |
2124 | /* link all gtt */ | ||
2125 | spinlock_t gtt_list_lock; | ||
2126 | struct list_head gtt_list; | ||
2127 | |||
2124 | }; | 2128 | }; |
2125 | 2129 | ||
2126 | bool amdgpu_device_is_px(struct drm_device *dev); | 2130 | bool amdgpu_device_is_px(struct drm_device *dev); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index f95bcb80dde3..bfdd445a8bb6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -1577,6 +1577,9 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
1577 | INIT_LIST_HEAD(&adev->shadow_list); | 1577 | INIT_LIST_HEAD(&adev->shadow_list); |
1578 | mutex_init(&adev->shadow_list_lock); | 1578 | mutex_init(&adev->shadow_list_lock); |
1579 | 1579 | ||
1580 | INIT_LIST_HEAD(&adev->gtt_list); | ||
1581 | spin_lock_init(&adev->gtt_list_lock); | ||
1582 | |||
1580 | if (adev->asic_type >= CHIP_BONAIRE) { | 1583 | if (adev->asic_type >= CHIP_BONAIRE) { |
1581 | adev->rmmio_base = pci_resource_start(adev->pdev, 5); | 1584 | adev->rmmio_base = pci_resource_start(adev->pdev, 5); |
1582 | adev->rmmio_size = pci_resource_len(adev->pdev, 5); | 1585 | adev->rmmio_size = pci_resource_len(adev->pdev, 5); |
@@ -1584,6 +1587,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
1584 | adev->rmmio_base = pci_resource_start(adev->pdev, 2); | 1587 | adev->rmmio_base = pci_resource_start(adev->pdev, 2); |
1585 | adev->rmmio_size = pci_resource_len(adev->pdev, 2); | 1588 | adev->rmmio_size = pci_resource_len(adev->pdev, 2); |
1586 | } | 1589 | } |
1590 | |||
1587 | adev->rmmio = ioremap(adev->rmmio_base, adev->rmmio_size); | 1591 | adev->rmmio = ioremap(adev->rmmio_base, adev->rmmio_size); |
1588 | if (adev->rmmio == NULL) { | 1592 | if (adev->rmmio == NULL) { |
1589 | return -ENOMEM; | 1593 | return -ENOMEM; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 5447973483ec..26ca3dd183eb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | |||
@@ -520,6 +520,7 @@ struct amdgpu_ttm_tt { | |||
520 | spinlock_t guptasklock; | 520 | spinlock_t guptasklock; |
521 | struct list_head guptasks; | 521 | struct list_head guptasks; |
522 | atomic_t mmu_invalidations; | 522 | atomic_t mmu_invalidations; |
523 | struct list_head list; | ||
523 | }; | 524 | }; |
524 | 525 | ||
525 | int amdgpu_ttm_tt_get_user_pages(struct ttm_tt *ttm, struct page **pages) | 526 | int amdgpu_ttm_tt_get_user_pages(struct ttm_tt *ttm, struct page **pages) |
@@ -666,6 +667,9 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, | |||
666 | ttm->num_pages, (unsigned)gtt->offset); | 667 | ttm->num_pages, (unsigned)gtt->offset); |
667 | return r; | 668 | return r; |
668 | } | 669 | } |
670 | spin_lock(>t->adev->gtt_list_lock); | ||
671 | list_add_tail(>t->list, >t->adev->gtt_list); | ||
672 | spin_unlock(>t->adev->gtt_list_lock); | ||
669 | return 0; | 673 | return 0; |
670 | } | 674 | } |
671 | 675 | ||
@@ -680,6 +684,10 @@ static int amdgpu_ttm_backend_unbind(struct ttm_tt *ttm) | |||
680 | if (gtt->userptr) | 684 | if (gtt->userptr) |
681 | amdgpu_ttm_tt_unpin_userptr(ttm); | 685 | amdgpu_ttm_tt_unpin_userptr(ttm); |
682 | 686 | ||
687 | spin_lock(>t->adev->gtt_list_lock); | ||
688 | list_del_init(>t->list); | ||
689 | spin_unlock(>t->adev->gtt_list_lock); | ||
690 | |||
683 | return 0; | 691 | return 0; |
684 | } | 692 | } |
685 | 693 | ||
@@ -716,6 +724,7 @@ static struct ttm_tt *amdgpu_ttm_tt_create(struct ttm_bo_device *bdev, | |||
716 | kfree(gtt); | 724 | kfree(gtt); |
717 | return NULL; | 725 | return NULL; |
718 | } | 726 | } |
727 | INIT_LIST_HEAD(>t->list); | ||
719 | return >t->ttm.ttm; | 728 | return >t->ttm.ttm; |
720 | } | 729 | } |
721 | 730 | ||