From patchwork Mon May 8 08:26:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 9715891 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 8F03660364 for ; Mon, 8 May 2017 08:26:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D30F27031 for ; Mon, 8 May 2017 08:26:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 71DCA27F10; Mon, 8 May 2017 08:26:52 +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 0F50F27031 for ; Mon, 8 May 2017 08:26:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0DA166E17D; Mon, 8 May 2017 08:26:49 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7681A6E17A for ; Mon, 8 May 2017 08:26:46 +0000 (UTC) Received: by mail-wr0-x244.google.com with SMTP id w50so7305422wrc.0 for ; Mon, 08 May 2017 01:26:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6rhhWkyhVvMnvr4dZXuFQ8XnshGoMKQ3i/n+Ku5/5wY=; b=S/H+fNc3XT+6meUK4tVk6LXg0IKCpY47inGFgyDrrDprU3Ncdkd2w8wooQRljTfb1f 8hsaLjSl6PVRZb2KbOzVA6LeubD8MGRk5LdIAZCxJWEoo+98kB/dyCA8Xmlyohr2OPPL WIAeP6NpYdd01UPSXvjvMEAds5N9BR8XKDEqI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6rhhWkyhVvMnvr4dZXuFQ8XnshGoMKQ3i/n+Ku5/5wY=; b=qgwG23/Dz/eCUKcG3jfaDK2dpFIibda8hcBxlruo883Bl9yFDaPGKtGDw6VaawgbVv 4tYF05b4kHSAqKa3kYTlnzFNvarMvzr0KF8cD7TcbFTSXJZQAbYii8bFi6vBGgPjnenX rCqjDh1XK4U+cPoXCHBInXHSBmkIchj3L7O+RTi4zUSfpbQoqn7OtOLy6N0ORBBFaIeG y6BGkm6fLKXvOvqlKYvUfiZBkpzd5mAOE/bPuQOCtVhI4rvgxoOBBYxYFSrPiAtbXBzG 08R9jY0Zzz7bJC0iWdpb4PxB/8K2k79BYwevf2RGXGo1XmrHU7sFoZc+LUoueU0Itmvv 655w== X-Gm-Message-State: AN3rC/4jXxrNI942LLFwWuRBogUz4u7e4H2F8sGLdMOklJIcQnVaLEH9 z6KCXXzgbW3JjoKC X-Received: by 10.223.183.16 with SMTP id l16mr44317399wre.42.1494232004703; Mon, 08 May 2017 01:26:44 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:5640:0:960b:2678:e223:c1c6]) by smtp.gmail.com with ESMTPSA id m185sm8650273wma.7.2017.05.08.01.26.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 May 2017 01:26:43 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH RESEND 4/4] drm: Nerf the preclose callback for modern drivers Date: Mon, 8 May 2017 10:26:33 +0200 Message-Id: <20170508082633.4214-4-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170508082633.4214-1-daniel.vetter@ffwll.ch> References: <20170508082633.4214-1-daniel.vetter@ffwll.ch> Cc: Daniel Vetter , Daniel Vetter 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 With all drivers converted there's only legacy dri1 drivers using it. Not going to touch those, instead just hide it like we've done with other dri1 driver hooks like firstopen. In all this I didn't find any real reason why we'd needed 2 hooks, and having symmetry between open and close just appeases my OCD better. Yeah, someone else could do an s/postclose/close/, but that's for someone who understands cocci. And maybe after this series is reviewed and landed, to avoid patch-regen churn. v2: s/last/post/close in the kernel-doc (Sean). Reviewed-by: Sean Paul Reviewed-by: Liviu Dudau Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_file.c | 8 ++++---- include/drm/drm_drv.h | 23 ++--------------------- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index 3783b659cd38..caad93dab54b 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -351,9 +351,8 @@ void drm_lastclose(struct drm_device * dev) * * This function must be used by drivers as their &file_operations.release * method. It frees any resources associated with the open file, and calls the - * &drm_driver.preclose and &drm_driver.lastclose driver callbacks. If this is - * the last open file for the DRM device also proceeds to call the - * &drm_driver.lastclose driver callback. + * &drm_driver.postclose driver callback. If this is the last open file for the + * DRM device also proceeds to call the &drm_driver.lastclose driver callback. * * RETURNS: * @@ -373,7 +372,8 @@ int drm_release(struct inode *inode, struct file *filp) list_del(&file_priv->lhead); mutex_unlock(&dev->filelist_mutex); - if (dev->driver->preclose) + if (drm_core_check_feature(dev, DRIVER_LEGACY) && + dev->driver->preclose) dev->driver->preclose(dev, file_priv); /* ======================================================== diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h index 53b98321df9b..d0b5f363bfa1 100644 --- a/include/drm/drm_drv.h +++ b/include/drm/drm_drv.h @@ -104,23 +104,6 @@ struct drm_driver { int (*open) (struct drm_device *, struct drm_file *); /** - * @preclose: - * - * One of the driver callbacks when a new &struct drm_file is closed. - * Useful for tearing down driver-private data structures allocated in - * @open like buffer allocators, execution contexts or similar things. - * - * Since the display/modeset side of DRM can only be owned by exactly - * one &struct drm_file (see &drm_file.is_master and &drm_device.master) - * there should never be a need to tear down any modeset related - * resources in this callback. Doing so would be a driver design bug. - * - * FIXME: It is not really clear why there's both @preclose and - * @postclose. Without a really good reason, use @postclose only. - */ - void (*preclose) (struct drm_device *, struct drm_file *file_priv); - - /** * @postclose: * * One of the driver callbacks when a new &struct drm_file is closed. @@ -131,9 +114,6 @@ struct drm_driver { * one &struct drm_file (see &drm_file.is_master and &drm_device.master) * there should never be a need to tear down any modeset related * resources in this callback. Doing so would be a driver design bug. - * - * FIXME: It is not really clear why there's both @preclose and - * @postclose. Without a really good reason, use @postclose only. */ void (*postclose) (struct drm_device *, struct drm_file *); @@ -150,7 +130,7 @@ struct drm_driver { * state changes, e.g. in conjunction with the :ref:`vga_switcheroo` * infrastructure. * - * This is called after @preclose and @postclose have been called. + * This is called after @postclose hook has been called. * * NOTE: * @@ -516,6 +496,7 @@ struct drm_driver { /* List of devices hanging off this driver with stealth attach. */ struct list_head legacy_dev_list; int (*firstopen) (struct drm_device *); + void (*preclose) (struct drm_device *, struct drm_file *file_priv); int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv); int (*dma_quiescent) (struct drm_device *); int (*context_dtor) (struct drm_device *dev, int context);