From patchwork Thu Aug 8 13:41:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 2841104 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 BA12C9F271 for ; Thu, 8 Aug 2013 13:49:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 03AD82024A for ; Thu, 8 Aug 2013 13:49:42 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7C391200DE for ; Thu, 8 Aug 2013 13:49:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5498CE70CD for ; Thu, 8 Aug 2013 06:49:40 -0700 (PDT) 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 D0449E6886 for ; Thu, 8 Aug 2013 06:41:37 -0700 (PDT) Received: by mail-ea0-f170.google.com with SMTP id h14so1485492eak.1 for ; Thu, 08 Aug 2013 06:41:37 -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:in-reply-to:references; bh=SR/7s8MXbisZJvjINRfUTf7UAeVSSLg7MN4rDA2pYz0=; b=MIxyQnadQTEMcBZkaDbogNU4GXZooisVkBoh/aF5k+ymPGutJI58WEqYJpN+E7GAIr KE7oO9uV7VhjSxuco+v5FS/Y5QH70h6gYQZjR4iPvVm6RhNKgIo3r/e78eilZvXdbl9j +/oSjN3kyY3OmyeFbt1qnyk8Fqjz4uKuXQEsQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SR/7s8MXbisZJvjINRfUTf7UAeVSSLg7MN4rDA2pYz0=; b=Uckn1mywPG6v7lEXSMnscgXGnfOyR6d52m3M/4GLXT0o+PgqbD2qv34lD3peA/9nnR KXGnU5j/EP47qzmjgyXfazXaSjoowkSSyM8luoXlWEi4sNQcW5iZqXvtyP2TEbq+LLzT 8frZG24ZoIEZ2g9rmTOt/UILT80Z1ljRdrKLk8tIzYUC9ct47qls6c8Gg9cA+O0XkDFc 4Wsl/ken1bw9NKjU6FJ2xfSA7HoBNd4VaYKc5JyB9IObusVhQz/UZvqe2B84clztYYcI lQcdhAz2y8sbdViRKg48YnK4ERGOGzUJ5e6OtyhkX85F2UX8QaZJJJkf1u95LqtGihGD iwiQ== X-Gm-Message-State: ALoCoQn/2bf9BJmRwtNcd6kneg2uEdfm8EarekjmqxqClGAxzV2jI1QydCK2v5LmHJzb2pV+CIq7 X-Received: by 10.14.111.198 with SMTP id w46mr8241167eeg.66.1375969296888; Thu, 08 Aug 2013 06:41:36 -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 bn13sm19282226eeb.11.2013.08.08.06.41.35 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 08 Aug 2013 06:41:36 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH 03/25] drm/imx: kill firstopen callback Date: Thu, 8 Aug 2013 15:41:13 +0200 Message-Id: <1375969295-18929-4-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1375969295-18929-1-git-send-email-daniel.vetter@ffwll.ch> References: <1375969295-18929-1-git-send-email-daniel.vetter@ffwll.ch> Cc: Daniel Vetter , Greg Kroah-Hartman 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.1 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 This thing seems to do some kind of delayed setup. Really, real kms drivers shouldn't do that at all. Either stuff needs to be dynamically hotplugged or the driver setup sequence needs to be fixed. This patch here just moves the setup at the very end of the driver load callback, with the locking adjusted accordingly. v2: Also move the corresponding put from ->lastclose to ->unload. Cc: Sascha Hauer Cc: Greg Kroah-Hartman Signed-off-by: Daniel Vetter Acked-by: Greg Kroah-Hartman --- Note that this is already in the staging tree but due to the follow-up cleanup it's probably best to merge it again through drm-next. -Daniel drivers/staging/imx-drm/imx-drm-core.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index a890049..2c58533 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -69,28 +69,20 @@ struct imx_drm_connector { struct module *owner; }; -static int imx_drm_driver_firstopen(struct drm_device *drm) -{ - if (!imx_drm_device_get()) - return -EINVAL; - - return 0; -} - static void imx_drm_driver_lastclose(struct drm_device *drm) { struct imx_drm_device *imxdrm = drm->dev_private; if (imxdrm->fbhelper) drm_fbdev_cma_restore_mode(imxdrm->fbhelper); - - imx_drm_device_put(); } static int imx_drm_driver_unload(struct drm_device *drm) { struct imx_drm_device *imxdrm = drm->dev_private; + imx_drm_device_put(); + drm_mode_config_cleanup(imxdrm->drm); drm_kms_helper_poll_fini(imxdrm->drm); @@ -226,8 +218,6 @@ struct drm_device *imx_drm_device_get(void) struct imx_drm_connector *con; struct imx_drm_crtc *crtc; - mutex_lock(&imxdrm->mutex); - list_for_each_entry(enc, &imxdrm->encoder_list, list) { if (!try_module_get(enc->owner)) { dev_err(imxdrm->dev, "could not get module %s\n", @@ -254,8 +244,6 @@ struct drm_device *imx_drm_device_get(void) imxdrm->references++; - mutex_unlock(&imxdrm->mutex); - return imxdrm->drm; unwind_crtc: @@ -447,6 +435,9 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) */ imxdrm->drm->vblank_disable_allowed = 1; + if (!imx_drm_device_get()) + ret = -EINVAL; + ret = 0; err_init: @@ -791,7 +782,6 @@ static struct drm_driver imx_drm_driver = { .driver_features = DRIVER_MODESET | DRIVER_GEM, .load = imx_drm_driver_load, .unload = imx_drm_driver_unload, - .firstopen = imx_drm_driver_firstopen, .lastclose = imx_drm_driver_lastclose, .gem_free_object = drm_gem_cma_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops,