From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751069AbbACKIk (ORCPT ); Sat, 3 Jan 2015 05:08:40 -0500 Received: from cantor2.suse.de ([195.135.220.15]:55143 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750932AbbACKIi (ORCPT ); Sat, 3 Jan 2015 05:08:38 -0500 Date: Sat, 03 Jan 2015 11:08:35 +0100 Message-ID: From: Takashi Iwai To: Takashi Iwai Cc: David Airlie , Alex Deucher , christian.koenig@amd.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/radeon: Fix kernel panic when plugging a HDMI w/o SAD In-Reply-To: <1420273672-32496-1-git-send-email-tiwai@suse.de> References: <1420273672-32496-1-git-send-email-tiwai@suse.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/24.4 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org At Sat, 3 Jan 2015 09:27:52 +0100, Takashi Iwai wrote: > > A BUG_ON() call in dce3_2_afmt_write_sad_regs() is triggered when a > HDMI monitor without SAD is plugged as the case sad_count = 0 is > overlooked in the code: > > kernel BUG at ../drivers/gpu/drm/radeon/dce3_1_afmt.c:110! > invalid opcode: 0000 [#1] PREEMPT SMP > CPU: 2 PID: 967 Comm: Xorg Tainted: PO 3.16.7-7-desktop #1 > Hardware name: System manufacturer System Product Name/M4A77T, BIOS 2401 05/18/2011 > task: ffff8800cea86350 ti: ffff8800c1880000 task.ti: ffff8800c1880000 > RIP: 0010:[] dce3_1_hdmi_setmode+0x570/0x5a0 [radeon] > Call Trace: > [] drm_crtc_helper_set_mode+0x346/0x520 [drm_kms_helper] > [] drm_crtc_helper_set_config+0x8a8/0xad0 [drm_kms_helper] > [] radeon_crtc_set_config+0x3f/0x110 [radeon] > [] drm_mode_set_config_internal+0x61/0xe0 [drm] > [] restore_fbdev_mode+0xab/0xd0 [drm_kms_helper] > [] drm_fb_helper_restore_fbdev_mode_unlocked+0x1e/0x30 [drm_kms_helper] > [] drm_fb_helper_set_par+0x22/0x60 [drm_kms_helper] > [] drm_fb_helper_hotplug_event+0x8b/0xe0 [drm_kms_helper] > [] drm_fb_helper_set_par+0x3a/0x60 [drm_kms_helper] > [] fb_set_var+0x15e/0x3b0 > [] fbcon_blank+0x1cb/0x2b0 > [] do_unblank_screen+0xa1/0x1b0 > [] complete_change_console+0x53/0xe0 > [] vt_ioctl+0xf49/0x10d0 > [] tty_ioctl+0x26c/0xb70 > [] do_vfs_ioctl+0x2e7/0x4c0 > [] SyS_ioctl+0x81/0xa0 > [] system_call_fastpath+0x1a/0x1f > [<00007f2fae8c6397>] 0x7f2fae8c6396 > > This patch fixes it by covering sad_count = 0 in the error check > properly, too. > > Bugzilla: https://bugzilla.opensuse.org/show_bug.cgi?id=911356 > Cc: > Signed-off-by: Takashi Iwai > --- > > IMO, BUG_ON() call itself is exaggerated there, but we may change it later > independently from this fix. > > drivers/gpu/drm/radeon/dce3_1_afmt.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/radeon/dce3_1_afmt.c b/drivers/gpu/drm/radeon/dce3_1_afmt.c > index 2fe8cfc966d9..bafdf92a5732 100644 > --- a/drivers/gpu/drm/radeon/dce3_1_afmt.c > +++ b/drivers/gpu/drm/radeon/dce3_1_afmt.c > @@ -103,7 +103,7 @@ static void dce3_2_afmt_write_sad_regs(struct drm_encoder *encoder) > } > > sad_count = drm_edid_to_sad(radeon_connector->edid, &sads); > - if (sad_count < 0) { > + if (sad_count <= 0) { > DRM_ERROR("Couldn't read SADs: %d\n", sad_count); > return; > } Looking back at this fix again, this seems suboptimal, as it prints the error even in the correct case (sad_count = 0), and it doesn't set the register in the later code. I'm going to post a revised patch. Takashi