From patchwork Wed Oct 26 15:34:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13020811 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 51036C38A2D for ; Wed, 26 Oct 2022 15:36:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1C62310E556; Wed, 26 Oct 2022 15:34: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 A898410E563 for ; Wed, 26 Oct 2022 15:34:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666798486; 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=fLaZVg/Gn3THIn1ghLrf5MedEqRFiq/AUqXfvtIcrvk=; b=WDZ/VQ7mAV3BLJUWozQ7m4KqM26e9cGITH2Jr43zY4kS2jfa6lvOWbmudI2TEAwy3BAARB SbkkejtYtl3wPjWxTwvGnFQ/HTFRHXkEGTVKHDY/Z6cdcCThtsW5c3cVLiWBVCcdpXzeMJ WN9Vc3BsaCNfbMwZIlxTiNQxlB/XxJ0= 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-503-W7eue0f-OFqS54BYogoSzA-1; Wed, 26 Oct 2022 11:34:43 -0400 X-MC-Unique: W7eue0f-OFqS54BYogoSzA-1 Received: by mail-ed1-f72.google.com with SMTP id c9-20020a05640227c900b0045d4a88c750so14176202ede.12 for ; Wed, 26 Oct 2022 08:34:42 -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:message-id:reply-to; bh=fLaZVg/Gn3THIn1ghLrf5MedEqRFiq/AUqXfvtIcrvk=; b=rKImN9Gbmj8a9TIJj7ykZqD+SirUQYEjQjNZLIErvRrS3sGq4bTHh6aJHr/sZV3Mq1 Nve2aca+F0qbV2dep0Vsb7zGW0sV3qXn7oDWGQubodc7cRw8ri/Zzv50BdJTf1gyHXYF UJM/YYJezZVALr92Ib76uvY8ZTWj2HOgSFKWLBC1wzGnHC2VVF6T7B5li1H7h6G8hURm Oc6M5nGD/apUdkGSdBslmwg9MOjAEkyLDL20G8bNr7MGJBUaQoixih15/TPcPyrOkltE C2PtKc0tVMewQ+jyt4AIKPW83TDs9iC5eUQtgZz5Lp7H59KvHNV4Y2rOYgPNGSHB/UAD 3WeQ== X-Gm-Message-State: ACrzQf2KMZCM49Geb/N2DjNxkFa/fn7Ko3fEQ8+Oyf66QaAYN7gPZBk2 RXjHl+08prEabGKu4uXOrNqepgVHwLU1/OoxUcLv0IPQc6GLjJH+gwj59SRhNhsWN7hPIorYYq3 DIZ0zumjCBpy8lFZZZ74cjKK6rzQp X-Received: by 2002:a05:6402:27c6:b0:461:e426:dc8b with SMTP id c6-20020a05640227c600b00461e426dc8bmr12855803ede.403.1666798482015; Wed, 26 Oct 2022 08:34:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7dYi2tzVQq42OFzB50D9ddEtWodBh0BQMxyElzqyZXWM3GFmgLvhs6sr8aj83t2ilqgGbccA== X-Received: by 2002:a05:6402:27c6:b0:461:e426:dc8b with SMTP id c6-20020a05640227c600b00461e426dc8bmr12855779ede.403.1666798481834; Wed, 26 Oct 2022 08:34:41 -0700 (PDT) Received: from pollux.. ([2a02:810d:4b40:2ee8:642:1aff:fe31:a15c]) by smtp.gmail.com with ESMTPSA id z17-20020a170906271100b0078a543e9301sm3048896ejc.200.2022.10.26.08.34.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 08:34:41 -0700 (PDT) From: Danilo Krummrich To: daniel@ffwll.ch, airlied@linux.ie, tzimmermann@suse.de, mripard@kernel.org, liviu.dudau@arm.com, brian.starkey@arm.com Subject: [PATCH drm-misc-next v4 1/4] drm/arm/hdlcd: use drmm_* to allocate driver structures Date: Wed, 26 Oct 2022 17:34:28 +0200 Message-Id: <20221026153431.72033-2-dakr@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221026153431.72033-1-dakr@redhat.com> References: <20221026153431.72033-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/arm/hdlcd_drv.c | 12 ++++-------- drivers/gpu/drm/arm/hdlcd_drv.h | 1 + 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c index a032003c340c..463381d11cff 100644 --- a/drivers/gpu/drm/arm/hdlcd_drv.c +++ b/drivers/gpu/drm/arm/hdlcd_drv.c @@ -247,13 +247,11 @@ static int hdlcd_drm_bind(struct device *dev) struct hdlcd_drm_private *hdlcd; int ret; - hdlcd = devm_kzalloc(dev, sizeof(*hdlcd), GFP_KERNEL); - if (!hdlcd) - return -ENOMEM; + hdlcd = devm_drm_dev_alloc(dev, &hdlcd_driver, typeof(*hdlcd), base); + if (IS_ERR(hdlcd)) + return PTR_ERR(hdlcd); - drm = drm_dev_alloc(&hdlcd_driver, dev); - if (IS_ERR(drm)) - return PTR_ERR(drm); + drm = &hdlcd->base; drm->dev_private = hdlcd; dev_set_drvdata(dev, drm); @@ -319,7 +317,6 @@ static int hdlcd_drm_bind(struct device *dev) err_free: drm_mode_config_cleanup(drm); dev_set_drvdata(dev, NULL); - drm_dev_put(drm); return ret; } @@ -344,7 +341,6 @@ static void hdlcd_drm_unbind(struct device *dev) drm_mode_config_cleanup(drm); drm->dev_private = NULL; dev_set_drvdata(dev, NULL); - drm_dev_put(drm); } static const struct component_master_ops hdlcd_master_ops = { diff --git a/drivers/gpu/drm/arm/hdlcd_drv.h b/drivers/gpu/drm/arm/hdlcd_drv.h index 909c39c28487..3892b36767ac 100644 --- a/drivers/gpu/drm/arm/hdlcd_drv.h +++ b/drivers/gpu/drm/arm/hdlcd_drv.h @@ -7,6 +7,7 @@ #define __HDLCD_DRV_H__ struct hdlcd_drm_private { + struct drm_device base; void __iomem *mmio; struct clk *clk; struct drm_crtc crtc; From patchwork Wed Oct 26 15:34:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13020813 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 40C7CC38A2D for ; Wed, 26 Oct 2022 15:36:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 208A210E571; Wed, 26 Oct 2022 15:35:09 +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 9152B10E576 for ; Wed, 26 Oct 2022 15:34:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666798487; 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=wv7XhFHELyxghr92um+sD68M2S8O9jxLDlBijfPgaUI=; b=Se8217V4r9B+3NcTwY6GTsPBkXvYFCtGXCPxJ2Ibx/CxFtn3n32cWOLcWAIwS0Sbd+L7GL 7duYDMWpLXPnl8fP9H/hqcKxQRB3J7BRMqgEf2LJfpurHue0oa9QtznfiELXALnglNtner YV7wL5E6JsFIRsYj+HwWPlTBrZXs8Lo= 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-116-Y2qJsSjtOKWFksHaOfqbyA-1; Wed, 26 Oct 2022 11:34:46 -0400 X-MC-Unique: Y2qJsSjtOKWFksHaOfqbyA-1 Received: by mail-ed1-f69.google.com with SMTP id z15-20020a05640240cf00b00461b253c220so8071474edb.3 for ; Wed, 26 Oct 2022 08:34:46 -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:message-id:reply-to; bh=wv7XhFHELyxghr92um+sD68M2S8O9jxLDlBijfPgaUI=; b=t7Q7ANOMtDLfw1Z0WTEJ9TrdONKIlIfFxmOf8VkAUdiJ7NQfQih5hO5BmW1IKwxRxM xT3lp6u0MzdQcKNrWM1yBgjbFJ6U8/9LISonZIO/3dEUtNIf/FLjsdU7pzoKHsD+B+pt JZgEsb/Q6c8K84FZRMNPmxz51D/Lqri96D5tYZZ3i07sdgj22b/emT4Daf+zZYxDn3JU GpxcpEGz+0OmsYEeuZf3Ly5bzeL1+fixfOpKb1R5i5ttHw5ve/dcvBnP0/2g9cQfCZFt kTZNP7Us+++Bukg/PFIioyRU068P0KA5FVuhcN1jDk48RjzZBb2zTWvYa5sdvDe1WLqQ 6nsw== X-Gm-Message-State: ACrzQf3s9Fk/YY0SeCWFrnGI7bJYkwcHcd2ieYZIf6tjZO5QK0INy0mX fHNAgplYmxpb3DH2MjrT3NparaIkEoyV6pnL52Iv7sH8zfjnM8OhkVflKTSXnGf5nedy7qTQRhr gNvBKbovpAgpPiWUpkUNwB0SZT5zj X-Received: by 2002:aa7:cd92:0:b0:456:cbb5:2027 with SMTP id x18-20020aa7cd92000000b00456cbb52027mr41214700edv.384.1666798485500; Wed, 26 Oct 2022 08:34:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4hSmFGZW5A+vOVIQIYLIAaA5j5SuIKXayCNg+a/tMrty6G3mAQlX05AW6FSdwf0iYaX8xCKg== X-Received: by 2002:aa7:cd92:0:b0:456:cbb5:2027 with SMTP id x18-20020aa7cd92000000b00456cbb52027mr41214687edv.384.1666798485360; Wed, 26 Oct 2022 08:34:45 -0700 (PDT) Received: from pollux.. ([2a02:810d:4b40:2ee8:642:1aff:fe31:a15c]) by smtp.gmail.com with ESMTPSA id s14-20020a170906960e00b00780ab5a9116sm3164438ejx.211.2022.10.26.08.34.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 08:34:45 -0700 (PDT) From: Danilo Krummrich To: daniel@ffwll.ch, airlied@linux.ie, tzimmermann@suse.de, mripard@kernel.org, liviu.dudau@arm.com, brian.starkey@arm.com Subject: [PATCH drm-misc-next v4 2/4] drm/arm/hdlcd: replace drm->dev_private with drm_to_hdlcd_priv() Date: Wed, 26 Oct 2022 17:34:29 +0200 Message-Id: <20221026153431.72033-3-dakr@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221026153431.72033-1-dakr@redhat.com> References: <20221026153431.72033-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 hdlcd_drm_private, hence we can use container_of() to get the struct drm_device instance instead. Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/arm/hdlcd_crtc.c | 6 +++--- drivers/gpu/drm/arm/hdlcd_drv.c | 10 ++++------ drivers/gpu/drm/arm/hdlcd_drv.h | 1 + 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c index 7030339fa232..2055b1abcec3 100644 --- a/drivers/gpu/drm/arm/hdlcd_crtc.c +++ b/drivers/gpu/drm/arm/hdlcd_crtc.c @@ -275,7 +275,7 @@ static void hdlcd_plane_atomic_update(struct drm_plane *plane, dest_h = drm_rect_height(&new_plane_state->dst); scanout_start = drm_fb_dma_get_gem_addr(fb, new_plane_state, 0); - hdlcd = plane->dev->dev_private; + hdlcd = drm_to_hdlcd_priv(plane->dev); hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_LENGTH, fb->pitches[0]); hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_PITCH, fb->pitches[0]); hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_COUNT, dest_h - 1); @@ -298,7 +298,7 @@ static const struct drm_plane_funcs hdlcd_plane_funcs = { static struct drm_plane *hdlcd_plane_init(struct drm_device *drm) { - struct hdlcd_drm_private *hdlcd = drm->dev_private; + struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm); struct drm_plane *plane = NULL; u32 formats[ARRAY_SIZE(supported_formats)], i; int ret; @@ -325,7 +325,7 @@ static struct drm_plane *hdlcd_plane_init(struct drm_device *drm) int hdlcd_setup_crtc(struct drm_device *drm) { - struct hdlcd_drm_private *hdlcd = drm->dev_private; + struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm); struct drm_plane *primary; int ret; diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c index 463381d11cff..120c87934a91 100644 --- a/drivers/gpu/drm/arm/hdlcd_drv.c +++ b/drivers/gpu/drm/arm/hdlcd_drv.c @@ -98,7 +98,7 @@ static void hdlcd_irq_uninstall(struct hdlcd_drm_private *hdlcd) static int hdlcd_load(struct drm_device *drm, unsigned long flags) { - struct hdlcd_drm_private *hdlcd = drm->dev_private; + struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm); struct platform_device *pdev = to_platform_device(drm->dev); struct resource *res; u32 version; @@ -190,7 +190,7 @@ static int hdlcd_show_underrun_count(struct seq_file *m, void *arg) { struct drm_info_node *node = (struct drm_info_node *)m->private; struct drm_device *drm = node->minor->dev; - struct hdlcd_drm_private *hdlcd = drm->dev_private; + struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm); seq_printf(m, "underrun : %d\n", atomic_read(&hdlcd->buffer_underrun_count)); seq_printf(m, "dma_end : %d\n", atomic_read(&hdlcd->dma_end_count)); @@ -203,7 +203,7 @@ static int hdlcd_show_pxlclock(struct seq_file *m, void *arg) { struct drm_info_node *node = (struct drm_info_node *)m->private; struct drm_device *drm = node->minor->dev; - struct hdlcd_drm_private *hdlcd = drm->dev_private; + struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm); unsigned long clkrate = clk_get_rate(hdlcd->clk); unsigned long mode_clock = hdlcd->crtc.mode.crtc_clock * 1000; @@ -253,7 +253,6 @@ static int hdlcd_drm_bind(struct device *dev) drm = &hdlcd->base; - drm->dev_private = hdlcd; dev_set_drvdata(dev, drm); hdlcd_setup_mode_config(drm); @@ -324,7 +323,7 @@ static int hdlcd_drm_bind(struct device *dev) static void hdlcd_drm_unbind(struct device *dev) { struct drm_device *drm = dev_get_drvdata(dev); - struct hdlcd_drm_private *hdlcd = drm->dev_private; + struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm); drm_dev_unregister(drm); drm_kms_helper_poll_fini(drm); @@ -339,7 +338,6 @@ static void hdlcd_drm_unbind(struct device *dev) pm_runtime_disable(dev); of_reserved_mem_device_release(dev); drm_mode_config_cleanup(drm); - drm->dev_private = NULL; dev_set_drvdata(dev, NULL); } diff --git a/drivers/gpu/drm/arm/hdlcd_drv.h b/drivers/gpu/drm/arm/hdlcd_drv.h index 3892b36767ac..f1c1da2ac2db 100644 --- a/drivers/gpu/drm/arm/hdlcd_drv.h +++ b/drivers/gpu/drm/arm/hdlcd_drv.h @@ -21,6 +21,7 @@ struct hdlcd_drm_private { #endif }; +#define drm_to_hdlcd_priv(x) container_of(x, struct hdlcd_drm_private, base) #define crtc_to_hdlcd_priv(x) container_of(x, struct hdlcd_drm_private, crtc) static inline void hdlcd_write(struct hdlcd_drm_private *hdlcd, From patchwork Wed Oct 26 15:34:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13020814 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 BE920C433FE for ; Wed, 26 Oct 2022 15:36:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6666310E2DA; Wed, 26 Oct 2022 15:35:13 +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 68D3610E556 for ; Wed, 26 Oct 2022 15:34:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666798491; 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=3W/r9ElK7sh/SFf0M/t1SVrs5dFd+1CxEY7lkRSmLhk=; b=DRM6D9bvQ/XQguMygKSFRHa+u6MKl5u/onsCWjNIhl+ZVUZyWanX6OsxV7theh8ODxh2Mu WCgq+9NAYN0Kgo4Izf0ypvvlpLgB4VVQASQ3XfWLPxJEjJoCvAFur/A5YxFbMZb9w4KcM9 ttrwLFAHSJ6PUol4DVqBtndwnKZ7dRo= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-515-m8q1zUFmNP6Y_GeBwCqzqg-1; Wed, 26 Oct 2022 11:34:50 -0400 X-MC-Unique: m8q1zUFmNP6Y_GeBwCqzqg-1 Received: by mail-ej1-f72.google.com with SMTP id hr26-20020a1709073f9a00b007a20c586f1eso3738666ejc.20 for ; Wed, 26 Oct 2022 08:34:50 -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:message-id:reply-to; bh=3W/r9ElK7sh/SFf0M/t1SVrs5dFd+1CxEY7lkRSmLhk=; b=UdaV2Ru4lLc+thYYTjT8uThDPNVEzE+tDqT395L66G7bUkkrxcdDS5xUGxugFNpcV0 8DmaoTVNNyMLqOzy1wqyD/ZbonokOCezPVwbTFNKYt6Z3kqpf7c3DyGnxxfd25W0PqMm xZ0rkQTjcg4wvyjXw5ODPULRMlLQ0Rnd+aZqDQE4J53vWCg/WS3mcx79BqhjDEtDS2h4 6lSSCvaHSsVyeLPEWgkciL6ZY/U5SyJgZzVCJlQGYuYl+NLMh40uPTdX/PEIrG1z3zze +UPfTxBctqzpRo3f3CrOeKCPTr3ih6yrSErHoXy3so97HfFdXqBOB0flXblGUayQVi+z +FNA== X-Gm-Message-State: ACrzQf3R0hT3Jo8HeF17dlA4pNxHjpUAO5X8vdhG7UIg1oAcBME56a4+ vkS2v/0XcqBQb6J45d8lmZUM5ADWflvd8zUO/9An++58g54+cFEmt9wxf4pIyuEO8lvGp4ffbHq JNebwK1N7txEcWT0EDnhrFF4rCEsx X-Received: by 2002:a17:906:8a65:b0:7ad:88f8:7ecc with SMTP id hy5-20020a1709068a6500b007ad88f87eccmr205487ejc.535.1666798489134; Wed, 26 Oct 2022 08:34:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7hZV+nzwBhtCJNCfdWd9aTbL+g+XhULTYvMLCYKRB9T7riygaPgFJlt+DyvtV2u2xPOacYiQ== X-Received: by 2002:a17:906:8a65:b0:7ad:88f8:7ecc with SMTP id hy5-20020a1709068a6500b007ad88f87eccmr205472ejc.535.1666798489007; Wed, 26 Oct 2022 08:34:49 -0700 (PDT) Received: from pollux.. ([2a02:810d:4b40:2ee8:642:1aff:fe31:a15c]) by smtp.gmail.com with ESMTPSA id m24-20020a056402051800b00459e3a3f3ddsm3684370edv.79.2022.10.26.08.34.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 08:34:48 -0700 (PDT) From: Danilo Krummrich To: daniel@ffwll.ch, airlied@linux.ie, tzimmermann@suse.de, mripard@kernel.org, liviu.dudau@arm.com, brian.starkey@arm.com Subject: [PATCH drm-misc-next v4 3/4] drm/arm/hdlcd: plane: use drm managed resources Date: Wed, 26 Oct 2022 17:34:30 +0200 Message-Id: <20221026153431.72033-4-dakr@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221026153431.72033-1-dakr@redhat.com> References: <20221026153431.72033-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/arm/hdlcd_crtc.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c index 2055b1abcec3..1de0f7b23766 100644 --- a/drivers/gpu/drm/arm/hdlcd_crtc.c +++ b/drivers/gpu/drm/arm/hdlcd_crtc.c @@ -290,7 +290,6 @@ static const struct drm_plane_helper_funcs hdlcd_plane_helper_funcs = { static const struct drm_plane_funcs hdlcd_plane_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = drm_plane_cleanup, .reset = drm_atomic_helper_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, @@ -301,21 +300,16 @@ static struct drm_plane *hdlcd_plane_init(struct drm_device *drm) struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm); struct drm_plane *plane = NULL; u32 formats[ARRAY_SIZE(supported_formats)], i; - int ret; - - plane = devm_kzalloc(drm->dev, sizeof(*plane), GFP_KERNEL); - if (!plane) - return ERR_PTR(-ENOMEM); for (i = 0; i < ARRAY_SIZE(supported_formats); i++) formats[i] = supported_formats[i].fourcc; - ret = drm_universal_plane_init(drm, plane, 0xff, &hdlcd_plane_funcs, - formats, ARRAY_SIZE(formats), - NULL, - DRM_PLANE_TYPE_PRIMARY, NULL); - if (ret) - return ERR_PTR(ret); + plane = drmm_universal_plane_alloc(drm, struct drm_plane, dev, 0xff, + &hdlcd_plane_funcs, + formats, ARRAY_SIZE(formats), + NULL, DRM_PLANE_TYPE_PRIMARY, NULL); + if (IS_ERR(plane)) + return plane; drm_plane_helper_add(plane, &hdlcd_plane_helper_funcs); hdlcd->plane = plane; From patchwork Wed Oct 26 15:34:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13020812 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 9C409FA373E for ; Wed, 26 Oct 2022 15:36:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1AAE610E3BD; Wed, 26 Oct 2022 15:35:04 +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 EF81010E567 for ; Wed, 26 Oct 2022 15:34:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666798495; 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=ejOPhJEJNpELka6gD2XD7ypHfsFu2fomcMBYmFfmxuI=; b=f4GK+j5FtFUck0/6gY3I3rygPKWDsElmuxjT+Mf1b4K/EVUI2B5R4OvIQe3wIuwdfhHkzi yTngzCODCKiigzcKxtiLzHMHdNpZvZVoiM4pMHLcHSVw9xMChmtGzsB2uFAn/87RoreQKK hoWpOduA0PJvqSWbab064/2w6p5iv1k= 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-533-ccv3Ol0AOxSaC6R2_Ivs_g-1; Wed, 26 Oct 2022 11:34:53 -0400 X-MC-Unique: ccv3Ol0AOxSaC6R2_Ivs_g-1 Received: by mail-ed1-f69.google.com with SMTP id c9-20020a05640227c900b0045d4a88c750so14176527ede.12 for ; Wed, 26 Oct 2022 08:34:53 -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:message-id:reply-to; bh=ejOPhJEJNpELka6gD2XD7ypHfsFu2fomcMBYmFfmxuI=; b=P1FcBxghWQ5eygvLBiMrXk39tFMlQrVpHaXT4UPxchyh5XewoPEvpVbmdhOwnqnSJh RcD4qjWFqEFvEcFpPs9VrqunQeIIBQT95k+BapExuCsCPJritw9F3iETRVXXrdqOxW+N Q7YAVtk5oU7Tv/bF56bUm8sncwe7czqHSPHp9y1F3RilpTvlnr3Osww81Zbcqf6fT50y No2zD3I1LmlDmwBZGjVSc9T55tEV9DjpZZAcJA+nO/yqtyU3Zaq61T2Zt+zvMMu5PqJF Eff9IXjAPj4K1rYnIB00tH0OkFIURNa/EQSFT5D1IG/7UtMctDoIKy0JUrIREHHk2ZUi LTxA== X-Gm-Message-State: ACrzQf3GTUC/7LqMEQp3sQGYzD5zY7VAduDk5eVa75fYuhiQOIbR1x+H +akPXwLClZFLrs+54DzAObOKzJgbF+FTHMp5X10jB711MMKwmKJEArJBlyLlxfQqqVfSjgyIvL+ Z2xMFkp8MuoP0DJCapZ11tYIExvTX X-Received: by 2002:a17:906:2f87:b0:78a:c0d5:d019 with SMTP id w7-20020a1709062f8700b0078ac0d5d019mr37917825eji.158.1666798492571; Wed, 26 Oct 2022 08:34:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5EBkDZr7mSHI/IJXrOR7VYqX6OqCiEF3KuvriT6LLy2miYkg3LlwMcfHJamXcTxJp1LQpWvw== X-Received: by 2002:a17:906:2f87:b0:78a:c0d5:d019 with SMTP id w7-20020a1709062f8700b0078ac0d5d019mr37917812eji.158.1666798492434; Wed, 26 Oct 2022 08:34:52 -0700 (PDT) Received: from pollux.. ([2a02:810d:4b40:2ee8:642:1aff:fe31:a15c]) by smtp.gmail.com with ESMTPSA id b12-20020a1709063f8c00b0078d4e39d87esm3114855ejj.225.2022.10.26.08.34.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 08:34:52 -0700 (PDT) From: Danilo Krummrich To: daniel@ffwll.ch, airlied@linux.ie, tzimmermann@suse.de, mripard@kernel.org, liviu.dudau@arm.com, brian.starkey@arm.com Subject: [PATCH drm-misc-next v4 4/4] drm/arm/hdlcd: remove calls to drm_mode_config_cleanup() Date: Wed, 26 Oct 2022 17:34:31 +0200 Message-Id: <20221026153431.72033-5-dakr@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221026153431.72033-1-dakr@redhat.com> References: <20221026153431.72033-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/arm/hdlcd_drv.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c index 120c87934a91..49c977cdae40 100644 --- a/drivers/gpu/drm/arm/hdlcd_drv.c +++ b/drivers/gpu/drm/arm/hdlcd_drv.c @@ -175,14 +175,21 @@ static const struct drm_mode_config_funcs hdlcd_mode_config_funcs = { .atomic_commit = drm_atomic_helper_commit, }; -static void hdlcd_setup_mode_config(struct drm_device *drm) +static int hdlcd_setup_mode_config(struct drm_device *drm) { - drm_mode_config_init(drm); + int ret; + + ret = drmm_mode_config_init(drm); + if (ret) + return ret; + drm->mode_config.min_width = 0; drm->mode_config.min_height = 0; drm->mode_config.max_width = HDLCD_MAX_XRES; drm->mode_config.max_height = HDLCD_MAX_YRES; drm->mode_config.funcs = &hdlcd_mode_config_funcs; + + return 0; } #ifdef CONFIG_DEBUG_FS @@ -255,7 +262,10 @@ static int hdlcd_drm_bind(struct device *dev) dev_set_drvdata(dev, drm); - hdlcd_setup_mode_config(drm); + ret = hdlcd_setup_mode_config(drm); + if (ret) + goto err_free; + ret = hdlcd_load(drm, 0); if (ret) goto err_free; @@ -314,9 +324,7 @@ static int hdlcd_drm_bind(struct device *dev) hdlcd_irq_uninstall(hdlcd); of_reserved_mem_device_release(drm->dev); err_free: - drm_mode_config_cleanup(drm); dev_set_drvdata(dev, NULL); - return ret; } @@ -337,7 +345,6 @@ static void hdlcd_drm_unbind(struct device *dev) if (pm_runtime_enabled(dev)) pm_runtime_disable(dev); of_reserved_mem_device_release(dev); - drm_mode_config_cleanup(drm); dev_set_drvdata(dev, NULL); }