Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp284133lqh; Fri, 31 May 2024 00:48:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWnY3cL3MbjKS5UOq3IDwGzWBHXXZqqX86g5aDavponcFG6+kZPI02wFyNdkbaMVd0G5GwSflTjJu3+K0hD/eZ1e7e9J3eUYpn/UnyDpw== X-Google-Smtp-Source: AGHT+IG819f3zbRfn+WhkY1n7cSTDmoYs0nI3pL8ZG+KyScVXgwL64B4oGU+6a3lAMmt0BbgzIta X-Received: by 2002:a05:6102:4652:b0:47f:3557:84fb with SMTP id ada2fe7eead31-48bc22e3ed2mr1218408137.26.1717141693893; Fri, 31 May 2024 00:48:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717141693; cv=pass; d=google.com; s=arc-20160816; b=Vda0Ql5HpqePcg2A0jgXdvZRPZDo7DUHE2x2eKdMNA4J2TFzT1GMAIWhfW4EnZN2hY 2ILBHvuOzpS20kkXTqsiOcn7ScL3UJUzgWmause8Gf43/xayh5rKVeocdZaPy17Dxip/ 99LTlDZF7E97Vuux4v6STVQmlNd6DfGqAlq00U1gONAxNYu5BXoraQJKWGztYVPS40FG OZw8uJFzBRwyDowIkr7PoyW0dZI7LFxK1f3VW053GU/NFEcz+Vaw+y/+P8DCTR6dFEl+ f5buDj83FhPLjUPSrMC+wX9I4DRuIBycFkFXb9G/bpREvROG1OnT32g8tIWk0KSwC3TZ BD7w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from:dkim-signature; bh=rYHuebSGZ7mqY6glOP6yJTsSa2h0lryE45zGutp7/dM=; fh=OIHhyxA0bBJXt3T6OnZAIyqhVpONss7G7HDRV2qtZQo=; b=yWX+kUtfsHrbBLPOu7RRYesolo1dDLqZWxJ8dvR1IbtEiXyhXWCYGpU+U8G+zxsIe7 N0eP3g3od+A24MHXJPToFI0RSb75iM5gEat0QU1KVtqkfMk3UO9mriIrWEvvMZOqWuYn eH/rcvoTAxVQ4ArByaFXXYiXVMUxsUH943xEqRcdUBq9SnGNfyF+9DvNJNqW/l3mqzP/ zcSNtFjPkCda3ONJ+Wou7G5o57wuqiaMxxzTB86WqUEkNa95/9tbYTQ2mbpfeG3DBaIT 6L5hhkKewRMjRcpLH6RWxX8KkWE0M9fAeqyMdBFPhugitN9FTyinmxjhR/5+JyM0pPPh CHdQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SHY82Che; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-196427-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196427-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 d75a77b69052e-43ff23ac68asi14728901cf.4.2024.05.31.00.48.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 00:48:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196427-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=@intel.com header.s=Intel header.b=SHY82Che; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-196427-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196427-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 ACC071C2136E for ; Fri, 31 May 2024 07:48:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7990E7441A; Fri, 31 May 2024 07:47:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SHY82Che" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D658F187567 for ; Fri, 31 May 2024 07:47:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717141677; cv=none; b=eKvXWnMxjiIx7J1+wZifoT26wwTOITZOgph8enoBsafbaed1OgAVyYfX4x7o2SQgUlT4mt0Cnl46GAU/Pmbc/NFsLjCEOaLGtN0OZNliEqWOeSbM5a/QECqyUGWm0i8QfbehiqAp3DI2aHzIx6pW+65B2VMRW57L2z2J8HmlweE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717141677; c=relaxed/simple; bh=Tu16eDOVCigfYW8Pz4VFPcNphxmr5sYpfmyZz/1SfQs=; h=From:To:Cc:Subject:Date:Message-Id; b=YmSpCg8E7cjEZq8p88UdKDwgzSCy2/YXGCRKFClxKEfsiYFryeOXmQH4+sWgoqwNfyOzyoDT3n4QXj1Zg1f0tAqqa6rGHVfWjQPBoZa/mnXxmePCdxexHTIGofuLIOKLeSRjOZe5DN/ubrhweB+M7ID+n1qKTsrb3uCuvN9z/gM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=SHY82Che; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717141676; x=1748677676; h=from:to:cc:subject:date:message-id; bh=Tu16eDOVCigfYW8Pz4VFPcNphxmr5sYpfmyZz/1SfQs=; b=SHY82Che2tqjU++MtTJLlC49JYKqpjIoij2p/YbE3LFB/iIxjJl7eXQb zo19oeJlsWUNESPY2AeI41coLbXhHPRRJjAO2LODdNAn/rT53mkHaYb3+ z/AHnnPxxXGhnr+VwSdmZ84NVpMtLcxixu4Ix0eEjWEDDGgPKX+kueU0C sjE9yyiG2OuzSn4yaDAz1r+AEvz98PijwLgbYUN2ZQXUOaFdSI9UBYb7V 8/gtq68XeFyGsiVKoWNiPN6cirNnI9TnuWeZgs0yUyTXHqpmjy8LZL5MZ hzIrbbavcdSFUkMiujGfA4N7LwH2vg01UDJRqOi2OzDAZUiazzIcHQO/j Q==; X-CSE-ConnectionGUID: 9fSflpo2S/Cv1ZeYRiFKrw== X-CSE-MsgGUID: Vn2y5sITSzeYevxig+T/9A== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="13520038" X-IronPort-AV: E=Sophos;i="6.08,203,1712646000"; d="scan'208";a="13520038" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2024 00:47:55 -0700 X-CSE-ConnectionGUID: CzEIJVuXTHuCo7DPY+hBFA== X-CSE-MsgGUID: vTWwWsuWRqiBcImIGrihwQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,203,1712646000"; d="scan'208";a="73567522" Received: from qiuxu-clx.sh.intel.com ([10.239.53.109]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2024 00:47:53 -0700 From: Qiuxu Zhuo To: maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, daniel@ffwll.ch Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, tony.luck@intel.com, qiuxu.zhuo@intel.com, yudong.wang@intel.com Subject: [PATCH 1/1] drm/fb-helper: Don't schedule_work() to flush frame buffer during panic() Date: Fri, 31 May 2024 15:45:21 +0800 Message-Id: <20240531074521.30406-1-qiuxu.zhuo@intel.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Sometimes the system [1] hangs on x86 I/O machine checks. However, the expected behavior is to reboot the system, as the machine check handler ultimately triggers a panic(), initiating a reboot in the last step. The root cause is that sometimes the panic() is blocked when drm_fb_helper_damage() invoking schedule_work() to flush the frame buffer. This occurs during the process of flushing all messages to the frame buffer driver as shown in the following call trace: Machine check occurs [2]: panic() console_flush_on_panic() console_flush_all() console_emit_next_record() con->write() vt_console_print() hide_cursor() vc->vc_sw->con_cursor() fbcon_cursor() ops->cursor() bit_cursor() soft_cursor() info->fbops->fb_imageblit() drm_fbdev_generic_defio_imageblit() drm_fb_helper_damage_area() drm_fb_helper_damage() schedule_work() // <--- blocked here ... emergency_restart() // wasn't invoked, so no reboot. During panic(), except the panic CPU, all the other CPUs are stopped. In schedule_work(), the panic CPU requires the lock of worker_pool to queue the work on that pool, while the lock may have been token by some other stopped CPU. So schedule_work() is blocked. Additionally, during a panic(), since there is no opportunity to execute any scheduled work, it's safe to fix this issue by skipping schedule_work() on 'oops_in_progress' in drm_fb_helper_damage(). [1] Enable the kernel option CONFIG_FRAMEBUFFER_CONSOLE, CONFIG_DRM_FBDEV_EMULATION, and boot with the 'console=tty0' kernel command line parameter. [2] Set 'panic_timeout' to a non-zero value before calling panic(). Reported-by: Yudong Wang Signed-off-by: Qiuxu Zhuo --- drivers/gpu/drm/drm_fb_helper.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index d612133e2cf7..6d7b6f038821 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -628,6 +628,9 @@ static void drm_fb_helper_add_damage_clip(struct drm_fb_helper *helper, u32 x, u static void drm_fb_helper_damage(struct drm_fb_helper *helper, u32 x, u32 y, u32 width, u32 height) { + if (oops_in_progress) + return; + drm_fb_helper_add_damage_clip(helper, x, y, width, height); schedule_work(&helper->damage_work); -- 2.17.1