Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp17413558rwd; Tue, 27 Jun 2023 02:39:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7dGDyBXw11D4V2GTsYvmxsWyuCQhZNnTikWM2i6HPm7OK4rPhueK6lnfNtFcHku3c9YEPF X-Received: by 2002:a17:902:ea06:b0:1b8:50d:9dd9 with SMTP id s6-20020a170902ea0600b001b8050d9dd9mr4991025plg.51.1687858753493; Tue, 27 Jun 2023 02:39:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687858753; cv=none; d=google.com; s=arc-20160816; b=pYqGCdGwNY4zGh4xLHY8pjP3BuNsHwo9ci9w61v5EF3RxlJsqgmHApV1jD6Nnd+eXe 9Z6uOhw8XwGA/9K1uZotFMWlml1rpNKGDFHIDZt1mLWRIJNq5/atTG8anEK2aLZDe6OA 7IwqPSxovLHEnI6HtmFEsa8fgJc5pMXzRMZmr2yrK0ZqB2ZmgmbyYDN/Of6GpDJiySvx sM4Wh5hwqPTj6XVlunXCDOLnPhsu2sCvZM72Q786b5HUV0fr8f981a+cW786FpkJnMSa KsHRt25uopv8AnQMDvtBdfI224KeYAuJmkrl01UODzgBIZ19BKUznM16xF38JNPEVM2F D09A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id; bh=7f4tgkVkU+VHH49YVG711zElQ8CezCVNDyWN5k3d8Vo=; fh=0DcFHgALHti3Fg832LcW+1CrO74w04uVrWlgx9zk0kk=; b=X3U9fkWzf+1DnU76lM0ToP+HwlrzNE6vTRrpH0UjIfDxmiCMya+CPMt5h4mWcmYOFW w9JsC1eYsY6O/LhqB/QyeOyzuMJYDOI8BjiOw4Qmbrbnp2WMTXj0RjAX5cE5NDCCdAu8 sWp+orWJOng6g6860jlJOaL3qNCNOOsfEh4EOC/RV1W2fabA/WKzMeLEt1J6+zZiNKvr AgcvHEaKK19LWZAKG6J9TuTUPM5+GNXNUAlzmywesL7YxVX+ffN6DeMh352VguYGSQ13 WgL1W6juo3PJyPyVFOsMd3TKVECxgsgPgv5q01NHciEFasLUuvs7mL5QKRlNbSrIWA4f TzTw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k7-20020a170902c40700b001b04c92cb42si7249729plk.357.2023.06.27.02.39.00; Tue, 27 Jun 2023 02:39:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231570AbjF0JFO (ORCPT + 99 others); Tue, 27 Jun 2023 05:05:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231182AbjF0JEs (ORCPT ); Tue, 27 Jun 2023 05:04:48 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D00A310DA for ; Tue, 27 Jun 2023 02:04:45 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.43]) by gateway (Coremail) with SMTP id _____8AxxvArpppk4PcCAA--.4621S3; Tue, 27 Jun 2023 17:04:43 +0800 (CST) Received: from [10.20.42.43] (unknown [10.20.42.43]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxWM0qpppkUbkLAA--.48575S3; Tue, 27 Jun 2023 17:04:42 +0800 (CST) Message-ID: <5aee218e-2e46-b929-f905-a28794caac8c@loongson.cn> Date: Tue, 27 Jun 2023 17:04:42 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH] drm: Remove the deprecated drm_put_dev() function Content-Language: en-US To: Jani Nikula , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Alex Deucher , Christian Koenig , Pan Xinhui Cc: amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org References: <20230625050901.393055-1-suijingfeng@loongson.cn> <87jzvqy897.fsf@intel.com> From: Sui Jingfeng Organization: Loongson In-Reply-To: <87jzvqy897.fsf@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8CxWM0qpppkUbkLAA--.48575S3 X-CM-SenderInfo: xvxlyxpqjiv03j6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBj93XoWxAFW7Gr1rAw47Xr13KFW8KrX_yoWrWFy7pF 43Aa4FkrW8tFZ8KrW7ZFnrCFy3Xa17Ka4xury7Gw13Ww1qvry7tF98JFy8GryUXrWkCF1S vF98XFyUuFy8CrcCm3ZEXasCq-sJn29KB7ZKAUJUUUUx529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUPab4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2kKe7AKxVWUAVWUtwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07 AIYIkI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWU tVWrXwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI4 8JMxk0xIA0c2IEe2xFo4CEbIxvr21lc7CjxVAaw2AFwI0_Jw0_GFyl42xK82IYc2Ij64vI r41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l4IxYO2xFxVAFwI0_Jw0_GFylx2IqxVAqx4xG67 AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIY rxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Gr0_Xr1lIxAIcVC0I7IYx2IY6xkF7I0E14 v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWx JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxU4YLvDU UUU X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 2023/6/26 15:48, Jani Nikula wrote: > On Sun, 25 Jun 2023, Sui Jingfeng wrote: >> As this function can be replaced with drm_dev_unregister() + drm_dev_put(), >> it is already marked as deprecated, so remove it. No functional change. >> >> Signed-off-by: Sui Jingfeng >> --- >> drivers/gpu/drm/drm_drv.c | 28 ---------------------------- >> drivers/gpu/drm/drm_pci.c | 3 ++- >> drivers/gpu/drm/radeon/radeon_drv.c | 3 ++- >> include/drm/drm_drv.h | 1 - >> 4 files changed, 4 insertions(+), 31 deletions(-) >> >> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c >> index 12687dd9e1ac..5057307fe22a 100644 >> --- a/drivers/gpu/drm/drm_drv.c >> +++ b/drivers/gpu/drm/drm_drv.c >> @@ -406,34 +406,6 @@ void drm_minor_release(struct drm_minor *minor) >> * possibly leaving the hardware enabled. >> */ >> >> -/** >> - * drm_put_dev - Unregister and release a DRM device >> - * @dev: DRM device >> - * >> - * Called at module unload time or when a PCI device is unplugged. >> - * >> - * Cleans up all DRM device, calling drm_lastclose(). >> - * >> - * Note: Use of this function is deprecated. It will eventually go away >> - * completely. Please use drm_dev_unregister() and drm_dev_put() explicitly >> - * instead to make sure that the device isn't userspace accessible any more >> - * while teardown is in progress, ensuring that userspace can't access an >> - * inconsistent state. > The last sentence is the crucial one. While the patch has no functional > changes, But my patch help to save a useless check(if (!dev)) on where we found the check is not necessary. ``` - if (!dev) { - DRM_ERROR("cleanup called no dev\n"); - return; - } ``` > I believe the goal never was to just mechanically replace one > call with the two. The DRM core lose nothing, just a function wrapper. Instead, this is probably a good chance to migrate the burden to the driver side. I think the device driver(drm/radeon, for example) have better understanding about how to ensure that userspace can't access an inconsistent state than the DRM core. > > BR, > Jani. > > >> - */ >> -void drm_put_dev(struct drm_device *dev) >> -{ >> - DRM_DEBUG("\n"); >> - >> - if (!dev) { >> - DRM_ERROR("cleanup called no dev\n"); >> - return; >> - } >> - >> - drm_dev_unregister(dev); >> - drm_dev_put(dev); >> -} >> -EXPORT_SYMBOL(drm_put_dev); >> - >> /** >> * drm_dev_enter - Enter device critical section >> * @dev: DRM device >> diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c >> index 39d35fc3a43b..b3a68a92eaa6 100644 >> --- a/drivers/gpu/drm/drm_pci.c >> +++ b/drivers/gpu/drm/drm_pci.c >> @@ -257,7 +257,8 @@ void drm_legacy_pci_exit(const struct drm_driver *driver, >> legacy_dev_list) { >> if (dev->driver == driver) { >> list_del(&dev->legacy_dev_list); >> - drm_put_dev(dev); >> + drm_dev_unregister(dev); >> + drm_dev_put(dev); >> } >> } >> mutex_unlock(&legacy_dev_list_lock); >> diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c >> index e4374814f0ef..a4955ae10659 100644 >> --- a/drivers/gpu/drm/radeon/radeon_drv.c >> +++ b/drivers/gpu/drm/radeon/radeon_drv.c >> @@ -357,7 +357,8 @@ radeon_pci_remove(struct pci_dev *pdev) >> { >> struct drm_device *dev = pci_get_drvdata(pdev); >> >> - drm_put_dev(dev); >> + drm_dev_unregister(dev); >> + drm_dev_put(dev); >> } >> >> static void >> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h >> index 89e2706cac56..289c97b12e82 100644 >> --- a/include/drm/drm_drv.h >> +++ b/include/drm/drm_drv.h >> @@ -511,7 +511,6 @@ void drm_dev_unregister(struct drm_device *dev); >> >> void drm_dev_get(struct drm_device *dev); >> void drm_dev_put(struct drm_device *dev); >> -void drm_put_dev(struct drm_device *dev); >> bool drm_dev_enter(struct drm_device *dev, int *idx); >> void drm_dev_exit(int idx); >> void drm_dev_unplug(struct drm_device *dev); -- Jingfeng