Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2315467lqt; Mon, 22 Apr 2024 07:36:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWmpgwOMfzR7YvXT7gCk4HYajFedvr9AjHy9UA3odwglcb3L+HD1zZT8fRtHi0NAcDT9ZR5sd1kS8Xzb75Kk5/3YNT/DY44+2iQkNTt/g== X-Google-Smtp-Source: AGHT+IFBroGZMBiH9RycuWKrZmCgd6RAJdBpEK4tTFa+HQhEUpuhozRh9Ch5iw8o4HzPFl1gOY3s X-Received: by 2002:a05:620a:55ba:b0:790:61c4:8490 with SMTP id vr26-20020a05620a55ba00b0079061c48490mr8494295qkn.0.1713796565996; Mon, 22 Apr 2024 07:36:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713796565; cv=pass; d=google.com; s=arc-20160816; b=c6UZwVYB66ZnKyIbI7ygMDmx8fhSg2souJB7zPIDqelQP7nTtaSCkncmHSOFOw/6wH n48p795+GypA0ymmL0iefmU8sQ6wYT4iCvSa9VTS6113h6gJQAk6UYDMjY60aZ1TMNEd 4hITsDBHRIfVp3IbpeM0EErZJfavVSnC7F6wa/8YbWfSeXpoGJ8WjocR8qHf+rRboLxa sa83GwC9qa8nGl1B0xG42wUeiScuxYAjxUCafGOMNRg29Wn6drVCOz8jUuyKMiLSTYzV Exq/dK+jzJPWKkYB2rVyV0wBwBkknYA5P7exngbwjDBHt4uFb3D1dwab5K4UAlrVKMnB R6Pg== 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=pTqCgGepNx6s+dU2klqt5maLM3ael/nCebUPVMKXEvg=; b=GS4ysVa5/Q20ZFwQyqH+aVPFzDGZQinaPuTPNUSgfxUG/1aNjDWdSThavv2wvYJB9J wrBgqtizM4yEkorB3nSl/24AZFM89yHwwjGKJCNfTiclUAxuYTuvytzyMH+o3u759ljK 2Y+j/wW0+wtCMs522Xd7cymAlQmZj0WPmPVRzem8873BPlO2pxiokZ/y2qPU9RTddcfv /BmssGpxk6GnIDLiEBtwKZhdmI8ALI435/r14gTfRe9QWaLQUgNwLvKiC25QeNGieZkS 1G9rM/Phewjf1Q/9lHmQ2MMfIx5Fuf3dxDcojaNs5/sjfIHxDe3HWAkZ8Rc9hctynBoF BpMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@netflix.com header.s=google header.b=piGpTv3k; 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-153557-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153557-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. [147.75.199.223]) by mx.google.com with ESMTPS id h8-20020a05620a400800b0078bcf5fbcd0si11920771qko.16.2024.04.22.07.36.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 07:36:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153557-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@netflix.com header.s=google header.b=piGpTv3k; 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-153557-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153557-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 B2F671C2183D for ; Mon, 22 Apr 2024 14:36:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 80197152160; Mon, 22 Apr 2024 14:35:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=netflix.com header.i=@netflix.com header.b="piGpTv3k" Received: from mail-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.54]) (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 04E393CF65 for ; Mon, 22 Apr 2024 14:35:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713796558; cv=none; b=JwjlZVx3/pl0Yo/wKNSWUfpiTV7IALo6JIEQrzzEpeDL9eU9D97jgQYB1JUC/o6hKHar731VGO4sGxgyUMdTIA0VlAgmgJNzwEiA1yAx4pgPywPzieEK830AVsmsFcU6L+PEp9YRmiGa4ljWQeLmwx8NKxlsPnCLyjIoCfr1moU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713796558; c=relaxed/simple; bh=EwGSVi8tsIBhQGwWzz1I/qZviamVBkcZz6+GbYrdYmk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=nHH31P53jljc/kjmPEW0Hqv09gwJ/XeRiyprEPaW2AiND+tqwXmdZb0m9v7XfeTcmqlwIYWY3y3VuyFbgv5CfM/50hx4xiwMuUX4+INIDXCIuvz7PLvBKmzNYkJr+tGnioh1POY+8myxBWBbi1/Okiaw1rVcLE2G6GMcwjQVeAc= 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=piGpTv3k; arc=none smtp.client-ip=209.85.166.54 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-io1-f54.google.com with SMTP id ca18e2360f4ac-7d6a772af5bso164423939f.1 for ; Mon, 22 Apr 2024 07:35:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netflix.com; s=google; t=1713796556; x=1714401356; 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=piGpTv3k1ztDsoA3KzFniS8OUrino3+OEdveBYnZ/vO5cXdm7yaIbfybmkwEYB+Emh +qObK+mu7bLCFtypkwHJabuPkZSF1ApPFlrbGmpAUwDrZzYy0d8rnOBAsqB5UH2BVbsx 9PkfSUNWjYKVu8EJxpFhLKiDq0U4lu7VmkhCA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713796556; x=1714401356; 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=eq21rZcmCx2Bre3ytScNZwS86etDzdQq24wTjtqe+Eek9hx0+yP19GHibDFddLdpOG lawUBtB84ooAZYSBxiseNgrT2VW12etEI5aEKAtTH8KAh7Ztq44C5HvpxK0ac0ewYp14 XfSnfX7rZe/TxCbY2Ky1yik2f7hNvKtGLK1Yl8hJno2Eruxjz0+wVEeSPtHmADDRV1RY owiL/c79z9aR6Q89eobh2VeHyZICQ3c7uR6d/9y0kNOVITYTAY3O+ePw9ixvGF6Ggqhq 9rrRGKEbOJ2JciCe/ZFnpx3LJYNEuEhRPmdA2CwZJ47k9V0mJGu4TskDfTx9/7y8HogD H2wA== X-Gm-Message-State: AOJu0YyjUuJ0Uwk7iA5Tk8oXur9ydKBYZBz0JsIN4q2+e4OeP+OrSY44 3074g9mlrDEFz5LaUo0PvscgvIbO/NWWGWsDbXO94pC5fH28/8JbJZ+oOWlQlMg= X-Received: by 2002:a05:6602:1b92:b0:7cb:ffe6:b320 with SMTP id dq18-20020a0566021b9200b007cbffe6b320mr11608580iob.5.1713796555960; Mon, 22 Apr 2024 07:35:55 -0700 (PDT) Received: from localhost ([2601:285:8700:8f20:e98c:6f5c:74a4:9a12]) by smtp.gmail.com with UTF8SMTPSA id dv10-20020a056638608a00b00482f7427748sm2849642jab.135.2024.04.22.07.35.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Apr 2024 07:35:55 -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 , 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 RESEND] drm/amd/display: Fix division by zero in setup_dsc_config Date: Mon, 22 Apr 2024 08:35:44 -0600 Message-Id: <20240422143544.20481-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