From patchwork Tue Oct 18 17:42:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Agner X-Patchwork-Id: 9382769 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 8C5A2607D0 for ; Tue, 18 Oct 2016 17:48:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 804852971E for ; Tue, 18 Oct 2016 17:48:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 747DD29720; Tue, 18 Oct 2016 17:48:43 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 B216F2971E for ; Tue, 18 Oct 2016 17:48:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A81056E7C1; Tue, 18 Oct 2016 17:48:41 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kmu-office.ch (mail.kmu-office.ch [IPv6:2a02:418:6a02::a2]) by gabe.freedesktop.org (Postfix) with ESMTPS id DE4B06E7C3 for ; Tue, 18 Oct 2016 17:48:39 +0000 (UTC) Received: from webmail.kmu-office.ch (unknown [178.209.48.103]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 14EA75C2F49; Tue, 18 Oct 2016 19:42:21 +0200 (CEST) MIME-Version: 1.0 Date: Tue, 18 Oct 2016 10:42:46 -0700 From: Stefan Agner To: Daniel Vetter Subject: Re: [PATCH v3 5/5] drm/fsl-dcu: only init fbdev if required In-Reply-To: <20161018074424.GX20761@phenom.ffwll.local> References: <20161017213321.8074-1-stefan@agner.ch> <20161017213321.8074-6-stefan@agner.ch> <20161018074424.GX20761@phenom.ffwll.local> Message-ID: X-Sender: stefan@agner.ch User-Agent: Roundcube Webmail/1.1.3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1476812541; bh=vNAWlMDBiLmzzN7PYNLgzFkCe7LuYezpMvpmmJlpL8U=; h=MIME-Version:Content-Type:Content-Transfer-Encoding:Date:From:To:Cc:Subject:In-Reply-To:References:Message-ID; b=NPjqgcQE5HtEkFCHN9Jo44oDH+Seis/+1r+I4bNtlpeSrgn/WjHzP4DrmCm1GQ0YOoj59wtInCenS8QRXKnLox8pgKeIXQI3G4wfi+rJYaXI070Oqkqd1rKM4E0MckJGgF2EUu8nLOY000DmImlLdWgVPrXZE0u0Z3TEctyG1Ew= Cc: jianwei.wang.chn@gmail.com, meng.yi@nxp.com, alison.wang@freescale.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org 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 On 2016-10-18 00:44, Daniel Vetter wrote: > On Mon, Oct 17, 2016 at 02:33:21PM -0700, Stefan Agner wrote: >> There is no need to request a CMA backed framebuffer if fbdev >> emulation is not enabled. >> >> Signed-off-by: Stefan Agner >> --- >> drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c >> index e04efbe..3a5880c 100644 >> --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c >> +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c >> @@ -87,7 +87,8 @@ static int fsl_dcu_load(struct drm_device *dev, unsigned long flags) >> goto done; >> dev->irq_enabled = true; >> >> - fsl_dcu_fbdev_init(dev); >> + if (IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION)) >> + fsl_dcu_fbdev_init(dev); > > Totally not required, since this will all no-op out. Also, please nuke > that fsl_dcu_fbdv_init wrapper seems like pointless indirection. Regarding fsl_dcu_fbdev_init wrapper: Fully agreed. That thing was there since inception of that driver, and I always was on the fence of doing it. Will do it for the next merge window! I somehow remembered there was something more to it than just "no need", but I somehow failed to document it in the patch description... So I went back and tested some things without the patch, here is when it blows: Unable to handle kernel NULL pointer dereference at virtual address 000002f0 pgd = cc24c000 [000002f0] *pgd=8c0df831, *pte=00000000, *ppte=00000000 Internal error: Oops: 17 [#1] SMP ARM Modules linked in: CPU: 0 PID: 536 Comm: sh Not tainted 4.9.0-rc1-00001-g4b1532a-dirty #568 Hardware name: Freescale Vybrid VF5xx/VF6xx (Device Tree) task: cc213000 task.stack: cc23e000 PC is at drm_fbdev_cma_fini+0x14/0x5c LR is at fsl_dcu_unload+0x28/0x4c pc : [] lr : [] psr: a0000013 sp : cc23fd80 ip : cc23fd98 fp : cc23fd94 r10: cc1d1e4c r9 : cc23e000 r8 : 00000000 r7 : c0e34888 r6 : 0000000d r5 : 00000000 r4 : ce6ff100 r3 : c0e13b18 r2 : c0e13b18 r1 : 00000110 r0 : ce6ff100 Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none Control: 10c5387d Table: 8c24c04a DAC: 00000051 Process sh (pid: 536, stack limit = 0xcc23e210) Stack: (0xcc23fd80 to 0xcc240000) ... Backtrace: [] (drm_fbdev_cma_fini) from [] (fsl_dcu_unload+0x28/0x4c) r5:ce61e810[ 372.213609] r4:ce61f000 [] (fsl_dcu_unload) from [] (drm_dev_unregister+0x38/0xbc) r5:ce61f000[ 372.228535] r4:ce61f000 ... > > And if there really is an issue with the cma helpers allocating an fb when > they should, then the correct fix is to fix that in the helpers, not in > the drivers. Hm, to safe memory, it would probably be best to do something like: dev_err(dev->dev, "Failed to allocate drm fbdev.\n"); But we don't have drm_fbdev_emulation emulation there. Maybe just add some NULL check in drm_fbdev_cma_fini? --- Stefan > > Nack. > -Daniel >> >> return 0; >> done: >> -- >> 2.10.0 >> >> _______________________________________________ >> dri-devel mailing list >> dri-devel@lists.freedesktop.org >> https://lists.freedesktop.org/mailman/listinfo/dri-devel --- a/drivers/gpu/drm/drm_fb_cma_helper.c +++ b/drivers/gpu/drm/drm_fb_cma_helper.c @@ -492,6 +492,9 @@ struct drm_fbdev_cma *drm_fbdev_cma_init_with_funcs(struct drm_device *dev, struct drm_fb_helper *helper; int ret; + if (!drm_fbdev_emulation) + return NULL; + fbdev_cma = kzalloc(sizeof(*fbdev_cma), GFP_KERNEL); if (!fbdev_cma) {