From: Greg Kroah-Hartman Date: Sat, 14 Sep 2024 07:12:07 +0000 (+0200) Subject: 6.10-stable patches X-Git-Tag: v6.1.111~17 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0c736c88a439b123254f6a5996dfdf548293d53a;p=thirdparty%2Fkernel%2Fstable-queue.git 6.10-stable patches added patches: dma-buf-heaps-fix-off-by-one-in-cma-heap-fault-handler.patch drm-amd-amdgpu-apply-command-submission-parser-for-jpeg-v1.patch drm-amd-amdgpu-apply-command-submission-parser-for-jpeg-v2.patch drm-amd-display-avoid-race-between-dcn10_set_drr-and-dc_state_destruct.patch drm-amd-display-avoid-race-between-dcn35_set_drr-and-dc_state_destruct.patch drm-amdgpu-atomfirmware-silence-ubsan-warning.patch drm-nouveau-fb-restore-init-for-ramgp102.patch drm-syncobj-fix-syncobj-leak-in-drm_syncobj_eventfd_ioctl.patch drm-xe-client-add-missing-bo-locking-in-show_meminfo.patch drm-xe-client-fix-deadlock-in-show_meminfo.patch soundwire-stream-revert-soundwire-stream-fix-programming-slave-ports-for-non-continous-port-maps.patch spi-nxp-fspi-fix-the-kasan-report-out-of-bounds-bug.patch tracing-kprobes-fix-build-error-when-find_module-is-not-available.patch tracing-osnoise-fix-build-when-timerlat-is-not-enabled.patch --- diff --git a/queue-6.10/dma-buf-heaps-fix-off-by-one-in-cma-heap-fault-handler.patch b/queue-6.10/dma-buf-heaps-fix-off-by-one-in-cma-heap-fault-handler.patch new file mode 100644 index 00000000000..fc7545243ee --- /dev/null +++ b/queue-6.10/dma-buf-heaps-fix-off-by-one-in-cma-heap-fault-handler.patch @@ -0,0 +1,41 @@ +From ea5ff5d351b520524019f7ff7f9ce418de2dad87 Mon Sep 17 00:00:00 2001 +From: "T.J. Mercier" +Date: Fri, 30 Aug 2024 19:26:26 +0000 +Subject: dma-buf: heaps: Fix off-by-one in CMA heap fault handler + +From: T.J. Mercier + +commit ea5ff5d351b520524019f7ff7f9ce418de2dad87 upstream. + +Until VM_DONTEXPAND was added in commit 1c1914d6e8c6 ("dma-buf: heaps: +Don't track CMA dma-buf pages under RssFile") it was possible to obtain +a mapping larger than the buffer size via mremap and bypass the overflow +check in dma_buf_mmap_internal. When using such a mapping to attempt to +fault past the end of the buffer, the CMA heap fault handler also checks +the fault offset against the buffer size, but gets the boundary wrong by +1. Fix the boundary check so that we don't read off the end of the pages +array and insert an arbitrary page in the mapping. + +Reported-by: Xingyu Jin +Fixes: a5d2d29e24be ("dma-buf: heaps: Move heap-helper logic into the cma_heap implementation") +Cc: stable@vger.kernel.org # Applicable >= 5.10. Needs adjustments only for 5.10. +Signed-off-by: T.J. Mercier +Acked-by: John Stultz +Signed-off-by: Sumit Semwal +Link: https://patchwork.freedesktop.org/patch/msgid/20240830192627.2546033-1-tjmercier@google.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/dma-buf/heaps/cma_heap.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/dma-buf/heaps/cma_heap.c ++++ b/drivers/dma-buf/heaps/cma_heap.c +@@ -165,7 +165,7 @@ static vm_fault_t cma_heap_vm_fault(stru + struct vm_area_struct *vma = vmf->vma; + struct cma_heap_buffer *buffer = vma->vm_private_data; + +- if (vmf->pgoff > buffer->pagecount) ++ if (vmf->pgoff >= buffer->pagecount) + return VM_FAULT_SIGBUS; + + return vmf_insert_pfn(vma, vmf->address, page_to_pfn(buffer->pages[vmf->pgoff])); diff --git a/queue-6.10/drm-amd-amdgpu-apply-command-submission-parser-for-jpeg-v1.patch b/queue-6.10/drm-amd-amdgpu-apply-command-submission-parser-for-jpeg-v1.patch new file mode 100644 index 00000000000..88e1a9e368d --- /dev/null +++ b/queue-6.10/drm-amd-amdgpu-apply-command-submission-parser-for-jpeg-v1.patch @@ -0,0 +1,151 @@ +From 8409fb50ce48d66cf9dc5391f03f05c56c430605 Mon Sep 17 00:00:00 2001 +From: "David (Ming Qiang) Wu" +Date: Thu, 5 Sep 2024 16:57:28 -0400 +Subject: drm/amd/amdgpu: apply command submission parser for JPEG v1 + +From: David (Ming Qiang) Wu + +commit 8409fb50ce48d66cf9dc5391f03f05c56c430605 upstream. + +Similar to jpeg_v2_dec_ring_parse_cs() but it has different +register ranges and a few other registers access. + +Acked-by: Alex Deucher +Signed-off-by: David (Ming Qiang) Wu +Signed-off-by: Alex Deucher +(cherry picked from commit 3d5adbdf1d01708777f2eda375227cbf7a98b9fe) +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c | 76 ++++++++++++++++++++++++++++++++- + drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.h | 11 ++++ + 2 files changed, 86 insertions(+), 1 deletion(-) + +--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c ++++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c +@@ -23,6 +23,7 @@ + + #include "amdgpu.h" + #include "amdgpu_jpeg.h" ++#include "amdgpu_cs.h" + #include "soc15.h" + #include "soc15d.h" + #include "vcn_v1_0.h" +@@ -34,6 +35,9 @@ + static void jpeg_v1_0_set_dec_ring_funcs(struct amdgpu_device *adev); + static void jpeg_v1_0_set_irq_funcs(struct amdgpu_device *adev); + static void jpeg_v1_0_ring_begin_use(struct amdgpu_ring *ring); ++static int jpeg_v1_dec_ring_parse_cs(struct amdgpu_cs_parser *parser, ++ struct amdgpu_job *job, ++ struct amdgpu_ib *ib); + + static void jpeg_v1_0_decode_ring_patch_wreg(struct amdgpu_ring *ring, uint32_t *ptr, uint32_t reg_offset, uint32_t val) + { +@@ -300,7 +304,10 @@ static void jpeg_v1_0_decode_ring_emit_i + + amdgpu_ring_write(ring, + PACKETJ(SOC15_REG_OFFSET(JPEG, 0, mmUVD_LMI_JRBC_IB_VMID), 0, 0, PACKETJ_TYPE0)); +- amdgpu_ring_write(ring, (vmid | (vmid << 4))); ++ if (ring->funcs->parse_cs) ++ amdgpu_ring_write(ring, 0); ++ else ++ amdgpu_ring_write(ring, (vmid | (vmid << 4))); + + amdgpu_ring_write(ring, + PACKETJ(SOC15_REG_OFFSET(JPEG, 0, mmUVD_LMI_JPEG_VMID), 0, 0, PACKETJ_TYPE0)); +@@ -554,6 +561,7 @@ static const struct amdgpu_ring_funcs jp + .get_rptr = jpeg_v1_0_decode_ring_get_rptr, + .get_wptr = jpeg_v1_0_decode_ring_get_wptr, + .set_wptr = jpeg_v1_0_decode_ring_set_wptr, ++ .parse_cs = jpeg_v1_dec_ring_parse_cs, + .emit_frame_size = + 6 + 6 + /* hdp invalidate / flush */ + SOC15_FLUSH_GPU_TLB_NUM_WREG * 6 + +@@ -612,3 +620,69 @@ static void jpeg_v1_0_ring_begin_use(str + + vcn_v1_0_set_pg_for_begin_use(ring, set_clocks); + } ++ ++/** ++ * jpeg_v1_dec_ring_parse_cs - command submission parser ++ * ++ * @parser: Command submission parser context ++ * @job: the job to parse ++ * @ib: the IB to parse ++ * ++ * Parse the command stream, return -EINVAL for invalid packet, ++ * 0 otherwise ++ */ ++static int jpeg_v1_dec_ring_parse_cs(struct amdgpu_cs_parser *parser, ++ struct amdgpu_job *job, ++ struct amdgpu_ib *ib) ++{ ++ u32 i, reg, res, cond, type; ++ int ret = 0; ++ struct amdgpu_device *adev = parser->adev; ++ ++ for (i = 0; i < ib->length_dw ; i += 2) { ++ reg = CP_PACKETJ_GET_REG(ib->ptr[i]); ++ res = CP_PACKETJ_GET_RES(ib->ptr[i]); ++ cond = CP_PACKETJ_GET_COND(ib->ptr[i]); ++ type = CP_PACKETJ_GET_TYPE(ib->ptr[i]); ++ ++ if (res || cond != PACKETJ_CONDITION_CHECK0) /* only allow 0 for now */ ++ return -EINVAL; ++ ++ if (reg >= JPEG_V1_REG_RANGE_START && reg <= JPEG_V1_REG_RANGE_END) ++ continue; ++ ++ switch (type) { ++ case PACKETJ_TYPE0: ++ if (reg != JPEG_V1_LMI_JPEG_WRITE_64BIT_BAR_HIGH && ++ reg != JPEG_V1_LMI_JPEG_WRITE_64BIT_BAR_LOW && ++ reg != JPEG_V1_LMI_JPEG_READ_64BIT_BAR_HIGH && ++ reg != JPEG_V1_LMI_JPEG_READ_64BIT_BAR_LOW && ++ reg != JPEG_V1_REG_CTX_INDEX && ++ reg != JPEG_V1_REG_CTX_DATA) { ++ ret = -EINVAL; ++ } ++ break; ++ case PACKETJ_TYPE1: ++ if (reg != JPEG_V1_REG_CTX_DATA) ++ ret = -EINVAL; ++ break; ++ case PACKETJ_TYPE3: ++ if (reg != JPEG_V1_REG_SOFT_RESET) ++ ret = -EINVAL; ++ break; ++ case PACKETJ_TYPE6: ++ if (ib->ptr[i] != CP_PACKETJ_NOP) ++ ret = -EINVAL; ++ break; ++ default: ++ ret = -EINVAL; ++ } ++ ++ if (ret) { ++ dev_err(adev->dev, "Invalid packet [0x%08x]!\n", ib->ptr[i]); ++ break; ++ } ++ } ++ ++ return ret; ++} +--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.h ++++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.h +@@ -29,4 +29,15 @@ int jpeg_v1_0_sw_init(void *handle); + void jpeg_v1_0_sw_fini(void *handle); + void jpeg_v1_0_start(struct amdgpu_device *adev, int mode); + ++#define JPEG_V1_REG_RANGE_START 0x8000 ++#define JPEG_V1_REG_RANGE_END 0x803f ++ ++#define JPEG_V1_LMI_JPEG_WRITE_64BIT_BAR_HIGH 0x8238 ++#define JPEG_V1_LMI_JPEG_WRITE_64BIT_BAR_LOW 0x8239 ++#define JPEG_V1_LMI_JPEG_READ_64BIT_BAR_HIGH 0x825a ++#define JPEG_V1_LMI_JPEG_READ_64BIT_BAR_LOW 0x825b ++#define JPEG_V1_REG_CTX_INDEX 0x8328 ++#define JPEG_V1_REG_CTX_DATA 0x8329 ++#define JPEG_V1_REG_SOFT_RESET 0x83a0 ++ + #endif /*__JPEG_V1_0_H__*/ diff --git a/queue-6.10/drm-amd-amdgpu-apply-command-submission-parser-for-jpeg-v2.patch b/queue-6.10/drm-amd-amdgpu-apply-command-submission-parser-for-jpeg-v2.patch new file mode 100644 index 00000000000..27896989dd3 --- /dev/null +++ b/queue-6.10/drm-amd-amdgpu-apply-command-submission-parser-for-jpeg-v2.patch @@ -0,0 +1,321 @@ +From 3a23aa0b9c24c682c506121e2e0f6cbcfdae9076 Mon Sep 17 00:00:00 2001 +From: "David (Ming Qiang) Wu" +Date: Fri, 16 Aug 2024 11:43:05 -0400 +Subject: drm/amd/amdgpu: apply command submission parser for JPEG v2+ + +From: David (Ming Qiang) Wu + +commit 3a23aa0b9c24c682c506121e2e0f6cbcfdae9076 upstream. + +This patch extends the same cs parser from JPEG v4.0.3 to +other JPEG versions (v2 and above). + +Rename to more common name as jpeg_v2_dec_ring_parse_cs() +from jpeg_v4_0_3_dec_ring_parse_cs(). + +Acked-by: Alex Deucher +Signed-off-by: David (Ming Qiang) Wu +Signed-off-by: Alex Deucher +(cherry picked from commit 88dcad2d07c8d82e6a097c8e74239eb67333bcf7) +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c | 63 ++++++++++++++++++++++++++++++- + drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.h | 6 ++ + drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c | 2 + drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c | 1 + drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c | 1 + drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.h | 1 + drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c | 57 ---------------------------- + drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.h | 7 --- + drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_5.c | 1 + drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_0.c | 3 - + 10 files changed, 78 insertions(+), 64 deletions(-) + +--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c ++++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c +@@ -23,6 +23,7 @@ + + #include "amdgpu.h" + #include "amdgpu_jpeg.h" ++#include "amdgpu_cs.h" + #include "amdgpu_pm.h" + #include "soc15.h" + #include "soc15d.h" +@@ -543,7 +544,11 @@ void jpeg_v2_0_dec_ring_emit_ib(struct a + + amdgpu_ring_write(ring, PACKETJ(mmUVD_LMI_JRBC_IB_VMID_INTERNAL_OFFSET, + 0, 0, PACKETJ_TYPE0)); +- amdgpu_ring_write(ring, (vmid | (vmid << 4) | (vmid << 8))); ++ ++ if (ring->funcs->parse_cs) ++ amdgpu_ring_write(ring, 0); ++ else ++ amdgpu_ring_write(ring, (vmid | (vmid << 4) | (vmid << 8))); + + amdgpu_ring_write(ring, PACKETJ(mmUVD_LMI_JPEG_VMID_INTERNAL_OFFSET, + 0, 0, PACKETJ_TYPE0)); +@@ -769,6 +774,7 @@ static const struct amdgpu_ring_funcs jp + .get_rptr = jpeg_v2_0_dec_ring_get_rptr, + .get_wptr = jpeg_v2_0_dec_ring_get_wptr, + .set_wptr = jpeg_v2_0_dec_ring_set_wptr, ++ .parse_cs = jpeg_v2_dec_ring_parse_cs, + .emit_frame_size = + SOC15_FLUSH_GPU_TLB_NUM_WREG * 6 + + SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 8 + +@@ -816,3 +822,58 @@ const struct amdgpu_ip_block_version jpe + .rev = 0, + .funcs = &jpeg_v2_0_ip_funcs, + }; ++ ++/** ++ * jpeg_v2_dec_ring_parse_cs - command submission parser ++ * ++ * @parser: Command submission parser context ++ * @job: the job to parse ++ * @ib: the IB to parse ++ * ++ * Parse the command stream, return -EINVAL for invalid packet, ++ * 0 otherwise ++ */ ++int jpeg_v2_dec_ring_parse_cs(struct amdgpu_cs_parser *parser, ++ struct amdgpu_job *job, ++ struct amdgpu_ib *ib) ++{ ++ u32 i, reg, res, cond, type; ++ struct amdgpu_device *adev = parser->adev; ++ ++ for (i = 0; i < ib->length_dw ; i += 2) { ++ reg = CP_PACKETJ_GET_REG(ib->ptr[i]); ++ res = CP_PACKETJ_GET_RES(ib->ptr[i]); ++ cond = CP_PACKETJ_GET_COND(ib->ptr[i]); ++ type = CP_PACKETJ_GET_TYPE(ib->ptr[i]); ++ ++ if (res) /* only support 0 at the moment */ ++ return -EINVAL; ++ ++ switch (type) { ++ case PACKETJ_TYPE0: ++ if (cond != PACKETJ_CONDITION_CHECK0 || reg < JPEG_REG_RANGE_START || ++ reg > JPEG_REG_RANGE_END) { ++ dev_err(adev->dev, "Invalid packet [0x%08x]!\n", ib->ptr[i]); ++ return -EINVAL; ++ } ++ break; ++ case PACKETJ_TYPE3: ++ if (cond != PACKETJ_CONDITION_CHECK3 || reg < JPEG_REG_RANGE_START || ++ reg > JPEG_REG_RANGE_END) { ++ dev_err(adev->dev, "Invalid packet [0x%08x]!\n", ib->ptr[i]); ++ return -EINVAL; ++ } ++ break; ++ case PACKETJ_TYPE6: ++ if (ib->ptr[i] == CP_PACKETJ_NOP) ++ continue; ++ dev_err(adev->dev, "Invalid packet [0x%08x]!\n", ib->ptr[i]); ++ return -EINVAL; ++ default: ++ dev_err(adev->dev, "Unknown packet type %d !\n", type); ++ return -EINVAL; ++ } ++ } ++ ++ return 0; ++} +--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.h ++++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.h +@@ -45,6 +45,9 @@ + + #define JRBC_DEC_EXTERNAL_REG_WRITE_ADDR 0x18000 + ++#define JPEG_REG_RANGE_START 0x4000 ++#define JPEG_REG_RANGE_END 0x41c2 ++ + void jpeg_v2_0_dec_ring_insert_start(struct amdgpu_ring *ring); + void jpeg_v2_0_dec_ring_insert_end(struct amdgpu_ring *ring); + void jpeg_v2_0_dec_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 seq, +@@ -57,6 +60,9 @@ void jpeg_v2_0_dec_ring_emit_vm_flush(st + unsigned vmid, uint64_t pd_addr); + void jpeg_v2_0_dec_ring_emit_wreg(struct amdgpu_ring *ring, uint32_t reg, uint32_t val); + void jpeg_v2_0_dec_ring_nop(struct amdgpu_ring *ring, uint32_t count); ++int jpeg_v2_dec_ring_parse_cs(struct amdgpu_cs_parser *parser, ++ struct amdgpu_job *job, ++ struct amdgpu_ib *ib); + + extern const struct amdgpu_ip_block_version jpeg_v2_0_ip_block; + +--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c ++++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c +@@ -664,6 +664,7 @@ static const struct amdgpu_ring_funcs jp + .get_rptr = jpeg_v2_5_dec_ring_get_rptr, + .get_wptr = jpeg_v2_5_dec_ring_get_wptr, + .set_wptr = jpeg_v2_5_dec_ring_set_wptr, ++ .parse_cs = jpeg_v2_dec_ring_parse_cs, + .emit_frame_size = + SOC15_FLUSH_GPU_TLB_NUM_WREG * 6 + + SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 8 + +@@ -693,6 +694,7 @@ static const struct amdgpu_ring_funcs jp + .get_rptr = jpeg_v2_5_dec_ring_get_rptr, + .get_wptr = jpeg_v2_5_dec_ring_get_wptr, + .set_wptr = jpeg_v2_5_dec_ring_set_wptr, ++ .parse_cs = jpeg_v2_dec_ring_parse_cs, + .emit_frame_size = + SOC15_FLUSH_GPU_TLB_NUM_WREG * 6 + + SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 8 + +--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c ++++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c +@@ -567,6 +567,7 @@ static const struct amdgpu_ring_funcs jp + .get_rptr = jpeg_v3_0_dec_ring_get_rptr, + .get_wptr = jpeg_v3_0_dec_ring_get_wptr, + .set_wptr = jpeg_v3_0_dec_ring_set_wptr, ++ .parse_cs = jpeg_v2_dec_ring_parse_cs, + .emit_frame_size = + SOC15_FLUSH_GPU_TLB_NUM_WREG * 6 + + SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 8 + +--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c ++++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c +@@ -729,6 +729,7 @@ static const struct amdgpu_ring_funcs jp + .get_rptr = jpeg_v4_0_dec_ring_get_rptr, + .get_wptr = jpeg_v4_0_dec_ring_get_wptr, + .set_wptr = jpeg_v4_0_dec_ring_set_wptr, ++ .parse_cs = jpeg_v2_dec_ring_parse_cs, + .emit_frame_size = + SOC15_FLUSH_GPU_TLB_NUM_WREG * 6 + + SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 8 + +--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.h ++++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.h +@@ -32,5 +32,4 @@ enum amdgpu_jpeg_v4_0_sub_block { + }; + + extern const struct amdgpu_ip_block_version jpeg_v4_0_ip_block; +- + #endif /* __JPEG_V4_0_H__ */ +--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c ++++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c +@@ -23,9 +23,9 @@ + + #include "amdgpu.h" + #include "amdgpu_jpeg.h" +-#include "amdgpu_cs.h" + #include "soc15.h" + #include "soc15d.h" ++#include "jpeg_v2_0.h" + #include "jpeg_v4_0_3.h" + #include "mmsch_v4_0_3.h" + +@@ -1068,7 +1068,7 @@ static const struct amdgpu_ring_funcs jp + .get_rptr = jpeg_v4_0_3_dec_ring_get_rptr, + .get_wptr = jpeg_v4_0_3_dec_ring_get_wptr, + .set_wptr = jpeg_v4_0_3_dec_ring_set_wptr, +- .parse_cs = jpeg_v4_0_3_dec_ring_parse_cs, ++ .parse_cs = jpeg_v2_dec_ring_parse_cs, + .emit_frame_size = + SOC15_FLUSH_GPU_TLB_NUM_WREG * 6 + + SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 8 + +@@ -1233,56 +1233,3 @@ static void jpeg_v4_0_3_set_ras_funcs(st + { + adev->jpeg.ras = &jpeg_v4_0_3_ras; + } +- +-/** +- * jpeg_v4_0_3_dec_ring_parse_cs - command submission parser +- * +- * @parser: Command submission parser context +- * @job: the job to parse +- * @ib: the IB to parse +- * +- * Parse the command stream, return -EINVAL for invalid packet, +- * 0 otherwise +- */ +-int jpeg_v4_0_3_dec_ring_parse_cs(struct amdgpu_cs_parser *parser, +- struct amdgpu_job *job, +- struct amdgpu_ib *ib) +-{ +- uint32_t i, reg, res, cond, type; +- struct amdgpu_device *adev = parser->adev; +- +- for (i = 0; i < ib->length_dw ; i += 2) { +- reg = CP_PACKETJ_GET_REG(ib->ptr[i]); +- res = CP_PACKETJ_GET_RES(ib->ptr[i]); +- cond = CP_PACKETJ_GET_COND(ib->ptr[i]); +- type = CP_PACKETJ_GET_TYPE(ib->ptr[i]); +- +- if (res) /* only support 0 at the moment */ +- return -EINVAL; +- +- switch (type) { +- case PACKETJ_TYPE0: +- if (cond != PACKETJ_CONDITION_CHECK0 || reg < JPEG_REG_RANGE_START || reg > JPEG_REG_RANGE_END) { +- dev_err(adev->dev, "Invalid packet [0x%08x]!\n", ib->ptr[i]); +- return -EINVAL; +- } +- break; +- case PACKETJ_TYPE3: +- if (cond != PACKETJ_CONDITION_CHECK3 || reg < JPEG_REG_RANGE_START || reg > JPEG_REG_RANGE_END) { +- dev_err(adev->dev, "Invalid packet [0x%08x]!\n", ib->ptr[i]); +- return -EINVAL; +- } +- break; +- case PACKETJ_TYPE6: +- if (ib->ptr[i] == CP_PACKETJ_NOP) +- continue; +- dev_err(adev->dev, "Invalid packet [0x%08x]!\n", ib->ptr[i]); +- return -EINVAL; +- default: +- dev_err(adev->dev, "Unknown packet type %d !\n", type); +- return -EINVAL; +- } +- } +- +- return 0; +-} +--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.h ++++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.h +@@ -46,9 +46,6 @@ + + #define JRBC_DEC_EXTERNAL_REG_WRITE_ADDR 0x18000 + +-#define JPEG_REG_RANGE_START 0x4000 +-#define JPEG_REG_RANGE_END 0x41c2 +- + extern const struct amdgpu_ip_block_version jpeg_v4_0_3_ip_block; + + void jpeg_v4_0_3_dec_ring_emit_ib(struct amdgpu_ring *ring, +@@ -65,7 +62,5 @@ void jpeg_v4_0_3_dec_ring_insert_end(str + void jpeg_v4_0_3_dec_ring_emit_wreg(struct amdgpu_ring *ring, uint32_t reg, uint32_t val); + void jpeg_v4_0_3_dec_ring_emit_reg_wait(struct amdgpu_ring *ring, uint32_t reg, + uint32_t val, uint32_t mask); +-int jpeg_v4_0_3_dec_ring_parse_cs(struct amdgpu_cs_parser *parser, +- struct amdgpu_job *job, +- struct amdgpu_ib *ib); ++ + #endif /* __JPEG_V4_0_3_H__ */ +--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_5.c ++++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_5.c +@@ -772,6 +772,7 @@ static const struct amdgpu_ring_funcs jp + .get_rptr = jpeg_v4_0_5_dec_ring_get_rptr, + .get_wptr = jpeg_v4_0_5_dec_ring_get_wptr, + .set_wptr = jpeg_v4_0_5_dec_ring_set_wptr, ++ .parse_cs = jpeg_v2_dec_ring_parse_cs, + .emit_frame_size = + SOC15_FLUSH_GPU_TLB_NUM_WREG * 6 + + SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 8 + +--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_0.c ++++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_0.c +@@ -26,6 +26,7 @@ + #include "amdgpu_pm.h" + #include "soc15.h" + #include "soc15d.h" ++#include "jpeg_v2_0.h" + #include "jpeg_v4_0_3.h" + + #include "vcn/vcn_5_0_0_offset.h" +@@ -523,7 +524,7 @@ static const struct amdgpu_ring_funcs jp + .get_rptr = jpeg_v5_0_0_dec_ring_get_rptr, + .get_wptr = jpeg_v5_0_0_dec_ring_get_wptr, + .set_wptr = jpeg_v5_0_0_dec_ring_set_wptr, +- .parse_cs = jpeg_v4_0_3_dec_ring_parse_cs, ++ .parse_cs = jpeg_v2_dec_ring_parse_cs, + .emit_frame_size = + SOC15_FLUSH_GPU_TLB_NUM_WREG * 6 + + SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 8 + diff --git a/queue-6.10/drm-amd-display-avoid-race-between-dcn10_set_drr-and-dc_state_destruct.patch b/queue-6.10/drm-amd-display-avoid-race-between-dcn10_set_drr-and-dc_state_destruct.patch new file mode 100644 index 00000000000..1bffc8ce10c --- /dev/null +++ b/queue-6.10/drm-amd-display-avoid-race-between-dcn10_set_drr-and-dc_state_destruct.patch @@ -0,0 +1,73 @@ +From a7aeb03888b92304e2fc7d4d1c242f54a312561b Mon Sep 17 00:00:00 2001 +From: Tobias Jakobi +Date: Mon, 2 Sep 2024 11:40:26 +0200 +Subject: drm/amd/display: Avoid race between dcn10_set_drr() and dc_state_destruct() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Tobias Jakobi + +commit a7aeb03888b92304e2fc7d4d1c242f54a312561b upstream. + +dc_state_destruct() nulls the resource context of the DC state. The pipe +context passed to dcn10_set_drr() is a member of this resource context. + +If dc_state_destruct() is called parallel to the IRQ processing (which +calls dcn10_set_drr() at some point), we can end up using already nulled +function callback fields of struct stream_resource. + +The logic in dcn10_set_drr() already tries to avoid this, by checking tg +against NULL. But if the nulling happens exactly after the NULL check and +before the next access, then we get a race. + +Avoid this by copying tg first to a local variable, and then use this +variable for all the operations. This should work, as long as nobody +frees the resource pool where the timing generators live. + +Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3142 +Fixes: 06ad7e164256 ("drm/amd/display: Destroy DC context while keeping DML and DML2") +Signed-off-by: Tobias Jakobi +Tested-by: Raoul van Rüschen +Tested-by: Christopher Snowhill +Reviewed-by: Harry Wentland +Tested-by: Sefa Eyeoglu +Signed-off-by: Mario Limonciello +Signed-off-by: Alex Deucher +(cherry picked from commit a3cc326a43bdc48fbdf53443e1027a03e309b643) +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/amd/display/dc/hwss/dcn10/dcn10_hwseq.c | 20 +++++++++------- + 1 file changed, 12 insertions(+), 8 deletions(-) + +--- a/drivers/gpu/drm/amd/display/dc/hwss/dcn10/dcn10_hwseq.c ++++ b/drivers/gpu/drm/amd/display/dc/hwss/dcn10/dcn10_hwseq.c +@@ -3223,15 +3223,19 @@ void dcn10_set_drr(struct pipe_ctx **pip + * as well. + */ + for (i = 0; i < num_pipes; i++) { +- if ((pipe_ctx[i]->stream_res.tg != NULL) && pipe_ctx[i]->stream_res.tg->funcs) { +- if (pipe_ctx[i]->stream_res.tg->funcs->set_drr) +- pipe_ctx[i]->stream_res.tg->funcs->set_drr( +- pipe_ctx[i]->stream_res.tg, ¶ms); ++ /* dc_state_destruct() might null the stream resources, so fetch tg ++ * here first to avoid a race condition. The lifetime of the pointee ++ * itself (the timing_generator object) is not a problem here. ++ */ ++ struct timing_generator *tg = pipe_ctx[i]->stream_res.tg; ++ ++ if ((tg != NULL) && tg->funcs) { ++ if (tg->funcs->set_drr) ++ tg->funcs->set_drr(tg, ¶ms); + if (adjust.v_total_max != 0 && adjust.v_total_min != 0) +- if (pipe_ctx[i]->stream_res.tg->funcs->set_static_screen_control) +- pipe_ctx[i]->stream_res.tg->funcs->set_static_screen_control( +- pipe_ctx[i]->stream_res.tg, +- event_triggers, num_frames); ++ if (tg->funcs->set_static_screen_control) ++ tg->funcs->set_static_screen_control( ++ tg, event_triggers, num_frames); + } + } + } diff --git a/queue-6.10/drm-amd-display-avoid-race-between-dcn35_set_drr-and-dc_state_destruct.patch b/queue-6.10/drm-amd-display-avoid-race-between-dcn35_set_drr-and-dc_state_destruct.patch new file mode 100644 index 00000000000..89d49636f3d --- /dev/null +++ b/queue-6.10/drm-amd-display-avoid-race-between-dcn35_set_drr-and-dc_state_destruct.patch @@ -0,0 +1,74 @@ +From e835d5144f5ef78e4f8828c63e2f0d61144f283a Mon Sep 17 00:00:00 2001 +From: Tobias Jakobi +Date: Mon, 2 Sep 2024 11:40:27 +0200 +Subject: drm/amd/display: Avoid race between dcn35_set_drr() and dc_state_destruct() + +From: Tobias Jakobi + +commit e835d5144f5ef78e4f8828c63e2f0d61144f283a upstream. + +dc_state_destruct() nulls the resource context of the DC state. The pipe +context passed to dcn35_set_drr() is a member of this resource context. + +If dc_state_destruct() is called parallel to the IRQ processing (which +calls dcn35_set_drr() at some point), we can end up using already nulled +function callback fields of struct stream_resource. + +The logic in dcn35_set_drr() already tries to avoid this, by checking tg +against NULL. But if the nulling happens exactly after the NULL check and +before the next access, then we get a race. + +Avoid this by copying tg first to a local variable, and then use this +variable for all the operations. This should work, as long as nobody +frees the resource pool where the timing generators live. + +Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3142 +Fixes: 06ad7e164256 ("drm/amd/display: Destroy DC context while keeping DML and DML2") +Signed-off-by: Tobias Jakobi +Reviewed-by: Harry Wentland +Signed-off-by: Mario Limonciello +Signed-off-by: Alex Deucher +(cherry picked from commit 0607a50c004798a96e62c089a4c34c220179dcb5) +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.c | 20 +++++++++------- + 1 file changed, 12 insertions(+), 8 deletions(-) + +--- a/drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.c ++++ b/drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.c +@@ -1371,7 +1371,13 @@ void dcn35_set_drr(struct pipe_ctx **pip + params.vertical_total_mid_frame_num = adjust.v_total_mid_frame_num; + + for (i = 0; i < num_pipes; i++) { +- if ((pipe_ctx[i]->stream_res.tg != NULL) && pipe_ctx[i]->stream_res.tg->funcs) { ++ /* dc_state_destruct() might null the stream resources, so fetch tg ++ * here first to avoid a race condition. The lifetime of the pointee ++ * itself (the timing_generator object) is not a problem here. ++ */ ++ struct timing_generator *tg = pipe_ctx[i]->stream_res.tg; ++ ++ if ((tg != NULL) && tg->funcs) { + struct dc_crtc_timing *timing = &pipe_ctx[i]->stream->timing; + struct dc *dc = pipe_ctx[i]->stream->ctx->dc; + +@@ -1384,14 +1390,12 @@ void dcn35_set_drr(struct pipe_ctx **pip + num_frames = 2 * (frame_rate % 60); + } + } +- if (pipe_ctx[i]->stream_res.tg->funcs->set_drr) +- pipe_ctx[i]->stream_res.tg->funcs->set_drr( +- pipe_ctx[i]->stream_res.tg, ¶ms); ++ if (tg->funcs->set_drr) ++ tg->funcs->set_drr(tg, ¶ms); + if (adjust.v_total_max != 0 && adjust.v_total_min != 0) +- if (pipe_ctx[i]->stream_res.tg->funcs->set_static_screen_control) +- pipe_ctx[i]->stream_res.tg->funcs->set_static_screen_control( +- pipe_ctx[i]->stream_res.tg, +- event_triggers, num_frames); ++ if (tg->funcs->set_static_screen_control) ++ tg->funcs->set_static_screen_control( ++ tg, event_triggers, num_frames); + } + } + } diff --git a/queue-6.10/drm-amdgpu-atomfirmware-silence-ubsan-warning.patch b/queue-6.10/drm-amdgpu-atomfirmware-silence-ubsan-warning.patch new file mode 100644 index 00000000000..88b2e2d2110 --- /dev/null +++ b/queue-6.10/drm-amdgpu-atomfirmware-silence-ubsan-warning.patch @@ -0,0 +1,41 @@ +From 17ea4383649fdeaff3181ddcf1ff03350d42e591 Mon Sep 17 00:00:00 2001 +From: Alex Deucher +Date: Fri, 6 Sep 2024 10:42:45 -0400 +Subject: drm/amdgpu/atomfirmware: Silence UBSAN warning + +From: Alex Deucher + +commit 17ea4383649fdeaff3181ddcf1ff03350d42e591 upstream. + +Per the comments, these are variable sized arrays. + +Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3613 +Reviewed-by: Harry Wentland +Signed-off-by: Alex Deucher +(cherry picked from commit 81f7804ba84ee617ed594de934ed87bcc4f83531) +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/amd/include/atomfirmware.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/gpu/drm/amd/include/atomfirmware.h ++++ b/drivers/gpu/drm/amd/include/atomfirmware.h +@@ -1038,7 +1038,7 @@ struct display_object_info_table_v1_4 + uint16_t supporteddevices; + uint8_t number_of_path; + uint8_t reserved; +- struct atom_display_object_path_v2 display_path[8]; //the real number of this included in the structure is calculated by using the (whole structure size - the header size- number_of_path)/size of atom_display_object_path ++ struct atom_display_object_path_v2 display_path[]; //the real number of this included in the structure is calculated by using the (whole structure size - the header size- number_of_path)/size of atom_display_object_path + }; + + struct display_object_info_table_v1_5 { +@@ -1048,7 +1048,7 @@ struct display_object_info_table_v1_5 { + uint8_t reserved; + // the real number of this included in the structure is calculated by using the + // (whole structure size - the header size- number_of_path)/size of atom_display_object_path +- struct atom_display_object_path_v3 display_path[8]; ++ struct atom_display_object_path_v3 display_path[]; + }; + + /* diff --git a/queue-6.10/drm-nouveau-fb-restore-init-for-ramgp102.patch b/queue-6.10/drm-nouveau-fb-restore-init-for-ramgp102.patch new file mode 100644 index 00000000000..58fdc7ce1dd --- /dev/null +++ b/queue-6.10/drm-nouveau-fb-restore-init-for-ramgp102.patch @@ -0,0 +1,63 @@ +From 6db9df4f7055eb4ea339e7b83ca676edd9ec1277 Mon Sep 17 00:00:00 2001 +From: Ben Skeggs +Date: Thu, 5 Sep 2024 09:24:18 +1000 +Subject: drm/nouveau/fb: restore init() for ramgp102 + +From: Ben Skeggs + +commit 6db9df4f7055eb4ea339e7b83ca676edd9ec1277 upstream. + +init() was removed from ramgp102 when reworking the memory detection, as +it was thought that the code was only necessary when the driver performs +mclk changes, which nouveau doesn't support on pascal. + +However, it turns out that we still need to execute this on some GPUs to +restore settings after DEVINIT, so revert to the original behaviour. + +v2: fix tags in commit message, cc stable + +Closes: https://gitlab.freedesktop.org/drm/nouveau/-/issues/319 +Fixes: 2c0c15a22fa0 ("drm/nouveau/fb/gp102-ga100: switch to simpler vram size detection method") +Cc: stable@vger.kernel.org # 6.6+ +Signed-off-by: Ben Skeggs +Signed-off-by: Danilo Krummrich +Link: https://patchwork.freedesktop.org/patch/msgid/20240904232418.8590-1-bskeggs@nvidia.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/nouveau/nvkm/subdev/fb/ram.h | 2 ++ + drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgp100.c | 2 +- + drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgp102.c | 1 + + 3 files changed, 4 insertions(+), 1 deletion(-) + +--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ram.h ++++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ram.h +@@ -46,6 +46,8 @@ u32 gm107_ram_probe_fbp(const struct nvk + u32 gm200_ram_probe_fbp_amount(const struct nvkm_ram_func *, u32, + struct nvkm_device *, int, int *); + ++int gp100_ram_init(struct nvkm_ram *); ++ + /* RAM type-specific MR calculation routines */ + int nvkm_sddr2_calc(struct nvkm_ram *); + int nvkm_sddr3_calc(struct nvkm_ram *); +--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgp100.c ++++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgp100.c +@@ -27,7 +27,7 @@ + #include + #include + +-static int ++int + gp100_ram_init(struct nvkm_ram *ram) + { + struct nvkm_subdev *subdev = &ram->fb->subdev; +--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgp102.c ++++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgp102.c +@@ -5,6 +5,7 @@ + + static const struct nvkm_ram_func + gp102_ram = { ++ .init = gp100_ram_init, + }; + + int diff --git a/queue-6.10/drm-syncobj-fix-syncobj-leak-in-drm_syncobj_eventfd_ioctl.patch b/queue-6.10/drm-syncobj-fix-syncobj-leak-in-drm_syncobj_eventfd_ioctl.patch new file mode 100644 index 00000000000..aa048a65091 --- /dev/null +++ b/queue-6.10/drm-syncobj-fix-syncobj-leak-in-drm_syncobj_eventfd_ioctl.patch @@ -0,0 +1,72 @@ +From 8c7c44be57672e1474bf15a451011c291e85fda4 Mon Sep 17 00:00:00 2001 +From: "T.J. Mercier" +Date: Mon, 9 Sep 2024 20:53:59 +0000 +Subject: drm/syncobj: Fix syncobj leak in drm_syncobj_eventfd_ioctl +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: T.J. Mercier + +commit 8c7c44be57672e1474bf15a451011c291e85fda4 upstream. + +A syncobj reference is taken in drm_syncobj_find, but not released if +eventfd_ctx_fdget or kzalloc fails. Put the reference in these error +paths. + +Reported-by: Xingyu Jin +Fixes: c7a472297169 ("drm/syncobj: add IOCTL to register an eventfd") +Signed-off-by: T.J. Mercier +Reviewed-by: Tvrtko Ursulin +Reviewed-by. Christian König +CC: stable@vger.kernel.org # 6.6+ +Link: https://patchwork.freedesktop.org/patch/msgid/20240909205400.3498337-1-tjmercier@google.com +Signed-off-by: Christian König +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/drm_syncobj.c | 17 +++++++++++++---- + 1 file changed, 13 insertions(+), 4 deletions(-) + +--- a/drivers/gpu/drm/drm_syncobj.c ++++ b/drivers/gpu/drm/drm_syncobj.c +@@ -1464,6 +1464,7 @@ drm_syncobj_eventfd_ioctl(struct drm_dev + struct drm_syncobj *syncobj; + struct eventfd_ctx *ev_fd_ctx; + struct syncobj_eventfd_entry *entry; ++ int ret; + + if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE)) + return -EOPNOTSUPP; +@@ -1479,13 +1480,15 @@ drm_syncobj_eventfd_ioctl(struct drm_dev + return -ENOENT; + + ev_fd_ctx = eventfd_ctx_fdget(args->fd); +- if (IS_ERR(ev_fd_ctx)) +- return PTR_ERR(ev_fd_ctx); ++ if (IS_ERR(ev_fd_ctx)) { ++ ret = PTR_ERR(ev_fd_ctx); ++ goto err_fdget; ++ } + + entry = kzalloc(sizeof(*entry), GFP_KERNEL); + if (!entry) { +- eventfd_ctx_put(ev_fd_ctx); +- return -ENOMEM; ++ ret = -ENOMEM; ++ goto err_kzalloc; + } + entry->syncobj = syncobj; + entry->ev_fd_ctx = ev_fd_ctx; +@@ -1496,6 +1499,12 @@ drm_syncobj_eventfd_ioctl(struct drm_dev + drm_syncobj_put(syncobj); + + return 0; ++ ++err_kzalloc: ++ eventfd_ctx_put(ev_fd_ctx); ++err_fdget: ++ drm_syncobj_put(syncobj); ++ return ret; + } + + int diff --git a/queue-6.10/drm-xe-client-add-missing-bo-locking-in-show_meminfo.patch b/queue-6.10/drm-xe-client-add-missing-bo-locking-in-show_meminfo.patch new file mode 100644 index 00000000000..b7952d679a6 --- /dev/null +++ b/queue-6.10/drm-xe-client-add-missing-bo-locking-in-show_meminfo.patch @@ -0,0 +1,116 @@ +From 94c4aa266111262c96c98f822d1bccc494786fee Mon Sep 17 00:00:00 2001 +From: Matthew Auld +Date: Wed, 11 Sep 2024 16:55:28 +0100 +Subject: drm/xe/client: add missing bo locking in show_meminfo() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Matthew Auld + +commit 94c4aa266111262c96c98f822d1bccc494786fee upstream. + +bo_meminfo() wants to inspect bo state like tt and the ttm resource, +however this state can change at any point leading to stuff like NPD and +UAF, if the bo lock is not held. Grab the bo lock when calling +bo_meminfo(), ensuring we drop any spinlocks first. In the case of +object_idr we now also need to hold a ref. + +v2 (MattB) + - Also add xe_bo_assert_held() + +Fixes: 0845233388f8 ("drm/xe: Implement fdinfo memory stats printing") +Signed-off-by: Matthew Auld +Cc: Himal Prasad Ghimiray +Cc: Tejas Upadhyay +Cc: "Thomas Hellström" +Cc: # v6.8+ +Reviewed-by: Matthew Brost +Reviewed-by: Tejas Upadhyay +Link: https://patchwork.freedesktop.org/patch/msgid/20240911155527.178910-6-matthew.auld@intel.com +(cherry picked from commit 4f63d712fa104c3ebefcb289d1e733e86d8698c7) +Signed-off-by: Rodrigo Vivi +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/xe/xe_drm_client.c | 39 ++++++++++++++++++++++++++++++++++--- + 1 file changed, 36 insertions(+), 3 deletions(-) + +--- a/drivers/gpu/drm/xe/xe_drm_client.c ++++ b/drivers/gpu/drm/xe/xe_drm_client.c +@@ -9,6 +9,7 @@ + #include + #include + ++#include "xe_assert.h" + #include "xe_bo.h" + #include "xe_bo_types.h" + #include "xe_device_types.h" +@@ -93,10 +94,13 @@ void xe_drm_client_add_bo(struct xe_drm_ + */ + void xe_drm_client_remove_bo(struct xe_bo *bo) + { ++ struct xe_device *xe = ttm_to_xe_device(bo->ttm.bdev); + struct xe_drm_client *client = bo->client; + ++ xe_assert(xe, !kref_read(&bo->ttm.base.refcount)); ++ + spin_lock(&client->bos_lock); +- list_del(&bo->client_link); ++ list_del_init(&bo->client_link); + spin_unlock(&client->bos_lock); + + xe_drm_client_put(client); +@@ -108,6 +112,8 @@ static void bo_meminfo(struct xe_bo *bo, + u64 sz = bo->size; + u32 mem_type; + ++ xe_bo_assert_held(bo); ++ + if (bo->placement.placement) + mem_type = bo->placement.placement->mem_type; + else +@@ -149,7 +155,20 @@ static void show_meminfo(struct drm_prin + idr_for_each_entry(&file->object_idr, obj, id) { + struct xe_bo *bo = gem_to_xe_bo(obj); + +- bo_meminfo(bo, stats); ++ if (dma_resv_trylock(bo->ttm.base.resv)) { ++ bo_meminfo(bo, stats); ++ xe_bo_unlock(bo); ++ } else { ++ xe_bo_get(bo); ++ spin_unlock(&file->table_lock); ++ ++ xe_bo_lock(bo, false); ++ bo_meminfo(bo, stats); ++ xe_bo_unlock(bo); ++ ++ xe_bo_put(bo); ++ spin_lock(&file->table_lock); ++ } + } + spin_unlock(&file->table_lock); + +@@ -159,7 +178,21 @@ static void show_meminfo(struct drm_prin + if (!kref_get_unless_zero(&bo->ttm.base.refcount)) + continue; + +- bo_meminfo(bo, stats); ++ if (dma_resv_trylock(bo->ttm.base.resv)) { ++ bo_meminfo(bo, stats); ++ xe_bo_unlock(bo); ++ } else { ++ spin_unlock(&client->bos_lock); ++ ++ xe_bo_lock(bo, false); ++ bo_meminfo(bo, stats); ++ xe_bo_unlock(bo); ++ ++ spin_lock(&client->bos_lock); ++ /* The bo ref will prevent this bo from being removed from the list */ ++ xe_assert(xef->xe, !list_empty(&bo->client_link)); ++ } ++ + xe_bo_put_deferred(bo, &deferred); + } + spin_unlock(&client->bos_lock); diff --git a/queue-6.10/drm-xe-client-fix-deadlock-in-show_meminfo.patch b/queue-6.10/drm-xe-client-fix-deadlock-in-show_meminfo.patch new file mode 100644 index 00000000000..8668a744403 --- /dev/null +++ b/queue-6.10/drm-xe-client-fix-deadlock-in-show_meminfo.patch @@ -0,0 +1,63 @@ +From 9bd7ff293fc84792514aeafa06c5a17f05cb5f4b Mon Sep 17 00:00:00 2001 +From: Matthew Auld +Date: Wed, 11 Sep 2024 16:55:27 +0100 +Subject: drm/xe/client: fix deadlock in show_meminfo() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Matthew Auld + +commit 9bd7ff293fc84792514aeafa06c5a17f05cb5f4b upstream. + +There is a real deadlock as well as sleeping in atomic() bug in here, if +the bo put happens to be the last ref, since bo destruction wants to +grab the same spinlock and sleeping locks. Fix that by dropping the ref +using xe_bo_put_deferred(), and moving the final commit outside of the +lock. Dropping the lock around the put is tricky since the bo can go +out of scope and delete itself from the list, making it difficult to +navigate to the next list entry. + +Fixes: 0845233388f8 ("drm/xe: Implement fdinfo memory stats printing") +Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/2727 +Signed-off-by: Matthew Auld +Cc: Himal Prasad Ghimiray +Cc: Tejas Upadhyay +Cc: "Thomas Hellström" +Cc: # v6.8+ +Reviewed-by: Matthew Brost +Reviewed-by: Tejas Upadhyay +Link: https://patchwork.freedesktop.org/patch/msgid/20240911155527.178910-5-matthew.auld@intel.com +(cherry picked from commit 0083b8e6f11d7662283a267d4ce7c966812ffd8a) +Signed-off-by: Rodrigo Vivi +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/xe/xe_drm_client.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +--- a/drivers/gpu/drm/xe/xe_drm_client.c ++++ b/drivers/gpu/drm/xe/xe_drm_client.c +@@ -138,6 +138,7 @@ static void show_meminfo(struct drm_prin + struct xe_drm_client *client; + struct drm_gem_object *obj; + struct xe_bo *bo; ++ LLIST_HEAD(deferred); + unsigned int id; + u32 mem_type; + +@@ -157,11 +158,14 @@ static void show_meminfo(struct drm_prin + list_for_each_entry(bo, &client->bos_list, client_link) { + if (!kref_get_unless_zero(&bo->ttm.base.refcount)) + continue; ++ + bo_meminfo(bo, stats); +- xe_bo_put(bo); ++ xe_bo_put_deferred(bo, &deferred); + } + spin_unlock(&client->bos_lock); + ++ xe_bo_put_commit(&deferred); ++ + for (mem_type = XE_PL_SYSTEM; mem_type < TTM_NUM_MEM_TYPES; ++mem_type) { + if (!xe_mem_type_to_name[mem_type]) + continue; diff --git a/queue-6.10/series b/queue-6.10/series index 183b7697616..837e3a1c0dd 100644 --- a/queue-6.10/series +++ b/queue-6.10/series @@ -94,3 +94,17 @@ net-hsr-prevent-null-pointer-dereference-in-hsr_prox.patch net-dsa-felix-ignore-pending-status-of-tas-module-wh.patch net-dpaa-pad-packets-to-eth_zlen.patch netlink-specs-mptcp-fix-port-endianness.patch +tracing-osnoise-fix-build-when-timerlat-is-not-enabled.patch +spi-nxp-fspi-fix-the-kasan-report-out-of-bounds-bug.patch +soundwire-stream-revert-soundwire-stream-fix-programming-slave-ports-for-non-continous-port-maps.patch +drm-syncobj-fix-syncobj-leak-in-drm_syncobj_eventfd_ioctl.patch +dma-buf-heaps-fix-off-by-one-in-cma-heap-fault-handler.patch +drm-nouveau-fb-restore-init-for-ramgp102.patch +drm-amdgpu-atomfirmware-silence-ubsan-warning.patch +drm-amd-display-avoid-race-between-dcn10_set_drr-and-dc_state_destruct.patch +drm-amd-display-avoid-race-between-dcn35_set_drr-and-dc_state_destruct.patch +drm-amd-amdgpu-apply-command-submission-parser-for-jpeg-v1.patch +drm-amd-amdgpu-apply-command-submission-parser-for-jpeg-v2.patch +drm-xe-client-fix-deadlock-in-show_meminfo.patch +drm-xe-client-add-missing-bo-locking-in-show_meminfo.patch +tracing-kprobes-fix-build-error-when-find_module-is-not-available.patch diff --git a/queue-6.10/soundwire-stream-revert-soundwire-stream-fix-programming-slave-ports-for-non-continous-port-maps.patch b/queue-6.10/soundwire-stream-revert-soundwire-stream-fix-programming-slave-ports-for-non-continous-port-maps.patch new file mode 100644 index 00000000000..b0f36b6cfaf --- /dev/null +++ b/queue-6.10/soundwire-stream-revert-soundwire-stream-fix-programming-slave-ports-for-non-continous-port-maps.patch @@ -0,0 +1,58 @@ +From 233a95fd574fde1c375c486540a90304a2d2d49f Mon Sep 17 00:00:00 2001 +From: Krzysztof Kozlowski +Date: Mon, 9 Sep 2024 18:47:46 +0200 +Subject: soundwire: stream: Revert "soundwire: stream: fix programming slave ports for non-continous port maps" + +From: Krzysztof Kozlowski + +commit 233a95fd574fde1c375c486540a90304a2d2d49f upstream. + +This reverts commit ab8d66d132bc8f1992d3eb6cab8d32dda6733c84 because it +breaks codecs using non-continuous masks in source and sink ports. The +commit missed the point that port numbers are not used as indices for +iterating over prop.sink_ports or prop.source_ports. + +Soundwire core and existing codecs expect that the array passed as +prop.sink_ports and prop.source_ports is continuous. The port mask still +might be non-continuous, but that's unrelated. + +Reported-by: Bard Liao +Closes: https://lore.kernel.org/all/b6c75eee-761d-44c8-8413-2a5b34ee2f98@linux.intel.com/ +Fixes: ab8d66d132bc ("soundwire: stream: fix programming slave ports for non-continous port maps") +Acked-by: Bard Liao +Reviewed-by: Charles Keepax +Cc: stable@vger.kernel.org +Signed-off-by: Krzysztof Kozlowski +Tested-by: Peter Ujfalusi +Link: https://lore.kernel.org/r/20240909164746.136629-1-krzysztof.kozlowski@linaro.org +Signed-off-by: Vinod Koul +Signed-off-by: Greg Kroah-Hartman +--- + drivers/soundwire/stream.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +--- a/drivers/soundwire/stream.c ++++ b/drivers/soundwire/stream.c +@@ -1286,18 +1286,18 @@ struct sdw_dpn_prop *sdw_get_slave_dpn_p + unsigned int port_num) + { + struct sdw_dpn_prop *dpn_prop; +- unsigned long mask; ++ u8 num_ports; + int i; + + if (direction == SDW_DATA_DIR_TX) { +- mask = slave->prop.source_ports; ++ num_ports = hweight32(slave->prop.source_ports); + dpn_prop = slave->prop.src_dpn_prop; + } else { +- mask = slave->prop.sink_ports; ++ num_ports = hweight32(slave->prop.sink_ports); + dpn_prop = slave->prop.sink_dpn_prop; + } + +- for_each_set_bit(i, &mask, 32) { ++ for (i = 0; i < num_ports; i++) { + if (dpn_prop[i].num == port_num) + return &dpn_prop[i]; + } diff --git a/queue-6.10/spi-nxp-fspi-fix-the-kasan-report-out-of-bounds-bug.patch b/queue-6.10/spi-nxp-fspi-fix-the-kasan-report-out-of-bounds-bug.patch new file mode 100644 index 00000000000..2c23c1c2437 --- /dev/null +++ b/queue-6.10/spi-nxp-fspi-fix-the-kasan-report-out-of-bounds-bug.patch @@ -0,0 +1,122 @@ +From 2a8787c1cdc7be24fdd8953ecd1a8743a1006235 Mon Sep 17 00:00:00 2001 +From: Han Xu +Date: Wed, 11 Sep 2024 16:11:45 -0500 +Subject: spi: nxp-fspi: fix the KASAN report out-of-bounds bug + +From: Han Xu + +commit 2a8787c1cdc7be24fdd8953ecd1a8743a1006235 upstream. + +Change the memcpy length to fix the out-of-bounds issue when writing the +data that is not 4 byte aligned to TX FIFO. + +To reproduce the issue, write 3 bytes data to NOR chip. + +dd if=3b of=/dev/mtd0 +[ 36.926103] ================================================================== +[ 36.933409] BUG: KASAN: slab-out-of-bounds in nxp_fspi_exec_op+0x26ec/0x2838 +[ 36.940514] Read of size 4 at addr ffff00081037c2a0 by task dd/455 +[ 36.946721] +[ 36.948235] CPU: 3 UID: 0 PID: 455 Comm: dd Not tainted 6.11.0-rc5-gc7b0e37c8434 #1070 +[ 36.956185] Hardware name: Freescale i.MX8QM MEK (DT) +[ 36.961260] Call trace: +[ 36.963723] dump_backtrace+0x90/0xe8 +[ 36.967414] show_stack+0x18/0x24 +[ 36.970749] dump_stack_lvl+0x78/0x90 +[ 36.974451] print_report+0x114/0x5cc +[ 36.978151] kasan_report+0xa4/0xf0 +[ 36.981670] __asan_report_load_n_noabort+0x1c/0x28 +[ 36.986587] nxp_fspi_exec_op+0x26ec/0x2838 +[ 36.990800] spi_mem_exec_op+0x8ec/0xd30 +[ 36.994762] spi_mem_no_dirmap_read+0x190/0x1e0 +[ 36.999323] spi_mem_dirmap_write+0x238/0x32c +[ 37.003710] spi_nor_write_data+0x220/0x374 +[ 37.007932] spi_nor_write+0x110/0x2e8 +[ 37.011711] mtd_write_oob_std+0x154/0x1f0 +[ 37.015838] mtd_write_oob+0x104/0x1d0 +[ 37.019617] mtd_write+0xb8/0x12c +[ 37.022953] mtdchar_write+0x224/0x47c +[ 37.026732] vfs_write+0x1e4/0x8c8 +[ 37.030163] ksys_write+0xec/0x1d0 +[ 37.033586] __arm64_sys_write+0x6c/0x9c +[ 37.037539] invoke_syscall+0x6c/0x258 +[ 37.041327] el0_svc_common.constprop.0+0x160/0x22c +[ 37.046244] do_el0_svc+0x44/0x5c +[ 37.049589] el0_svc+0x38/0x78 +[ 37.052681] el0t_64_sync_handler+0x13c/0x158 +[ 37.057077] el0t_64_sync+0x190/0x194 +[ 37.060775] +[ 37.062274] Allocated by task 455: +[ 37.065701] kasan_save_stack+0x2c/0x54 +[ 37.069570] kasan_save_track+0x20/0x3c +[ 37.073438] kasan_save_alloc_info+0x40/0x54 +[ 37.077736] __kasan_kmalloc+0xa0/0xb8 +[ 37.081515] __kmalloc_noprof+0x158/0x2f8 +[ 37.085563] mtd_kmalloc_up_to+0x120/0x154 +[ 37.089690] mtdchar_write+0x130/0x47c +[ 37.093469] vfs_write+0x1e4/0x8c8 +[ 37.096901] ksys_write+0xec/0x1d0 +[ 37.100332] __arm64_sys_write+0x6c/0x9c +[ 37.104287] invoke_syscall+0x6c/0x258 +[ 37.108064] el0_svc_common.constprop.0+0x160/0x22c +[ 37.112972] do_el0_svc+0x44/0x5c +[ 37.116319] el0_svc+0x38/0x78 +[ 37.119401] el0t_64_sync_handler+0x13c/0x158 +[ 37.123788] el0t_64_sync+0x190/0x194 +[ 37.127474] +[ 37.128977] The buggy address belongs to the object at ffff00081037c2a0 +[ 37.128977] which belongs to the cache kmalloc-8 of size 8 +[ 37.141177] The buggy address is located 0 bytes inside of +[ 37.141177] allocated 3-byte region [ffff00081037c2a0, ffff00081037c2a3) +[ 37.153465] +[ 37.154971] The buggy address belongs to the physical page: +[ 37.160559] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x89037c +[ 37.168596] flags: 0xbfffe0000000000(node=0|zone=2|lastcpupid=0x1ffff) +[ 37.175149] page_type: 0xfdffffff(slab) +[ 37.179021] raw: 0bfffe0000000000 ffff000800002500 dead000000000122 0000000000000000 +[ 37.186788] raw: 0000000000000000 0000000080800080 00000001fdffffff 0000000000000000 +[ 37.194553] page dumped because: kasan: bad access detected +[ 37.200144] +[ 37.201647] Memory state around the buggy address: +[ 37.206460] ffff00081037c180: fa fc fc fc fa fc fc fc fa fc fc fc fa fc fc fc +[ 37.213701] ffff00081037c200: fa fc fc fc 05 fc fc fc 03 fc fc fc 02 fc fc fc +[ 37.220946] >ffff00081037c280: 06 fc fc fc 03 fc fc fc fc fc fc fc fc fc fc fc +[ 37.228186] ^ +[ 37.232473] ffff00081037c300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc +[ 37.239718] ffff00081037c380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc +[ 37.246962] ================================================================== +[ 37.254394] Disabling lock debugging due to kernel taint +0+1 records in +0+1 records out +3 bytes copied, 0.335911 s, 0.0 kB/s + +Fixes: a5356aef6a90 ("spi: spi-mem: Add driver for NXP FlexSPI controller") +Cc: stable@kernel.org +Signed-off-by: Han Xu +Link: https://patch.msgid.link/20240911211146.3337068-1-han.xu@nxp.com +Signed-off-by: Mark Brown +Signed-off-by: Greg Kroah-Hartman +--- + drivers/spi/spi-nxp-fspi.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +--- a/drivers/spi/spi-nxp-fspi.c ++++ b/drivers/spi/spi-nxp-fspi.c +@@ -805,14 +805,15 @@ static void nxp_fspi_fill_txfifo(struct + if (i < op->data.nbytes) { + u32 data = 0; + int j; ++ int remaining = op->data.nbytes - i; + /* Wait for TXFIFO empty */ + ret = fspi_readl_poll_tout(f, f->iobase + FSPI_INTR, + FSPI_INTR_IPTXWE, 0, + POLL_TOUT, true); + WARN_ON(ret); + +- for (j = 0; j < ALIGN(op->data.nbytes - i, 4); j += 4) { +- memcpy(&data, buf + i + j, 4); ++ for (j = 0; j < ALIGN(remaining, 4); j += 4) { ++ memcpy(&data, buf + i + j, min_t(int, 4, remaining - j)); + fspi_writel(f, data, base + FSPI_TFDR + j); + } + fspi_writel(f, FSPI_INTR_IPTXWE, base + FSPI_INTR); diff --git a/queue-6.10/tracing-kprobes-fix-build-error-when-find_module-is-not-available.patch b/queue-6.10/tracing-kprobes-fix-build-error-when-find_module-is-not-available.patch new file mode 100644 index 00000000000..b392bafeb1e --- /dev/null +++ b/queue-6.10/tracing-kprobes-fix-build-error-when-find_module-is-not-available.patch @@ -0,0 +1,67 @@ +From b10545b6b86b7a0b3e26b4c2a5c99b72d49bc4de Mon Sep 17 00:00:00 2001 +From: "Masami Hiramatsu (Google)" +Date: Wed, 10 Jul 2024 08:36:31 +0900 +Subject: tracing/kprobes: Fix build error when find_module() is not available + +From: Masami Hiramatsu (Google) + +commit b10545b6b86b7a0b3e26b4c2a5c99b72d49bc4de upstream. + +The kernel test robot reported that the find_module() is not available +if CONFIG_MODULES=n. +Fix this error by hiding find_modules() in #ifdef CONFIG_MODULES with +related rcu locks as try_module_get_by_name(). + +Link: https://lore.kernel.org/all/172056819167.201571.250053007194508038.stgit@devnote2/ + +Reported-by: kernel test robot +Closes: https://lore.kernel.org/oe-kbuild-all/202407070744.RcLkn8sq-lkp@intel.com/ +Closes: https://lore.kernel.org/oe-kbuild-all/202407070917.VVUCBlaS-lkp@intel.com/ +Signed-off-by: Masami Hiramatsu (Google) +Cc: Thorsten Leemhuis +Signed-off-by: Greg Kroah-Hartman +--- + kernel/trace/trace_kprobe.c | 25 +++++++++++++++++++------ + 1 file changed, 19 insertions(+), 6 deletions(-) + +--- a/kernel/trace/trace_kprobe.c ++++ b/kernel/trace/trace_kprobe.c +@@ -794,6 +794,24 @@ static int validate_module_probe_symbol( + return 0; + } + ++#ifdef CONFIG_MODULES ++/* Return NULL if the module is not loaded or under unloading. */ ++static struct module *try_module_get_by_name(const char *name) ++{ ++ struct module *mod; ++ ++ rcu_read_lock_sched(); ++ mod = find_module(name); ++ if (mod && !try_module_get(mod)) ++ mod = NULL; ++ rcu_read_unlock_sched(); ++ ++ return mod; ++} ++#else ++#define try_module_get_by_name(name) (NULL) ++#endif ++ + static int validate_probe_symbol(char *symbol) + { + struct module *mod = NULL; +@@ -805,12 +823,7 @@ static int validate_probe_symbol(char *s + modname = symbol; + symbol = p + 1; + *p = '\0'; +- /* Return 0 (defer) if the module does not exist yet. */ +- rcu_read_lock_sched(); +- mod = find_module(modname); +- if (mod && !try_module_get(mod)) +- mod = NULL; +- rcu_read_unlock_sched(); ++ mod = try_module_get_by_name(modname); + if (!mod) + goto out; + } diff --git a/queue-6.10/tracing-osnoise-fix-build-when-timerlat-is-not-enabled.patch b/queue-6.10/tracing-osnoise-fix-build-when-timerlat-is-not-enabled.patch new file mode 100644 index 00000000000..6b303b6c2af --- /dev/null +++ b/queue-6.10/tracing-osnoise-fix-build-when-timerlat-is-not-enabled.patch @@ -0,0 +1,57 @@ +From af178143343028fdec9d5960a22d17f5587fd3f5 Mon Sep 17 00:00:00 2001 +From: Steven Rostedt +Date: Mon, 9 Sep 2024 10:32:31 -0400 +Subject: tracing/osnoise: Fix build when timerlat is not enabled + +From: Steven Rostedt + +commit af178143343028fdec9d5960a22d17f5587fd3f5 upstream. + +To fix some critical section races, the interface_lock was added to a few +locations. One of those locations was above where the interface_lock was +declared, so the declaration was moved up before that usage. +Unfortunately, where it was placed was inside a CONFIG_TIMERLAT_TRACER +ifdef block. As the interface_lock is used outside that config, this broke +the build when CONFIG_OSNOISE_TRACER was enabled but +CONFIG_TIMERLAT_TRACER was not. + +Cc: Masami Hiramatsu +Cc: Mathieu Desnoyers +Cc: "Helena Anna" +Cc: "Luis Claudio R. Goncalves" +Cc: Tomas Glozar +Link: https://lore.kernel.org/20240909103231.23a289e2@gandalf.local.home +Fixes: e6a53481da29 ("tracing/timerlat: Only clear timer if a kthread exists") +Reported-by: "Bityutskiy, Artem" +Signed-off-by: Steven Rostedt (Google) +Signed-off-by: Greg Kroah-Hartman +--- + kernel/trace/trace_osnoise.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +--- a/kernel/trace/trace_osnoise.c ++++ b/kernel/trace/trace_osnoise.c +@@ -228,6 +228,11 @@ static inline struct osnoise_variables * + return this_cpu_ptr(&per_cpu_osnoise_var); + } + ++/* ++ * Protect the interface. ++ */ ++static struct mutex interface_lock; ++ + #ifdef CONFIG_TIMERLAT_TRACER + /* + * Runtime information for the timer mode. +@@ -253,11 +258,6 @@ static inline struct timerlat_variables + } + + /* +- * Protect the interface. +- */ +-static struct mutex interface_lock; +- +-/* + * tlat_var_reset - Reset the values of the given timerlat_variables + */ + static inline void tlat_var_reset(void)