Message ID | 20230625050901.393055-1-suijingfeng@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6745710vqr; Sat, 24 Jun 2023 22:30:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7z+U3Ghi6ar+4xgXZuQN+AvAy+ugLTQAk39b4WgNICL6jkpTzBb66NQ8DlydjzyU/e0ccI X-Received: by 2002:a05:6830:1d8b:b0:6b7:1cdb:84c8 with SMTP id y11-20020a0568301d8b00b006b71cdb84c8mr9117435oti.24.1687671042410; Sat, 24 Jun 2023 22:30:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687671042; cv=none; d=google.com; s=arc-20160816; b=yB9uP7E+S+/VHCCo5lZ1NLKphsNM7A/wCF10a7OMw8PL//HaaUfImYr1GYe6ZWSAIw fuWjhNwuftA8UzYOUCFNxa+oU43+xYkT57z17t+oa0RQbWNbWIheQIBMGWu4wdXIytG9 0q/rz4CDmCSMfZD+XZva6/yBgKFNSFruUlGFOVYjzn54tJNYv6ylAWy7e0vE1j7T9HPP F42Mgk1JGj/0zDwkOQGeIi8emIJDcpXmthU1rlDndqal+Z5Q9T8UpOBcae70mVmAvBUx /9a5L57MV5h/1j8mkh2xqUp3XROBn/9dq/unoRH94YBMncBQlBS4Zfjgt85D+NF6SrE3 ZjFg== 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 :message-id:date:subject:cc:to:from; bh=5ZxhGTsuNmOUVcA+M5HwROZTYvMujixSpg6pE1OUOCE=; fh=+MdEEJw+I4lQ16cDrrbHjWFpd/9RHvnjyrlBz6damVk=; b=XksOktP4BgQu5gSILb/Vgp/0s93U5Gr8Ge1UgNDoqAaUhgkOInxR5biTy8uudCN/us ufOxISgA03RjSgIv9RPG9DV0pMClYv/xgWv6HQ7EWu6xc19naVUfmwZ1RZLrvtp/JYCq r/XIst3FH1xALHc7Rz7dw2NBe9GLJBarkEgMf+2HDHmxPR+KdQUSaHpdbVkKW41GnipP EEyo5wxyCrbV4czXaE+IKQnkxSFzKJk113rk3XL2wXjrgNz3MStIlSdESloAnTL0FzfB ka42odZmpJ0zDzw2MV80Ll3fXaRAYcuS4RbXen4ElbRhMAyku7o5nEBv0aQASJhlJNoN EAcw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u62-20020a638541000000b0054ff0049d08si2607834pgd.404.2023.06.24.22.30.30; Sat, 24 Jun 2023 22:30:42 -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 S231480AbjFYFJL (ORCPT <rfc822;duw91626@gmail.com> + 99 others); Sun, 25 Jun 2023 01:09:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230045AbjFYFJG (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 25 Jun 2023 01:09:06 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 45C3C1B8 for <linux-kernel@vger.kernel.org>; Sat, 24 Jun 2023 22:09:03 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.43]) by gateway (Coremail) with SMTP id _____8Dxvsfty5dk7W8BAA--.2200S3; Sun, 25 Jun 2023 13:09:01 +0800 (CST) Received: from openarena.loongson.cn (unknown [10.20.42.43]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bxxszty5dk80sGAA--.8429S2; Sun, 25 Jun 2023 13:09:01 +0800 (CST) From: Sui Jingfeng <suijingfeng@loongson.cn> To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Maxime Ripard <mripard@kernel.org>, Thomas Zimmermann <tzimmermann@suse.de>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, Alex Deucher <alexander.deucher@amd.com>, Christian Koenig <christian.koenig@amd.com>, Pan Xinhui <Xinhui.Pan@amd.com> Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org Subject: [PATCH] drm: Remove the deprecated drm_put_dev() function Date: Sun, 25 Jun 2023 13:09:01 +0800 Message-Id: <20230625050901.393055-1-suijingfeng@loongson.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8Bxxszty5dk80sGAA--.8429S2 X-CM-SenderInfo: xvxlyxpqjiv03j6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBj93XoWxZryfCw1xGrWDGF17uF4rZwc_yoW5CF1rpF 43JasakrW8tFZ8K3yUAFnrCFy5Ja17GayI9ryUG3sxWr4qvry7AF98JFyUJ345XrWkCF1a v3ZxXFyUZFy0krcCm3ZEXasCq-sJn29KB7ZKAUJUUUUx529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUBIb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2kKe7AKxVWUAVWUtwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07 AIYIkI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWU AVWUtwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7V AKI48JMxkF7I0En4kS14v26r126r1DMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY 6r1j6r4UMxCIbckI1I0E14v26r126r1DMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7 xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xII jxv20xvE14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw2 0EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x02 67AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU8uc_3UUUUU== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769651351040465583?= X-GMAIL-MSGID: =?utf-8?q?1769651351040465583?= |
Series |
drm: Remove the deprecated drm_put_dev() function
|
|
Commit Message
Sui Jingfeng
June 25, 2023, 5:09 a.m. UTC
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 <suijingfeng@loongson.cn>
---
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(-)
Comments
On Sun, 25 Jun 2023, Sui Jingfeng <suijingfeng@loongson.cn> 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 <suijingfeng@loongson.cn> > --- > 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, I believe the goal never was to just mechanically replace one call with the two. 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);
Hi Am 25.06.23 um 07:09 schrieb Sui Jingfeng: > 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 <suijingfeng@loongson.cn> > --- > 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. > - */ > -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); Did you verify that dev cannot be NULL here? There was a check in drm_put_dev() for !dev. Best regards Thomas > + 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); -- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)
Hi, On 2023/6/26 15:56, Thomas Zimmermann wrote: > Hi > > Am 25.06.23 um 07:09 schrieb Sui Jingfeng: >> 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 <suijingfeng@loongson.cn> >> --- >> 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. >> - */ >> -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); > > Did you verify that dev cannot be NULL here? There was a check in > drm_put_dev() for !dev. > I have verified : 1) If there is no radeon card(say R5-340) mounted in the system, I modprobe the radeon.ko manually. then both the radeon_pci_probe() and the radeon_pci_remove() function won't get called. There is no chance that the driver_probe_device() function getting called. |- driver_register() |-- bus_add_driver() |--- driver_attach() |---- bus_for_each_dev(drv->bus, NULL, drv, __driver_attach) |----- __driver_attach() |------ __device_attach_driver() // There is no chance that the driver_probe_device() function get called. |------- driver_probe_device(drv, dev) ``` 2) normal case: If there are radeon cards mounted in the system, then as long as the pci_set_drvdata(pdev, dev) get called, the 'driver_data' member of struct device will hold the pointer to the 'struct drm_device'; So, it will be fine as long as the radeon.ko get loaded normally. I'm sure it will works as expected on normal case, with 100% confident. 3) Abnormal case If there is a error happen before the 'pci_set_drvdata(pdev, dev)' function get called. It is also don't need to worry, if the ->probe() failed, then the ->remove will be get called. I have verified that if the ->probe() failed, then the ->remove will be get called. I'm doing the test by add a line before the drm_dev_alloc() function in the body of radeon_pci_probe() function. See below: ``` return -ENODEV; dev = drm_dev_alloc(&kms_driver, &pdev->dev); if (IS_ERR(dev)) return PTR_ERR(dev); ret = pci_enable_device(pdev); if (ret) goto err_free; ``` So, there is no problem, as far as I can see. > Best regards > Thomas > >> + 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); >
Hi, On 2023/6/26 15:48, Jani Nikula wrote: > On Sun, 25 Jun 2023, Sui Jingfeng <suijingfeng@loongson.cn> 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 <suijingfeng@loongson.cn> >> --- >> 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);
On Tue, 27 Jun 2023, Sui Jingfeng <suijingfeng@loongson.cn> wrote: > Hi, > > On 2023/6/26 15:48, Jani Nikula wrote: >> On Sun, 25 Jun 2023, Sui Jingfeng <suijingfeng@loongson.cn> 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 <suijingfeng@loongson.cn> >>> --- >>> 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. The point is to *fix* this stuff while doing the conversion. Anyone can replace one function call with two, but that's just brushing the problem under the carpet. The current state is that we have a function the use of which is potentially problematic, it's documented, and we can trivially locate all the call sites. After your change, we've lost that information, and we haven't fixed anything. BR, Jani. > > 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);
Hi On 2023/6/27 17:33, Jani Nikula wrote: > On Tue, 27 Jun 2023, Sui Jingfeng <suijingfeng@loongson.cn> wrote: >> Hi, >> >> On 2023/6/26 15:48, Jani Nikula wrote: >>> On Sun, 25 Jun 2023, Sui Jingfeng <suijingfeng@loongson.cn> 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 <suijingfeng@loongson.cn> >>>> --- >>>> 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. > The point is to *fix* this stuff while doing the conversion. Anyone can > replace one function call with two, but that's just brushing the problem > under the carpet. Well, drm/i915 don't call this function either. Only the drm/radeon call this function. > The current state is that we have a function the use of which is > potentially problematic, it's documented, and we can trivially locate > all the call sites. But I do agree with you that the comments of this function are sort of good quality document. > After your change, we've lost that information, and we haven't fixed > anything. But back to the technique question, is it true that the drm_dev_unregister() function alone can't guarantee the device isn't userspace accessible any more ? > > BR, > Jani. > > >> 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);
On 2023/6/27 16:41, Sui Jingfeng wrote: > > if the ->probe() failed, then the ->remove will be get called. if the ->probe() failed, then the ->remove() will *NOT* get called.
Hi, On 2023/6/27 17:33, Jani Nikula wrote: > On Tue, 27 Jun 2023, Sui Jingfeng <suijingfeng@loongson.cn> wrote: >> Hi, >> >> On 2023/6/26 15:48, Jani Nikula wrote: >>> On Sun, 25 Jun 2023, Sui Jingfeng <suijingfeng@loongson.cn> 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 <suijingfeng@loongson.cn> >>>> --- >>>> 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. > The point is to *fix* this stuff while doing the conversion. Anyone can > replace one function call with two, but that's just brushing the problem > under the carpet. Interesting! To be honest, I love you reviews. I think, I probably be able to solve more practical problem, This patch is just a trivial, I don't care much. Can you help to have a look at my vgaarb patch set [1] [1] https://patchwork.freedesktop.org/series/119250/ Really need you guidance there. > The current state is that we have a function the use of which is > potentially problematic, it's documented, and we can trivially locate > all the call sites. I can merge the document to comments of the drm_dev_unregister() function, remove the drm_put_dev function only. What do you think about this? > After your change, we've lost that information, and we haven't fixed > anything. > My understanding is that drm_dev_unregister() alone is enough to stop the user-space program accessing the kernel interface exposed. ``` radeon_pci_remove(struct pci_dev *pdev) { // should be called first in the pci remove funcition drm_dev_unregister(dev); // do the various(necessary) cleanup and free resource allocated // call this function at the bottom of the radeon_pci_remove() function drm_dev_put(dev); } ``` And the drm_dev_unregister() function already told us, see below: ``` /** * drm_dev_unregister - Unregister DRM device * @dev: Device to unregister * * Unregister the DRM device from the system. This does the reverse of * drm_dev_register() but does not deallocate the device. The caller must call * drm_dev_put() to drop their final reference, unless it is managed with devres * (as devices allocated with devm_drm_dev_alloc() are), in which case there is * already an unwind action registered. * * A special form of unregistering for hotpluggable devices is drm_dev_unplug(), * which can be called while there are still open users of @dev. * * This should be called first in the device teardown code to make sure * userspace can't access the device instance any more. */ void drm_dev_unregister(struct drm_device *dev) ... ``` Thanks for the interesting remark again. > BR, > Jani. > > >> 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);
Hi, On 2023/6/27 16:41, Sui Jingfeng wrote: > I have verified that > > if the ->probe() failed, then the ->remove will be get called. > Sorry, if the ->probe() failed, then the ->remove() will *NOT* get called. > I'm doing the test by add a line before the drm_dev_alloc() > I do the test by adding one line code before the drm_dev_alloc() function to generate a fault(error) manually, > > See below: > > ``` > > return -ENODEV; > > dev = drm_dev_alloc(&kms_driver, &pdev->dev); > if (IS_ERR(dev)) > return PTR_ERR(dev); > > ret = pci_enable_device(pdev); > if (ret) > goto err_free; > ``` > > > So, there is no problem, as far as I can see. All in all, if the ->probe() failed, then the ->remove() will *NOT* get called.
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. - */ -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);