From patchwork Thu Jun 1 13:00:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9759569 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 2744B602BF for ; Thu, 1 Jun 2017 13:00:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 176A228423 for ; Thu, 1 Jun 2017 13:00:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A231284BF; Thu, 1 Jun 2017 13:00:49 +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 838A728423 for ; Thu, 1 Jun 2017 13:00:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 09E896E354; Thu, 1 Jun 2017 13:00:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3F30D6E354 for ; Thu, 1 Jun 2017 13:00:43 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 7069236-1500050 for multiple; Thu, 01 Jun 2017 14:00:30 +0100 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Thu, 01 Jun 2017 14:00:29 +0100 From: Chris Wilson To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm: Add deprecation warnings to the old midlayer callbacks Date: Thu, 1 Jun 2017 14:00:26 +0100 Message-Id: <20170601130026.15964-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 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-Virus-Scanned: ClamAV using ClamSMTP Daniel started a crusade a few years back to move control over the initialisation and teardown into the driver rather than drm core, for greater control and far fewer surprises. Help in that fight by adding compiler warnings to the stale functions. Signed-off-by: Chris Wilson --- This is not as useful as I hoped. I wanted for gcc to emit a compile-time warning when a deprecated field was assigned, however it only emits when it is used. So we end up with a lot of noise in drm_core and none in the drivers. However, the runtime warning is probably useful and a motivator for change? Should be made WARN_ONCE though --- drivers/gpu/drm/Kconfig | 11 +++++++++++ drivers/gpu/drm/drm_drv.c | 4 ++-- drivers/gpu/drm/drm_gem.c | 2 +- include/drm/drm_deprecated.h | 35 +++++++++++++++++++++++++++++++++++ include/drm/drm_drv.h | 4 ++++ 5 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 include/drm/drm_deprecated.h diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 83cb2a88c204..530d56a2fa01 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -34,6 +34,17 @@ config DRM_DP_AUX_CHARDEV read and write values to arbitrary DPCD registers on the DP aux channel. +config DRM_DEBUG_DEPRECATED + bool "Insert extra warnings if deprecated code is used" + default n + depends on DRM + help + Enables extra warnings if deprecated code and callbacks are used. + + Recommended for driver developers only. + + If in doubt, say "N". + config DRM_DEBUG_MM bool "Insert extra checks and debug info into the DRM range managers" default n diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index b5c6bb46a425..63f968ec1f05 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -778,7 +778,7 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags) dev->registered = true; - if (dev->driver->load) { + if (DRM_DEPRECATED_WARN(dev->driver->load)) { ret = dev->driver->load(dev, flags); if (ret) goto err_minors; @@ -830,7 +830,7 @@ void drm_dev_unregister(struct drm_device *dev) if (drm_core_check_feature(dev, DRIVER_MODESET)) drm_modeset_unregister_all(dev); - if (dev->driver->unload) + if (DRM_DEPRECATED_WARN(dev->driver->unload)) dev->driver->unload(dev); if (dev->agp) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 8dc11064253d..c0998a9b1ba0 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -800,7 +800,7 @@ drm_gem_object_free(struct kref *kref) if (dev->driver->gem_free_object_unlocked) { dev->driver->gem_free_object_unlocked(obj); - } else if (dev->driver->gem_free_object) { + } else if (DRM_DEPRECATED_WARN(dev->driver->gem_free_object)) { WARN_ON(!mutex_is_locked(&dev->struct_mutex)); dev->driver->gem_free_object(obj); diff --git a/include/drm/drm_deprecated.h b/include/drm/drm_deprecated.h new file mode 100644 index 000000000000..e0debe496f28 --- /dev/null +++ b/include/drm/drm_deprecated.h @@ -0,0 +1,35 @@ +/* + * Copyright 2017 Intel Corp. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _DRM_DEPRECATED_H_ +#define _DRM_DEPRECATED_H_ + +#ifdef CONFIG_DRM_DEBUG_DEPRECATED +#define drm_deprecated __deprecated +#define DRM_DEPRECATED_WARN(cond) WARN(cond, "Use of %s is deprecated\n", #cond) +#else +#define drm_deprecated +#define DRM_DEPRECATED_WARN(cond) (cond) +#endif + +#endif diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h index 18f3181674e8..a2cb895cdfe3 100644 --- a/include/drm/drm_drv.h +++ b/include/drm/drm_drv.h @@ -29,6 +29,7 @@ #include #include +#include struct drm_device; struct drm_file; @@ -81,6 +82,7 @@ struct drm_driver { * * Zero on success, non-zero value on failure. */ + drm_deprecated int (*load) (struct drm_device *, unsigned long flags); /** @@ -160,6 +162,7 @@ struct drm_driver { * the device. * */ + drm_deprecated void (*unload) (struct drm_device *); /** @@ -399,6 +402,7 @@ struct drm_driver { * This is deprecated and should not be used by new drivers. Use * @gem_free_object_unlocked instead. */ + drm_deprecated void (*gem_free_object) (struct drm_gem_object *obj); /**