From patchwork Sat Oct 1 14:57:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 12996543 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CE868C4332F for ; Sat, 1 Oct 2022 14:58:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C0E8A10E405; Sat, 1 Oct 2022 14:58:20 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id DD63210E405 for ; Sat, 1 Oct 2022 14:58:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664636294; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d5wQaZFEzn9uIXApEc4pGB3KbziveTZ08VHPOZH9w9g=; b=JnRDFXGmsVqZC75GSwYLkWVwteYkdvvNGwLjPMgvff9x/oadCdxFievaWGcVw0kHV9zA5B jlNqcatQkH1k+UOfMVgwH2VjLoc2QaDs6v/Ir8mezrkz6jeeqACeplsXjTE8klnhqSWGsK c/xC0nSs7ROPQHI6oilW6mcg/+6xeLw= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-107-5ikvhEB7PFy4oWeKtgi2rw-1; Sat, 01 Oct 2022 10:58:12 -0400 X-MC-Unique: 5ikvhEB7PFy4oWeKtgi2rw-1 Received: by mail-ed1-f70.google.com with SMTP id y9-20020a056402270900b00451dfbbc9b2so5601965edd.12 for ; Sat, 01 Oct 2022 07:58:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=d5wQaZFEzn9uIXApEc4pGB3KbziveTZ08VHPOZH9w9g=; b=PXILOfnmkNlx1VYnBfY04Yd7q+eoVvp5YevEdvYGVOXE97ur1XlnzLOSInvlBKW6ux NHtKc7Zlu9YmiSIxS7QBVA1vvPEnpnEBTXZSDqAGTB7YBARhRKKRgstvXaIJuyqAyAvN dxH8GByh4n9lxfJCGNboXYZMzQ4qQeLxGxE6oSkHCTla01UyT8+9AGCCLxtK1eeSzpWh 2cuDnXT+iIyag7nSSTjXOCyX9AwTxdX3Sq2UE2+pf4Odm6crsDLlXG2LMgOoAj9zfIxf nqnm7D6WB+dbNME7Qq6dK+4WBejuC6UnlyoDG3PXyzVj9BOsRQI8PK5edK9ArhRtH0xR 9/sg== X-Gm-Message-State: ACrzQf2dat9wwWfDhadKF8jgqS2mKRRoprJUbtXDbez1Bnfr+xLF88JL sUWuUi7SxIWuVED5K8cEYEg5tiaReIx6PTYIdgsaG6dNRWwGG2YbOUHneelPTS8PFs8rHPwDfzu mQCLdM7gYqEY4C5pqYHAUAZy+I6gu X-Received: by 2002:aa7:cd4f:0:b0:458:6077:c3ac with SMTP id v15-20020aa7cd4f000000b004586077c3acmr8383496edw.32.1664636291371; Sat, 01 Oct 2022 07:58:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5quDAMs15O1EjA+ONIf+6V51idpelHTXT3LBeScuciqSA9637lLszp8q/Y+fE9d7gydpiI7A== X-Received: by 2002:aa7:cd4f:0:b0:458:6077:c3ac with SMTP id v15-20020aa7cd4f000000b004586077c3acmr8383476edw.32.1664636291177; Sat, 01 Oct 2022 07:58:11 -0700 (PDT) Received: from pollux.redhat.com ([2a02:810d:4b40:2ee8:642:1aff:fe31:a15c]) by smtp.gmail.com with ESMTPSA id q1-20020a17090609a100b00772b5835c12sm2841964eje.23.2022.10.01.07.58.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Oct 2022 07:58:10 -0700 (PDT) From: Danilo Krummrich To: daniel@ffwll.ch, airlied@linux.ie, tzimmermann@suse.de, mripard@kernel.org, stefan@agner.ch, alison.wang@nxp.com Subject: [PATCH drm-misc-next v2 1/9] drm/fsl-dcu: use drmm_* to allocate driver structures Date: Sat, 1 Oct 2022 16:57:54 +0200 Message-Id: <20221001145802.515916-2-dakr@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221001145802.515916-1-dakr@redhat.com> References: <20221001145802.515916-1-dakr@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Danilo Krummrich , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use drm managed resources to allocate driver structures and get rid of the deprecated drm_dev_alloc() call and replace it with devm_drm_dev_alloc(). This also serves as preparation to get rid of drm_device->dev_private and to fix use-after-free issues on driver unload. Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c | 7 ++--- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 30 +++++++++------------- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h | 2 +- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.c | 19 +++++++------- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c | 8 +++--- 5 files changed, 31 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c index 2af60d98f48f..a1b8ce70928a 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c @@ -171,15 +171,16 @@ int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev) { struct drm_plane *primary; struct drm_crtc *crtc = &fsl_dev->crtc; + struct drm_device *drm = &fsl_dev->base; int ret; - fsl_dcu_drm_init_planes(fsl_dev->drm); + fsl_dcu_drm_init_planes(drm); - primary = fsl_dcu_drm_primary_create_plane(fsl_dev->drm); + primary = fsl_dcu_drm_primary_create_plane(drm); if (!primary) return -ENOMEM; - ret = drm_crtc_init_with_planes(fsl_dev->drm, crtc, primary, NULL, + ret = drm_crtc_init_with_planes(drm, crtc, primary, NULL, &fsl_dcu_drm_crtc_funcs, NULL); if (ret) { primary->funcs->destroy(primary); diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c index b4acc3422ba4..a47b72995fcf 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c @@ -168,6 +168,7 @@ static const struct drm_driver fsl_dcu_drm_driver = { static int fsl_dcu_drm_pm_suspend(struct device *dev) { struct fsl_dcu_drm_device *fsl_dev = dev_get_drvdata(dev); + struct drm_device *drm = &fsl_dev->base; int ret; if (!fsl_dev) @@ -175,7 +176,7 @@ static int fsl_dcu_drm_pm_suspend(struct device *dev) disable_irq(fsl_dev->irq); - ret = drm_mode_config_helper_suspend(fsl_dev->drm); + ret = drm_mode_config_helper_suspend(drm); if (ret) { enable_irq(fsl_dev->irq); return ret; @@ -189,6 +190,7 @@ static int fsl_dcu_drm_pm_suspend(struct device *dev) static int fsl_dcu_drm_pm_resume(struct device *dev) { struct fsl_dcu_drm_device *fsl_dev = dev_get_drvdata(dev); + struct drm_device *drm = &fsl_dev->base; int ret; if (!fsl_dev) @@ -202,10 +204,10 @@ static int fsl_dcu_drm_pm_resume(struct device *dev) if (fsl_dev->tcon) fsl_tcon_bypass_enable(fsl_dev->tcon); - fsl_dcu_drm_init_planes(fsl_dev->drm); + fsl_dcu_drm_init_planes(drm); enable_irq(fsl_dev->irq); - drm_mode_config_helper_resume(fsl_dev->drm); + drm_mode_config_helper_resume(drm); return 0; } @@ -255,9 +257,10 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev) int ret; u8 div_ratio_shift = 0; - fsl_dev = devm_kzalloc(dev, sizeof(*fsl_dev), GFP_KERNEL); - if (!fsl_dev) - return -ENOMEM; + fsl_dev = devm_drm_dev_alloc(dev, &fsl_dcu_drm_driver, + typeof(*fsl_dev), base); + if (IS_ERR(fsl_dev)) + return PTR_ERR(fsl_dev); id = of_match_node(fsl_dcu_of_match, pdev->dev.of_node); if (!id) @@ -317,28 +320,19 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev) fsl_dev->tcon = fsl_tcon_init(dev); - drm = drm_dev_alloc(&fsl_dcu_drm_driver, dev); - if (IS_ERR(drm)) { - ret = PTR_ERR(drm); - goto unregister_pix_clk; - } - fsl_dev->dev = dev; - fsl_dev->drm = drm; fsl_dev->np = dev->of_node; drm->dev_private = fsl_dev; dev_set_drvdata(dev, fsl_dev); ret = drm_dev_register(drm, 0); if (ret < 0) - goto put; + goto unregister_pix_clk; drm_fbdev_generic_setup(drm, legacyfb_depth); return 0; -put: - drm_dev_put(drm); unregister_pix_clk: clk_unregister(fsl_dev->pix_clk); disable_clk: @@ -349,9 +343,9 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev) static int fsl_dcu_drm_remove(struct platform_device *pdev) { struct fsl_dcu_drm_device *fsl_dev = platform_get_drvdata(pdev); + struct drm_device *drm = &fsl_dev->base; - drm_dev_unregister(fsl_dev->drm); - drm_dev_put(fsl_dev->drm); + drm_dev_unregister(drm); clk_disable_unprepare(fsl_dev->clk); clk_unregister(fsl_dev->pix_clk); diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h index e2049a0e8a92..20ca13ff618a 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h @@ -177,6 +177,7 @@ struct fsl_dcu_soc_data { }; struct fsl_dcu_drm_device { + struct drm_device base; struct device *dev; struct device_node *np; struct regmap *regmap; @@ -186,7 +187,6 @@ struct fsl_dcu_drm_device { struct fsl_tcon *tcon; /*protects hardware register*/ spinlock_t irq_lock; - struct drm_device *drm; struct drm_crtc crtc; struct drm_encoder encoder; struct fsl_dcu_drm_connector connector; diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.c index 5b47000738e4..c3d55c0aca9f 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.c @@ -20,15 +20,16 @@ static const struct drm_mode_config_funcs fsl_dcu_drm_mode_config_funcs = { int fsl_dcu_drm_modeset_init(struct fsl_dcu_drm_device *fsl_dev) { + struct drm_device *drm = &fsl_dev->base; int ret; - drm_mode_config_init(fsl_dev->drm); + drm_mode_config_init(drm); - fsl_dev->drm->mode_config.min_width = 0; - fsl_dev->drm->mode_config.min_height = 0; - fsl_dev->drm->mode_config.max_width = 2031; - fsl_dev->drm->mode_config.max_height = 2047; - fsl_dev->drm->mode_config.funcs = &fsl_dcu_drm_mode_config_funcs; + drm->mode_config.min_width = 0; + drm->mode_config.min_height = 0; + drm->mode_config.max_width = 2031; + drm->mode_config.max_height = 2047; + drm->mode_config.funcs = &fsl_dcu_drm_mode_config_funcs; ret = fsl_dcu_drm_crtc_create(fsl_dev); if (ret) @@ -42,12 +43,12 @@ int fsl_dcu_drm_modeset_init(struct fsl_dcu_drm_device *fsl_dev) if (ret) goto err; - drm_mode_config_reset(fsl_dev->drm); - drm_kms_helper_poll_init(fsl_dev->drm); + drm_mode_config_reset(drm); + drm_kms_helper_poll_init(drm); return 0; err: - drm_mode_config_cleanup(fsl_dev->drm); + drm_mode_config_cleanup(drm); return ret; } diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c index 4d4a715b429d..b9b02f617cd2 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c @@ -22,6 +22,7 @@ int fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev, struct drm_crtc *crtc) { struct drm_encoder *encoder = &fsl_dev->encoder; + struct drm_device *drm = &fsl_dev->base; int ret; encoder->possible_crtcs = 1; @@ -30,8 +31,7 @@ int fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev, if (fsl_dev->tcon) fsl_tcon_bypass_enable(fsl_dev->tcon); - ret = drm_simple_encoder_init(fsl_dev->drm, encoder, - DRM_MODE_ENCODER_LVDS); + ret = drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_LVDS); if (ret < 0) return ret; @@ -79,12 +79,12 @@ static int fsl_dcu_attach_panel(struct fsl_dcu_drm_device *fsl_dev, { struct drm_encoder *encoder = &fsl_dev->encoder; struct drm_connector *connector = &fsl_dev->connector.base; + struct drm_device *drm = &fsl_dev->base; int ret; fsl_dev->connector.encoder = encoder; - ret = drm_connector_init(fsl_dev->drm, connector, - &fsl_dcu_drm_connector_funcs, + ret = drm_connector_init(drm, connector, &fsl_dcu_drm_connector_funcs, DRM_MODE_CONNECTOR_LVDS); if (ret < 0) return ret; From patchwork Sat Oct 1 14:57:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 12996544 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A6AEEC4332F for ; Sat, 1 Oct 2022 14:58:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AC7AD10E46A; Sat, 1 Oct 2022 14:58:25 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0B24710E405 for ; Sat, 1 Oct 2022 14:58:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664636297; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H68P8iepWfLJpYbHEar6qJMBNCk2+2oF4KGUobttlNs=; b=VuxtWRztgPv6Tbo85uKG+JCJrrj9Qy3zFz28OzrJuQNmIr4bpWi96ElQ5KOFjHqK7iV+We 25UBjKff3SNJnzN/QoDMzsA39xois2XwuxEI0FnUNIJuWJm/EiK1P8EZycd3fqBjncv8eW 5XQejbre2e9iYWDRVT2sVR6KG2rUXuY= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-611-Jofvsy2_M1upsdonSygREg-1; Sat, 01 Oct 2022 10:58:16 -0400 X-MC-Unique: Jofvsy2_M1upsdonSygREg-1 Received: by mail-ed1-f70.google.com with SMTP id s17-20020a056402521100b004511c8d59e3so5669217edd.11 for ; Sat, 01 Oct 2022 07:58:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=H68P8iepWfLJpYbHEar6qJMBNCk2+2oF4KGUobttlNs=; b=Vx+7KAy8YGGvC0ti3snqCe+RYLnIpcUAGA6QfgB2BQUnkm4Gi9cbAN5h2Bl9ul5lkX lOSL9JsAgsz/o00918SgR2VAaQxZxQ0b49Rx3cHNbzHbQ34BG9C1kyQhcQQWxNCO7bH9 rAESij5U5ZfisocHqHrmVOAYqtrsbSurdkHhlaC9JJX59Al3YsjbQQi3c++yU9+1UMgn cWci1o5jqUVSZzcjX40cw8q/aL9mSsB92CMMTHpuVpT/lCCscFwMHewWY5ytqacdtIXj lP6A5ZzvdJaJ9l7cDRiyWGmdh5HAU12IIuSCJUYYNZAryXtHSdZ1IcHneKkD9sroIiHV c5TQ== X-Gm-Message-State: ACrzQf3zHQugLc7rVRxGHJCOeHWlmur/R/81w81OCsJZoEEf071xjw40 JnKuRkNjelNLGiOAoHlxwN3S/zOTE1T2YpS4gugq9w9OaMqxBBTtL5oCObDbZ2t6dJwTXQDhL55 bFVkZDO2PqNcH5KhJt2uqMQTsgklg X-Received: by 2002:a17:907:1607:b0:788:799e:dc97 with SMTP id hb7-20020a170907160700b00788799edc97mr4561646ejc.747.1664636295093; Sat, 01 Oct 2022 07:58:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5VJBdJUX0WjKukx6WE4HACChCOch/Y067lt40Lp/eZFkvVlX4nIZuEOa8HPfaHF1kX200UDQ== X-Received: by 2002:a17:907:1607:b0:788:799e:dc97 with SMTP id hb7-20020a170907160700b00788799edc97mr4561641ejc.747.1664636294860; Sat, 01 Oct 2022 07:58:14 -0700 (PDT) Received: from pollux.redhat.com ([2a02:810d:4b40:2ee8:642:1aff:fe31:a15c]) by smtp.gmail.com with ESMTPSA id p20-20020a1709066a9400b0072f112a6ad2sm2805616ejr.97.2022.10.01.07.58.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Oct 2022 07:58:14 -0700 (PDT) From: Danilo Krummrich To: daniel@ffwll.ch, airlied@linux.ie, tzimmermann@suse.de, mripard@kernel.org, stefan@agner.ch, alison.wang@nxp.com Subject: [PATCH drm-misc-next v2 2/9] drm/fsl-dcu: replace drm->dev_private with drm_to_fsl_dcu_drm_dev() Date: Sat, 1 Oct 2022 16:57:55 +0200 Message-Id: <20221001145802.515916-3-dakr@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221001145802.515916-1-dakr@redhat.com> References: <20221001145802.515916-1-dakr@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Danilo Krummrich , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Using drm_device->dev_private is deprecated. Since we've switched to devm_drm_dev_alloc(), struct drm_device is now embedded in struct malidp_drm, hence we can use container_of() to get the struct drm_device instance instead. Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c | 12 ++++++------ drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 13 ++++--------- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h | 2 ++ drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c | 8 ++++---- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c index a1b8ce70928a..e05311e2b0e0 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c @@ -24,7 +24,7 @@ static void fsl_dcu_drm_crtc_atomic_flush(struct drm_crtc *crtc, struct drm_atomic_state *state) { struct drm_device *dev = crtc->dev; - struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; + struct fsl_dcu_drm_device *fsl_dev = drm_to_fsl_dcu_drm_dev(dev); struct drm_pending_vblank_event *event = crtc->state->event; regmap_write(fsl_dev->regmap, @@ -48,7 +48,7 @@ static void fsl_dcu_drm_crtc_atomic_disable(struct drm_crtc *crtc, struct drm_crtc_state *old_crtc_state = drm_atomic_get_old_crtc_state(state, crtc); struct drm_device *dev = crtc->dev; - struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; + struct fsl_dcu_drm_device *fsl_dev = drm_to_fsl_dcu_drm_dev(dev); /* always disable planes on the CRTC */ drm_atomic_helper_disable_planes_on_crtc(old_crtc_state, true); @@ -67,7 +67,7 @@ static void fsl_dcu_drm_crtc_atomic_enable(struct drm_crtc *crtc, struct drm_atomic_state *state) { struct drm_device *dev = crtc->dev; - struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; + struct fsl_dcu_drm_device *fsl_dev = drm_to_fsl_dcu_drm_dev(dev); clk_prepare_enable(fsl_dev->pix_clk); regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE, @@ -82,7 +82,7 @@ static void fsl_dcu_drm_crtc_atomic_enable(struct drm_crtc *crtc, static void fsl_dcu_drm_crtc_mode_set_nofb(struct drm_crtc *crtc) { struct drm_device *dev = crtc->dev; - struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; + struct fsl_dcu_drm_device *fsl_dev = drm_to_fsl_dcu_drm_dev(dev); struct drm_connector *con = &fsl_dev->connector.base; struct drm_display_mode *mode = &crtc->state->mode; unsigned int pol = 0; @@ -135,7 +135,7 @@ static const struct drm_crtc_helper_funcs fsl_dcu_drm_crtc_helper_funcs = { static int fsl_dcu_drm_crtc_enable_vblank(struct drm_crtc *crtc) { struct drm_device *dev = crtc->dev; - struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; + struct fsl_dcu_drm_device *fsl_dev = drm_to_fsl_dcu_drm_dev(dev); unsigned int value; regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value); @@ -148,7 +148,7 @@ static int fsl_dcu_drm_crtc_enable_vblank(struct drm_crtc *crtc) static void fsl_dcu_drm_crtc_disable_vblank(struct drm_crtc *crtc) { struct drm_device *dev = crtc->dev; - struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; + struct fsl_dcu_drm_device *fsl_dev = drm_to_fsl_dcu_drm_dev(dev); unsigned int value; regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value); diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c index a47b72995fcf..4139f674c5de 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c @@ -52,7 +52,7 @@ static const struct regmap_config fsl_dcu_regmap_config = { static void fsl_dcu_irq_reset(struct drm_device *dev) { - struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; + struct fsl_dcu_drm_device *fsl_dev = drm_to_fsl_dcu_drm_dev(dev); regmap_write(fsl_dev->regmap, DCU_INT_STATUS, ~0); regmap_write(fsl_dev->regmap, DCU_INT_MASK, ~0); @@ -61,7 +61,7 @@ static void fsl_dcu_irq_reset(struct drm_device *dev) static irqreturn_t fsl_dcu_drm_irq(int irq, void *arg) { struct drm_device *dev = arg; - struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; + struct fsl_dcu_drm_device *fsl_dev = drm_to_fsl_dcu_drm_dev(dev); unsigned int int_status; int ret; @@ -91,7 +91,7 @@ static int fsl_dcu_irq_install(struct drm_device *dev, unsigned int irq) static void fsl_dcu_irq_uninstall(struct drm_device *dev) { - struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; + struct fsl_dcu_drm_device *fsl_dev = drm_to_fsl_dcu_drm_dev(dev); fsl_dcu_irq_reset(dev); free_irq(fsl_dev->irq, dev); @@ -99,7 +99,7 @@ static void fsl_dcu_irq_uninstall(struct drm_device *dev) static int fsl_dcu_load(struct drm_device *dev, unsigned long flags) { - struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; + struct fsl_dcu_drm_device *fsl_dev = drm_to_fsl_dcu_drm_dev(dev); int ret; ret = fsl_dcu_drm_modeset_init(fsl_dev); @@ -133,8 +133,6 @@ static int fsl_dcu_load(struct drm_device *dev, unsigned long flags) drm_mode_config_cleanup(dev); done_vblank: - dev->dev_private = NULL; - return ret; } @@ -145,8 +143,6 @@ static void fsl_dcu_unload(struct drm_device *dev) drm_mode_config_cleanup(dev); fsl_dcu_irq_uninstall(dev); - - dev->dev_private = NULL; } DEFINE_DRM_GEM_DMA_FOPS(fsl_dcu_drm_fops); @@ -322,7 +318,6 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev) fsl_dev->dev = dev; fsl_dev->np = dev->of_node; - drm->dev_private = fsl_dev; dev_set_drvdata(dev, fsl_dev); ret = drm_dev_register(drm, 0); diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h index 20ca13ff618a..5b61d443da96 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h @@ -193,6 +193,8 @@ struct fsl_dcu_drm_device { const struct fsl_dcu_soc_data *soc; }; +#define drm_to_fsl_dcu_drm_dev(x) container_of(x, struct fsl_dcu_drm_device, base) + int fsl_dcu_drm_modeset_init(struct fsl_dcu_drm_device *fsl_dev); #endif /* __FSL_DCU_DRM_DRV_H__ */ diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c index 794a87d16f88..91865956da02 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c @@ -22,7 +22,7 @@ static int fsl_dcu_drm_plane_index(struct drm_plane *plane) { - struct fsl_dcu_drm_device *fsl_dev = plane->dev->dev_private; + struct fsl_dcu_drm_device *fsl_dev = drm_to_fsl_dcu_drm_dev(plane->dev); unsigned int total_layer = fsl_dev->soc->total_layer; unsigned int index; @@ -63,7 +63,7 @@ static int fsl_dcu_drm_plane_atomic_check(struct drm_plane *plane, static void fsl_dcu_drm_plane_atomic_disable(struct drm_plane *plane, struct drm_atomic_state *state) { - struct fsl_dcu_drm_device *fsl_dev = plane->dev->dev_private; + struct fsl_dcu_drm_device *fsl_dev = drm_to_fsl_dcu_drm_dev(plane->dev); unsigned int value; int index; @@ -80,7 +80,7 @@ static void fsl_dcu_drm_plane_atomic_update(struct drm_plane *plane, struct drm_atomic_state *state) { - struct fsl_dcu_drm_device *fsl_dev = plane->dev->dev_private; + struct fsl_dcu_drm_device *fsl_dev = drm_to_fsl_dcu_drm_dev(plane->dev); struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane); struct drm_framebuffer *fb = plane->state->fb; @@ -194,7 +194,7 @@ static const u32 fsl_dcu_drm_plane_formats[] = { void fsl_dcu_drm_init_planes(struct drm_device *dev) { - struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; + struct fsl_dcu_drm_device *fsl_dev = drm_to_fsl_dcu_drm_dev(dev); int i, j; for (i = 0; i < fsl_dev->soc->total_layer; i++) { From patchwork Sat Oct 1 14:57:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 12996545 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2FAD8C433FE for ; Sat, 1 Oct 2022 14:58:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A7F8910E5C9; Sat, 1 Oct 2022 14:58:28 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id E59D110E40B for ; Sat, 1 Oct 2022 14:58:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664636301; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xaw3iUtMLKwH2xCvo5P17z6DGidg5D+TvENUAVXK2ek=; b=V7P63kD+Nw81eF0XxMKLp2BS7t+13/8Cf++yR5mJEolo+jhlonxKwXL0lBoXpRTCjeUfg5 wMeRRrejGEKnX/NlCDrQvowDsfH5SKc2yYFXhFJK24qagHOIdlYfDYloNmK6WG7o/Pqsnj 7vl978VlOeiqsVBpEgeD/ZJoNdxT4P8= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-201-QcbulKGbOf6-mTpmYPIP7g-1; Sat, 01 Oct 2022 10:58:19 -0400 X-MC-Unique: QcbulKGbOf6-mTpmYPIP7g-1 Received: by mail-ed1-f69.google.com with SMTP id e15-20020a056402190f00b0044f41e776a0so5609758edz.0 for ; Sat, 01 Oct 2022 07:58:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Xaw3iUtMLKwH2xCvo5P17z6DGidg5D+TvENUAVXK2ek=; b=vRz0HdG76zEkJqp4i2gPV06zEREGj9RyAeXYf1PnKA+r+LV43lO65WveRBAZMICnWf TMtRg0SL136s+idUSp42DJ276R77EHjYv3fzCWuzN9cwfMtxqEUronNGjQNMnjD6uw+t KjJuYpapqTyq+rV1SzM9lMmycE60esHGaLVgFdqZyowhYWr5vSPQN20yP8B3UiPm5mSb zDiTT/LP4vz2arnDk7+Ccbiv5dTPxVyrCx48SarUum9zr0Qo0vUfPBIfAFAJTNjeC/75 GiPmZY73r8eGhqQapUqJmyCOuwRyNtF0LJ8jQnAE6gTzE1RUhb6jisyWfbEqke3DBSIM XrSA== X-Gm-Message-State: ACrzQf2cvjJ2sE0DaXHX4jJyhbK7MnJ2vjCiAgdEZOGTK5k7UAgzS78U hcZjLKX2+btezF5YAllqDEEnKpLvVvn09cXnbAfZw+DN8m84TYvjoKpdKvcqm3B7TuKOd1I460n hK7Oe/MSOZ1935oSOvi3ih0LE9+GB X-Received: by 2002:a17:907:3e03:b0:722:e694:438 with SMTP id hp3-20020a1709073e0300b00722e6940438mr9931980ejc.755.1664636298702; Sat, 01 Oct 2022 07:58:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6McnwQbh25ByTVLN8VQt9u6fQvaQzvbsTHh1j6XxDmkF9GAiQCD/6b0HFlFj3pU/ONxJXXjQ== X-Received: by 2002:a17:907:3e03:b0:722:e694:438 with SMTP id hp3-20020a1709073e0300b00722e6940438mr9931973ejc.755.1664636298531; Sat, 01 Oct 2022 07:58:18 -0700 (PDT) Received: from pollux.redhat.com ([2a02:810d:4b40:2ee8:642:1aff:fe31:a15c]) by smtp.gmail.com with ESMTPSA id q21-20020a17090676d500b0072af4af2f46sm2816338ejn.74.2022.10.01.07.58.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Oct 2022 07:58:18 -0700 (PDT) From: Danilo Krummrich To: daniel@ffwll.ch, airlied@linux.ie, tzimmermann@suse.de, mripard@kernel.org, stefan@agner.ch, alison.wang@nxp.com Subject: [PATCH drm-misc-next v2 3/9] drm/fsl-dcu: crtc: use drmm_crtc_init_with_planes() Date: Sat, 1 Oct 2022 16:57:56 +0200 Message-Id: <20221001145802.515916-4-dakr@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221001145802.515916-1-dakr@redhat.com> References: <20221001145802.515916-1-dakr@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Danilo Krummrich , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use drmm_crtc_init_with_planes() instead of drm_crtc_init_with_planes() to get rid of the explicit destroy hook in struct drm_plane_funcs. Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c index e05311e2b0e0..0b70624260fc 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c @@ -159,7 +159,6 @@ static void fsl_dcu_drm_crtc_disable_vblank(struct drm_crtc *crtc) static const struct drm_crtc_funcs fsl_dcu_drm_crtc_funcs = { .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, - .destroy = drm_crtc_cleanup, .page_flip = drm_atomic_helper_page_flip, .reset = drm_atomic_helper_crtc_reset, .set_config = drm_atomic_helper_set_config, @@ -180,8 +179,8 @@ int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev) if (!primary) return -ENOMEM; - ret = drm_crtc_init_with_planes(drm, crtc, primary, NULL, - &fsl_dcu_drm_crtc_funcs, NULL); + ret = drmm_crtc_init_with_planes(drm, crtc, primary, NULL, + &fsl_dcu_drm_crtc_funcs, NULL); if (ret) { primary->funcs->destroy(primary); return ret; From patchwork Sat Oct 1 14:57:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 12996546 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C8DECC433F5 for ; Sat, 1 Oct 2022 14:58:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 033B010E40B; Sat, 1 Oct 2022 14:58:34 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6E18C10E5C9 for ; Sat, 1 Oct 2022 14:58:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664636305; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OuGypoVnJNhzQ829OSUgv+IQ/uot1AKSMTgWYQGrHy8=; b=RDWTtjoluaYFPWRekYrQlHvK5UB3V3HOcdgNQMV4VUPjN5tWPPnsYnsqfdWmCYQ4HAGITl 4HzC9OMf3AD1zrWqF0deRAzlfkObl7fSBABIM6MGFOqcn5qB8rHNiWAoW3UrI1aJfxEiBm oSf0ISv42VTnbmWN6B3L+b2lbabiOi0= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-458-yLv-o96jMWSLNaOyBd1Ndg-1; Sat, 01 Oct 2022 10:58:24 -0400 X-MC-Unique: yLv-o96jMWSLNaOyBd1Ndg-1 Received: by mail-ed1-f69.google.com with SMTP id v11-20020a056402348b00b004516e0b7eedso5622400edc.8 for ; Sat, 01 Oct 2022 07:58:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=OuGypoVnJNhzQ829OSUgv+IQ/uot1AKSMTgWYQGrHy8=; b=deD/MCjbuwNl4/h0bKnrcuLmCh48MDPgAOfTFeEJbEPMvMB9eFDuSbAfJ7n0SCrNMX QOwzMoBVknTcp/3tPU0E99b3VsWlSLPMLTCxyfTdOJ9ZXA86nIjIxGvhwAHOkqMyxwjA sKi6UuLqZajnPN0WAHMXc1KNVI5hA6QCLox7xL7WCzvuOR3dQEDNJTIi68CN9wkSlSOk zAdbbFOeZts+F+AZjtZvuQSuC7qOKGZLNqRHsiWJVqh8tmx7uoNda7G2BAD1dL8nrfI9 EE8xvomX/N9oQG6yn47OG4HybZBET6DjFoZII5Koj9/wIKChe0xdMk3hZYTk6lebdBAL iaeg== X-Gm-Message-State: ACrzQf1Ir0WHBX/GR/iY0HmrpgtCmmGOFHZdcRocMye6exXxefcqUJOb OBlnKnde4bBPCO2yWrdG+MalzgRvg0I6Tv25W+kEZFpojsb8nSxI1x8uYoBsh60RBIrXN4vimu4 e0ICGvCDZ6el6IyLZhAcMAH3Pk0l3 X-Received: by 2002:a17:907:75c6:b0:788:e57b:e809 with SMTP id jl6-20020a17090775c600b00788e57be809mr3735263ejc.381.1664636302381; Sat, 01 Oct 2022 07:58:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6tYvJN/BoUijgGJpiQA9gruyLcr6e+s4NgjahO10nZI7Z+Sz0VARMJ4HyrIlczlfiZU4mzZw== X-Received: by 2002:a17:907:75c6:b0:788:e57b:e809 with SMTP id jl6-20020a17090775c600b00788e57be809mr3735257ejc.381.1664636302172; Sat, 01 Oct 2022 07:58:22 -0700 (PDT) Received: from pollux.redhat.com ([2a02:810d:4b40:2ee8:642:1aff:fe31:a15c]) by smtp.gmail.com with ESMTPSA id y8-20020a056402358800b0044dbecdcd29sm3761029edc.12.2022.10.01.07.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Oct 2022 07:58:21 -0700 (PDT) From: Danilo Krummrich To: daniel@ffwll.ch, airlied@linux.ie, tzimmermann@suse.de, mripard@kernel.org, stefan@agner.ch, alison.wang@nxp.com Subject: [PATCH drm-misc-next v2 4/9] drm/fsl-dcu: plane: use drm managed resources Date: Sat, 1 Oct 2022 16:57:57 +0200 Message-Id: <20221001145802.515916-5-dakr@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221001145802.515916-1-dakr@redhat.com> References: <20221001145802.515916-1-dakr@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Danilo Krummrich , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use drm managed resource allocation (drmm_universal_plane_alloc()) in order to get rid of the explicit destroy hook in struct drm_plane_funcs. Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c | 4 ++-- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c | 25 ++++++++------------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c index 0b70624260fc..1dad90f701c8 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c @@ -176,8 +176,8 @@ int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev) fsl_dcu_drm_init_planes(drm); primary = fsl_dcu_drm_primary_create_plane(drm); - if (!primary) - return -ENOMEM; + if (IS_ERR(primary)) + return PTR_ERR(primary); ret = drmm_crtc_init_with_planes(drm, crtc, primary, NULL, &fsl_dcu_drm_crtc_funcs, NULL); diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c index 91865956da02..23ff285da477 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c @@ -174,7 +174,6 @@ static const struct drm_plane_helper_funcs fsl_dcu_drm_plane_helper_funcs = { static const struct drm_plane_funcs fsl_dcu_drm_plane_funcs = { .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, - .destroy = drm_plane_helper_destroy, .disable_plane = drm_atomic_helper_disable_plane, .reset = drm_atomic_helper_plane_reset, .update_plane = drm_atomic_helper_update_plane, @@ -206,24 +205,18 @@ void fsl_dcu_drm_init_planes(struct drm_device *dev) struct drm_plane *fsl_dcu_drm_primary_create_plane(struct drm_device *dev) { struct drm_plane *primary; - int ret; - - primary = kzalloc(sizeof(*primary), GFP_KERNEL); - if (!primary) { - DRM_DEBUG_KMS("Failed to allocate primary plane\n"); - return NULL; - } /* possible_crtc's will be filled in later by crtc_init */ - ret = drm_universal_plane_init(dev, primary, 0, - &fsl_dcu_drm_plane_funcs, - fsl_dcu_drm_plane_formats, - ARRAY_SIZE(fsl_dcu_drm_plane_formats), - NULL, DRM_PLANE_TYPE_PRIMARY, NULL); - if (ret) { - kfree(primary); - primary = NULL; + primary = drmm_universal_plane_alloc(dev, struct drm_plane, dev, 0, + &fsl_dcu_drm_plane_funcs, + fsl_dcu_drm_plane_formats, + ARRAY_SIZE(fsl_dcu_drm_plane_formats), + NULL, DRM_PLANE_TYPE_PRIMARY, NULL); + if (IS_ERR(primary)) { + DRM_DEBUG_KMS("Failed to create primary plane\n"); + return primary; } + drm_plane_helper_add(primary, &fsl_dcu_drm_plane_helper_funcs); return primary; From patchwork Sat Oct 1 14:57:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 12996547 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DA5B3C433F5 for ; Sat, 1 Oct 2022 14:58:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7D6CA10E638; Sat, 1 Oct 2022 14:58:35 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id F352B10E638 for ; Sat, 1 Oct 2022 14:58:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664636308; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AJ+r++kfC5cLOYGbcZ2ityl6Btvuyg0jJylQkWmqY/s=; b=Aws1LkqsAAqJaGtG9DxIjd5Xrki4gfUb8zZZNTtBNkHFCwrIZS2X5I3XikO5RYOYcQTi1c yDE9z450iiaYFuSMxZzvI6tfYT7kwzxMTmckbCbzRaz3bVxsZp3s1xF2yT9o35JHHTCBoD HgG4Kza8s9vqicWJop1pAJ+E4sPVWCY= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-326-OhB-yn8FN5GEN-Lm62AF9Q-1; Sat, 01 Oct 2022 10:58:27 -0400 X-MC-Unique: OhB-yn8FN5GEN-Lm62AF9Q-1 Received: by mail-ej1-f71.google.com with SMTP id hr29-20020a1709073f9d00b0078333782c48so2524030ejc.10 for ; Sat, 01 Oct 2022 07:58:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=AJ+r++kfC5cLOYGbcZ2ityl6Btvuyg0jJylQkWmqY/s=; b=Yv2HzIoqV/MnlKuIz+Kcw0uQmnF55YiZfvah2PzhRjMwMm7kEh7/1mVm0hb1NDGOIS hH37ZV9nNi2vxShTy1zsqTkL9hrb54kzU+BG3TOhrUKdtroX2/g4vSDUkE0V/Ns6pZEs JiRNr8Uk4T5gNKJ1aWcvcmuYLedBOoKy+lKrMtuonuGqg6QdwvqHjbwhG+auC89VuYu1 8cOVsVGUq/J1nEofm4U0l7bxfSX2Y/RGKv3oXViZrfFTQekHkRRvtQc9gGvOfrgaxSfl whY4RruTQqDprDFKugzTPFvW6m1eap2Rbm7QAYHSoX93unfIYRlF5+V5krpIH+DO8L56 E3EA== X-Gm-Message-State: ACrzQf2zrGqtI33lsvMEBsuCIqi8S9xyRYRdrdXJrnMXYpNxpDKhPxin ZRk6gyeJugqT843G0JcNP/nyG98i/G7UWY2nIv7Cl+ZcbQ7kpVzHdCAd/qyOSir8uU+n4oZXGdY vX9BUq3w1snvbeWwq2u5mKsMrt9kF X-Received: by 2002:a05:6402:d58:b0:458:5eca:a2c9 with SMTP id ec24-20020a0564020d5800b004585ecaa2c9mr8666625edb.306.1664636306052; Sat, 01 Oct 2022 07:58:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4syfsKXsxvYYfn7fvRiEa9nCMbGy+JIuRGwK9SSQu/V4k3YaMKliTq0OSkaegLlpeFXpoyig== X-Received: by 2002:a05:6402:d58:b0:458:5eca:a2c9 with SMTP id ec24-20020a0564020d5800b004585ecaa2c9mr8666615edb.306.1664636305905; Sat, 01 Oct 2022 07:58:25 -0700 (PDT) Received: from pollux.redhat.com ([2a02:810d:4b40:2ee8:642:1aff:fe31:a15c]) by smtp.gmail.com with ESMTPSA id 17-20020a170906301100b00731582babcasm2832561ejz.71.2022.10.01.07.58.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Oct 2022 07:58:25 -0700 (PDT) From: Danilo Krummrich To: daniel@ffwll.ch, airlied@linux.ie, tzimmermann@suse.de, mripard@kernel.org, stefan@agner.ch, alison.wang@nxp.com Subject: [PATCH drm-misc-next v2 5/9] drm/fsl-dcu: use drm_dev_unplug() Date: Sat, 1 Oct 2022 16:57:58 +0200 Message-Id: <20221001145802.515916-6-dakr@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221001145802.515916-1-dakr@redhat.com> References: <20221001145802.515916-1-dakr@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Danilo Krummrich , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" When the driver is unbound, there might still be users in userspace having an open fd and are calling into the driver. While this is fine for drm managed resources, it is not for resources bound to the device/driver lifecycle, e.g. clocks or MMIO mappings. To prevent use-after-free issues we need to protect those resources with drm_dev_enter() and drm_dev_exit(). This does only work if we indicate that the drm device was unplugged, hence use drm_dev_unplug() instead of drm_dev_unregister(). Protecting the particular resources with drm_dev_enter()/drm_dev_exit() is handled by subsequent patches. Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c index 4139f674c5de..3ac57516c3fe 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c @@ -340,7 +340,7 @@ static int fsl_dcu_drm_remove(struct platform_device *pdev) struct fsl_dcu_drm_device *fsl_dev = platform_get_drvdata(pdev); struct drm_device *drm = &fsl_dev->base; - drm_dev_unregister(drm); + drm_dev_unplug(drm); clk_disable_unprepare(fsl_dev->clk); clk_unregister(fsl_dev->pix_clk); From patchwork Sat Oct 1 14:57:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 12996548 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1F984C433FE for ; Sat, 1 Oct 2022 14:58:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9CACB10E645; Sat, 1 Oct 2022 14:58:40 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id D8F1E10E638 for ; Sat, 1 Oct 2022 14:58:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664636312; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fbBek+DLo1uAiT4bxT5GcOfjUqanpBLVsNY+19U/h8w=; b=YC+ozLuBdsAZbA68YtxHi57xxIPawhrMmCUm4OSUWXX/pWC0Fwge9yjFECWAROMVCo3Z0a +oC/ImQjQzHlJUoF+ZgMgXcJk1qGkXklNgpYUEzQAvGvhgBeMnk52qr2c76HaqsX6PnQbU ZR87HwqqKPKdapoDu1VUb3KhDsnqQ+8= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-484-Jx-qTyIeN9qwwN6159dklg-1; Sat, 01 Oct 2022 10:58:30 -0400 X-MC-Unique: Jx-qTyIeN9qwwN6159dklg-1 Received: by mail-ed1-f72.google.com with SMTP id z16-20020a05640235d000b0045485e4a5e0so5635716edc.1 for ; Sat, 01 Oct 2022 07:58:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=fbBek+DLo1uAiT4bxT5GcOfjUqanpBLVsNY+19U/h8w=; b=29l2idM/Cdcsp1CFdnviqzONEgbQ2KtQrtrT+k7c+wzvklT4mkCeuqySBBrkroM3vo aoRjiPc/iRewYed9vXeZIQFIKaJMBuogr6LzYWswb1MrWfYJjcpsTqs7Li6OgruGTx9E qd5pRF4J2G348abgAmY9PN+C4ZHzYFtSXY3h/3UW/LGkmXyRLh4pOPmXX2f7cfmWfslx bAsgGsJAEzKnzPx++2oqt2bMrrHkRiX2His52wlk0nwmKpL0y+5Ir8eQSzXGWBi5de5H E+UkNGGnu+AeAayFIN54z1ZxZnp9Q0XYVEvVwl3bHdj/6627lBafGvX8hI9EGPLt62i0 jmSg== X-Gm-Message-State: ACrzQf2H59JQlU9b6xTJkdaJ69roqcmCjmPFuy2W+ixvqPcgJCra9x0w Hee8khJRG1pz2dzhUetc7pIi1KPT4YtTvyegUCdawDpx1+GleTESFfWFJuYpr2q2f5oGYGGnrE/ RdsxChrT4ZI79vEhLDtSPPxwq11QC X-Received: by 2002:a17:907:845:b0:731:2f6c:6dbd with SMTP id ww5-20020a170907084500b007312f6c6dbdmr9754608ejb.551.1664636309689; Sat, 01 Oct 2022 07:58:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM77lcdC7sJsRPEhN5747tLtzHdni0e5EG5ogppqYZX80M+PrQk5aORErJsk4Ntf6tTYwo6zXw== X-Received: by 2002:a17:907:845:b0:731:2f6c:6dbd with SMTP id ww5-20020a170907084500b007312f6c6dbdmr9754596ejb.551.1664636309517; Sat, 01 Oct 2022 07:58:29 -0700 (PDT) Received: from pollux.redhat.com ([2a02:810d:4b40:2ee8:642:1aff:fe31:a15c]) by smtp.gmail.com with ESMTPSA id cb15-20020a0564020b6f00b004576e3aee69sm3768376edb.4.2022.10.01.07.58.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Oct 2022 07:58:29 -0700 (PDT) From: Danilo Krummrich To: daniel@ffwll.ch, airlied@linux.ie, tzimmermann@suse.de, mripard@kernel.org, stefan@agner.ch, alison.wang@nxp.com Subject: [PATCH drm-misc-next v2 6/9] drm/fsl-dcu: plane: protect device resources after removal Date: Sat, 1 Oct 2022 16:57:59 +0200 Message-Id: <20221001145802.515916-7-dakr@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221001145802.515916-1-dakr@redhat.com> References: <20221001145802.515916-1-dakr@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Danilo Krummrich , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" (Hardware) resources which are bound to the driver and device lifecycle must not be accessed after the device and driver are unbound. However, the DRM device isn't freed as long as the last user didn't close it, hence userspace can still call into the driver. Therefore protect the critical sections which are accessing those resources with drm_dev_enter() and drm_dev_exit(). Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c | 24 +++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c index 23ff285da477..b1305f0af9d5 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -65,15 +66,21 @@ static void fsl_dcu_drm_plane_atomic_disable(struct drm_plane *plane, { struct fsl_dcu_drm_device *fsl_dev = drm_to_fsl_dcu_drm_dev(plane->dev); unsigned int value; - int index; + int index, idx; + + if (!drm_dev_enter(plane->dev, &idx)) + return; index = fsl_dcu_drm_plane_index(plane); if (index < 0) - return; + goto out; regmap_read(fsl_dev->regmap, DCU_CTRLDESCLN(index, 4), &value); value &= ~DCU_LAYER_EN; regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 4), value); + +out: + drm_dev_exit(idx); } static void fsl_dcu_drm_plane_atomic_update(struct drm_plane *plane, @@ -86,14 +93,17 @@ static void fsl_dcu_drm_plane_atomic_update(struct drm_plane *plane, struct drm_framebuffer *fb = plane->state->fb; struct drm_gem_dma_object *gem; unsigned int alpha = DCU_LAYER_AB_NONE, bpp; - int index; + int index, idx; - if (!fb) + if (!drm_dev_enter(plane->dev, &idx)) return; + if (!fb) + goto out; + index = fsl_dcu_drm_plane_index(plane); if (index < 0) - return; + goto out; gem = drm_fb_dma_get_gem_obj(fb, 0); @@ -126,7 +136,7 @@ static void fsl_dcu_drm_plane_atomic_update(struct drm_plane *plane, bpp = FSL_DCU_YUV422; break; default: - return; + goto out; } regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 1), @@ -162,6 +172,8 @@ static void fsl_dcu_drm_plane_atomic_update(struct drm_plane *plane, DCU_LAYER_PRE_SKIP(0)); } +out: + drm_dev_exit(idx); return; } From patchwork Sat Oct 1 14:58:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 12996550 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6B1A7C4332F for ; Sat, 1 Oct 2022 14:59:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8D10210E63F; Sat, 1 Oct 2022 14:58:51 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8EDA510E64C for ; Sat, 1 Oct 2022 14:58:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664636321; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IqWM55e5x02znRK55veSvbQ977VUM5OMWrptzYqj4WI=; b=fiUHS3VdoDphSYkM1e94qIKF3Ouu4LE3bv9W+OrwfXw0BXw07gpyKSy0ys9aKoGO05At7X XZwkmgk6vJeNPtVtk/fwY33cLA/13L6cBuPyV/HolusLlUsfX5lUrZAVxc4ha0wxRhf33b 8Mpa1cSRG9HCWqCtHVWfHJd79gWEsWA= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-212-yoEUomsqPDq7ixSuGW3i9w-1; Sat, 01 Oct 2022 10:58:34 -0400 X-MC-Unique: yoEUomsqPDq7ixSuGW3i9w-1 Received: by mail-ed1-f69.google.com with SMTP id b17-20020a056402351100b00453b19d9bd0so5567031edd.4 for ; Sat, 01 Oct 2022 07:58:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=IqWM55e5x02znRK55veSvbQ977VUM5OMWrptzYqj4WI=; b=QkglaLwWO56I1dY0y8keGLeb0hBHeZDIJ9o3GaQ5KypW/x0Q9tsnbiIP0GvMIcEvpc jFOSuHu1d1T1vOMo9/sFFG/1uNcwcUXO7JFppCtL3m7hwNoqid2/+Vq3NoN1FvTT5ls8 eay69EMNP4xYtureuB7uV18vXSxK2dY1xL3AER0LyY0fFlLY7d6br56hUVI+2+uCGpmc TrDBVDpnQbuX6anmxJEz9Tp/nbV+zWges8+Mb2/3g/jhjWCZ4N3SSONzdFNwjFig6RSC 137EYDM3N0oEazoYj5N0H5lXQBw9GVDj91TS47pvYR/c2+vcXu5HKqd2Sr0ShEpisimh 5tJw== X-Gm-Message-State: ACrzQf39W/rDgd7ZUvoJldqal1EoO+ASvN2dyY2wNQPiGLAy3sReMiFM eCIkiozHi0AgkU92XnrTUyoRr2UXBou7I12jkZpKvIM0uM2Af469HGrmLW4DkzTK/O/kCl7QdM3 /LXsOJsXNT65Hxld+eF8r4dVTholO X-Received: by 2002:a17:907:6ea4:b0:782:6b82:a2cb with SMTP id sh36-20020a1709076ea400b007826b82a2cbmr10122998ejc.408.1664636313413; Sat, 01 Oct 2022 07:58:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7yvsyArbVNFdDnwv/ocXdiRliElOJYmVUR11MG6/x3BFrrdNeYB3g5s60MP+XkB94O71odTg== X-Received: by 2002:a17:907:6ea4:b0:782:6b82:a2cb with SMTP id sh36-20020a1709076ea400b007826b82a2cbmr10122982ejc.408.1664636313177; Sat, 01 Oct 2022 07:58:33 -0700 (PDT) Received: from pollux.redhat.com ([2a02:810d:4b40:2ee8:642:1aff:fe31:a15c]) by smtp.gmail.com with ESMTPSA id i26-20020a50fc1a000000b00457c9b7ac07sm3649245edr.84.2022.10.01.07.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Oct 2022 07:58:32 -0700 (PDT) From: Danilo Krummrich To: daniel@ffwll.ch, airlied@linux.ie, tzimmermann@suse.de, mripard@kernel.org, stefan@agner.ch, alison.wang@nxp.com Subject: [PATCH drm-misc-next v2 7/9] drm/fsl-dcu: crtc: protect device resources after removal Date: Sat, 1 Oct 2022 16:58:00 +0200 Message-Id: <20221001145802.515916-8-dakr@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221001145802.515916-1-dakr@redhat.com> References: <20221001145802.515916-1-dakr@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Danilo Krummrich , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" (Hardware) resources which are bound to the driver and device lifecycle must not be accessed after the device and driver are unbound. However, the DRM device isn't freed as long as the last user didn't close it, hence userspace can still call into the driver. Therefore protect the critical sections which are accessing those resources with drm_dev_enter() and drm_dev_exit(). Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c index 1dad90f701c8..c77df9b7893f 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -26,6 +27,10 @@ static void fsl_dcu_drm_crtc_atomic_flush(struct drm_crtc *crtc, struct drm_device *dev = crtc->dev; struct fsl_dcu_drm_device *fsl_dev = drm_to_fsl_dcu_drm_dev(dev); struct drm_pending_vblank_event *event = crtc->state->event; + int idx; + + if (!drm_dev_enter(dev, &idx)) + return; regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE, DCU_UPDATE_MODE_READREG); @@ -40,6 +45,8 @@ static void fsl_dcu_drm_crtc_atomic_flush(struct drm_crtc *crtc, drm_crtc_send_vblank_event(crtc, event); spin_unlock_irq(&crtc->dev->event_lock); } + + drm_dev_exit(idx); } static void fsl_dcu_drm_crtc_atomic_disable(struct drm_crtc *crtc, @@ -49,6 +56,10 @@ static void fsl_dcu_drm_crtc_atomic_disable(struct drm_crtc *crtc, crtc); struct drm_device *dev = crtc->dev; struct fsl_dcu_drm_device *fsl_dev = drm_to_fsl_dcu_drm_dev(dev); + int idx; + + if (!drm_dev_enter(dev, &idx)) + return; /* always disable planes on the CRTC */ drm_atomic_helper_disable_planes_on_crtc(old_crtc_state, true); @@ -61,6 +72,8 @@ static void fsl_dcu_drm_crtc_atomic_disable(struct drm_crtc *crtc, regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE, DCU_UPDATE_MODE_READREG); clk_disable_unprepare(fsl_dev->pix_clk); + + drm_dev_exit(idx); } static void fsl_dcu_drm_crtc_atomic_enable(struct drm_crtc *crtc, @@ -68,6 +81,10 @@ static void fsl_dcu_drm_crtc_atomic_enable(struct drm_crtc *crtc, { struct drm_device *dev = crtc->dev; struct fsl_dcu_drm_device *fsl_dev = drm_to_fsl_dcu_drm_dev(dev); + int idx; + + if (!drm_dev_enter(dev, &idx)) + return; clk_prepare_enable(fsl_dev->pix_clk); regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE, @@ -77,6 +94,8 @@ static void fsl_dcu_drm_crtc_atomic_enable(struct drm_crtc *crtc, DCU_UPDATE_MODE_READREG); drm_crtc_vblank_on(crtc); + + drm_dev_exit(idx); } static void fsl_dcu_drm_crtc_mode_set_nofb(struct drm_crtc *crtc) @@ -87,6 +106,10 @@ static void fsl_dcu_drm_crtc_mode_set_nofb(struct drm_crtc *crtc) struct drm_display_mode *mode = &crtc->state->mode; unsigned int pol = 0; struct videomode vm; + int idx; + + if (!drm_dev_enter(dev, &idx)) + return; clk_set_rate(fsl_dev->pix_clk, mode->clock * 1000); @@ -122,6 +145,8 @@ static void fsl_dcu_drm_crtc_mode_set_nofb(struct drm_crtc *crtc) DCU_THRESHOLD_LS_BF_VS(BF_VS_VAL) | DCU_THRESHOLD_OUT_BUF_HIGH(BUF_MAX_VAL) | DCU_THRESHOLD_OUT_BUF_LOW(BUF_MIN_VAL)); + + drm_dev_exit(idx); return; } @@ -137,11 +162,17 @@ static int fsl_dcu_drm_crtc_enable_vblank(struct drm_crtc *crtc) struct drm_device *dev = crtc->dev; struct fsl_dcu_drm_device *fsl_dev = drm_to_fsl_dcu_drm_dev(dev); unsigned int value; + int idx; + + if (!drm_dev_enter(dev, &idx)) + return -ENODEV; regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value); value &= ~DCU_INT_MASK_VBLANK; regmap_write(fsl_dev->regmap, DCU_INT_MASK, value); + drm_dev_exit(idx); + return 0; } @@ -150,10 +181,16 @@ static void fsl_dcu_drm_crtc_disable_vblank(struct drm_crtc *crtc) struct drm_device *dev = crtc->dev; struct fsl_dcu_drm_device *fsl_dev = drm_to_fsl_dcu_drm_dev(dev); unsigned int value; + int idx; + + if (!drm_dev_enter(dev, &idx)) + return; regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value); value |= DCU_INT_MASK_VBLANK; regmap_write(fsl_dev->regmap, DCU_INT_MASK, value); + + drm_dev_exit(idx); } static const struct drm_crtc_funcs fsl_dcu_drm_crtc_funcs = { From patchwork Sat Oct 1 14:58:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 12996549 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 86554C433FE for ; Sat, 1 Oct 2022 14:59:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 49F3110E639; Sat, 1 Oct 2022 14:58:48 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 037D810E63A for ; Sat, 1 Oct 2022 14:58:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664636319; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V/3Usn0qxo83EKXGxCer0F1RKa2ZQEkOpzpL2CjOlas=; b=FwVth9/NwbeNz0KnIYJ8EyUdV4o091Dq6oCaeF1S87NDC+i52wvlusQ0jeL9cyo/U+ZQoA Bjnt2x/D3pjJgg2k7H4xfHqirOsrPr714xitmFUSgoKZt5UlCYQ2QKPPUjmBv6NQAflbDZ yDoDIf4I/96Bl5GIEEMRV+IJx4pzyjc= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-344-Qmxj-6kGMVy9SotbP2yTTA-1; Sat, 01 Oct 2022 10:58:38 -0400 X-MC-Unique: Qmxj-6kGMVy9SotbP2yTTA-1 Received: by mail-ed1-f72.google.com with SMTP id h11-20020a05640250cb00b004580ee86ca8so5522556edb.6 for ; Sat, 01 Oct 2022 07:58:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=V/3Usn0qxo83EKXGxCer0F1RKa2ZQEkOpzpL2CjOlas=; b=Lb9bywiGAr7ctosLYeAITQ7k0A129tUpzjEhC9l0j6F8UzUkMYmif7iKw3Y/fkGW2y xbz1VUzL4IsFCU9pR2FeCdFJcudkW+NhIuxTaQPfaWtNIxRANuZcvqk/k3ztt5VODdIv 3GP9Zy2jZVdR5Svu5LGdgBu/yYCfPoXFtj2ZI95wsYoft1mRXlXUEevVosMJ1/OHE4yP f/zjQ268SyxG4bHlUf7c5XC1w/qR1Y3F/S9tdZ54SWep4uYeo29qfm7ujbppiQyk1K6i nZVz4W8Otj16hAKjSkJVt0+YrnQQMPMXauHAvXm6U9ldSxYaYKoApwBhU08Quha0GG1r fb5g== X-Gm-Message-State: ACrzQf2IRPHVn1vu6HPTsxiCGsI/uNW2ufE7rOcKiG+nexIdHgDoGzUv 1kZ24ferJaoUTL/TcvF30RYKh/h62iyBSNl99OAANLTzQxtwA00EXzapAugutqIg/p1XdJUUutC bnqC5doUJW0wAE/QVxC3T7y1CsX2Z X-Received: by 2002:a17:907:1b1c:b0:72f:9aac:ee41 with SMTP id mp28-20020a1709071b1c00b0072f9aacee41mr9815147ejc.56.1664636317149; Sat, 01 Oct 2022 07:58:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM46nLpKvPd5A48MwRU0YYtpmobTJ4KvgIEBc3OFsMZ1VMWEAONqeJWMYiLUogbRofwIWzwDfQ== X-Received: by 2002:a17:907:1b1c:b0:72f:9aac:ee41 with SMTP id mp28-20020a1709071b1c00b0072f9aacee41mr9815139ejc.56.1664636316950; Sat, 01 Oct 2022 07:58:36 -0700 (PDT) Received: from pollux.redhat.com ([2a02:810d:4b40:2ee8:642:1aff:fe31:a15c]) by smtp.gmail.com with ESMTPSA id e20-20020a170906c01400b007803083a36asm2805616ejz.115.2022.10.01.07.58.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Oct 2022 07:58:36 -0700 (PDT) From: Danilo Krummrich To: daniel@ffwll.ch, airlied@linux.ie, tzimmermann@suse.de, mripard@kernel.org, stefan@agner.ch, alison.wang@nxp.com Subject: [PATCH drm-misc-next v2 8/9] drm/fsl-dcu: remove trailing return statements Date: Sat, 1 Oct 2022 16:58:01 +0200 Message-Id: <20221001145802.515916-9-dakr@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221001145802.515916-1-dakr@redhat.com> References: <20221001145802.515916-1-dakr@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Danilo Krummrich , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Remove the trailing return statements at the end of void functions. Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c | 1 - drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c index c77df9b7893f..23687551c831 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c @@ -147,7 +147,6 @@ static void fsl_dcu_drm_crtc_mode_set_nofb(struct drm_crtc *crtc) DCU_THRESHOLD_OUT_BUF_LOW(BUF_MIN_VAL)); drm_dev_exit(idx); - return; } static const struct drm_crtc_helper_funcs fsl_dcu_drm_crtc_helper_funcs = { diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c index b1305f0af9d5..b95dca47de3e 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c @@ -174,7 +174,6 @@ static void fsl_dcu_drm_plane_atomic_update(struct drm_plane *plane, out: drm_dev_exit(idx); - return; } static const struct drm_plane_helper_funcs fsl_dcu_drm_plane_helper_funcs = { From patchwork Sat Oct 1 14:58:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 12996551 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3665EC433FE for ; Sat, 1 Oct 2022 14:59:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D425410E63C; Sat, 1 Oct 2022 14:58:55 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id B6A5810E639 for ; Sat, 1 Oct 2022 14:58:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664636324; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kkvjlmHN1GT70TYbeV/tCW9Fb42UM2HGXIPJtWzhOMU=; b=BJ6HHgebOX1W9EqFbggc+G49ec078Ew5hbs02j/8mELVyZgykQg596CnvxOkRt4I5bLN+m zXdhc4+a6Xa5I+QDJ1Vua7UIXUDOf7c6J9+TDYETKM3WaxEvEN6xqO9RmDjCVYTH4YWHR5 WyrV6+mItiP+Ty9wJIAdnklKL3K/mXY= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-219-4dXzmJxbPke6sj4eY-TzZw-1; Sat, 01 Oct 2022 10:58:41 -0400 X-MC-Unique: 4dXzmJxbPke6sj4eY-TzZw-1 Received: by mail-ej1-f70.google.com with SMTP id qk10-20020a1709077f8a00b0078297c303afso2586554ejc.20 for ; Sat, 01 Oct 2022 07:58:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=kkvjlmHN1GT70TYbeV/tCW9Fb42UM2HGXIPJtWzhOMU=; b=wXIjxMJx2lPX2pv+6kjcN7yhbjU7x9yzXWET05SvYb6R76ed6JJRZs+/WhMyWKT+9T 0x06W8s0gdQmhtPO2pCiRDKPyGLybguwTgJOkKjrfWjcFp/laaTkTYnrBr3G07E9P/pm 1o8FbEeKN2P2B637siRKo+oBQCMHe9lTYgjX7u76rDVuMo7p+41wEKCuaJTrVTynp4TY 30vXOP3N+fBYRiyHPXU+JtnMgg48X7in6DIVYR+i27+VKpF6lRTrctjbCGaClx9G0fNV 9Sr940VvYxiu4Nq40N5jODNg2bKI25BgkS87t1X6ulfdce4JPUx2QZl7+l5Gf05HLYw/ fvkA== X-Gm-Message-State: ACrzQf3WTDvX6v8E0rHzjk3NT2fgOiqdVst24HO+Wz0QWut12gYsBBX2 kgtobOrQv0fs9aMsvvmViPi/2WJNN/w1pzWkF9uZ+iP3orZH+I+R5czsDU03tIIFrxjfWQxJuwZ dkr4NExwY8d/hJyxHCIwLms7FVVE2 X-Received: by 2002:a17:906:8461:b0:78a:5e7c:a46b with SMTP id hx1-20020a170906846100b0078a5e7ca46bmr368871ejc.592.1664636320786; Sat, 01 Oct 2022 07:58:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6iCEsOFNwU2idahd/mpe75sVMBpercNJiTFFD1VX3LoGxt69klTiFnKH/4LCENoljmciJjXw== X-Received: by 2002:a17:906:8461:b0:78a:5e7c:a46b with SMTP id hx1-20020a170906846100b0078a5e7ca46bmr368859ejc.592.1664636320624; Sat, 01 Oct 2022 07:58:40 -0700 (PDT) Received: from pollux.redhat.com ([2a02:810d:4b40:2ee8:642:1aff:fe31:a15c]) by smtp.gmail.com with ESMTPSA id la15-20020a170907780f00b007812ba2a360sm2868328ejc.149.2022.10.01.07.58.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Oct 2022 07:58:40 -0700 (PDT) From: Danilo Krummrich To: daniel@ffwll.ch, airlied@linux.ie, tzimmermann@suse.de, mripard@kernel.org, stefan@agner.ch, alison.wang@nxp.com Subject: [PATCH drm-misc-next v2 9/9] drm/fsl-dcu: remove calls to drm_mode_config_cleanup() Date: Sat, 1 Oct 2022 16:58:02 +0200 Message-Id: <20221001145802.515916-10-dakr@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221001145802.515916-1-dakr@redhat.com> References: <20221001145802.515916-1-dakr@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Danilo Krummrich , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" drm_mode_config_init() simply calls drmm_mode_config_init(), hence cleanup is automatically handled through registering drm_mode_config_cleanup() with drmm_add_action_or_reset(). While at it, get rid of the deprecated drm_mode_config_init() and replace it with drmm_mode_config_init() directly. Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 4 +--- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.c | 5 +++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c index 3ac57516c3fe..cb74ae663f25 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c @@ -128,10 +128,9 @@ static int fsl_dcu_load(struct drm_device *dev, unsigned long flags) } return 0; + done_irq: drm_kms_helper_poll_fini(dev); - - drm_mode_config_cleanup(dev); done_vblank: return ret; } @@ -141,7 +140,6 @@ static void fsl_dcu_unload(struct drm_device *dev) drm_atomic_helper_shutdown(dev); drm_kms_helper_poll_fini(dev); - drm_mode_config_cleanup(dev); fsl_dcu_irq_uninstall(dev); } diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.c index c3d55c0aca9f..219ca539dedd 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.c @@ -23,7 +23,9 @@ int fsl_dcu_drm_modeset_init(struct fsl_dcu_drm_device *fsl_dev) struct drm_device *drm = &fsl_dev->base; int ret; - drm_mode_config_init(drm); + ret = drmm_mode_config_init(drm); + if (ret) + goto err; drm->mode_config.min_width = 0; drm->mode_config.min_height = 0; @@ -49,6 +51,5 @@ int fsl_dcu_drm_modeset_init(struct fsl_dcu_drm_device *fsl_dev) return 0; err: - drm_mode_config_cleanup(drm); return ret; }