Skip to content

Commit 09e1049

Browse files
committed
Merge tag 'drm-misc-fixes-2024-05-02' of https://gitlab.freedesktop.org/drm/misc/kernel into drm-fixes
Short summary of fixes pull: imagination: - fix page-count macro nouveau: - avoid page-table allocation failures - fix firmware memory allocation panel: - ili9341: avoid OF for device properties; respect deferred probe; fix usage of errno codes ttm: - fix status output vmwgfx: - fix legacy display unit - fix read length in fence signalling Signed-off-by: Dave Airlie <[email protected]> From: Thomas Zimmermann <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 5c75d68 + da85f0a commit 09e1049

File tree

9 files changed

+80
-45
lines changed

9 files changed

+80
-45
lines changed

drivers/gpu/drm/imagination/pvr_fw_mips.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
#include "pvr_rogue_mips.h"
88

99
#include <asm/page.h>
10+
#include <linux/math.h>
1011
#include <linux/types.h>
1112

1213
/* Forward declaration from pvr_gem.h. */
1314
struct pvr_gem_object;
1415

15-
#define PVR_MIPS_PT_PAGE_COUNT ((ROGUE_MIPSFW_MAX_NUM_PAGETABLE_PAGES * ROGUE_MIPSFW_PAGE_SIZE_4K) \
16-
>> PAGE_SHIFT)
16+
#define PVR_MIPS_PT_PAGE_COUNT DIV_ROUND_UP(ROGUE_MIPSFW_MAX_NUM_PAGETABLE_PAGES * ROGUE_MIPSFW_PAGE_SIZE_4K, PAGE_SIZE)
17+
1718
/**
1819
* struct pvr_fw_mips_data - MIPS-specific data
1920
*/

drivers/gpu/drm/nouveau/include/nvkm/subdev/gsp.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ struct nvkm_gsp_mem {
1515
};
1616

1717
struct nvkm_gsp_radix3 {
18-
struct nvkm_gsp_mem mem[3];
18+
struct nvkm_gsp_mem lvl0;
19+
struct nvkm_gsp_mem lvl1;
20+
struct sg_table lvl2;
1921
};
2022

