From patchwork Mon Mar 6 10:07:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 659366 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7D72C6FD1E for ; Mon, 6 Mar 2023 10:09:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230281AbjCFKJb (ORCPT ); Mon, 6 Mar 2023 05:09:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230244AbjCFKJX (ORCPT ); Mon, 6 Mar 2023 05:09:23 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FD98222E3; Mon, 6 Mar 2023 02:09:21 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E7A52B80D75; Mon, 6 Mar 2023 10:09:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83D85C4339B; Mon, 6 Mar 2023 10:09:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678097358; bh=bGa3LGEVgDSMBMrHbY9SDca40Ab9EZJo6raY1+G6bnw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D4K/DO2KNmrupnIfHYchxc2UfYBt+ntb9XeIKxWGY2NvBnr/6pLEOGvemrg5fN2Ng TDJDSWJnlYK7NM2bkxFtMOJxLHJVlFpUbr+FiIG8IN3B9mOORHSv7o87F3gv4Tijg/ suIUfLnherbiHKtKgP5iAsBoXOd+Ao9o2eDq0fT4jqNGh7Q104rOdU5WZRNsMCVY3I ZDtHhN4TUeQ68TtJsBTlDoo/iKSMV6YsFHhwOMLvgtPAs8cWXHV7K0ixfLS8piv/F4 eCUvpOujgpTkX4c0tW1ZCXJxxoQZmhlCgZxOH0/Oo5hVjzAuypSTNG+gv4yV93FL3j eGlI8UyK2RmoQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ7n5-0007Qb-1F; Mon, 06 Mar 2023 11:09:59 +0100 From: Johan Hovold To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov Cc: Sean Paul , David Airlie , Daniel Vetter , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Johan Hovold , Jiasheng Jiang Subject: [PATCH 01/10] Revert "drm/msm: Add missing check and destroy for alloc_ordered_workqueue" Date: Mon, 6 Mar 2023 11:07:13 +0100 Message-Id: <20230306100722.28485-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306100722.28485-1-johan+linaro@kernel.org> References: <20230306100722.28485-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org This reverts commit 643b7d0869cc7f1f7a5ac7ca6bd25d88f54e31d0. A recent patch that tried to fix up the msm_drm_init() paths with respect to the workqueue but only ended up making things worse: First, the newly added calls to msm_drm_uninit() on early errors would trigger NULL-pointer dereferences, for example, as the kms pointer would not have been initialised. (Note that these paths were also modified by a second broken error handling patch which in effect cancelled out this part when merged.) Second, the newly added allocation sanity check would still leak the previously allocated drm device. Instead of trying to salvage what was badly broken (and clearly not tested), let's revert the bad commit so that clean and backportable fixes can be added in its place. Fixes: 643b7d0869cc ("drm/msm: Add missing check and destroy for alloc_ordered_workqueue") Cc: Jiasheng Jiang Signed-off-by: Johan Hovold Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/msm_drv.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index aca48c868c14..b7f5a78eadd4 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -420,8 +420,6 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) priv->dev = ddev; priv->wq = alloc_ordered_workqueue("msm", 0); - if (!priv->wq) - return -ENOMEM; INIT_LIST_HEAD(&priv->objects); mutex_init(&priv->obj_lock); From patchwork Mon Mar 6 10:07:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 660675 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34C5EC6FD1A for ; Mon, 6 Mar 2023 10:09:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230361AbjCFKJg (ORCPT ); Mon, 6 Mar 2023 05:09:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230292AbjCFKJX (ORCPT ); Mon, 6 Mar 2023 05:09:23 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EC42222E2; Mon, 6 Mar 2023 02:09:21 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BECA0B80D34; Mon, 6 Mar 2023 10:09:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7AA50C433D2; Mon, 6 Mar 2023 10:09:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678097358; bh=O0hTTeG0QACttF+fPXxT6uAirlSnSJBFPVa+P9Yvy/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qpjXXYZIym9UdjFV6O62sj5OjqtochKZULP2b69pLqWSCTZNQTzEejftf/Z7xMj0K qfsZ4PZpmX+tYN3oYGAB2oDZuHylS83gOPYBaUoyh5HF7MgG9uT3qsSugcjOfe+vy4 VswTjv9xErBdJ8T3bzmaBp5lmGsn4cZRspEuUdIbnT8+1bjgMHrFuSxSPWO6J4wUhv NE+MnaJlKa4TFAoTOwRp7xETj1Mr/hyYDrqIZ/Tvwzv3citvV+MgJO2Y5xKyMN/L4F WHqUgVUdAR55D3A7M7Ppo+yJA15ZEmQqmwnWQDnaaB0nWraF0ECtvVM58FV5A90vBN n7dfvW3Y41CJQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ7n5-0007Qd-4T; Mon, 06 Mar 2023 11:09:59 +0100 From: Johan Hovold To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov Cc: Sean Paul , David Airlie , Daniel Vetter , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Johan Hovold , Akhil P Oommen Subject: [PATCH 02/10] Revert "drm/msm: Fix failure paths in msm_drm_init()" Date: Mon, 6 Mar 2023 11:07:14 +0100 Message-Id: <20230306100722.28485-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306100722.28485-1-johan+linaro@kernel.org> References: <20230306100722.28485-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org This reverts commit 8636500300a01740d92b345c680b036b94555b1b. A recent commit tried to address a drm device leak in the early msm_drm_uninit() error paths but ended up making things worse. Specifically, it moved the drm device reference put in msm_drm_uninit() to msm_drm_init() which means that the drm would now be leaked on normal unbind. For reasons that were never spelled out, it also added kms NULL pointer checks to a couple of helper functions that had nothing to do with the paths modified by the patch. Instead of trying to salvage this incrementally, let's revert the bad commit so that clean and backportable fixes can be added in its place. Fixes: 8636500300a0 ("drm/msm: Fix failure paths in msm_drm_init()") Cc: Akhil P Oommen Signed-off-by: Johan Hovold Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/disp/msm_disp_snapshot.c | 3 --- drivers/gpu/drm/msm/msm_drv.c | 11 ++++------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/msm_disp_snapshot.c b/drivers/gpu/drm/msm/disp/msm_disp_snapshot.c index b73031cd48e4..e75b97127c0d 100644 --- a/drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +++ b/drivers/gpu/drm/msm/disp/msm_disp_snapshot.c @@ -129,9 +129,6 @@ void msm_disp_snapshot_destroy(struct drm_device *drm_dev) } priv = drm_dev->dev_private; - if (!priv->kms) - return; - kms = priv->kms; if (kms->dump_worker) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index b7f5a78eadd4..9ded384acba4 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -150,9 +150,6 @@ static void msm_irq_uninstall(struct drm_device *dev) struct msm_drm_private *priv = dev->dev_private; struct msm_kms *kms = priv->kms; - if (!priv->kms) - return; - kms->funcs->irq_uninstall(kms); if (kms->irq_requested) free_irq(kms->irq, dev); @@ -270,6 +267,8 @@ static int msm_drm_uninit(struct device *dev) component_unbind_all(dev, ddev); ddev->dev_private = NULL; + drm_dev_put(ddev); + destroy_workqueue(priv->wq); return 0; @@ -442,12 +441,12 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) ret = msm_init_vram(ddev); if (ret) - goto err_drm_dev_put; + return ret; /* Bind all our sub-components: */ ret = component_bind_all(dev, ddev); if (ret) - goto err_drm_dev_put; + return ret; dma_set_max_seg_size(dev, UINT_MAX); @@ -542,8 +541,6 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) err_msm_uninit: msm_drm_uninit(dev); -err_drm_dev_put: - drm_dev_put(ddev); return ret; } From patchwork Mon Mar 6 10:07:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 660679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A76F0C6FD1D for ; Mon, 6 Mar 2023 10:09:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230298AbjCFKJZ (ORCPT ); Mon, 6 Mar 2023 05:09:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230272AbjCFKJU (ORCPT ); Mon, 6 Mar 2023 05:09:20 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A41CB22001; Mon, 6 Mar 2023 02:09:19 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 42D0E60DC1; Mon, 6 Mar 2023 10:09:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98A49C433A1; Mon, 6 Mar 2023 10:09:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678097358; bh=oHtOiiLls+D/brpZp/GfYW0LOJJAvdIWo6VBajIFJFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FWY4vLrWgV44TRuLq2J4Mfxnhm4vWWeRrePKjiND/BjJ8pjdbtFYWkdbOY6u28fXF 5xSUDav0bMngErNyVJQ+EUR/6z0MUMlsJza97tywfH2jjIl4DMMQo/kKC0COBlsvzr n48eO7snFlpxYT9QcvifF2L3xPa2krIgZfprVnQSVoKfU2YRz8L4BVCR/SEy8YN/iq MCi98skpVAP2AJR4oj1k9b4zqai4ho+ID6Q2Ph0+411m7N2u2ESgJFKoMKkCO52Gcp wHJb6uzimOIeRgVzRn/ZJEt/p/e7CzZtjzu0i4QHtw++GBWcPYCWnb+XPp+Oj6z1gI LYvQOqHte8c6A== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ7n5-0007Qf-71; Mon, 06 Mar 2023 11:09:59 +0100 From: Johan Hovold To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov Cc: Sean Paul , David Airlie , Daniel Vetter , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH 03/10] drm/msm: fix NULL-deref on snapshot tear down Date: Mon, 6 Mar 2023 11:07:15 +0100 Message-Id: <20230306100722.28485-4-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306100722.28485-1-johan+linaro@kernel.org> References: <20230306100722.28485-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In case of early initialisation errors and on platforms that do not use the DPU controller, the deinitilisation code can be called with the kms pointer set to NULL. Fixes: 98659487b845 ("drm/msm: add support to take dpu snapshot") Cc: stable@vger.kernel.org # 5.14 Cc: Abhinav Kumar Signed-off-by: Johan Hovold Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/msm_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 9ded384acba4..17a59d73fe01 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -242,7 +242,8 @@ static int msm_drm_uninit(struct device *dev) msm_fbdev_free(ddev); #endif - msm_disp_snapshot_destroy(ddev); + if (kms) + msm_disp_snapshot_destroy(ddev); drm_mode_config_cleanup(ddev); From patchwork Mon Mar 6 10:07:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 659367 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FE1CC6FD1D for ; Mon, 6 Mar 2023 10:09:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230317AbjCFKJ3 (ORCPT ); Mon, 6 Mar 2023 05:09:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230274AbjCFKJW (ORCPT ); Mon, 6 Mar 2023 05:09:22 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A44ED222CD; Mon, 6 Mar 2023 02:09:19 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4164B60C61; Mon, 6 Mar 2023 10:09:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97427C433A0; Mon, 6 Mar 2023 10:09:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678097358; bh=4+aatQXI0SCxRlCzdLvMFS4VkyXlIErsdSaIxooTjLo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JPL2f+tKt/HlM/ila+Orez2fDpuyMV0hIP4O874wDP4+xCQEchxA603rlXWnrkk6c kIEhbFdGw3uBtjiSVawaRUDsNzbaqqs2epRR19PgUyvgIIJSKvHc64VeqzFcc2s70N m+lcsfh5V86J88FjoMXYhgYwnqBf4RjYRYrTpsvy3YcZHelZJeE1MgiAbHVFdbBf07 pIO9ZEEo7VWv7jmcZfrGckJPQXErTytebZr3qfBgChPdP59WuZ9qEe7/Rrr2dbavO5 ZKgOMx1LSAWdzux+8TYBELjRKvLtaTIWj+k6h/te4YBGOz5AzKPvyJZ7n7XFYQ1g9w 20iTjSh2bjAAw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ7n5-0007Qi-9X; Mon, 06 Mar 2023 11:09:59 +0100 From: Johan Hovold To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov Cc: Sean Paul , David Airlie , Daniel Vetter , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 04/10] drm/msm: fix NULL-deref on irq uninstall Date: Mon, 6 Mar 2023 11:07:16 +0100 Message-Id: <20230306100722.28485-5-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306100722.28485-1-johan+linaro@kernel.org> References: <20230306100722.28485-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In case of early initialisation errors and on platforms that do not use the DPU controller, the deinitilisation code can be called with the kms pointer set to NULL. Fixes: f026e431cf86 ("drm/msm: Convert to Linux IRQ interfaces") Cc: stable@vger.kernel.org # 5.14 Cc: Thomas Zimmermann Signed-off-by: Johan Hovold Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/msm_drv.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 17a59d73fe01..2f2bcdb671d2 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -251,9 +251,11 @@ static int msm_drm_uninit(struct device *dev) drm_bridge_remove(priv->bridges[i]); priv->num_bridges = 0; - pm_runtime_get_sync(dev); - msm_irq_uninstall(ddev); - pm_runtime_put_sync(dev); + if (kms) { + pm_runtime_get_sync(dev); + msm_irq_uninstall(ddev); + pm_runtime_put_sync(dev); + } if (kms && kms->funcs) kms->funcs->destroy(kms); From patchwork Mon Mar 6 10:07:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 660676 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48602C678D4 for ; Mon, 6 Mar 2023 10:09:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230326AbjCFKJb (ORCPT ); Mon, 6 Mar 2023 05:09:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230280AbjCFKJX (ORCPT ); Mon, 6 Mar 2023 05:09:23 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45ED9222E1; Mon, 6 Mar 2023 02:09:20 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D1A9160DCA; Mon, 6 Mar 2023 10:09:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DF96C4339C; Mon, 6 Mar 2023 10:09:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678097358; bh=X7Gj43NEKH3ef23xjVhwnnWwIQxNkYo2UW1bxn+SqkE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c8BncGvgcE6nNUvBtSWfH1uDOZUB3o+kJy7hCuVAqZmnT56FGYwjCf+7FiOFC2lf5 rw8XNSPhLLKA1WlR4/GeruxoZUVT8EZFoiuzpVum5aeg25OF6aLjs00WtOq4aJ5cdh VXVZJo5WogxLOQw6b4Qhcx0MiTP5CtTSQVeS6r13+aXF09RYyyYX27ziBAWBLHZ2Us zIsp6CXnP5hhory3bwWCJLp8pdifROWqwystI2L7qrosrcoviLDutr8oCB3ngtU0nd aTfllirJ+xDBWxgfvFhN6Ng+D7MMDeSm0WLbQ6LV/SPfmzdSiWYDZujFaIlLORnUKY Q0vjuwbcmS8xg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ7n5-0007Ql-C4; Mon, 06 Mar 2023 11:09:59 +0100 From: Johan Hovold To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov Cc: Sean Paul , David Airlie , Daniel Vetter , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH 05/10] drm/msm: fix drm device leak on bind errors Date: Mon, 6 Mar 2023 11:07:17 +0100 Message-Id: <20230306100722.28485-6-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306100722.28485-1-johan+linaro@kernel.org> References: <20230306100722.28485-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Make sure to free the DRM device also in case of early errors during bind(). Fixes: 2027e5b3413d ("drm/msm: Initialize MDSS irq domain at probe time") Cc: stable@vger.kernel.org # 5.17 Cc: Dmitry Baryshkov Signed-off-by: Johan Hovold Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/msm_drv.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 2f2bcdb671d2..89634159ad75 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -444,12 +444,12 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) ret = msm_init_vram(ddev); if (ret) - return ret; + goto err_put_dev; /* Bind all our sub-components: */ ret = component_bind_all(dev, ddev); if (ret) - return ret; + goto err_put_dev; dma_set_max_seg_size(dev, UINT_MAX); @@ -544,6 +544,12 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) err_msm_uninit: msm_drm_uninit(dev); + + return ret; + +err_put_dev: + drm_dev_put(ddev); + return ret; } From patchwork Mon Mar 6 10:07:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 660674 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7339C6FD1C for ; Mon, 6 Mar 2023 10:09:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230372AbjCFKJj (ORCPT ); Mon, 6 Mar 2023 05:09:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230295AbjCFKJY (ORCPT ); Mon, 6 Mar 2023 05:09:24 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC72DBDD4; Mon, 6 Mar 2023 02:09:21 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9866AB80D7E; Mon, 6 Mar 2023 10:09:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1747C433B0; Mon, 6 Mar 2023 10:09:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678097358; bh=uqvw+1pPZqa3n7JUisPLnCC2+5ng04ROJJhyzn6R2aQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kgo+sXz7XTVxNF0eFyruT96oYiVmmTPThA28T0KckXZ4WWNJYYNzEQv2504qqdPfw dRIQJk/iNj7y5NxqWiKSljgClNgwB82YP2hgSzxfVqxL2Bu3v8PIKOD46X3rVYXUPL g+vZAt63IRSksCsoRyOd7I5QWyqF4AE4vXwZEZMehIZP/dS2OnnhVIWxQitO/LLQzj b3y59NTU3AGxYV02OVFYxQy3ALV8yyxzcdByiuz33ETmPBr+LJViAslA/MFwBUnE5Z ggzRuuTKM910iaTqBtC7NmHLDSxIizP0uxLankzyqGNDKSr/0oLw3JCMnXSkDHSAfa ohmugVe96Nceg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ7n5-0007Qo-Er; Mon, 06 Mar 2023 11:09:59 +0100 From: Johan Hovold To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov Cc: Sean Paul , David Airlie , Daniel Vetter , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Craig Tatlor Subject: [PATCH 06/10] drm/msm: fix vram leak on bind errors Date: Mon, 6 Mar 2023 11:07:18 +0100 Message-Id: <20230306100722.28485-7-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306100722.28485-1-johan+linaro@kernel.org> References: <20230306100722.28485-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Make sure to release the VRAM buffer also in a case a subcomponent fails to bind. Fixes: d863f0c7b536 ("drm/msm: Call msm_init_vram before binding the gpu") Cc: stable@vger.kernel.org # 5.11 Cc: Craig Tatlor Signed-off-by: Johan Hovold Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/msm_drv.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 89634159ad75..41cc6cd690cd 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -51,6 +51,8 @@ #define MSM_VERSION_MINOR 10 #define MSM_VERSION_PATCHLEVEL 0 +static void msm_deinit_vram(struct drm_device *ddev); + static const struct drm_mode_config_funcs mode_config_funcs = { .fb_create = msm_framebuffer_create, .output_poll_changed = drm_fb_helper_output_poll_changed, @@ -260,12 +262,7 @@ static int msm_drm_uninit(struct device *dev) if (kms && kms->funcs) kms->funcs->destroy(kms); - if (priv->vram.paddr) { - unsigned long attrs = DMA_ATTR_NO_KERNEL_MAPPING; - drm_mm_takedown(&priv->vram.mm); - dma_free_attrs(dev, priv->vram.size, NULL, - priv->vram.paddr, attrs); - } + msm_deinit_vram(ddev); component_unbind_all(dev, ddev); @@ -403,6 +400,19 @@ static int msm_init_vram(struct drm_device *dev) return ret; } +static void msm_deinit_vram(struct drm_device *ddev) +{ + struct msm_drm_private *priv = ddev->dev_private; + unsigned long attrs = DMA_ATTR_NO_KERNEL_MAPPING; + + if (!priv->vram.paddr) + return; + + drm_mm_takedown(&priv->vram.mm); + dma_free_attrs(ddev->dev, priv->vram.size, NULL, priv->vram.paddr, + attrs); +} + static int msm_drm_init(struct device *dev, const struct drm_driver *drv) { struct msm_drm_private *priv = dev_get_drvdata(dev); @@ -449,7 +459,7 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) /* Bind all our sub-components: */ ret = component_bind_all(dev, ddev); if (ret) - goto err_put_dev; + goto err_deinit_vram; dma_set_max_seg_size(dev, UINT_MAX); @@ -547,6 +557,8 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) return ret; +err_deinit_vram: + msm_deinit_vram(ddev); err_put_dev: drm_dev_put(ddev); From patchwork Mon Mar 6 10:07:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 659368 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2B95C6FD1A for ; Mon, 6 Mar 2023 10:09:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230313AbjCFKJ2 (ORCPT ); Mon, 6 Mar 2023 05:09:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230287AbjCFKJX (ORCPT ); Mon, 6 Mar 2023 05:09:23 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43B34222E0; Mon, 6 Mar 2023 02:09:20 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CE32460CF7; Mon, 6 Mar 2023 10:09:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C06C2C433A8; Mon, 6 Mar 2023 10:09:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678097358; bh=5WWc/IA6KEuvk5qRgQkziyYcmpqaQV99Q299DA5bkuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XmLuhUwNoWU4IVC3iCrUwuhv3eh0i+kq4h5bW1w33pSFpe+CwK2HxoWKZsKTByNBf 6yzugc3HGaFj9ddQ/D8SdZPYuyGO/747QGtagRaWE15638eUSXetb085HvdJ0tb0yD k9d59zOGwVE4RqTl7E/wLxO/u8ETt3gibWI5EZEMPxl87z9qhmqYQhRWoA4wc5mfdE Gv+F6VLJAZF1brS+mhjVTpfD0+/8ZFNkL1Wu/rtA6BWzzole3ogicanzUKDc6evCDS uAEGNwIz8xUAj8quEXrn4ZKxOwK7LJnsIiUt9LWN9jh4b+def2ILb+fso6oGj75De0 rxU1+j1HjZ8yQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ7n5-0007Qq-HN; Mon, 06 Mar 2023 11:09:59 +0100 From: Johan Hovold To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov Cc: Sean Paul , David Airlie , Daniel Vetter , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH 07/10] drm/msm: fix missing wq allocation error handling Date: Mon, 6 Mar 2023 11:07:19 +0100 Message-Id: <20230306100722.28485-8-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306100722.28485-1-johan+linaro@kernel.org> References: <20230306100722.28485-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add the missing sanity check to handle workqueue allocation failures. Fixes: c8afe684c95c ("drm/msm: basic KMS driver for snapdragon") Cc: stable@vger.kernel.org # 3.12 Cc: Rob Clark Signed-off-by: Johan Hovold Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/msm_drv.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 41cc6cd690cd..ac3b77dbfacc 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -432,6 +432,10 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) priv->dev = ddev; priv->wq = alloc_ordered_workqueue("msm", 0); + if (!priv->wq) { + ret = -ENOMEM; + goto err_put_dev; + } INIT_LIST_HEAD(&priv->objects); mutex_init(&priv->obj_lock); From patchwork Mon Mar 6 10:07:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 659365 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CDD5C61DA4 for ; Mon, 6 Mar 2023 10:09:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230367AbjCFKJh (ORCPT ); Mon, 6 Mar 2023 05:09:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230294AbjCFKJY (ORCPT ); Mon, 6 Mar 2023 05:09:24 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3ED1D50E; Mon, 6 Mar 2023 02:09:21 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A1C82B80D7F; Mon, 6 Mar 2023 10:09:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9E1FC433AF; Mon, 6 Mar 2023 10:09:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678097359; bh=rDU5BreCn1IEiZpcHkbtqMClvnHYxm1xtdxFVkqG/ZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XRnzFwJRsM7C5JKkLY0cAIM6rr+X551YIOBPQwDQ4kz2cds+EO/6tffdt584fcCK5 mXYRABzCvNFHEqCqNa782uGR1cS7+wPf6GY7HpTpBSykWEZuF3p9JpDBeMLD+agAA4 yMmKF4Dbk7CY9qWCH+4RA2p+rA12QtYFxnkhc8RrF4fbzxsFJ+gBva2LUsfWyW9wH9 om/IK7zXzYyEioXi/CWsUixGErL+i0OYoJ9HtNp6yPxavWH4fhNwR0fuudCSi9V9GG Gm57wOshg5aEbyJm7TqxfMVArn6mdreTF56yXAPwv0nIl5VxLfYN8ALBwwmZgFY88z RMc9udy1qWxxw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ7n5-0007Qt-K0; Mon, 06 Mar 2023 11:09:59 +0100 From: Johan Hovold To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov Cc: Sean Paul , David Airlie , Daniel Vetter , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH 08/10] drm/msm: fix workqueue leak on bind errors Date: Mon, 6 Mar 2023 11:07:20 +0100 Message-Id: <20230306100722.28485-9-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306100722.28485-1-johan+linaro@kernel.org> References: <20230306100722.28485-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Make sure to destroy the workqueue also in case of early errors during bind (e.g. a subcomponent failing to bind). Since commit c3b790ea07a1 ("drm: Manage drm_mode_config_init with drmm_") the mode config will be freed when the drm device is released also when using the legacy interface, but add an explicit cleanup for consistency and to facilitate backporting. Fixes: 060530f1ea67 ("drm/msm: use componentised device support") Cc: stable@vger.kernel.org # 3.15 Cc: Rob Clark Signed-off-by: Johan Hovold Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/msm_drv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index ac3b77dbfacc..73c597565f99 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -458,7 +458,7 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) ret = msm_init_vram(ddev); if (ret) - goto err_put_dev; + goto err_cleanup_mode_config; /* Bind all our sub-components: */ ret = component_bind_all(dev, ddev); @@ -563,6 +563,9 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) err_deinit_vram: msm_deinit_vram(ddev); +err_cleanup_mode_config: + drm_mode_config_cleanup(ddev); + destroy_workqueue(priv->wq); err_put_dev: drm_dev_put(ddev); From patchwork Mon Mar 6 10:07:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 659369 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B431C6FD19 for ; Mon, 6 Mar 2023 10:09:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230300AbjCFKJ0 (ORCPT ); Mon, 6 Mar 2023 05:09:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230281AbjCFKJW (ORCPT ); Mon, 6 Mar 2023 05:09:22 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A84E12851; Mon, 6 Mar 2023 02:09:20 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0937260DCF; Mon, 6 Mar 2023 10:09:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0204BC43443; Mon, 6 Mar 2023 10:09:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678097359; bh=3O2+vKPnLHdh79mUXLHW8Z5Q6SqDEjWRNnKKiIQoTyo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IOQ1dpwgPoDXO4aiBJSjYqIBjjTrJvx4ZM6BOucb21+jO367iDOtXc9uMsB2xp22s 4hx3KBEAws9s2wc9vNLId50VtSst4NzGH9V7rJvoFS/A11MUBW02HA+0jHS3yCsr8F x8Y/aK2QG7EHznQ7PU5t4uq4USyZh2NMntJ5LgVYZsEDIuyDW2VQ2sL29UXYFQ/0rl zV0hOYaV8DkkUePYi0FA1WuOr3B40kaUOBF4TREIf44sN1/mBHKdUAmbiO7z1rcTpv XhMP/mfQ5RzYfMB5YoMdxx3xgvawGJmdcqDNPZP6M1+SgwsTs8rBSa9tc5pIioox8j 7eXa/DguDGy/w== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ7n5-0007Qx-NB; Mon, 06 Mar 2023 11:09:59 +0100 From: Johan Hovold To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov Cc: Sean Paul , David Airlie , Daniel Vetter , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 09/10] drm/msm: use drmm_mode_config_init() Date: Mon, 6 Mar 2023 11:07:21 +0100 Message-Id: <20230306100722.28485-10-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306100722.28485-1-johan+linaro@kernel.org> References: <20230306100722.28485-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Switch to using drmm_mode_config_init() so that the mode config is released when the last reference to the DRM device is dropped rather than unconditionally at unbind() (which may be too soon). Signed-off-by: Johan Hovold --- drivers/gpu/drm/msm/msm_drv.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 73c597565f99..ade17947d1e5 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -247,8 +247,6 @@ static int msm_drm_uninit(struct device *dev) if (kms) msm_disp_snapshot_destroy(ddev); - drm_mode_config_cleanup(ddev); - for (i = 0; i < priv->num_bridges; i++) drm_bridge_remove(priv->bridges[i]); priv->num_bridges = 0; @@ -454,11 +452,13 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) might_lock(&priv->lru.lock); fs_reclaim_release(GFP_KERNEL); - drm_mode_config_init(ddev); + ret = drmm_mode_config_init(ddev); + if (ret) + goto err_destroy_wq; ret = msm_init_vram(ddev); if (ret) - goto err_cleanup_mode_config; + goto err_destroy_wq; /* Bind all our sub-components: */ ret = component_bind_all(dev, ddev); @@ -563,8 +563,7 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) err_deinit_vram: msm_deinit_vram(ddev); -err_cleanup_mode_config: - drm_mode_config_cleanup(ddev); +err_destroy_wq: destroy_workqueue(priv->wq); err_put_dev: drm_dev_put(ddev); From patchwork Mon Mar 6 10:07:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 660678 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0A49C6FD1E for ; Mon, 6 Mar 2023 10:09:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230282AbjCFKJ1 (ORCPT ); Mon, 6 Mar 2023 05:09:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230286AbjCFKJW (ORCPT ); Mon, 6 Mar 2023 05:09:22 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FFC7222F1; Mon, 6 Mar 2023 02:09:21 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0B85C60DCB; Mon, 6 Mar 2023 10:09:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14371C43445; Mon, 6 Mar 2023 10:09:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678097359; bh=b151yW+qXdaWwZr+uJKZCMaPRLko8VNYQPQR6bpEA/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CkpNJJsthW0e/lsNOja6kI178cQAVWSxRPwJbe7ITZtDKyFNkVC0OwHWMoVq1Wi0/ 6BhvtipTNV0HHiROwWY7E6EaLKiedZoxV5zlzzNs+mTHAFkuVN893iP1O1K3GJyQi3 VlDEVI45ff/2yTwyIrpuD1Tfri98WoFyyXeAOX3BuAIEnjdNndeb3RomSmR4iN+H0h DZqR399MX86QV7gYtONI5PdqJPsG/oNlxMkNCPfW/rjAy8xuXXsjhptPYN9LBxpLwj 8U8gU8Q3afvyLi+8J8FOETfZGBBNWhLBbdqD43+0DIIfW9sexuM+hjmIafGEedRj7D n9PhgmHrzhLIg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ7n5-0007R0-Q4; Mon, 06 Mar 2023 11:09:59 +0100 From: Johan Hovold To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov Cc: Sean Paul , David Airlie , Daniel Vetter , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 10/10] drm/msm: move include directive Date: Mon, 6 Mar 2023 11:07:22 +0100 Message-Id: <20230306100722.28485-11-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306100722.28485-1-johan+linaro@kernel.org> References: <20230306100722.28485-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Move the include of of_address.h to the top of the file where it belongs. Signed-off-by: Johan Hovold Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/msm_drv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index ade17947d1e5..42ae7575622b 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -272,8 +273,6 @@ static int msm_drm_uninit(struct device *dev) return 0; } -#include - struct msm_gem_address_space *msm_kms_init_aspace(struct drm_device *dev) { struct msm_gem_address_space *aspace;