From patchwork Tue Jan 12 08:43:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 12012753 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B22EC433E0 for ; Tue, 12 Jan 2021 08:44:20 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id EDDA222E00 for ; Tue, 12 Jan 2021 08:44:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EDDA222E00 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 464956E13C; Tue, 12 Jan 2021 08:44:14 +0000 (UTC) Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9FA996E133 for ; Tue, 12 Jan 2021 08:44:10 +0000 (UTC) Received: by mail-wm1-x334.google.com with SMTP id a6so1141298wmc.2 for ; Tue, 12 Jan 2021 00:44:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NlIVHCD+/Jf8D5qfvDDFtITxKQ16elawMgN9NTrVVIs=; b=RXXYUkB3Bp5VrpJQNLPUZZXGIW7QEuEBbY6AlBxgN2cCfvtOnFv44k4Pg52vj+NtyT KznN7a2AcnQ4dWyDmwygoiGiHvuz7PSHV37TGw+2UemLBEXKJmMgeOOO7zIbj6qJRZrZ 2siGrnlxFYwQCdGC4N6xJVW+UP1GfWvXgNffM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NlIVHCD+/Jf8D5qfvDDFtITxKQ16elawMgN9NTrVVIs=; b=iKhKSVNZaF03JcRdBdcwP4WANSTkj9Jrmb1smOMbAWBO88WKZKBx0e0c2e6mFpdR4H GWFkOWsDv/eAkVfywpuaoswyKfYSbUCdLBzMaNTmKoFmEtsMvdYVFbz3CX9C2h9jFlLw mN+PVDFyBCgN8ebvVVG2QhNHbA3caNPD7IqiqiK/h2yZRfexoQHW77druweeo/nA/fa8 G81BRz1xatSTB6wX9fb+PXsWpIGo2KBGGJ+RTXwZs/UChr9AVR38rqfcIh8UPxo4ivV+ GU/M5JprGeDX+AziDUl5YqdN90YtGnms7zlnujHsqr7vetU8LrYn8hQup0/a2PKQarub S6zw== X-Gm-Message-State: AOAM532sfeWINtnGp/UwK94fzeIc/F23/AjCWjz3vq6tSL4f+WMiQlkJ GRjejpdZS4skaN81qzosp7cpAvko3UdmVmeh X-Google-Smtp-Source: ABdhPJxLJXWBfcNk/YZ6MkBDO3rWOpu/n02luyfMIgokA65HiJc+5GuJvW9ItlwJ6TM58o04HdQ0uQ== X-Received: by 2002:a1c:9a57:: with SMTP id c84mr2351928wme.183.1610441049103; Tue, 12 Jan 2021 00:44:09 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id j15sm3707017wrr.85.2021.01.12.00.44.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 00:44:08 -0800 (PST) From: Daniel Vetter To: DRI Development Subject: [PATCH 04/15] drm/arc: Embedded a drm_simple_display_pipe Date: Tue, 12 Jan 2021 09:43:47 +0100 Message-Id: <20210112084358.2771527-4-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210112084358.2771527-1-daniel.vetter@ffwll.ch> References: <20210112084358.2771527-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 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: Sam Ravnborg , Alexey Brodkin , Daniel Vetter , Daniel Vetter , tiantao6@hisilicon.com, Eugeniy Paltsev Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This is a prep step to convert arc over to the simple kms helpers, for now we just use this as an embedding container to drop all the various allocations. Big change is the removal of the various devm_kzalloc, which have the wrong lifetimes anyway. Acked-by: Sam Ravnborg Cc: Eugeniy Paltsev Signed-off-by: Daniel Vetter Cc: Alexey Brodkin --- drivers/gpu/drm/arc/arcpgu.h | 7 ++++--- drivers/gpu/drm/arc/arcpgu_crtc.c | 9 +++------ drivers/gpu/drm/arc/arcpgu_drv.c | 2 +- drivers/gpu/drm/arc/arcpgu_hdmi.c | 5 ++--- drivers/gpu/drm/arc/arcpgu_sim.c | 5 ++--- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h index ed77dd5dd5cb..52afd638a4d2 100644 --- a/drivers/gpu/drm/arc/arcpgu.h +++ b/drivers/gpu/drm/arc/arcpgu.h @@ -8,17 +8,18 @@ #ifndef _ARCPGU_H_ #define _ARCPGU_H_ +#include + struct arcpgu_drm_private { struct drm_device drm; void __iomem *regs; struct clk *clk; - struct drm_crtc crtc; - struct drm_plane *plane; + struct drm_simple_display_pipe pipe; }; #define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm) -#define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, crtc) +#define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe.crtc) static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu, unsigned int reg, u32 value) diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c index c32038b6366f..31a85c703307 100644 --- a/drivers/gpu/drm/arc/arcpgu_crtc.c +++ b/drivers/gpu/drm/arc/arcpgu_crtc.c @@ -182,9 +182,7 @@ static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm) struct drm_plane *plane = NULL; int ret; - plane = devm_kzalloc(drm->dev, sizeof(*plane), GFP_KERNEL); - if (!plane) - return ERR_PTR(-ENOMEM); + plane = &arcpgu->pipe.plane; ret = drm_universal_plane_init(drm, plane, 0xff, &arc_pgu_plane_funcs, arc_pgu_supported_formats, @@ -195,7 +193,6 @@ static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm) return ERR_PTR(ret); drm_plane_helper_add(plane, &arc_pgu_plane_helper_funcs); - arcpgu->plane = plane; return plane; } @@ -210,13 +207,13 @@ int arc_pgu_setup_crtc(struct drm_device *drm) if (IS_ERR(primary)) return PTR_ERR(primary); - ret = drm_crtc_init_with_planes(drm, &arcpgu->crtc, primary, NULL, + ret = drm_crtc_init_with_planes(drm, &arcpgu->pipe.crtc, primary, NULL, &arc_pgu_crtc_funcs, NULL); if (ret) { arc_pgu_plane_destroy(primary); return ret; } - drm_crtc_helper_add(&arcpgu->crtc, &arc_pgu_crtc_helper_funcs); + drm_crtc_helper_add(&arcpgu->pipe.crtc, &arc_pgu_crtc_helper_funcs); return 0; } diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c index c6a8deb56b0f..9020352816fa 100644 --- a/drivers/gpu/drm/arc/arcpgu_drv.c +++ b/drivers/gpu/drm/arc/arcpgu_drv.c @@ -120,7 +120,7 @@ static int arcpgu_show_pxlclock(struct seq_file *m, void *arg) struct drm_device *drm = node->minor->dev; struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm); unsigned long clkrate = clk_get_rate(arcpgu->clk); - unsigned long mode_clock = arcpgu->crtc.mode.crtc_clock * 1000; + unsigned long mode_clock = arcpgu->pipe.crtc.mode.crtc_clock * 1000; seq_printf(m, "hw : %lu\n", clkrate); seq_printf(m, "mode: %lu\n", mode_clock); diff --git a/drivers/gpu/drm/arc/arcpgu_hdmi.c b/drivers/gpu/drm/arc/arcpgu_hdmi.c index 52839934f2fb..dbad2c9237fe 100644 --- a/drivers/gpu/drm/arc/arcpgu_hdmi.c +++ b/drivers/gpu/drm/arc/arcpgu_hdmi.c @@ -18,14 +18,13 @@ static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = { int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np) { + struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm); struct drm_encoder *encoder; struct drm_bridge *bridge; int ret = 0; - encoder = devm_kzalloc(drm->dev, sizeof(*encoder), GFP_KERNEL); - if (encoder == NULL) - return -ENOMEM; + encoder = &arcpgu->pipe.encoder; /* Locate drm bridge from the hdmi encoder DT node */ bridge = of_drm_find_bridge(np); diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c index 37d961668dfe..134afb9fa625 100644 --- a/drivers/gpu/drm/arc/arcpgu_sim.c +++ b/drivers/gpu/drm/arc/arcpgu_sim.c @@ -56,14 +56,13 @@ static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = { int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np) { + struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm); struct arcpgu_drm_connector *arcpgu_connector; struct drm_encoder *encoder; struct drm_connector *connector; int ret; - encoder = devm_kzalloc(drm->dev, sizeof(*encoder), GFP_KERNEL); - if (encoder == NULL) - return -ENOMEM; + encoder = &arcpgu->pipe.encoder; encoder->possible_crtcs = 1; encoder->possible_clones = 0;