From patchwork Mon Feb 12 09:44:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 127958 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3040211ljc; Mon, 12 Feb 2018 01:45:42 -0800 (PST) X-Google-Smtp-Source: AH8x227M8sDOM05L5avZNrrJAXZS7V5yt3oweNeHN0MLhXxw2D++Ykvwal7AjNK/WcHYDMchHi2y X-Received: by 10.99.2.67 with SMTP id 64mr9046199pgc.117.1518428741850; Mon, 12 Feb 2018 01:45:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518428741; cv=none; d=google.com; s=arc-20160816; b=C22j7QbMECTYV540t2Kd9H8/Dr0KdJQdXoltPzRNE8DhWTPQz6fpbsKUVvPEmjfp5o Ke0Kyqb5FLF5dx4LnxXuPcsSFcBR+/Il+Zy82fKTonXzvlR96h1o5P5RaKzzlIArqOEy cjCg0Ld5MVvKi5w01WtBxOKXdMAhcFaGfIhT09YAg6I8DA+1273K93qd8AYsglO7JsnO ntNeqk20fAbplQMJkAL9B69K+IjannKFkksXeguCD6MXtBBX3GLP5lgmL1KrHbdMUYlC 5tkSWqSL4qyDP+xZz0aDuib6y36jRsRRUpGSHpc5fwbzkwCZmcQJNYDgSOloK88Uh/BX qnmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to :arc-authentication-results; bh=cpziUGSAH0YNfDYxQN21xwDSwtpAiFyTRRAFZyCOeKQ=; b=HoHdmPIy8eEPrEm2dm8mOgOTbM5N4ybyaqXwi0+rfX1Cw8u8LdMhHDs2rp37+WHMbi s2Rw0hFXVKZ79dJTt1bduUMSFhyCSrMA9C2qkfbiFtelGNu8Al67poguXQHCPZ+nuDQl 2vorrQ5uB9V4iQrf7K9TCaktmwsCP20TfVdioulApyUUGcLDZ55CTWbvu5zm2o/76D3k ZVMG0mEZACgVdBKEp+C7bUdXUHl1ChykwKp9COuKF4u2qRam6UjitXAfuq2HgLgO+toO wJQ+8xZm49WUyIMSqVtFfS30Iel7AdXz4xvweH9FQnf+HEu3G9uV/sEVHMT3i3ZNLQ0L kxRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=xPvZPLnG; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id d19si755321pfk.194.2018.02.12.01.45.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 01:45:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=xPvZPLnG; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 14D416E164; Mon, 12 Feb 2018 09:45:21 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fllnx209.ext.ti.com (fllnx209.ext.ti.com [198.47.19.16]) by gabe.freedesktop.org (Postfix) with ESMTPS id 605816E143 for ; Mon, 12 Feb 2018 09:45:16 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id w1C9jELx018927; Mon, 12 Feb 2018 03:45:14 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1518428714; bh=/nrhXs0M2g3HICvmru5MCUupu6UaI0sj3oSuYGOZ7dU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=xPvZPLnGpyghFhChjU3iFEQafKR2k+10Np9iW60xwieElaPc0bwaBkO0JJ4qJ2loi OM0hX03FZK0vYWRiXOV3tn9yKUAbhjLc+ZlquCdo8dwa2zHr30Ka+UfvlVXs3OGyYY x2pN224jcDxZaid/idgKORqdYNbdEmniFWFLT9Ls= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1C9jDeI018528; Mon, 12 Feb 2018 03:45:13 -0600 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Mon, 12 Feb 2018 03:45:13 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Mon, 12 Feb 2018 03:45:13 -0600 Received: from deskari.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1C9j0N3003439; Mon, 12 Feb 2018 03:45:12 -0600 From: Tomi Valkeinen To: , Laurent Pinchart , Peter Ujfalusi , Jyri Sarha , Benoit Parrot Subject: [PATCH 06/24] drm/omap: Allocate drm_device earlier and unref it as last step Date: Mon, 12 Feb 2018 11:44:36 +0200 Message-ID: <1518428694-18018-7-git-send-email-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518428694-18018-1-git-send-email-tomi.valkeinen@ti.com> References: <1518428694-18018-1-git-send-email-tomi.valkeinen@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tomi Valkeinen Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Peter Ujfalusi If we allocate the drm_device earlier we can just return the error code without the need to use goto. Do the unref of the drm_device as a last step when cleaning up. This will make the drm_device available longer for us and makes sure that we only free up the memory when all other cleanups have been already done. Signed-off-by: Peter Ujfalusi Reviewed-by: Laurent Pinchart Signed-off-by: Tomi Valkeinen --- drivers/gpu/drm/omapdrm/omap_drv.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index 3cd9188ab30b..57d11f9aeead 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -533,6 +533,14 @@ static int pdev_probe(struct platform_device *pdev) if (!priv) return -ENOMEM; + /* Allocate and initialize the DRM device. */ + ddev = drm_dev_alloc(&omap_drm_driver, &pdev->dev); + if (IS_ERR(ddev)) + return PTR_ERR(ddev); + + ddev->dev_private = priv; + platform_set_drvdata(pdev, ddev); + omap_crtc_pre_init(); ret = omap_connect_dssdevs(); @@ -549,16 +557,6 @@ static int pdev_probe(struct platform_device *pdev) spin_lock_init(&priv->list_lock); INIT_LIST_HEAD(&priv->obj_list); - /* Allocate and initialize the DRM device. */ - ddev = drm_dev_alloc(&omap_drm_driver, &pdev->dev); - if (IS_ERR(ddev)) { - ret = PTR_ERR(ddev); - goto err_destroy_wq; - } - - ddev->dev_private = priv; - platform_set_drvdata(pdev, ddev); - /* Get memory bandwidth limits */ if (priv->dispc_ops->get_memory_bandwidth_limit) priv->max_bandwidth = @@ -569,7 +567,7 @@ static int pdev_probe(struct platform_device *pdev) ret = omap_modeset_init(ddev); if (ret) { dev_err(&pdev->dev, "omap_modeset_init failed: ret=%d\n", ret); - goto err_free_drm_dev; + goto err_gem_deinit; } /* Initialize vblank handling, start with all CRTCs disabled. */ @@ -605,14 +603,13 @@ static int pdev_probe(struct platform_device *pdev) err_cleanup_modeset: drm_mode_config_cleanup(ddev); omap_drm_irq_uninstall(ddev); -err_free_drm_dev: +err_gem_deinit: omap_gem_deinit(ddev); - drm_dev_unref(ddev); -err_destroy_wq: destroy_workqueue(priv->wq); omap_disconnect_dssdevs(); err_crtc_uninit: omap_crtc_pre_uninit(); + drm_dev_unref(ddev); return ret; } @@ -637,13 +634,13 @@ static int pdev_remove(struct platform_device *pdev) omap_drm_irq_uninstall(ddev); omap_gem_deinit(ddev); - drm_dev_unref(ddev); - destroy_workqueue(priv->wq); omap_disconnect_dssdevs(); omap_crtc_pre_uninit(); + drm_dev_unref(ddev); + return 0; }