Received: by 2002:ab2:687:0:b0:1f4:6588:b3a7 with SMTP id s7csp198880lqe; Tue, 9 Apr 2024 21:34:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVwvcO5TwqznL1hbD2HItc4R5CmPkr+R+t3FdfMrIgRSfTxrmI6fOAbiwwt+8pGBHJ4t+STrRD+xdn9ahKvWPI8QSGomouI7xLS5Kk46A== X-Google-Smtp-Source: AGHT+IHKlEQyFgD5AhNDbZ+VSjW5cjucoNGKx+BaIv4xYTe/xIs/Sv4sJJD941Q72VAKw5KhQ5k+ X-Received: by 2002:ac8:703:0:b0:434:fea0:656b with SMTP id g3-20020ac80703000000b00434fea0656bmr1305529qth.12.1712723699680; Tue, 09 Apr 2024 21:34:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712723699; cv=pass; d=google.com; s=arc-20160816; b=Mk2dHqarcrmtIYeGCnOxK7+iKq6Z4zU3uzKL6ctAA4efljg+U7d1XCN6odiyBdXDB5 jNoa2f7DjHtmHejaYdS1MWvIQFUBfNVzAHECqq5ZPDlvRxTUUqm4V7OMJobIxjOorr5f zpqvEEd4vGBpy781ZRxVh9/UnWwIWMqHzCO/IDeQSMGYHsa4av0rawYQkJ3rsEV5iqCU jNacH6T0RnN2NefdKPm3UHGSa1BCIawuTVlxrHrbhaCv3Cf7jFjLcmSFIySSArWUfZU9 cSKyVEgkPoa+Yu9Yz1B6SXOJA6/Ffn2hGv/ZRC0zL5TwebpoWxz7wAlK5CMUpRh5r9YM AtJQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=a/JPFUxV2ArWkhwNnn1v7zuWOs9XoBJjsryMcg9Mcoo=; fh=MmjVQKcIChhr8HaTwC1UNRXW4cWQGEZFqiBOIjPTU7Q=; b=UhB3Q3t/11wTS7S5B00qXGQe8hL9G9KSd1JK5nYjefhvJcEcf8V6C1u8AOxRK7toBZ WspNGqkJVUHSVduI7SrylsOlFS6auX9/PIxC0ejp8N3xzUDANDAA1QkxU7LhyI3Pc9wb 92Cd2AyMPEp2v8yNe+HVe+b/GyaigujnnzT2JGPc3mnSSKD7ZIC0aJKZ3m16Au37dHep 2Zal/wDa4FGg10SxIBvjotAfPB0D0apc+kceLfBoI+oKExcz5jeUpFlKTDvEn6WJK2Dd q/sdqX77bjUva/HZQ2621S1kIGjk3fP0upCFrf1AmBgzM29sHCuWlhFqJJ64eCpAKjpz 2yeg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@netflix.com header.s=google header.b=R7ohwTgC; arc=pass (i=1 spf=pass spfdomain=netflix.com dkim=pass dkdomain=netflix.com dmarc=pass fromdomain=netflix.com); spf=pass (google.com: domain of linux-kernel+bounces-137886-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137886-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=netflix.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o7-20020ac85a47000000b00434ba49a73bsi4447381qta.114.2024.04.09.21.34.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 21:34:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137886-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@netflix.com header.s=google header.b=R7ohwTgC; arc=pass (i=1 spf=pass spfdomain=netflix.com dkim=pass dkdomain=netflix.com dmarc=pass fromdomain=netflix.com); spf=pass (google.com: domain of linux-kernel+bounces-137886-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137886-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=netflix.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6BE071C22722 for ; Wed, 10 Apr 2024 04:34:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA74ED51A; Wed, 10 Apr 2024 04:34:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=netflix.com header.i=@netflix.com header.b="R7ohwTgC" Received: from mail-il1-f170.google.com (mail-il1-f170.google.com [209.85.166.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D48E7460 for ; Wed, 10 Apr 2024 04:34:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712723687; cv=none; b=namMnNe0exLbKcTCajx/ON8Ng5Hn2u+z599AFJrrARD7V6TaLNk8pyLgmnedNl/HU/X6UK7KLj8OB/LUkdckGG2Ki9zoZlyUv0QHhnx0OOZobbcC/1o1fMnv/pPnMNdGMRmIoLz6UkkSgUuTbwfr+MUXEsRL+JXYghinQOch6GI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712723687; c=relaxed/simple; bh=EwGSVi8tsIBhQGwWzz1I/qZviamVBkcZz6+GbYrdYmk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ViCTaijU22Cpd6JSfGrlqrTRK60reChfeysqMjNvSzwxkQtBOI6CZvchUc5I5tkaYwsTg7n5dD2A3movh+Bw7UaGjy5MbTSkDU/aAF2JxqFWcb28RaL3RD4bijR45EW7pgQidNbtE9FDZs4oVWsFtqwSicSXGeBVP8ybsEekU7g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=netflix.com; spf=pass smtp.mailfrom=netflix.com; dkim=pass (1024-bit key) header.d=netflix.com header.i=@netflix.com header.b=R7ohwTgC; arc=none smtp.client-ip=209.85.166.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=netflix.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netflix.com Received: by mail-il1-f170.google.com with SMTP id e9e14a558f8ab-36a205e0f16so12294455ab.1 for ; Tue, 09 Apr 2024 21:34:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netflix.com; s=google; t=1712723685; x=1713328485; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=a/JPFUxV2ArWkhwNnn1v7zuWOs9XoBJjsryMcg9Mcoo=; b=R7ohwTgCEg/QJQ8V7LMvmWQTuOLEBRgNpllbR4GDO7T5CaJMfUeK1/41c+FR32Ivxk juiY1IZ6qPKDSLRYoJevxJ1JW4nzviRSSvvTm4TB34B7jlttE0qKamwkN3pxslxyHkvk yj3gxdGRW6qRJLin03IKxXtVt/rxHDow0Tsv8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712723685; x=1713328485; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=a/JPFUxV2ArWkhwNnn1v7zuWOs9XoBJjsryMcg9Mcoo=; b=PSfyrYn5rhuJ4ib7X38fDDy6tgLRDgA4R/wbtpYZlppI9MI2Y2/AI7TmCY4Kk00q7f NZ6jyWNPoGwcGHOoULmKuB3RYtVTiJPumCxj4NHa84oTQqwpsjg21gMnDbYu3J2408JA 8ipdPcVE4nC/+pvYsgEONtscPHmYf8MivMY9b9H7WRg3Pur+eF+3xfef30AawvJ9n6zL jFAh4run15zZCa69XK+zNTBXuGgp/c6TxaCveluJB70qXi7rvO5pMDAwGDcUEk535PIq 5Zmkj6H5T/QSFHP3nCCvMIYcXPdKt8s9I7OQ5hsiHVYKW7/OUWo4dX6xdncYcKNr8o2y IU6w== X-Gm-Message-State: AOJu0YxLQlBHJzHoPydqQtUR9gCeVmGC3CSi53xrK+paIB/KQfYwmbgn +fxVKmUdrCdtBwtokXp9M3CKePW+iudhGGPRGS68GVeq9Lp78TBKuLa2JWmMOG4= X-Received: by 2002:a05:6e02:1607:b0:369:ed5b:dd56 with SMTP id t7-20020a056e02160700b00369ed5bdd56mr2350659ilu.17.1712723685172; Tue, 09 Apr 2024 21:34:45 -0700 (PDT) Received: from localhost ([2601:285:8700:8f20:fa81:e682:614d:196f]) by smtp.gmail.com with UTF8SMTPSA id hb2-20020a0566386c0200b0048290482c7bsm2023528jab.54.2024.04.09.21.34.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Apr 2024 21:34:44 -0700 (PDT) From: Jose Fernandez To: Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , christian.koenig@amd.com, Xinhui.Pan@amd.com, David Airlie , Daniel Vetter , Wenjing Liu , Alan Liu , George Shen , Nicholas Kazlauskas , Ilya Bakoulin , Nasir Osman , Hamza Mahfooz , Fangzhi Zuo , Leo Ma , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org, Jose Fernandez Subject: [PATCH] drm/amd/display: Fix division by zero in setup_dsc_config Date: Tue, 9 Apr 2024 22:34:33 -0600 Message-Id: <20240410043433.12854-1-josef@netflix.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When slice_height is 0, the division by slice_height in the calculation of the number of slices will cause a division by zero driver crash. This leaves the kernel in a state that requires a reboot. This patch adds a check to avoid the division by zero. The stack trace below is for the 6.8.4 Kernel. I reproduced the issue on a Z16 Gen 2 Lenovo Thinkpad with a Apple Studio Display monitor connected via Thunderbolt. The amdgpu driver crashed with this exception when I rebooted the system with the monitor connected. kernel: ? die (arch/x86/kernel/dumpstack.c:421 arch/x86/kernel/dumpstack.c:434 arch/x86/kernel/dumpstack.c:447) kernel: ? do_trap (arch/x86/kernel/traps.c:113 arch/x86/kernel/traps.c:154) kernel: ? setup_dsc_config (drivers/gpu/drm/amd/amdgpu/../display/dc/dsc/dc_dsc.c:1053) amdgpu kernel: ? do_error_trap (./arch/x86/include/asm/traps.h:58 arch/x86/kernel/traps.c:175) kernel: ? setup_dsc_config (drivers/gpu/drm/amd/amdgpu/../display/dc/dsc/dc_dsc.c:1053) amdgpu kernel: ? exc_divide_error (arch/x86/kernel/traps.c:194 (discriminator 2)) kernel: ? setup_dsc_config (drivers/gpu/drm/amd/amdgpu/../display/dc/dsc/dc_dsc.c:1053) amdgpu kernel: ? asm_exc_divide_error (./arch/x86/include/asm/idtentry.h:548) kernel: ? setup_dsc_config (drivers/gpu/drm/amd/amdgpu/../display/dc/dsc/dc_dsc.c:1053) amdgpu kernel: dc_dsc_compute_config (drivers/gpu/drm/amd/amdgpu/../display/dc/dsc/dc_dsc.c:1109) amdgpu After applying this patch, the driver no longer crashes when the monitor is connected and the system is rebooted. I believe this is the same issue reported for 3113. Signed-off-by: Jose Fernandez Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3113 --- drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c b/drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c index ac41f9c0a283..597d5425d6cb 100644 --- a/drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c +++ b/drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c @@ -1055,7 +1055,12 @@ static bool setup_dsc_config( if (!is_dsc_possible) goto done; - dsc_cfg->num_slices_v = pic_height/slice_height; + if (slice_height > 0) + dsc_cfg->num_slices_v = pic_height/slice_height; + else { + is_dsc_possible = false; + goto done; + } if (target_bandwidth_kbps > 0) { is_dsc_possible = decide_dsc_target_bpp_x16( -- 2.44.0