A null pointer dereference fix for v3d, a TTM pool initialization fix,
several fixes for nouveau around register size, DMA buffer leaks and API consistency, a multiple fixes for ivpu around MMU setup, initialization and firmware interactions. -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZcTCuAAKCRDj7w1vZxhR xTI/AP4wnENmQLfNjGGAZNoAPgbonxSCsy2lNLDPj2LKCckpLgEApf0b8UCpbWGd 3obSP91CD/WzyT6v+txDhXmG7STU3g0= =R6LM -----END PGP SIGNATURE----- Merge tag 'drm-misc-fixes-2024-02-08' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes A null pointer dereference fix for v3d, a TTM pool initialization fix, several fixes for nouveau around register size, DMA buffer leaks and API consistency, a multiple fixes for ivpu around MMU setup, initialization and firmware interactions. Signed-off-by: Dave Airlie <airlied@redhat.com> From: Maxime Ripard <mripard@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/4wsi2i6kgkqdu7nzp4g7hxasbswnrmc5cakgf5zzvnix53u7lr@4rmp7hwblow3
This commit is contained in:
commit
6c2bf9ca24
@ -480,9 +480,8 @@ static int ivpu_pci_init(struct ivpu_device *vdev)
|
||||
/* Clear any pending errors */
|
||||
pcie_capability_clear_word(pdev, PCI_EXP_DEVSTA, 0x3f);
|
||||
|
||||
/* VPU 37XX does not require 10m D3hot delay */
|
||||
if (ivpu_hw_gen(vdev) == IVPU_HW_37XX)
|
||||
pdev->d3hot_delay = 0;
|
||||
/* NPU does not require 10m D3hot delay */
|
||||
pdev->d3hot_delay = 0;
|
||||
|
||||
ret = pcim_enable_device(pdev);
|
||||
if (ret) {
|
||||
|
@ -222,7 +222,6 @@ ivpu_fw_init_wa(struct ivpu_device *vdev)
|
||||
const struct vpu_firmware_header *fw_hdr = (const void *)vdev->fw->file->data;
|
||||
|
||||
if (IVPU_FW_CHECK_API_VER_LT(vdev, fw_hdr, BOOT, 3, 17) ||
|
||||
(ivpu_hw_gen(vdev) > IVPU_HW_37XX) ||
|
||||
(ivpu_test_mode & IVPU_TEST_MODE_D0I3_MSG_DISABLE))
|
||||
vdev->wa.disable_d0i3_msg = true;
|
||||
|
||||
|
@ -525,7 +525,7 @@ static void ivpu_boot_no_snoop_enable(struct ivpu_device *vdev)
|
||||
u32 val = REGV_RD32(VPU_37XX_HOST_IF_TCU_PTW_OVERRIDES);
|
||||
|
||||
val = REG_SET_FLD(VPU_37XX_HOST_IF_TCU_PTW_OVERRIDES, NOSNOOP_OVERRIDE_EN, val);
|
||||
val = REG_SET_FLD(VPU_37XX_HOST_IF_TCU_PTW_OVERRIDES, AW_NOSNOOP_OVERRIDE, val);
|
||||
val = REG_CLR_FLD(VPU_37XX_HOST_IF_TCU_PTW_OVERRIDES, AW_NOSNOOP_OVERRIDE, val);
|
||||
val = REG_SET_FLD(VPU_37XX_HOST_IF_TCU_PTW_OVERRIDES, AR_NOSNOOP_OVERRIDE, val);
|
||||
|
||||
REGV_WR32(VPU_37XX_HOST_IF_TCU_PTW_OVERRIDES, val);
|
||||
|
@ -530,7 +530,7 @@ static void ivpu_boot_no_snoop_enable(struct ivpu_device *vdev)
|
||||
u32 val = REGV_RD32(VPU_40XX_HOST_IF_TCU_PTW_OVERRIDES);
|
||||
|
||||
val = REG_SET_FLD(VPU_40XX_HOST_IF_TCU_PTW_OVERRIDES, SNOOP_OVERRIDE_EN, val);
|
||||
val = REG_CLR_FLD(VPU_40XX_HOST_IF_TCU_PTW_OVERRIDES, AW_SNOOP_OVERRIDE, val);
|
||||
val = REG_SET_FLD(VPU_40XX_HOST_IF_TCU_PTW_OVERRIDES, AW_SNOOP_OVERRIDE, val);
|
||||
val = REG_CLR_FLD(VPU_40XX_HOST_IF_TCU_PTW_OVERRIDES, AR_SNOOP_OVERRIDE, val);
|
||||
|
||||
REGV_WR32(VPU_40XX_HOST_IF_TCU_PTW_OVERRIDES, val);
|
||||
@ -704,7 +704,6 @@ static int ivpu_hw_40xx_info_init(struct ivpu_device *vdev)
|
||||
{
|
||||
struct ivpu_hw_info *hw = vdev->hw;
|
||||
u32 tile_disable;
|
||||
u32 tile_enable;
|
||||
u32 fuse;
|
||||
|
||||
fuse = REGB_RD32(VPU_40XX_BUTTRESS_TILE_FUSE);
|
||||
@ -725,10 +724,6 @@ static int ivpu_hw_40xx_info_init(struct ivpu_device *vdev)
|
||||
else
|
||||
ivpu_dbg(vdev, MISC, "Fuse: All %d tiles enabled\n", TILE_MAX_NUM);
|
||||
|
||||
tile_enable = (~tile_disable) & TILE_MAX_MASK;
|
||||
|
||||
hw->sku = REG_SET_FLD_NUM(SKU, HW_ID, LNL_HW_ID, hw->sku);
|
||||
hw->sku = REG_SET_FLD_NUM(SKU, TILE, tile_enable, hw->sku);
|
||||
hw->tile_fuse = tile_disable;
|
||||
hw->pll.profiling_freq = PLL_PROFILING_FREQ_DEFAULT;
|
||||
|
||||
|
@ -294,7 +294,7 @@ static int ivpu_job_signal_and_destroy(struct ivpu_device *vdev, u32 job_id, u32
|
||||
return -ENOENT;
|
||||
|
||||
if (job->file_priv->has_mmu_faults)
|
||||
job_status = VPU_JSM_STATUS_ABORTED;
|
||||
job_status = DRM_IVPU_JOB_STATUS_ABORTED;
|
||||
|
||||
job->bos[CMD_BUF_IDX]->job_status = job_status;
|
||||
dma_fence_signal(job->done_fence);
|
||||
@ -315,7 +315,7 @@ void ivpu_jobs_abort_all(struct ivpu_device *vdev)
|
||||
unsigned long id;
|
||||
|
||||
xa_for_each(&vdev->submitted_jobs_xa, id, job)
|
||||
ivpu_job_signal_and_destroy(vdev, id, VPU_JSM_STATUS_ABORTED);
|
||||
ivpu_job_signal_and_destroy(vdev, id, DRM_IVPU_JOB_STATUS_ABORTED);
|
||||
}
|
||||
|
||||
static int ivpu_job_submit(struct ivpu_job *job)
|
||||
|
@ -72,10 +72,10 @@
|
||||
|
||||
#define IVPU_MMU_Q_COUNT_LOG2 4 /* 16 entries */
|
||||
#define IVPU_MMU_Q_COUNT ((u32)1 << IVPU_MMU_Q_COUNT_LOG2)
|
||||
#define IVPU_MMU_Q_WRAP_BIT (IVPU_MMU_Q_COUNT << 1)
|
||||
#define IVPU_MMU_Q_WRAP_MASK (IVPU_MMU_Q_WRAP_BIT - 1)
|
||||
#define IVPU_MMU_Q_IDX_MASK (IVPU_MMU_Q_COUNT - 1)
|
||||
#define IVPU_MMU_Q_WRAP_MASK GENMASK(IVPU_MMU_Q_COUNT_LOG2, 0)
|
||||
#define IVPU_MMU_Q_IDX_MASK (IVPU_MMU_Q_COUNT - 1)
|
||||
#define IVPU_MMU_Q_IDX(val) ((val) & IVPU_MMU_Q_IDX_MASK)
|
||||
#define IVPU_MMU_Q_WRP(val) ((val) & IVPU_MMU_Q_COUNT)
|
||||
|
||||
#define IVPU_MMU_CMDQ_CMD_SIZE 16
|
||||
#define IVPU_MMU_CMDQ_SIZE (IVPU_MMU_Q_COUNT * IVPU_MMU_CMDQ_CMD_SIZE)
|
||||
@ -475,20 +475,32 @@ static int ivpu_mmu_cmdq_wait_for_cons(struct ivpu_device *vdev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool ivpu_mmu_queue_is_full(struct ivpu_mmu_queue *q)
|
||||
{
|
||||
return ((IVPU_MMU_Q_IDX(q->prod) == IVPU_MMU_Q_IDX(q->cons)) &&
|
||||
(IVPU_MMU_Q_WRP(q->prod) != IVPU_MMU_Q_WRP(q->cons)));
|
||||
}
|
||||
|
||||
static bool ivpu_mmu_queue_is_empty(struct ivpu_mmu_queue *q)
|
||||
{
|
||||
return ((IVPU_MMU_Q_IDX(q->prod) == IVPU_MMU_Q_IDX(q->cons)) &&
|
||||
(IVPU_MMU_Q_WRP(q->prod) == IVPU_MMU_Q_WRP(q->cons)));
|
||||
}
|
||||
|
||||
static int ivpu_mmu_cmdq_cmd_write(struct ivpu_device *vdev, const char *name, u64 data0, u64 data1)
|
||||
{
|
||||
struct ivpu_mmu_queue *q = &vdev->mmu->cmdq;
|
||||
u64 *queue_buffer = q->base;
|
||||
int idx = IVPU_MMU_Q_IDX(q->prod) * (IVPU_MMU_CMDQ_CMD_SIZE / sizeof(*queue_buffer));
|
||||
struct ivpu_mmu_queue *cmdq = &vdev->mmu->cmdq;
|
||||
u64 *queue_buffer = cmdq->base;
|
||||
int idx = IVPU_MMU_Q_IDX(cmdq->prod) * (IVPU_MMU_CMDQ_CMD_SIZE / sizeof(*queue_buffer));
|
||||
|
||||
if (!CIRC_SPACE(IVPU_MMU_Q_IDX(q->prod), IVPU_MMU_Q_IDX(q->cons), IVPU_MMU_Q_COUNT)) {
|
||||
if (ivpu_mmu_queue_is_full(cmdq)) {
|
||||
ivpu_err(vdev, "Failed to write MMU CMD %s\n", name);
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
queue_buffer[idx] = data0;
|
||||
queue_buffer[idx + 1] = data1;
|
||||
q->prod = (q->prod + 1) & IVPU_MMU_Q_WRAP_MASK;
|
||||
cmdq->prod = (cmdq->prod + 1) & IVPU_MMU_Q_WRAP_MASK;
|
||||
|
||||
ivpu_dbg(vdev, MMU, "CMD write: %s data: 0x%llx 0x%llx\n", name, data0, data1);
|
||||
|
||||
@ -560,7 +572,6 @@ static int ivpu_mmu_reset(struct ivpu_device *vdev)
|
||||
mmu->cmdq.cons = 0;
|
||||
|
||||
memset(mmu->evtq.base, 0, IVPU_MMU_EVTQ_SIZE);
|
||||
clflush_cache_range(mmu->evtq.base, IVPU_MMU_EVTQ_SIZE);
|
||||
mmu->evtq.prod = 0;
|
||||
mmu->evtq.cons = 0;
|
||||
|
||||
@ -874,14 +885,10 @@ static u32 *ivpu_mmu_get_event(struct ivpu_device *vdev)
|
||||
u32 *evt = evtq->base + (idx * IVPU_MMU_EVTQ_CMD_SIZE);
|
||||
|
||||
evtq->prod = REGV_RD32(IVPU_MMU_REG_EVTQ_PROD_SEC);
|
||||
if (!CIRC_CNT(IVPU_MMU_Q_IDX(evtq->prod), IVPU_MMU_Q_IDX(evtq->cons), IVPU_MMU_Q_COUNT))
|
||||
if (ivpu_mmu_queue_is_empty(evtq))
|
||||
return NULL;
|
||||
|
||||
clflush_cache_range(evt, IVPU_MMU_EVTQ_CMD_SIZE);
|
||||
|
||||
evtq->cons = (evtq->cons + 1) & IVPU_MMU_Q_WRAP_MASK;
|
||||
REGV_WR32(IVPU_MMU_REG_EVTQ_CONS_SEC, evtq->cons);
|
||||
|
||||
return evt;
|
||||
}
|
||||
|
||||
@ -902,6 +909,7 @@ void ivpu_mmu_irq_evtq_handler(struct ivpu_device *vdev)
|
||||
}
|
||||
|
||||
ivpu_mmu_user_context_mark_invalid(vdev, ssid);
|
||||
REGV_WR32(IVPU_MMU_REG_EVTQ_CONS_SEC, vdev->mmu->evtq.cons);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#define GSP_PAGE_SIZE BIT(GSP_PAGE_SHIFT)
|
||||
|
||||
struct nvkm_gsp_mem {
|
||||
u32 size;
|
||||
size_t size;
|
||||
void *data;
|
||||
dma_addr_t addr;
|
||||
};
|
||||
|
@ -997,6 +997,32 @@ r535_gsp_rpc_get_gsp_static_info(struct nvkm_gsp *gsp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
nvkm_gsp_mem_dtor(struct nvkm_gsp *gsp, struct nvkm_gsp_mem *mem)
|
||||
{
|
||||
if (mem->data) {
|
||||
/*
|
||||
* Poison the buffer to catch any unexpected access from
|
||||
* GSP-RM if the buffer was prematurely freed.
|
||||
*/
|
||||
memset(mem->data, 0xFF, mem->size);
|
||||
|
||||
dma_free_coherent(gsp->subdev.device->dev, mem->size, mem->data, mem->addr);
|
||||
memset(mem, 0, sizeof(*mem));
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
nvkm_gsp_mem_ctor(struct nvkm_gsp *gsp, size_t size, struct nvkm_gsp_mem *mem)
|
||||
{
|
||||
mem->size = size;
|
||||
mem->data = dma_alloc_coherent(gsp->subdev.device->dev, size, &mem->addr, GFP_KERNEL);
|
||||
if (WARN_ON(!mem->data))
|
||||
return -ENOMEM;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
r535_gsp_postinit(struct nvkm_gsp *gsp)
|
||||
{
|
||||
@ -1024,6 +1050,13 @@ r535_gsp_postinit(struct nvkm_gsp *gsp)
|
||||
|
||||
nvkm_inth_allow(&gsp->subdev.inth);
|
||||
nvkm_wr32(device, 0x110004, 0x00000040);
|
||||
|
||||
/* Release the DMA buffers that were needed only for boot and init */
|
||||
nvkm_gsp_mem_dtor(gsp, &gsp->boot.fw);
|
||||
nvkm_gsp_mem_dtor(gsp, &gsp->libos);
|
||||
nvkm_gsp_mem_dtor(gsp, &gsp->rmargs);
|
||||
nvkm_gsp_mem_dtor(gsp, &gsp->wpr_meta);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1532,27 +1565,6 @@ r535_gsp_msg_run_cpu_sequencer(void *priv, u32 fn, void *repv, u32 repc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
nvkm_gsp_mem_dtor(struct nvkm_gsp *gsp, struct nvkm_gsp_mem *mem)
|
||||
{
|
||||
if (mem->data) {
|
||||
dma_free_coherent(gsp->subdev.device->dev, mem->size, mem->data, mem->addr);
|
||||
mem->data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
nvkm_gsp_mem_ctor(struct nvkm_gsp *gsp, u32 size, struct nvkm_gsp_mem *mem)
|
||||
{
|
||||
mem->size = size;
|
||||
mem->data = dma_alloc_coherent(gsp->subdev.device->dev, size, &mem->addr, GFP_KERNEL);
|
||||
if (WARN_ON(!mem->data))
|
||||
return -ENOMEM;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
r535_gsp_booter_unload(struct nvkm_gsp *gsp, u32 mbox0, u32 mbox1)
|
||||
{
|
||||
@ -1938,20 +1950,20 @@ nvkm_gsp_radix3_dtor(struct nvkm_gsp *gsp, struct nvkm_gsp_radix3 *rx3)
|
||||
* See kgspCreateRadix3_IMPL
|
||||
*/
|
||||
static int
|
||||
nvkm_gsp_radix3_sg(struct nvkm_device *device, struct sg_table *sgt, u64 size,
|
||||
nvkm_gsp_radix3_sg(struct nvkm_gsp *gsp, struct sg_table *sgt, u64 size,
|
||||
struct nvkm_gsp_radix3 *rx3)
|
||||
{
|
||||
u64 addr;
|
||||
|
||||
for (int i = ARRAY_SIZE(rx3->mem) - 1; i >= 0; i--) {
|
||||
u64 *ptes;
|
||||
int idx;
|
||||
size_t bufsize;
|
||||
int ret, idx;
|
||||
|
||||
rx3->mem[i].size = ALIGN((size / GSP_PAGE_SIZE) * sizeof(u64), GSP_PAGE_SIZE);
|
||||
rx3->mem[i].data = dma_alloc_coherent(device->dev, rx3->mem[i].size,
|
||||
&rx3->mem[i].addr, GFP_KERNEL);
|
||||
if (WARN_ON(!rx3->mem[i].data))
|
||||
return -ENOMEM;
|
||||
bufsize = ALIGN((size / GSP_PAGE_SIZE) * sizeof(u64), GSP_PAGE_SIZE);
|
||||
ret = nvkm_gsp_mem_ctor(gsp, bufsize, &rx3->mem[i]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ptes = rx3->mem[i].data;
|
||||
if (i == 2) {
|
||||
@ -1991,7 +2003,7 @@ r535_gsp_fini(struct nvkm_gsp *gsp, bool suspend)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = nvkm_gsp_radix3_sg(gsp->subdev.device, &gsp->sr.sgt, len, &gsp->sr.radix3);
|
||||
ret = nvkm_gsp_radix3_sg(gsp, &gsp->sr.sgt, len, &gsp->sr.radix3);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@ -2150,6 +2162,11 @@ r535_gsp_dtor(struct nvkm_gsp *gsp)
|
||||
mutex_destroy(&gsp->cmdq.mutex);
|
||||
|
||||
r535_gsp_dtor_fws(gsp);
|
||||
|
||||
nvkm_gsp_mem_dtor(gsp, &gsp->shm.mem);
|
||||
nvkm_gsp_mem_dtor(gsp, &gsp->loginit);
|
||||
nvkm_gsp_mem_dtor(gsp, &gsp->logintr);
|
||||
nvkm_gsp_mem_dtor(gsp, &gsp->logrm);
|
||||
}
|
||||
|
||||
int
|
||||
@ -2194,7 +2211,7 @@ r535_gsp_oneinit(struct nvkm_gsp *gsp)
|
||||
memcpy(gsp->sig.data, data, size);
|
||||
|
||||
/* Build radix3 page table for ELF image. */
|
||||
ret = nvkm_gsp_radix3_sg(device, &gsp->fw.mem.sgt, gsp->fw.len, &gsp->radix3);
|
||||
ret = nvkm_gsp_radix3_sg(gsp, &gsp->fw.mem.sgt, gsp->fw.len, &gsp->radix3);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -305,6 +305,7 @@ struct drm_ivpu_submit {
|
||||
|
||||
/* drm_ivpu_bo_wait job status codes */
|
||||
#define DRM_IVPU_JOB_STATUS_SUCCESS 0
|
||||
#define DRM_IVPU_JOB_STATUS_ABORTED 256
|
||||
|
||||
/**
|
||||
* struct drm_ivpu_bo_wait - Wait for BO to become inactive
|
||||
|
Loading…
x
Reference in New Issue
Block a user