Skip to content

Commit 2a5599c

Browse files
airliedopsiff
authored andcommitted
Revert "drm/nouveau/firmware: Fix SG_DEBUG error with nvkm_firmware_ctor()"
commit a222a64 upstream. This reverts commit 52a6947. This causes loading failures in [ 0.367379] nouveau 0000:01:00.0: NVIDIA GP104 (134000a1) [ 0.474499] nouveau 0000:01:00.0: bios: version 86.04.50.80.13 [ 0.474620] nouveau 0000:01:00.0: pmu: firmware unavailable [ 0.474977] nouveau 0000:01:00.0: fb: 8192 MiB GDDR5 [ 0.484371] nouveau 0000:01:00.0: sec2(acr): mbox 00000001 00000000 [ 0.484377] nouveau 0000:01:00.0: sec2(acr):load: boot failed: -5 [ 0.484379] nouveau 0000:01:00.0: acr: init failed, -5 [ 0.484466] nouveau 0000:01:00.0: init failed with -5 [ 0.484468] nouveau: DRM-master:00000000:00000080: init failed with -5 [ 0.484470] nouveau 0000:01:00.0: DRM-master: Device allocation failed: -5 [ 0.485078] nouveau 0000:01:00.0: probe with driver nouveau failed with error -50 I tried tracking it down but ran out of time this week, will revisit next week. Reported-by: Dan Moulding <[email protected]> Cc: [email protected] Signed-off-by: Dave Airlie <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3566bee commit 2a5599c

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

drivers/gpu/drm/nouveau/nvkm/core/firmware.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,7 @@ nvkm_firmware_dtor(struct nvkm_firmware *fw)
187187
break;
188188
case NVKM_FIRMWARE_IMG_DMA:
189189
nvkm_memory_unref(&memory);
190-
dma_unmap_single(fw->device->dev, fw->phys, sg_dma_len(&fw->mem.sgl),
191-
DMA_TO_DEVICE);
192-
kfree(fw->img);
190+
dma_free_coherent(fw->device->dev, sg_dma_len(&fw->mem.sgl), fw->img, fw->phys);
193191
break;
194192
default:
195193
WARN_ON(1);
@@ -213,17 +211,14 @@ nvkm_firmware_ctor(const struct nvkm_firmware_func *func, const char *name,
213211
fw->img = kmemdup(src, fw->len, GFP_KERNEL);
214212
break;
215213
case NVKM_FIRMWARE_IMG_DMA: {
216-
len = ALIGN(fw->len, PAGE_SIZE);
214+
dma_addr_t addr;
217215

218-
fw->img = kmalloc(len, GFP_KERNEL);
219-
if (!fw->img)
220-
return -ENOMEM;
216+
len = ALIGN(fw->len, PAGE_SIZE);
221217

222-
memcpy(fw->img, src, fw->len);
223-
fw->phys = dma_map_single(fw->device->dev, fw->img, len, DMA_TO_DEVICE);
224-
if (dma_mapping_error(fw->device->dev, fw->phys)) {
225-
kfree(fw->img);
226-
return -EFAULT;
218+
fw->img = dma_alloc_coherent(fw->device->dev, len, &addr, GFP_KERNEL);
219+
if (fw->img) {
220+
memcpy(fw->img, src, fw->len);
221+
fw->phys = addr;
227222
}
228223

229224
sg_init_one(&fw->mem.sgl, fw->img, len);

0 commit comments

Comments
 (0)