From patchwork Tue Oct 10 12:09:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hao X-Patchwork-Id: 9998871 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C7E1960230 for ; Wed, 11 Oct 2017 07:33:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B926F1FF8F for ; Wed, 11 Oct 2017 07:33:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE0B62891B; Wed, 11 Oct 2017 07:33:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 466631FF8F for ; Wed, 11 Oct 2017 07:33:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3DA6F6E5F7; Wed, 11 Oct 2017 07:32:50 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 3843 seconds by postgrey-1.35 at gabe; Tue, 10 Oct 2017 13:06:19 UTC Received: from mail5.wrs.com (mail5.windriver.com [192.103.53.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 433476E458 for ; Tue, 10 Oct 2017 13:06:19 +0000 (UTC) Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail5.wrs.com (8.15.2/8.15.2) with ESMTPS id v9AC2Dnp005182 (version=TLSv1 cipher=AES128-SHA bits=128 verify=OK); Tue, 10 Oct 2017 05:02:13 -0700 Received: from pek-lpgbuild2.wrs.com (128.224.153.30) by ALA-HCA.corp.ad.wrs.com (147.11.189.50) with Microsoft SMTP Server id 14.3.361.1; Tue, 10 Oct 2017 05:02:12 -0700 From: Kevin Hao To: Subject: [PATCH] drm: tilcdc: Calculate the vrefresh if it is not set by userspace Date: Tue, 10 Oct 2017 20:09:09 +0800 Message-ID: <20171010120909.26290-1-kexin.hao@windriver.com> X-Mailer: git-send-email 2.9.3 MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 11 Oct 2017 07:32:33 +0000 Cc: Tomi Valkeinen , Jyri Sarha X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The check for vrefresh has been removed by commit 11abbc9f39e0 ("drm/tilcdc: Set framebuffer DMA address to HW only if CRTC is enabled"). But the userspace is really possible to request a display mode with vrefresh uninitialized, then it would cause the following calltrace: [] (unwind_backtrace) from [] (show_stack+0x20/0x24) [] (show_stack) from [] (dump_stack+0x20/0x28) [] (dump_stack) from [] (__div0+0x20/0x28) [] (__div0) from [] (Ldiv0+0x8/0x14) [] (Ldiv0) from [] (tilcdc_crtc_update_fb+0xa8/0x1d4) [] (tilcdc_crtc_update_fb) from [] (tilcdc_plane_atomic_update+0x54/0x5c) [] (tilcdc_plane_atomic_update) from [] (drm_atomic_helper_commit_planes+0x1b4/0x270) [] (drm_atomic_helper_commit_planes) from [] (tilcdc_commit+0x58/0x84) [] (tilcdc_commit) from [] (drm_atomic_commit+0x54/0x68) [] (drm_atomic_commit) from [] (drm_atomic_helper_set_config+0x68/0x9c) [] (drm_atomic_helper_set_config) from [] (__drm_mode_set_config_internal+0x60/0xe0) [] (__drm_mode_set_config_internal) from [] (drm_mode_setcrtc+0x3a8/0x4c0) [] (drm_mode_setcrtc) from [] (drm_ioctl_kernel+0x78/0xb0) [] (drm_ioctl_kernel) from [] (drm_ioctl+0x1fc/0x328) [] (drm_ioctl) from [] (vfs_ioctl+0x28/0x44) [] (vfs_ioctl) from [] (do_vfs_ioctl+0x890/0x8ec) [] (do_vfs_ioctl) from [] (SyS_ioctl+0x60/0x7c) [] (SyS_ioctl) from [] (ret_fast_syscall+0x0/0x48) So calculate the vrefresh in mode_fixup() to make sure there always have a valid vrefresh. Fixes: 11abbc9f39e0 ("drm/tilcdc: Set framebuffer DMA address to HW only if CRTC is enabled") Cc: # v4.11+ Signed-off-by: Kevin Hao --- drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c index d2589f310437..16b020a9044c 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c @@ -690,6 +690,9 @@ static bool tilcdc_crtc_mode_fixup(struct drm_crtc *crtc, adjusted_mode->flags &= ~DRM_MODE_FLAG_PHSYNC; } + if (!adjusted_mode->vrefresh) + adjusted_mode->vrefresh = drm_mode_vrefresh(adjusted_mode); + return true; }