From patchwork Thu Sep 6 22:18:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Wu X-Patchwork-Id: 10591143 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 79731921 for ; Thu, 6 Sep 2018 22:18:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66C612AD28 for ; Thu, 6 Sep 2018 22:18:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B4512AD2E; Thu, 6 Sep 2018 22:18:30 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 0188D2AD28 for ; Thu, 6 Sep 2018 22:18:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EA48F6E79E; Thu, 6 Sep 2018 22:18:23 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.lekensteyn.nl (mail.lekensteyn.nl [IPv6:2a02:2308::360:1:25]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8D20F6E781 for ; Thu, 6 Sep 2018 22:18:18 +0000 (UTC) Received: by lekensteyn.nl with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1fy2bO-0005Us-IX; Fri, 07 Sep 2018 00:18:15 +0200 From: Peter Wu To: Gerd Hoffmann Subject: [PATCH v2 4/4] drm/fb-helper: improve documentation and print warnings Date: Fri, 7 Sep 2018 00:18:10 +0200 Message-Id: <20180906221810.20170-5-peter@lekensteyn.nl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180906221810.20170-1-peter@lekensteyn.nl> References: <20180906221810.20170-1-peter@lekensteyn.nl> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Clarify the relation between drm_fb_helper_fbdev_setup/teardown. Clarify requirements for the new generic fbdev emulation API and log some more details in case the driver does something wrong. Fix related typos. Cc: Noralf Trønnes Signed-off-by: Peter Wu Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_fb_helper.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 4b0dd20bccb8..7f92ff173986 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -2821,7 +2821,9 @@ EXPORT_SYMBOL(drm_fb_helper_hotplug_event); * The caller must to provide a &drm_fb_helper_funcs->fb_probe callback * function. * - * See also: drm_fb_helper_initial_config() + * Use drm_fb_helper_fbdev_teardown() to destroy the fbdev. + * + * See also: drm_fb_helper_initial_config(), drm_fbdev_generic_setup(). * * Returns: * Zero on success or negative error code on failure. @@ -3037,7 +3039,7 @@ static struct fb_deferred_io drm_fbdev_defio = { * @fb_helper: fbdev helper structure * @sizes: describes fbdev size and scanout surface size * - * This function uses the client API to crate a framebuffer backed by a dumb buffer. + * This function uses the client API to create a framebuffer backed by a dumb buffer. * * The _sys_ versions are used for &fb_ops.fb_read, fb_write, fb_fillrect, * fb_copyarea, fb_imageblit. @@ -3165,8 +3167,10 @@ static int drm_fbdev_client_hotplug(struct drm_client_dev *client) if (dev->fb_helper) return drm_fb_helper_hotplug_event(dev->fb_helper); - if (!dev->mode_config.num_connector) + if (!dev->mode_config.num_connector) { + DRM_DEV_DEBUG(dev->dev, "No connectors found, will not create framebuffer!\n"); return 0; + } ret = drm_fb_helper_fbdev_setup(dev, fb_helper, &drm_fb_helper_generic_funcs, fb_helper->preferred_bpp, 0); @@ -3187,13 +3191,15 @@ static const struct drm_client_funcs drm_fbdev_client_funcs = { }; /** - * drm_fb_helper_generic_fbdev_setup() - Setup generic fbdev emulation + * drm_fbdev_generic_setup() - Setup generic fbdev emulation * @dev: DRM device * @preferred_bpp: Preferred bits per pixel for the device. * @dev->mode_config.preferred_depth is used if this is zero. * * This function sets up generic fbdev emulation for drivers that supports - * dumb buffers with a virtual address and that can be mmap'ed. + * dumb buffers with a virtual address and that can be mmap'ed. If the driver + * does not support these functions, it could use drm_fb_helper_fbdev_setup(). + * This function can only be used with devices created using drm_dev_register(). * * Restore, hotplug events and teardown are all taken care of. Drivers that do * suspend/resume need to call drm_fb_helper_set_suspend_unlocked() themselves. @@ -3206,6 +3212,8 @@ static const struct drm_client_funcs drm_fbdev_client_funcs = { * This function is safe to call even when there are no connectors present. * Setup will be retried on the next hotplug event. * + * The fbdev is destroyed by drm_dev_unregister(). + * * Returns: * Zero on success or negative error code on failure. */ @@ -3214,6 +3222,8 @@ int drm_fbdev_generic_setup(struct drm_device *dev, unsigned int preferred_bpp) struct drm_fb_helper *fb_helper; int ret; + WARN(dev->fb_helper, "fb_helper is already set!\n"); + if (!drm_fbdev_emulation) return 0; @@ -3224,12 +3234,15 @@ int drm_fbdev_generic_setup(struct drm_device *dev, unsigned int preferred_bpp) ret = drm_client_new(dev, &fb_helper->client, "fbdev", &drm_fbdev_client_funcs); if (ret) { kfree(fb_helper); + DRM_DEV_ERROR(dev->dev, "Failed to register client: %d\n", ret); return ret; } fb_helper->preferred_bpp = preferred_bpp; - drm_fbdev_client_hotplug(&fb_helper->client); + ret = drm_fbdev_client_hotplug(&fb_helper->client); + if (ret) + DRM_DEV_DEBUG(dev->dev, "client hotplug ret=%d\n", ret); return 0; }