diff options
author | Alex Deucher <alexander.deucher@amd.com> | 2015-08-24 22:46:13 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2015-08-25 10:09:30 -0400 |
commit | 52293c67f1e7542a6dc61037d83c266e216bef27 (patch) | |
tree | 51af2a9e0c5cbd678d74373082683f43995a767d /drivers/gpu/drm | |
parent | a887adadb7b9ef9eb4ee48e4ad575aefcfd1db14 (diff) |
drm/amdgpu: fix IH ring allocation for bus addresses (v2)
Use pci_alloc_consistent rather than kzalloc since we
need 256 byte aligned memory for the ring buffer.
v2: fix copy paste typo in free function noticed
by Jammy.
bug:
https://bugs.freedesktop.org/show_bug.cgi?id=91749
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c index 90044b254404..5c8a803acedc 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c | |||
@@ -98,18 +98,12 @@ int amdgpu_ih_ring_init(struct amdgpu_device *adev, unsigned ring_size, | |||
98 | /* add 8 bytes for the rptr/wptr shadows and | 98 | /* add 8 bytes for the rptr/wptr shadows and |
99 | * add them to the end of the ring allocation. | 99 | * add them to the end of the ring allocation. |
100 | */ | 100 | */ |
101 | adev->irq.ih.ring = kzalloc(adev->irq.ih.ring_size + 8, GFP_KERNEL); | 101 | adev->irq.ih.ring = pci_alloc_consistent(adev->pdev, |
102 | adev->irq.ih.ring_size + 8, | ||
103 | &adev->irq.ih.rb_dma_addr); | ||
102 | if (adev->irq.ih.ring == NULL) | 104 | if (adev->irq.ih.ring == NULL) |
103 | return -ENOMEM; | 105 | return -ENOMEM; |
104 | adev->irq.ih.rb_dma_addr = pci_map_single(adev->pdev, | 106 | memset((void *)adev->irq.ih.ring, 0, adev->irq.ih.ring_size + 8); |
105 | (void *)adev->irq.ih.ring, | ||
106 | adev->irq.ih.ring_size, | ||
107 | PCI_DMA_BIDIRECTIONAL); | ||
108 | if (pci_dma_mapping_error(adev->pdev, adev->irq.ih.rb_dma_addr)) { | ||
109 | dev_err(&adev->pdev->dev, "Failed to DMA MAP the IH RB page\n"); | ||
110 | kfree((void *)adev->irq.ih.ring); | ||
111 | return -ENOMEM; | ||
112 | } | ||
113 | adev->irq.ih.wptr_offs = (adev->irq.ih.ring_size / 4) + 0; | 107 | adev->irq.ih.wptr_offs = (adev->irq.ih.ring_size / 4) + 0; |
114 | adev->irq.ih.rptr_offs = (adev->irq.ih.ring_size / 4) + 1; | 108 | adev->irq.ih.rptr_offs = (adev->irq.ih.ring_size / 4) + 1; |
115 | } | 109 | } |
@@ -149,9 +143,9 @@ void amdgpu_ih_ring_fini(struct amdgpu_device *adev) | |||
149 | /* add 8 bytes for the rptr/wptr shadows and | 143 | /* add 8 bytes for the rptr/wptr shadows and |
150 | * add them to the end of the ring allocation. | 144 | * add them to the end of the ring allocation. |
151 | */ | 145 | */ |
152 | pci_unmap_single(adev->pdev, adev->irq.ih.rb_dma_addr, | 146 | pci_free_consistent(adev->pdev, adev->irq.ih.ring_size + 8, |
153 | adev->irq.ih.ring_size + 8, PCI_DMA_BIDIRECTIONAL); | 147 | (void *)adev->irq.ih.ring, |
154 | kfree((void *)adev->irq.ih.ring); | 148 | adev->irq.ih.rb_dma_addr); |
155 | adev->irq.ih.ring = NULL; | 149 | adev->irq.ih.ring = NULL; |
156 | } | 150 | } |
157 | } else { | 151 | } else { |