Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2661497pxb; Tue, 9 Mar 2021 07:57:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHMmP169zSY55e1C6Tora77bVs9yDFFbW3dTAc4CUz5HTFpSvDnTYX517dbfZ9Tmg4L4Fs X-Received: by 2002:a17:906:7754:: with SMTP id o20mr21377024ejn.209.1615305460670; Tue, 09 Mar 2021 07:57:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615305460; cv=none; d=google.com; s=arc-20160816; b=KF6/SMkjKTUNlSpAncdp/iy2tcyCmg+9xLAHxeJw9Ylb4biYeo/H4OcC1Q1WYsPdQZ nvx/N7tLpksjtHfindbAUpwEkh9uO4pKveXwHvRnp7dHAU9Ik9Ro68CBwayeRD5QOEoG opHT0uu/xreZLo82/bbVKHK7umFN2oeGCFPyF53QXNcm4k5gH110Mbpo+mKpPLAt/laT G1QWCVPP/Dkd5hPWGUSZIQ1vwADuXUuhxyaq3SWBDSevWRx8r8kSm94LOfGqUePIRmj9 Of3tBKDdNEb5zbe4YJB2DrlTbJ8HG3Jwh4M5M/f0xxY898lS3iVt42WkyO3SLRnauaBE AHQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=B2QcStvhg9D54BxwbuG4jJNpXPybnK2FqQydroBhB+g=; b=CAK5waVEvhPaQc1CX2jMaPYL5bbtHKKgw7zvSYb95D+2WAov64CxsyQKho6y2T2Jeq Wnz6XYurpUcC0OYzTh9J91KvicdK/Uwqt5C8FbrQ5jJ6tmooLoRj1hjKm8aFuNwE5s+P sq/1D2m/7n+d+Ti99AbjY3FXUVx7b7A9VLUP4xdZvjrFGI+dyXPdop73tiVoBw1LOsD6 klGc+Mi6FeW9c7HMZVhWbvkjSn4MsoRkW4oUTOpbxdlozrrXfzS9QsKsb1a1PmDoeqE1 NTwdXGFvBGhjAfAw4zuSn9t1xl1I3TcbOhW/xpEsDwi6snARSN8q9TqcG5gztMSb+7Rb ozKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=oEJ8ugE1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x9si9907350eje.662.2021.03.09.07.57.18; Tue, 09 Mar 2021 07:57:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=oEJ8ugE1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231955AbhCIPzs (ORCPT + 99 others); Tue, 9 Mar 2021 10:55:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231950AbhCIPzb (ORCPT ); Tue, 9 Mar 2021 10:55:31 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0425C06174A; Tue, 9 Mar 2021 07:55:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=B2QcStvhg9D54BxwbuG4jJNpXPybnK2FqQydroBhB+g=; b=oEJ8ugE1x4j/2X9l3CQfTDXGMS Q/n8jpu9Ywp7imVSmXif75d7xXHeM2tpMwxW924TC0hKzyzBN3JCiriBDAgPrtO08TnExSGXkYom5 7IbMPTnUuWT0+4FIiqi7z5LJmACctZ8ew34Oddm3TWS2SIrzIvkQ2W0M5x3gWrrLvJ6qGpXUZGoOZ DlpO6fH34pmRLyy8a4XCFgrzNs5TMW9rbySvmlrus7F/24wWk6Mj2OPm6RbyqI73AJJjBOpDqNtte j+piA+rYwRzXkiyu0lStNu6yIiQ3gMwi00aj7zbkeQUeYd19n7y+DMkqw+8Akrri9KEMJ3DD2bIJZ /NW9ZR2g==; Received: from [2001:4bb8:180:9884:c70:4a89:bc61:3] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lJegw-000lNb-Ow; Tue, 09 Mar 2021 15:54:41 +0000 From: Christoph Hellwig To: Al Viro Cc: Andrew Morton , Daniel Vetter , Nadav Amit , "VMware, Inc." , "Michael S. Tsirkin" , David Hildenbrand , Minchan Kim , Nitin Gupta , Jason Gunthorpe , Alex Williamson , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 4/9] drm: remove the drm file system Date: Tue, 9 Mar 2021 16:53:43 +0100 Message-Id: <20210309155348.974875-5-hch@lst.de> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210309155348.974875-1-hch@lst.de> References: <20210309155348.974875-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Just use the generic anon_inode file system. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/drm_drv.c | 64 ++------------------------------------- 1 file changed, 3 insertions(+), 61 deletions(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 87e7214a8e3565..af293d76f979e5 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -26,6 +26,7 @@ * DEALINGS IN THE SOFTWARE. */ +#include #include #include #include @@ -475,65 +476,6 @@ void drm_dev_unplug(struct drm_device *dev) } EXPORT_SYMBOL(drm_dev_unplug); -/* - * DRM internal mount - * We want to be able to allocate our own "struct address_space" to control - * memory-mappings in VRAM (or stolen RAM, ...). However, core MM does not allow - * stand-alone address_space objects, so we need an underlying inode. As there - * is no way to allocate an independent inode easily, we need a fake internal - * VFS mount-point. - * - * The drm_fs_inode_new() function allocates a new inode, drm_fs_inode_free() - * frees it again. You are allowed to use iget() and iput() to get references to - * the inode. But each drm_fs_inode_new() call must be paired with exactly one - * drm_fs_inode_free() call (which does not have to be the last iput()). - * We use drm_fs_inode_*() to manage our internal VFS mount-point and share it - * between multiple inode-users. You could, technically, call - * iget() + drm_fs_inode_free() directly after alloc and sometime later do an - * iput(), but this way you'd end up with a new vfsmount for each inode. - */ - -static int drm_fs_cnt; -static struct vfsmount *drm_fs_mnt; - -static int drm_fs_init_fs_context(struct fs_context *fc) -{ - return init_pseudo(fc, 0x010203ff) ? 0 : -ENOMEM; -} - -static struct file_system_type drm_fs_type = { - .name = "drm", - .owner = THIS_MODULE, - .init_fs_context = drm_fs_init_fs_context, - .kill_sb = kill_anon_super, -}; - -static struct inode *drm_fs_inode_new(void) -{ - struct inode *inode; - int r; - - r = simple_pin_fs(&drm_fs_type, &drm_fs_mnt, &drm_fs_cnt); - if (r < 0) { - DRM_ERROR("Cannot mount pseudo fs: %d\n", r); - return ERR_PTR(r); - } - - inode = alloc_anon_inode_sb(drm_fs_mnt->mnt_sb); - if (IS_ERR(inode)) - simple_release_fs(&drm_fs_mnt, &drm_fs_cnt); - - return inode; -} - -static void drm_fs_inode_free(struct inode *inode) -{ - if (inode) { - iput(inode); - simple_release_fs(&drm_fs_mnt, &drm_fs_cnt); - } -} - /** * DOC: component helper usage recommendations * @@ -563,7 +505,7 @@ static void drm_dev_init_release(struct drm_device *dev, void *res) { drm_legacy_ctxbitmap_cleanup(dev); drm_legacy_remove_map_hash(dev); - drm_fs_inode_free(dev->anon_inode); + iput(dev->anon_inode); put_device(dev->dev); /* Prevent use-after-free in drm_managed_release when debugging is @@ -616,7 +558,7 @@ static int drm_dev_init(struct drm_device *dev, if (ret) return ret; - dev->anon_inode = drm_fs_inode_new(); + dev->anon_inode = alloc_anon_inode(); if (IS_ERR(dev->anon_inode)) { ret = PTR_ERR(dev->anon_inode); DRM_ERROR("Cannot allocate anonymous inode: %d\n", ret); -- 2.30.1