From patchwork Wed Jul 10 15:51:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 2825781 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4BB47C0AB2 for ; Wed, 10 Jul 2013 15:52:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 188FB201C7 for ; Wed, 10 Jul 2013 15:52:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 58918201B7 for ; Wed, 10 Jul 2013 15:52:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 627E8E63CB for ; Wed, 10 Jul 2013 08:52:20 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ea0-f179.google.com (mail-ea0-f179.google.com [209.85.215.179]) by gabe.freedesktop.org (Postfix) with ESMTP id 73F72E5CB0 for ; Wed, 10 Jul 2013 08:51:18 -0700 (PDT) Received: by mail-ea0-f179.google.com with SMTP id b15so5052193eae.24 for ; Wed, 10 Jul 2013 08:51:17 -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:x-mailer:in-reply-to:references; bh=+hTtsuPJGRPqOISSYTPyIr1zqaTj7UtpMejb2Vx8IrI=; b=iRh5VNskr+BgM0u28zCTIKWH+kwpkqZ8cZ+9x/uqItItcRlr83911u6oAQJzgXgBLn wytqyIuUlz7DCHRIPF+G3BdvWBJKKKUZUIFfawdJZAkwdsd9E2RFZYb7T1Upu1F8Rou+ D/v9WFAZu/c1tMAUzlI2uoU6GiSTNn0A3+Foo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=+hTtsuPJGRPqOISSYTPyIr1zqaTj7UtpMejb2Vx8IrI=; b=UfEgBcvkKbQKH9FYZkax5OrY21JjleSd4l1drIjY0lX2dEMzOWRghiY2wRQwoOnGm3 Uj2fE415Wu8Sdm0XqEvM5ZV0lBnDT32QI6Semlaek3xpC1jVtqSDRGwr7VrOmFoWe3dR LRAIgKGkZOCh/R3BYKaTgU8dNw72FGnNll9C9clKYJbivBkZKrK4JHWAHMoTQmXfcGhb lT/EsiD7o1RBFktxeizAookJXkNrWMqjfCHWQHCTKfJpb58KOKFZ8CqWZk8hSr5BFbrO zE7yGrbj8PW3uMOKJLo56j+T8JZojK6jhwPRrkplsh+kry7WajvbEmrXfuBoeyWLkgEw zLuQ== X-Received: by 10.14.172.194 with SMTP id t42mr37157878eel.78.1373471477266; Wed, 10 Jul 2013 08:51:17 -0700 (PDT) Received: from phenom.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPSA id m1sm60852238eex.17.2013.07.10.08.51.15 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 10 Jul 2013 08:51:16 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH 2/2] drm: move dev data clearing from drm_setup to lastclose Date: Wed, 10 Jul 2013 17:51:11 +0200 Message-Id: <1373471471-32368-2-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1373471471-32368-1-git-send-email-daniel.vetter@ffwll.ch> References: <1373458333-5988-1-git-send-email-daniel.vetter@ffwll.ch> <1373471471-32368-1-git-send-email-daniel.vetter@ffwll.ch> X-Gm-Message-State: ALoCoQngVXbEJYsLN8L8XMqIyaIUwr9Io6L8Pk561/yy2yUIMVg4Mj9uCzij9h+hz3tVpS4mLvKL 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+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-4.4 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 We kzalloc this structure, and for real kms devices we should never loose track of things really. But ums/legacy drivers rely on the drm core to clean up a bit of cruft between lastclose and firstopen (i.e. when X is being restarted), so keep this around. But give it a clear drm_legacy_ prefix and conditionalize the code on !DRIVER_MODESET. Cc: David Herrmann Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_drv.c | 27 +++++++++++++++++++++++++++ drivers/gpu/drm/drm_fops.c | 27 +++------------------------ 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index a9f48ff..7b4fd72 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -171,6 +171,31 @@ static const struct drm_ioctl_desc drm_ioctls[] = { #define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls ) /** + * drm_legacy_dev_reinit + * + * Reinitializes a legacy/ums drm device in it's lastclose function. + */ +static void drm_legacy_dev_reinit(struct drm_device *dev) +{ + int i; + + if (drm_core_check_feature(dev, DRIVER_MODESET)) + return; + + atomic_set(&dev->ioctl_count, 0); + atomic_set(&dev->vma_count, 0); + + for (i = 0; i < ARRAY_SIZE(dev->counts); i++) + atomic_set(&dev->counts[i], 0); + + dev->sigdata.lock = NULL; + + dev->context_flag = 0; + dev->last_context = 0; + dev->if_version = 0; +} + +/** * Take down the DRM device. * * \param dev DRM device structure. @@ -229,6 +254,8 @@ int drm_lastclose(struct drm_device * dev) dev->dev_mapping = NULL; mutex_unlock(&dev->struct_mutex); + drm_legacy_dev_reinit(dev); + DRM_DEBUG("lastclose completed\n"); return 0; } diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index 5679971..59f4592 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c @@ -48,7 +48,6 @@ static int drm_open_helper(struct inode *inode, struct file *filp, static int drm_setup(struct drm_device * dev) { - int i; int ret; if (dev->driver->firstopen && @@ -58,32 +57,12 @@ static int drm_setup(struct drm_device * dev) return ret; } - atomic_set(&dev->ioctl_count, 0); - atomic_set(&dev->vma_count, 0); - - i = drm_legacy_dma_setup(dev); - if (i < 0) - return i; - - for (i = 0; i < ARRAY_SIZE(dev->counts); i++) - atomic_set(&dev->counts[i], 0); - - dev->sigdata.lock = NULL; + ret = drm_legacy_dma_setup(dev); + if (ret < 0) + return ret; - dev->context_flag = 0; - dev->last_context = 0; - dev->if_version = 0; DRM_DEBUG("\n"); - - /* - * The kernel's context could be created here, but is now created - * in drm_dma_enqueue. This is more resource-efficient for - * hardware that does not do DMA, but may mean that - * drm_select_queue fails between the time the interrupt is - * initialized and the time the queues are initialized. - */ - return 0; }