From patchwork Wed Dec 11 10:34:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 3323791 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 169BC9F37A for ; Wed, 11 Dec 2013 10:34:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CEB79206C3 for ; Wed, 11 Dec 2013 10:34:55 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id E4716206C1 for ; Wed, 11 Dec 2013 10:34:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 490A0FB476; Wed, 11 Dec 2013 02:34:50 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ea0-f170.google.com (mail-ea0-f170.google.com [209.85.215.170]) by gabe.freedesktop.org (Postfix) with ESMTP id DD52BFB51A for ; Wed, 11 Dec 2013 02:34:43 -0800 (PST) Received: by mail-ea0-f170.google.com with SMTP id k10so2822749eaj.1 for ; Wed, 11 Dec 2013 02:34:43 -0800 (PST) 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=jMenuueIbaQyxHtdlPvTZP8rjIPK599RRx8M+BRQx7Y=; b=fcjFj6lrdHhjL9gK9d/CYxFnSTSCi+eHv6zjbMRPTXQWNnxrSfoYRXfuHSX8Mx8njk TiebmRFgi53NaFb6c7Ao4VNkJNty5URIHg5rH9NxyuAhLygYHoeoAojYKAe0JxqfPZS8 RJkI3//R3aKJsHDW5xnWSUm2I9KVcfhDXXc+g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jMenuueIbaQyxHtdlPvTZP8rjIPK599RRx8M+BRQx7Y=; b=SU7iv9IDWtuRThbELT5d/Y5l62B6s5w5uin+YVznwb5hNcGJ2m4ZsDiJtRed3KP80M hDFtnfxQ9xpHF9FBZHAR8ZehQraaJ9gV9vbbwmt86mLAfv+G6HRxQz0/Bkhd99zPRmki iNjuCxVjdlJjMcARMCtgQ1Dn0k9OjPisOUwSCTmYPOdWWOIac7JjufSkQDCZtegBry0l tR+kM+8YCVEaY7WcPhGlzCFqwDrz05VlL2BijOjBmdqyACQ0jQx3aYYEgXcdJSN0/nsM PMpBWnrMiQ7T4JT37R0/OdphpcOn0spLOcq1qe9IoBbwjXVIOIGx+h1K/ipM1uMXu77d K4vw== X-Gm-Message-State: ALoCoQnDb2/jONwOdszoIEN67hGCegD2VtvKATAc3IPTfR0nXacLshASbhB++XY8K5Lc/A4oHGnv X-Received: by 10.15.86.75 with SMTP id h51mr1023407eez.44.1386758083246; Wed, 11 Dec 2013 02:34:43 -0800 (PST) Received: from phenom.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPSA id b41sm51932269eef.16.2013.12.11.02.34.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Dec 2013 02:34:42 -0800 (PST) From: Daniel Vetter To: DRI Development Subject: [PATCH 10/50] drm: restrict the device list for shadow attached drivers Date: Wed, 11 Dec 2013 11:34:31 +0100 Message-Id: <1386758111-3446-11-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1386758111-3446-1-git-send-email-daniel.vetter@ffwll.ch> References: <1386758111-3446-1-git-send-email-daniel.vetter@ffwll.ch> Cc: Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There's really no need for the drm core to keep a list of all devices of a given driver - the linux device model keeps perfect track of this already for us. The exception is old legacy ums drivers using pci shadow attaching. So rename the lists to make the use case clearer and rip out everything else. v2: Rebase on top of David Herrmann's drm device register changes. Also drop the bogus dev_set_drvdata for platform drivers that somehow crept into the original version - drivers really should be in full control of that field. v3: Initialize driver->legacy_dev_list outside of the loop, spotted by David Herrmann. v4: Rebase on top of the newly created host1x drm_bus for tegra. Cc: David Herrmann Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_pci.c | 12 ++++++++++-- drivers/gpu/drm/drm_platform.c | 1 - drivers/gpu/drm/drm_stub.c | 4 ---- drivers/gpu/drm/drm_usb.c | 1 - drivers/gpu/drm/tegra/bus.c | 1 - include/drm/drmP.h | 6 +++--- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c index 02679793c9e2..efadad850288 100644 --- a/drivers/gpu/drm/drm_pci.c +++ b/drivers/gpu/drm/drm_pci.c @@ -346,6 +346,11 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent, driver->name, driver->major, driver->minor, driver->patchlevel, driver->date, pci_name(pdev), dev->primary->index); + /* No locking needed since shadow-attach is single-threaded since it may + * only be called from the per-driver module init hook. */ + if (!drm_core_check_feature(dev, DRIVER_MODESET)) + list_add_tail(&dev->legacy_dev_list, &driver->legacy_dev_list); + return 0; err_pci: @@ -375,7 +380,6 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) DRM_DEBUG("\n"); - INIT_LIST_HEAD(&driver->device_list); driver->kdriver.pci = pdriver; driver->bus = &drm_pci_bus; @@ -383,6 +387,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) return pci_register_driver(pdriver); /* If not using KMS, fall back to stealth mode manual scanning. */ + INIT_LIST_HEAD(&driver->legacy_dev_list); for (i = 0; pdriver->id_table[i].vendor != 0; i++) { pid = &pdriver->id_table[i]; @@ -465,8 +470,11 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver) if (driver->driver_features & DRIVER_MODESET) { pci_unregister_driver(pdriver); } else { - list_for_each_entry_safe(dev, tmp, &driver->device_list, driver_item) + list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list, + legacy_dev_list) { drm_put_dev(dev); + list_del(&dev->legacy_dev_list); + } } DRM_INFO("Module unloaded\n"); } diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c index 56a48033eced..21fc82006b78 100644 --- a/drivers/gpu/drm/drm_platform.c +++ b/drivers/gpu/drm/drm_platform.c @@ -147,7 +147,6 @@ int drm_platform_init(struct drm_driver *driver, struct platform_device *platfor driver->kdriver.platform_device = platform_device; driver->bus = &drm_platform_bus; - INIT_LIST_HEAD(&driver->device_list); return drm_get_platform_dev(platform_device, driver); } EXPORT_SYMBOL(drm_platform_init); diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index f53d5246979c..4c57da81c141 100644 --- a/drivers/gpu/drm/drm_stub.c +++ b/drivers/gpu/drm/drm_stub.c @@ -557,8 +557,6 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags) goto err_unload; } - list_add_tail(&dev->driver_item, &dev->driver->device_list); - ret = 0; goto out_unlock; @@ -608,7 +606,5 @@ void drm_dev_unregister(struct drm_device *dev) drm_unplug_minor(dev->control); drm_unplug_minor(dev->render); drm_unplug_minor(dev->primary); - - list_del(&dev->driver_item); } EXPORT_SYMBOL(drm_dev_unregister); diff --git a/drivers/gpu/drm/drm_usb.c b/drivers/gpu/drm/drm_usb.c index b179b70e7853..21ae8d96880b 100644 --- a/drivers/gpu/drm/drm_usb.c +++ b/drivers/gpu/drm/drm_usb.c @@ -63,7 +63,6 @@ int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver) int res; DRM_DEBUG("\n"); - INIT_LIST_HEAD(&driver->device_list); driver->kdriver.usb = udriver; driver->bus = &drm_usb_bus; diff --git a/drivers/gpu/drm/tegra/bus.c b/drivers/gpu/drm/tegra/bus.c index 565f8f7b9a47..e38e5967d77b 100644 --- a/drivers/gpu/drm/tegra/bus.c +++ b/drivers/gpu/drm/tegra/bus.c @@ -46,7 +46,6 @@ int drm_host1x_init(struct drm_driver *driver, struct host1x_device *device) struct drm_device *drm; int ret; - INIT_LIST_HEAD(&driver->device_list); driver->bus = &drm_host1x_bus; drm = drm_dev_alloc(driver, &device->dev); diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 43f69bb2cff4..8654a8b27fee 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -995,8 +995,8 @@ struct drm_driver { } kdriver; struct drm_bus *bus; - /* List of devices hanging off this driver */ - struct list_head device_list; + /* List of devices hanging off this driver with stealth attach. */ + struct list_head legacy_dev_list; }; #define DRM_MINOR_UNASSIGNED 0 @@ -1085,7 +1085,7 @@ struct drm_vblank_crtc { * may contain multiple heads. */ struct drm_device { - struct list_head driver_item; /**< list of devices per driver */ + struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */ char *devname; /**< For /proc/interrupts */ int if_version; /**< Highest interface version set */