2123
int nvkm_gsp_sg(struct nvkm_device *, u64 size, struct sg_table *);

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ nvkm_firmware_dtor(struct nvkm_firmware *fw)
205205
break;
206206
case NVKM_FIRMWARE_IMG_DMA:
207207
nvkm_memory_unref(&memory);
208-
dma_free_coherent(fw->device->dev, sg_dma_len(&fw->mem.sgl), fw->img, fw->phys);
208+
dma_unmap_single(fw->device->dev, fw->phys, sg_dma_len(&fw->mem.sgl),
209+
DMA_TO_DEVICE);
210+
kfree(fw->img);
209211
break;
210212
case NVKM_FIRMWARE_IMG_SGT:
211213
nvkm_memory_unref(&memory);
@@ -235,14 +237,17 @@ nvkm_firmware_ctor(const struct nvkm_firmware_func *func, const char *name,
235237
fw->img = kmemdup(src, fw->len, GFP_KERNEL);
236238
break;
237239
case NVKM_FIRMWARE_IMG_DMA: {
238-
dma_addr_t addr;
239-
240240
len = ALIGN(fw->len, PAGE_SIZE);
241241

242-
fw->img = dma_alloc_coherent(fw->device->dev, len, &addr, GFP_KERNEL);
243-
if (fw->img) {
244-
memcpy(fw->img, src, fw->len);
245-
fw->phys = addr;
242+
fw->img = kmalloc(len, GFP_KERNEL);
243+
if (!fw->img)
244+
return -ENOMEM;
245+
246+
memcpy(fw->img, src, fw->len);
247+
fw->phys = dma_map_single(fw->device->dev, fw->img, len, DMA_TO_DEVICE);
248+
if (dma_mapping_error(fw->device->dev, fw->phys)) {
249+
kfree(fw->img);
250+
return -EFAULT;
246251
}
247252

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

drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,7 +1624,7 @@ r535_gsp_wpr_meta_init(struct nvkm_gsp *gsp)
16241624
meta->magic = GSP_FW_WPR_META_MAGIC;
16251625
meta->revision = GSP_FW_WPR_META_REVISION;
16261626

1627-
meta->sysmemAddrOfRadix3Elf = gsp->radix3.mem[0].addr;
1627+
meta->sysmemAddrOfRadix3Elf = gsp->radix3.lvl0.addr;
16281628
meta->sizeOfRadix3Elf = gsp->fb.wpr2.elf.size;
16291629

16301630
meta->sysmemAddrOfBootloader = gsp->boot.fw.addr;
@@ -1919,8 +1919,9 @@ nvkm_gsp_sg(struct nvkm_device *device, u64 size, struct sg_table *sgt)
19191919
static void
19201920
nvkm_gsp_radix3_dtor(struct nvkm_gsp *gsp, struct nvkm_gsp_radix3 *rx3)
19211921
{
1922-
for (int i = ARRAY_SIZE(rx3->mem) - 1; i >= 0; i--)
1923-
nvkm_gsp_mem_dtor(gsp, &rx3->mem[i]);
1922+
nvkm_gsp_sg_free(gsp->subdev.device, &rx3->lvl2);
1923+
nvkm_gsp_mem_dtor(gsp, &rx3->lvl1);
1924+
nvkm_gsp_mem_dtor(gsp, &rx3->lvl0);
19241925
}
19251926

19261927
/**
@@ -1960,36 +1961,60 @@ static int
19601961
nvkm_gsp_radix3_sg(struct nvkm_gsp *gsp, struct sg_table *sgt, u64 size,
19611962
struct nvkm_gsp_radix3 *rx3)
19621963
{
1963-
u64 addr;
1964+
struct sg_dma_page_iter sg_dma_iter;
1965+
struct scatterlist *sg;
1966+
size_t bufsize;
1967+
u64 *pte;
1968+
int ret, i, page_idx = 0;
19641969

1965-
for (int i = ARRAY_SIZE(rx3->mem) - 1; i >= 0; i--) {
1966-
u64 *ptes;
1967-
size_t bufsize;
1968-
int ret, idx;
1970+
ret = nvkm_gsp_mem_ctor(gsp, GSP_PAGE_SIZE, &rx3->lvl0);
1971+
if (ret)
1972+
return ret;
19691973

1970-
bufsize = ALIGN((size / GSP_PAGE_SIZE) * sizeof(u64), GSP_PAGE_SIZE);
1971-
ret = nvkm_gsp_mem_ctor(gsp, bufsize, &rx3->mem[i]);
1972-
if (ret)
1973-
return ret;
1974+
ret = nvkm_gsp_mem_ctor(gsp, GSP_PAGE_SIZE, &rx3->lvl1);
1975+
if (ret)
1976+
goto lvl1_fail;
19741977

1975-
ptes = rx3->mem[i].data;
1976-
if (i == 2) {
1977-
struct scatterlist *sgl;
1978+
// Allocate level 2
1979+
bufsize = ALIGN((size / GSP_PAGE_SIZE) * sizeof(u64), GSP_PAGE_SIZE);
1980+
ret = nvkm_gsp_sg(gsp->subdev.device, bufsize, &rx3->lvl2);
1981+
if (ret)
1982+
goto lvl2_fail;
19781983

1979-
for_each_sgtable_dma_sg(sgt, sgl, idx) {
1980-
for (int j = 0; j < sg_dma_len(sgl) / GSP_PAGE_SIZE; j++)
1981-
*ptes++ = sg_dma_address(sgl) + (GSP_PAGE_SIZE * j);
1982-
}
1983-
} else {
1984-
for (int j = 0; j < size / GSP_PAGE_SIZE; j++)
1985-
*ptes++ = addr + GSP_PAGE_SIZE * j;
1984+
// Write the bus address of level 1 to level 0
1985+
pte = rx3->lvl0.data;
1986+
*pte = rx3->lvl1.addr;
1987+
1988+
// Write the bus address of each page in level 2 to level 1
1989+
pte = rx3->lvl1.data;
1990+
for_each_sgtable_dma_page(&rx3->lvl2, &sg_dma_iter, 0)
1991+
*pte++ = sg_page_iter_dma_address(&sg_dma_iter);
1992+
1993+
// Finally, write the bus address of each page in sgt to level 2
1994+
for_each_sgtable_sg(&rx3->lvl2, sg, i) {
1995+
void *sgl_end;
1996+
1997+
pte = sg_virt(sg);
1998+
sgl_end = (void *)pte + sg->length;
1999+
2000+
for_each_sgtable_dma_page(sgt, &sg_dma_iter, page_idx) {
2001+
*pte++ = sg_page_iter_dma_address(&sg_dma_iter);
2002+
page_idx++;
2003+
2004+
// Go to the next scatterlist for level 2 if we've reached the end
2005+
if ((void *)pte >= sgl_end)
2006+
break;
19862007
}
2008+
}
19872009

1988-
size = rx3->mem[i].size;
1989-
addr = rx3->mem[i].addr;
2010+
if (ret) {
2011+
lvl2_fail:
2012+
nvkm_gsp_mem_dtor(gsp, &rx3->lvl1);
2013+
lvl1_fail:
2014+
nvkm_gsp_mem_dtor(gsp, &rx3->lvl0);
19902015
}
19912016

1992-
return 0;
2017+
return ret;
19932018
}
19942019

19952020
int
@@ -2021,7 +2046,7 @@ r535_gsp_fini(struct nvkm_gsp *gsp, bool suspend)
20212046
sr = gsp->sr.meta.data;
20222047
sr->magic = GSP_FW_SR_META_MAGIC;
20232048
sr->revision = GSP_FW_SR_META_REVISION;
2024-
sr->sysmemAddrOfSuspendResumeData = gsp->sr.radix3.mem[0].addr;
2049+
sr->sysmemAddrOfSuspendResumeData = gsp->sr.radix3.lvl0.addr;
20252050
sr->sizeOfSuspendResumeData = len;
20262051

20272052
mbox0 = lower_32_bits(gsp->sr.meta.addr);

drivers/gpu/drm/panel/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ config DRM_PANEL_ILITEK_IL9322
177177

178178
config DRM_PANEL_ILITEK_ILI9341
179179
tristate "Ilitek ILI9341 240x320 QVGA panels"
180-
depends on OF && SPI
180+
depends on SPI
181181
select DRM_KMS_HELPER
182182
select DRM_GEM_DMA_HELPER
183183
depends on BACKLIGHT_CLASS_DEVICE

drivers/gpu/drm/panel/panel-ilitek-ili9341.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
#include <linux/bitops.h>
2323
#include <linux/delay.h>
2424
#include <linux/gpio/consumer.h>
25+
#include <linux/mod_devicetable.h>
2526
#include <linux/module.h>
26-
#include <linux/of.h>
27+
#include <linux/property.h>
2728
#include <linux/regulator/consumer.h>
2829
#include <linux/spi/spi.h>
2930

@@ -421,7 +422,7 @@ static int ili9341_dpi_prepare(struct drm_panel *panel)
421422

422423
ili9341_dpi_init(ili);
423424

424-
return ret;
425+
return 0;
425426
}
426427

427428
static int ili9341_dpi_enable(struct drm_panel *panel)
@@ -691,7 +692,7 @@ static int ili9341_dpi_probe(struct spi_device *spi, struct gpio_desc *dc,
691692
* Every new incarnation of this display must have a unique
692693
* data entry for the system in this driver.
693694
*/
694-
ili->conf = of_device_get_match_data(dev);
695+
ili->conf = device_get_match_data(dev);
695696
if (!ili->conf) {
696697
dev_err(dev, "missing device configuration\n");
697698
return -ENODEV;
@@ -714,18 +715,18 @@ static int ili9341_probe(struct spi_device *spi)
714715

715716
reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
716717
if (IS_ERR(reset))
717-
dev_err(dev, "Failed to get gpio 'reset'\n");
718+
return dev_err_probe(dev, PTR_ERR(reset), "Failed to get gpio 'reset'\n");
718719

719720
dc = devm_gpiod_get_optional(dev, "dc", GPIOD_OUT_LOW);
720721
if (IS_ERR(dc))
721-
dev_err(dev, "Failed to get gpio 'dc'\n");
722+
return dev_err_probe(dev, PTR_ERR(dc), "Failed to get gpio 'dc'\n");
722723

723724
if (!strcmp(id->name, "sf-tc240t-9370-t"))
724725
return ili9341_dpi_probe(spi, dc, reset);
725726
else if (!strcmp(id->name, "yx240qv29"))
726727
return ili9341_dbi_probe(spi, dc, reset);
727728

728-
return -1;
729+
return -ENODEV;
729730
}
730731

731732
static void ili9341_remove(struct spi_device *spi)

drivers/gpu/drm/ttm/ttm_tt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc)
9292
*/
9393
if (bdev->pool.use_dma_alloc && cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)) {
9494
page_flags |= TTM_TT_FLAG_DECRYPTED;
95-
drm_info(ddev, "TT memory decryption enabled.");
95+
drm_info_once(ddev, "TT memory decryption enabled.");
9696
}
9797

9898
bo->ttm = bdev->funcs->ttm_tt_create(bo, page_flags);

drivers/gpu/drm/vmwgfx/vmwgfx_bo.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv,
204204
VMW_BO_DOMAIN_VRAM,
205205
VMW_BO_DOMAIN_VRAM);
206206
buf->places[0].lpfn = PFN_UP(bo->resource->size);
207+
buf->busy_places[0].lpfn = PFN_UP(bo->resource->size);
207208
ret = ttm_bo_validate(bo, &buf->placement, &ctx);
208209

209210
/* For some reason we didn't end up at the start of vram */

drivers/gpu/drm/vmwgfx/vmwgfx_fence.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ static int vmw_event_fence_action_create(struct drm_file *file_priv,
991991
}
992992

993993
event->event.base.type = DRM_VMW_EVENT_FENCE_SIGNALED;
994-
event->event.base.length = sizeof(*event);
994+
event->event.base.length = sizeof(event->event);
995995
event->event.user_data = user_data;
996996

997997
ret = drm_event_reserve_init(dev, file_priv, &event->base, &event->event.base);

0 commit comments

Comments
 (0)