From patchwork Thu May 5 09:47:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9023051 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 842A9BF29F for ; Thu, 5 May 2016 09:47:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 90080203F3 for ; Thu, 5 May 2016 09:47:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2E0B2203EB for ; Thu, 5 May 2016 09:47:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BDE6E6E021; Thu, 5 May 2016 09:47:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 112556E021; Thu, 5 May 2016 09:47:18 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id w143so2478630wmw.3; Thu, 05 May 2016 02:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=ggMM9wAA4AQ6e2OGRmv6XErpCQDwOAcF5DFlDugymSM=; b=q7cXXZnU5+dGw8X3+MxnKv6Iet34ane35jrJmc0erPqa+d7fHR/tDXUe5v/oLa7Jw0 gype9cqM1hn8sO94Y0gyfToCKEYwCc8wLdKqPl6UUKAiJ04aQoZrGkwckLIEaQUiVLh5 YjBVhbdZv89AwxftRQSjVjR6edOmVOchEoOVnBA53ePO/VQywRL2tGVFUgwVkz75AmEK DSC0KSdE+dAldyUT/u3ytZPkL6F76sxl4IfbfvOkh+UJQuaDk9EGW9OI4ovLYDsgOGRJ +zPBIThB6eRKnMEagpJ0mifaQh/FxXcqbNTlXtZ8nER8EPLZjSYfTKks6uUspz+FI/qw t7dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=ggMM9wAA4AQ6e2OGRmv6XErpCQDwOAcF5DFlDugymSM=; b=Dg6EM52PqD0cV0L19FHq5Uxaac21VsmaqTj+YGhtSqu2YRE5y9Z+INQPC4Q9ZxqBej tG1wdTJUPCI8WAmITj+ouJqEAZdp35dPW0QUE8w5OORTwQs+6QjCfApLpB58e20K6bMS NSWuwfteXo7dvDOVPfEf7WIeTQSNmCa/9mhu8NB8qQOgAPipHUxuIdyrnbeOFiZikb7q Ts6nZ0xDcfnkDT130nOsZejioUIjkh5dipsBeFO3E6K1kHxTli8xmEFBlxtWaUTdBbQl rpZwsWuDesjLw8p2Iam0E1xcua9YGNiQzyBxZgSHZHjoFXZngiWhklQ9czXDK4+Eh5S5 4XwQ== X-Gm-Message-State: AOPr4FVW0f04ysAHG/5MLYVRZBYtIuKdHjxvuDu9Jm8KePM37EX+mZ5M1m5YjY6sHOcMUw== X-Received: by 10.28.11.143 with SMTP id 137mr2269955wml.92.1462441636725; Thu, 05 May 2016 02:47:16 -0700 (PDT) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id jh2sm8843194wjb.39.2016.05.05.02.47.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 May 2016 02:47:15 -0700 (PDT) From: Chris Wilson To: intel-gfx@lists.freedesktop.org Subject: [PATCH] drm: Continue after failure to setup debugfs Date: Thu, 5 May 2016 10:47:10 +0100 Message-Id: <1462441630-681-1-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.8.1 Cc: 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If we fail to setup the debugfs we lose debugging convenience, but we should still endeavour to enable modesetting so that we can control the outputs and enable use of the system to debug the issue. In all likelihood if we can not create our debugfs files then there is a larger underlying issue that will prevent the module loading, but this should get us further towards resilience. Signed-off-by: Chris Wilson Cc: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/drm_debugfs.c | 13 +++++++++---- drivers/gpu/drm/drm_drv.c | 19 ++++++++----------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index 3bcf8e6a85b3..8f36e014fbd2 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -160,10 +160,8 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id, ret = drm_debugfs_create_files(drm_debugfs_list, DRM_DEBUGFS_ENTRIES, minor->debugfs_root, minor); if (ret) { - debugfs_remove(minor->debugfs_root); - minor->debugfs_root = NULL; DRM_ERROR("Failed to create core drm debugfs files\n"); - return ret; + goto err_root; } if (dev->driver->debugfs_init) { @@ -171,10 +169,17 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id, if (ret) { DRM_ERROR("DRM: Driver failed to initialize " "/sys/kernel/debug/dri.\n"); - return ret; + goto err_core; } } return 0; + +err_core: + drm_debugfs_remove_files(drm_debugfs_list, DRM_DEBUGFS_ENTRIES, minor); +err_root: + debugfs_remove(minor->debugfs_root); + minor->debugfs_root = NULL; + return ret; } diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index bff89226a344..18de82e4388a 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -307,11 +307,11 @@ static int drm_minor_register(struct drm_device *dev, unsigned int type) if (!minor) return 0; - ret = drm_debugfs_init(minor, minor->index, drm_debugfs_root); - if (ret) { + ret = -ENOENT; + if (drm_debugfs_root) + ret = drm_debugfs_init(minor, minor->index, drm_debugfs_root); + if (ret) DRM_ERROR("DRM: Failed to initialize /sys/kernel/debug/dri.\n"); - return ret; - } ret = device_add(minor->kdev); if (ret) @@ -904,17 +904,13 @@ static int __init drm_core_init(void) } drm_debugfs_root = debugfs_create_dir("dri", NULL); - if (!drm_debugfs_root) { + if (!drm_debugfs_root) DRM_ERROR("Cannot create /sys/kernel/debug/dri\n"); - ret = -1; - goto err_p3; - } DRM_INFO("Initialized %s %d.%d.%d %s\n", CORE_NAME, CORE_MAJOR, CORE_MINOR, CORE_PATCHLEVEL, CORE_DATE); return 0; -err_p3: - drm_sysfs_destroy(); + err_p2: unregister_chrdev(DRM_MAJOR, "drm"); @@ -925,7 +921,8 @@ err_p1: static void __exit drm_core_exit(void) { - debugfs_remove(drm_debugfs_root); + if (drm_debugfs_root) + debugfs_remove(drm_debugfs_root); drm_sysfs_destroy(); unregister_chrdev(DRM_MAJOR, "drm");