From nobody Wed Oct 1 22:19:48 2025 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D600C27A93D for ; Wed, 1 Oct 2025 02:21:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759285307; cv=pass; b=QoXrw2JO/I+mRkd4bnMH6m9XaP8X47a5y2lUIxFrmFD9wvYxGpzKbTWC+aifSouzjp+xZ1XpKbfoNi7jbsgU004BvbdZMkcxkApyYiwoWbjpk0/4QCXrcbmus6YbdL2Ro1TonF9vnKWGPDH8lcUZoahLqyu81Qx9j0Q9pPDwezk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759285307; c=relaxed/simple; bh=gZSxkSD+frJyP+7ndv0VFOexvGIlyZL5PQiyErRjYO8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DjztPu+ZL/MXRvqm6xHc6Zk0cuMTyfTrhcbIZ9G1Uj26zspBUBqWdzsLMriVBiWCbI7/xSlt62Zu7u9XVu2hCB66PbHjKw1UyRujDDQBaePjZiWzqg0l3TPajeXM2+0hvZsu5OpPV6XDvNtqoNyt/Q83zBQNGshsm9JGuPZavlg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=adrian.larumbe@collabora.com header.b=SbRi/Q61; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=adrian.larumbe@collabora.com header.b="SbRi/Q61" ARC-Seal: i=1; a=rsa-sha256; t=1759285278; cv=none; d=zohomail.com; s=zohoarc; b=TYANoMtwW2zMBSNtKa9oDDcvFtnSeJ9ttT3k/J5A2u/WVudguZrjOVM1k0fujGUBBrSODubuH8m9k1TwkO6hpycKMyi250jhcfEYQplPeqa3gsu2iBNVz8NuPUdSSwlZ/QhD5TE9EjhjPnkjBEiK5+o0JmL0Ijt1pvtx+qyPaX0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759285278; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=1UJ3Zyhs6+THUjoBuuHGOq3Ud0B78IZY5E7bVsUuNzY=; b=N05gpM/gVxjnolgcb2z8MPJzjFtB2rdf3/htbj/DtbYaPdP9fqxCKkqg/3Lt/FU4wi7JQTN3S8gi3lxuES0auXGZ6eGmR4VHpy9fDH9JfXPgRJ0glxI6SSk0WODJiGhkOMRgiBzcFP6/aYieZsMo51lrmgl9ZDseKb/Zk3na6u8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=adrian.larumbe@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1759285278; s=zohomail; d=collabora.com; i=adrian.larumbe@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=1UJ3Zyhs6+THUjoBuuHGOq3Ud0B78IZY5E7bVsUuNzY=; b=SbRi/Q61C21CilI3flEdjYPyZOtI5QiGmel275+Dcee2k5ns3nVaoLImR71EmvFh iNoAK44w8FJLJy/fDdsmBbRaBBfl6dKEK1VFbAUmkdo8OxW7VLtZf/BHjQAodfK06LE IfZbpxzwr8xKzdSuzl1C3LDHyehcP9Na5Xa15vb4= Received: by mx.zohomail.com with SMTPS id 1759285276236488.64319760736726; Tue, 30 Sep 2025 19:21:16 -0700 (PDT) From: =?UTF-8?q?Adri=C3=A1n=20Larumbe?= To: linux-kernel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org, Steven Price , Boris Brezillon , kernel@collabora.com, =?UTF-8?q?Adri=C3=A1n=20Larumbe?= , Rob Herring , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Philipp Zabel Subject: [PATCH v4 01/10] drm/panfrost: Replace DRM driver allocation method with newer one Date: Wed, 1 Oct 2025 03:20:22 +0100 Message-ID: <20251001022039.1215976-2-adrian.larumbe@collabora.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251001022039.1215976-1-adrian.larumbe@collabora.com> References: <20251001022039.1215976-1-adrian.larumbe@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Drop the deprecated DRM driver allocation method in favour of devm_drm_dev_alloc(). Overall just make it the same as in Panthor. Also discard now superfluous generic and platform device pointers inside the main panfrost device structure. Some ancient checkpatch issues unearthed as a result of these changes were also fixed, like lines too long or double assignment in one line. Reviewed-by: Steven Price Acked-by: Boris Brezillon Signed-off-by: Adri=C3=A1n Larumbe --- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 4 +- drivers/gpu/drm/panfrost/panfrost_device.c | 49 ++++++------ drivers/gpu/drm/panfrost/panfrost_device.h | 6 +- drivers/gpu/drm/panfrost/panfrost_drv.c | 74 ++++++++----------- drivers/gpu/drm/panfrost/panfrost_dump.c | 8 +- drivers/gpu/drm/panfrost/panfrost_gem.c | 8 +- .../gpu/drm/panfrost/panfrost_gem_shrinker.c | 4 +- drivers/gpu/drm/panfrost/panfrost_gpu.c | 49 ++++++------ drivers/gpu/drm/panfrost/panfrost_job.c | 37 +++++----- drivers/gpu/drm/panfrost/panfrost_mmu.c | 46 ++++++------ drivers/gpu/drm/panfrost/panfrost_perfcnt.c | 18 ++--- 11 files changed, 146 insertions(+), 157 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/= panfrost/panfrost_devfreq.c index 5d0dce10336b..ac05df2a54fe 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c @@ -74,7 +74,7 @@ static int panfrost_devfreq_get_dev_status(struct device = *dev, =20 spin_unlock_irqrestore(&pfdevfreq->lock, irqflags); =20 - dev_dbg(pfdev->dev, "busy %lu total %lu %lu %% freq %lu MHz\n", + dev_dbg(pfdev->base.dev, "busy %lu total %lu %lu %% freq %lu MHz\n", status->busy_time, status->total_time, status->busy_time / (status->total_time / 100), status->current_frequency / 1000 / 1000); @@ -119,7 +119,7 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) int ret; struct dev_pm_opp *opp; unsigned long cur_freq; - struct device *dev =3D &pfdev->pdev->dev; + struct device *dev =3D pfdev->base.dev; struct devfreq *devfreq; struct thermal_cooling_device *cooling; struct panfrost_devfreq *pfdevfreq =3D &pfdev->pfdevfreq; diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/p= anfrost/panfrost_device.c index 04bec27449cb..733b728ec75f 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.c +++ b/drivers/gpu/drm/panfrost/panfrost_device.c @@ -20,9 +20,9 @@ =20 static int panfrost_reset_init(struct panfrost_device *pfdev) { - pfdev->rstc =3D devm_reset_control_array_get_optional_exclusive(pfdev->de= v); + pfdev->rstc =3D devm_reset_control_array_get_optional_exclusive(pfdev->ba= se.dev); if (IS_ERR(pfdev->rstc)) { - dev_err(pfdev->dev, "get reset failed %ld\n", PTR_ERR(pfdev->rstc)); + dev_err(pfdev->base.dev, "get reset failed %ld\n", PTR_ERR(pfdev->rstc)); return PTR_ERR(pfdev->rstc); } =20 @@ -39,22 +39,22 @@ static int panfrost_clk_init(struct panfrost_device *pf= dev) int err; unsigned long rate; =20 - pfdev->clock =3D devm_clk_get(pfdev->dev, NULL); + pfdev->clock =3D devm_clk_get(pfdev->base.dev, NULL); if (IS_ERR(pfdev->clock)) { - dev_err(pfdev->dev, "get clock failed %ld\n", PTR_ERR(pfdev->clock)); + dev_err(pfdev->base.dev, "get clock failed %ld\n", PTR_ERR(pfdev->clock)= ); return PTR_ERR(pfdev->clock); } =20 rate =3D clk_get_rate(pfdev->clock); - dev_info(pfdev->dev, "clock rate =3D %lu\n", rate); + dev_info(pfdev->base.dev, "clock rate =3D %lu\n", rate); =20 err =3D clk_prepare_enable(pfdev->clock); if (err) return err; =20 - pfdev->bus_clock =3D devm_clk_get_optional(pfdev->dev, "bus"); + pfdev->bus_clock =3D devm_clk_get_optional(pfdev->base.dev, "bus"); if (IS_ERR(pfdev->bus_clock)) { - dev_err(pfdev->dev, "get bus_clock failed %ld\n", + dev_err(pfdev->base.dev, "get bus_clock failed %ld\n", PTR_ERR(pfdev->bus_clock)); err =3D PTR_ERR(pfdev->bus_clock); goto disable_clock; @@ -62,7 +62,7 @@ static int panfrost_clk_init(struct panfrost_device *pfde= v) =20 if (pfdev->bus_clock) { rate =3D clk_get_rate(pfdev->bus_clock); - dev_info(pfdev->dev, "bus_clock rate =3D %lu\n", rate); + dev_info(pfdev->base.dev, "bus_clock rate =3D %lu\n", rate); =20 err =3D clk_prepare_enable(pfdev->bus_clock); if (err) @@ -87,7 +87,7 @@ static int panfrost_regulator_init(struct panfrost_device= *pfdev) { int ret, i; =20 - pfdev->regulators =3D devm_kcalloc(pfdev->dev, pfdev->comp->num_supplies, + pfdev->regulators =3D devm_kcalloc(pfdev->base.dev, pfdev->comp->num_supp= lies, sizeof(*pfdev->regulators), GFP_KERNEL); if (!pfdev->regulators) @@ -96,12 +96,12 @@ static int panfrost_regulator_init(struct panfrost_devi= ce *pfdev) for (i =3D 0; i < pfdev->comp->num_supplies; i++) pfdev->regulators[i].supply =3D pfdev->comp->supply_names[i]; =20 - ret =3D devm_regulator_bulk_get(pfdev->dev, + ret =3D devm_regulator_bulk_get(pfdev->base.dev, pfdev->comp->num_supplies, pfdev->regulators); if (ret < 0) { if (ret !=3D -EPROBE_DEFER) - dev_err(pfdev->dev, "failed to get regulators: %d\n", + dev_err(pfdev->base.dev, "failed to get regulators: %d\n", ret); return ret; } @@ -109,7 +109,7 @@ static int panfrost_regulator_init(struct panfrost_devi= ce *pfdev) ret =3D regulator_bulk_enable(pfdev->comp->num_supplies, pfdev->regulators); if (ret < 0) { - dev_err(pfdev->dev, "failed to enable regulators: %d\n", ret); + dev_err(pfdev->base.dev, "failed to enable regulators: %d\n", ret); return ret; } =20 @@ -144,7 +144,7 @@ static int panfrost_pm_domain_init(struct panfrost_devi= ce *pfdev) int err; int i, num_domains; =20 - num_domains =3D of_count_phandle_with_args(pfdev->dev->of_node, + num_domains =3D of_count_phandle_with_args(pfdev->base.dev->of_node, "power-domains", "#power-domain-cells"); =20 @@ -156,7 +156,7 @@ static int panfrost_pm_domain_init(struct panfrost_devi= ce *pfdev) return 0; =20 if (num_domains !=3D pfdev->comp->num_pm_domains) { - dev_err(pfdev->dev, + dev_err(pfdev->base.dev, "Incorrect number of power domains: %d provided, %d needed\n", num_domains, pfdev->comp->num_pm_domains); return -EINVAL; @@ -168,20 +168,21 @@ static int panfrost_pm_domain_init(struct panfrost_de= vice *pfdev) =20 for (i =3D 0; i < num_domains; i++) { pfdev->pm_domain_devs[i] =3D - dev_pm_domain_attach_by_name(pfdev->dev, - pfdev->comp->pm_domain_names[i]); + dev_pm_domain_attach_by_name(pfdev->base.dev, + pfdev->comp->pm_domain_names[i]); if (IS_ERR_OR_NULL(pfdev->pm_domain_devs[i])) { err =3D PTR_ERR(pfdev->pm_domain_devs[i]) ? : -ENODATA; pfdev->pm_domain_devs[i] =3D NULL; - dev_err(pfdev->dev, + dev_err(pfdev->base.dev, "failed to get pm-domain %s(%d): %d\n", pfdev->comp->pm_domain_names[i], i, err); goto err; } =20 - pfdev->pm_domain_links[i] =3D device_link_add(pfdev->dev, - pfdev->pm_domain_devs[i], DL_FLAG_PM_RUNTIME | - DL_FLAG_STATELESS | DL_FLAG_RPM_ACTIVE); + pfdev->pm_domain_links[i] =3D + device_link_add(pfdev->base.dev, + pfdev->pm_domain_devs[i], DL_FLAG_PM_RUNTIME | + DL_FLAG_STATELESS | DL_FLAG_RPM_ACTIVE); if (!pfdev->pm_domain_links[i]) { dev_err(pfdev->pm_domain_devs[i], "adding device link failed!\n"); @@ -220,20 +221,20 @@ int panfrost_device_init(struct panfrost_device *pfde= v) =20 err =3D panfrost_reset_init(pfdev); if (err) { - dev_err(pfdev->dev, "reset init failed %d\n", err); + dev_err(pfdev->base.dev, "reset init failed %d\n", err); goto out_pm_domain; } =20 err =3D panfrost_clk_init(pfdev); if (err) { - dev_err(pfdev->dev, "clk init failed %d\n", err); + dev_err(pfdev->base.dev, "clk init failed %d\n", err); goto out_reset; } =20 err =3D panfrost_devfreq_init(pfdev); if (err) { if (err !=3D -EPROBE_DEFER) - dev_err(pfdev->dev, "devfreq init failed %d\n", err); + dev_err(pfdev->base.dev, "devfreq init failed %d\n", err); goto out_clk; } =20 @@ -244,7 +245,7 @@ int panfrost_device_init(struct panfrost_device *pfdev) goto out_devfreq; } =20 - pfdev->iomem =3D devm_platform_ioremap_resource(pfdev->pdev, 0); + pfdev->iomem =3D devm_platform_ioremap_resource(to_platform_device(pfdev-= >base.dev), 0); if (IS_ERR(pfdev->iomem)) { err =3D PTR_ERR(pfdev->iomem); goto out_regulator; diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/p= anfrost/panfrost_device.h index 1e73efad02a8..474b232bb38e 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.h +++ b/drivers/gpu/drm/panfrost/panfrost_device.h @@ -124,9 +124,7 @@ struct panfrost_device_debugfs { }; =20 struct panfrost_device { - struct device *dev; - struct drm_device *ddev; - struct platform_device *pdev; + struct drm_device base; int gpu_irq; int mmu_irq; =20 @@ -222,7 +220,7 @@ static inline bool panfrost_high_prio_allowed(struct dr= m_file *file) =20 static inline struct panfrost_device *to_panfrost_device(struct drm_device= *ddev) { - return ddev->dev_private; + return container_of(ddev, struct panfrost_device, base); } =20 static inline int panfrost_model_cmp(struct panfrost_device *pfdev, s32 id) diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panf= rost/panfrost_drv.c index 22350ce8a08f..2b57f6813714 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -36,7 +36,7 @@ static int panfrost_ioctl_query_timestamp(struct panfrost= _device *pfdev, { int ret; =20 - ret =3D pm_runtime_resume_and_get(pfdev->dev); + ret =3D pm_runtime_resume_and_get(pfdev->base.dev); if (ret) return ret; =20 @@ -44,14 +44,14 @@ static int panfrost_ioctl_query_timestamp(struct panfro= st_device *pfdev, *arg =3D panfrost_timestamp_read(pfdev); panfrost_cycle_counter_put(pfdev); =20 - pm_runtime_put(pfdev->dev); + pm_runtime_put(pfdev->base.dev); return 0; } =20 static int panfrost_ioctl_get_param(struct drm_device *ddev, void *data, s= truct drm_file *file) { struct drm_panfrost_get_param *param =3D data; - struct panfrost_device *pfdev =3D ddev->dev_private; + struct panfrost_device *pfdev =3D to_panfrost_device(ddev); int ret; =20 if (param->pad !=3D 0) @@ -283,7 +283,7 @@ panfrost_copy_in_sync(struct drm_device *dev, static int panfrost_ioctl_submit(struct drm_device *dev, void *data, struct drm_file *file) { - struct panfrost_device *pfdev =3D dev->dev_private; + struct panfrost_device *pfdev =3D to_panfrost_device(dev); struct panfrost_file_priv *file_priv =3D file->driver_priv; struct drm_panfrost_submit *args =3D data; struct drm_syncobj *sync_out =3D NULL; @@ -457,7 +457,7 @@ static int panfrost_ioctl_madvise(struct drm_device *de= v, void *data, { struct panfrost_file_priv *priv =3D file_priv->driver_priv; struct drm_panfrost_madvise *args =3D data; - struct panfrost_device *pfdev =3D dev->dev_private; + struct panfrost_device *pfdev =3D to_panfrost_device(dev); struct drm_gem_object *gem_obj; struct panfrost_gem_object *bo; int ret =3D 0; @@ -590,7 +590,7 @@ static int panfrost_open(struct drm_device *dev, struct drm_file *file) { int ret; - struct panfrost_device *pfdev =3D dev->dev_private; + struct panfrost_device *pfdev =3D to_panfrost_device(dev); struct panfrost_file_priv *panfrost_priv; =20 panfrost_priv =3D kzalloc(sizeof(*panfrost_priv), GFP_KERNEL); @@ -690,8 +690,7 @@ static void panfrost_gpu_show_fdinfo(struct panfrost_de= vice *pfdev, =20 static void panfrost_show_fdinfo(struct drm_printer *p, struct drm_file *f= ile) { - struct drm_device *dev =3D file->minor->dev; - struct panfrost_device *pfdev =3D dev->dev_private; + struct panfrost_device *pfdev =3D to_panfrost_device(file->minor->dev); =20 panfrost_gpu_show_fdinfo(pfdev, file->driver_priv, p); =20 @@ -708,8 +707,7 @@ static const struct file_operations panfrost_drm_driver= _fops =3D { static int panthor_gems_show(struct seq_file *m, void *data) { struct drm_info_node *node =3D m->private; - struct drm_device *dev =3D node->minor->dev; - struct panfrost_device *pfdev =3D dev->dev_private; + struct panfrost_device *pfdev =3D to_panfrost_device(node->minor->dev); =20 panfrost_gem_debugfs_print_bos(pfdev, m); =20 @@ -758,7 +756,8 @@ static int show_file_jm_ctxs(struct panfrost_file_priv = *pfile, } =20 static struct drm_info_list panthor_debugfs_list[] =3D { - {"gems", panthor_gems_show, 0, NULL}, + {"gems", + panthor_gems_show, 0, NULL}, }; =20 static int panthor_gems_debugfs_init(struct drm_minor *minor) @@ -865,15 +864,12 @@ static const struct drm_driver panfrost_drm_driver = =3D { static int panfrost_probe(struct platform_device *pdev) { struct panfrost_device *pfdev; - struct drm_device *ddev; int err; =20 - pfdev =3D devm_kzalloc(&pdev->dev, sizeof(*pfdev), GFP_KERNEL); - if (!pfdev) - return -ENOMEM; - - pfdev->pdev =3D pdev; - pfdev->dev =3D &pdev->dev; + pfdev =3D devm_drm_dev_alloc(&pdev->dev, &panfrost_drm_driver, + struct panfrost_device, base); + if (IS_ERR(pfdev)) + return PTR_ERR(pfdev); =20 platform_set_drvdata(pdev, pfdev); =20 @@ -883,14 +879,6 @@ static int panfrost_probe(struct platform_device *pdev) =20 pfdev->coherent =3D device_get_dma_attr(&pdev->dev) =3D=3D DEV_DMA_COHERE= NT; =20 - /* Allocate and initialize the DRM device. */ - ddev =3D drm_dev_alloc(&panfrost_drm_driver, &pdev->dev); - if (IS_ERR(ddev)) - return PTR_ERR(ddev); - - ddev->dev_private =3D pfdev; - pfdev->ddev =3D ddev; - mutex_init(&pfdev->shrinker_lock); INIT_LIST_HEAD(&pfdev->shrinker_list); =20 @@ -901,51 +889,47 @@ static int panfrost_probe(struct platform_device *pde= v) goto err_out0; } =20 - pm_runtime_set_active(pfdev->dev); - pm_runtime_mark_last_busy(pfdev->dev); - pm_runtime_enable(pfdev->dev); - pm_runtime_set_autosuspend_delay(pfdev->dev, 50); /* ~3 frames */ - pm_runtime_use_autosuspend(pfdev->dev); + pm_runtime_set_active(pfdev->base.dev); + pm_runtime_mark_last_busy(pfdev->base.dev); + pm_runtime_enable(pfdev->base.dev); + pm_runtime_set_autosuspend_delay(pfdev->base.dev, 50); /* ~3 frames */ + pm_runtime_use_autosuspend(pfdev->base.dev); =20 /* * Register the DRM device with the core and the connectors with * sysfs */ - err =3D drm_dev_register(ddev, 0); + err =3D drm_dev_register(&pfdev->base, 0); if (err < 0) goto err_out1; =20 - err =3D panfrost_gem_shrinker_init(ddev); + err =3D panfrost_gem_shrinker_init(&pfdev->base); if (err) goto err_out2; =20 return 0; =20 err_out2: - drm_dev_unregister(ddev); + drm_dev_unregister(&pfdev->base); err_out1: - pm_runtime_disable(pfdev->dev); + pm_runtime_disable(pfdev->base.dev); panfrost_device_fini(pfdev); - pm_runtime_set_suspended(pfdev->dev); + pm_runtime_set_suspended(pfdev->base.dev); err_out0: - drm_dev_put(ddev); return err; } =20 static void panfrost_remove(struct platform_device *pdev) { struct panfrost_device *pfdev =3D platform_get_drvdata(pdev); - struct drm_device *ddev =3D pfdev->ddev; =20 - drm_dev_unregister(ddev); - panfrost_gem_shrinker_cleanup(ddev); + drm_dev_unregister(&pfdev->base); + panfrost_gem_shrinker_cleanup(&pfdev->base); =20 - pm_runtime_get_sync(pfdev->dev); - pm_runtime_disable(pfdev->dev); + pm_runtime_get_sync(pfdev->base.dev); + pm_runtime_disable(pfdev->base.dev); panfrost_device_fini(pfdev); - pm_runtime_set_suspended(pfdev->dev); - - drm_dev_put(ddev); + pm_runtime_set_suspended(pfdev->base.dev); } =20 static ssize_t profiling_show(struct device *dev, diff --git a/drivers/gpu/drm/panfrost/panfrost_dump.c b/drivers/gpu/drm/pan= frost/panfrost_dump.c index 4042afe2fbf4..3ed6c902d0a1 100644 --- a/drivers/gpu/drm/panfrost/panfrost_dump.c +++ b/drivers/gpu/drm/panfrost/panfrost_dump.c @@ -163,7 +163,7 @@ void panfrost_core_dump(struct panfrost_job *job) iter.start =3D __vmalloc(file_size, GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY); if (!iter.start) { - dev_warn(pfdev->dev, "failed to allocate devcoredump file\n"); + dev_warn(pfdev->base.dev, "failed to allocate devcoredump file\n"); return; } =20 @@ -204,14 +204,14 @@ void panfrost_core_dump(struct panfrost_job *job) mapping =3D job->mappings[i]; =20 if (!bo->base.sgt) { - dev_err(pfdev->dev, "Panfrost Dump: BO has no sgt, cannot dump\n"); + dev_err(pfdev->base.dev, "Panfrost Dump: BO has no sgt, cannot dump\n"); iter.hdr->bomap.valid =3D 0; goto dump_header; } =20 ret =3D drm_gem_vmap(&bo->base.base, &map); if (ret) { - dev_err(pfdev->dev, "Panfrost Dump: couldn't map Buffer Object\n"); + dev_err(pfdev->base.dev, "Panfrost Dump: couldn't map Buffer Object\n"); iter.hdr->bomap.valid =3D 0; goto dump_header; } @@ -237,5 +237,5 @@ dump_header: panfrost_core_dump_header(&iter, PANFROSTD= UMP_BUF_BO, iter.data + } panfrost_core_dump_header(&iter, PANFROSTDUMP_BUF_TRAILER, iter.data); =20 - dev_coredumpv(pfdev->dev, iter.start, iter.data - iter.start, GFP_KERNEL); + dev_coredumpv(pfdev->base.dev, iter.start, iter.data - iter.start, GFP_KE= RNEL); } diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panf= rost/panfrost_gem.c index 85d6289a6eda..0528de674a4f 100644 --- a/drivers/gpu/drm/panfrost/panfrost_gem.c +++ b/drivers/gpu/drm/panfrost/panfrost_gem.c @@ -26,7 +26,7 @@ static void panfrost_gem_debugfs_bo_add(struct panfrost_d= evice *pfdev, =20 static void panfrost_gem_debugfs_bo_rm(struct panfrost_gem_object *bo) { - struct panfrost_device *pfdev =3D bo->base.base.dev->dev_private; + struct panfrost_device *pfdev =3D to_panfrost_device(bo->base.base.dev); =20 if (list_empty(&bo->debugfs.node)) return; @@ -48,7 +48,7 @@ static void panfrost_gem_debugfs_bo_rm(struct panfrost_ge= m_object *bo) {} static void panfrost_gem_free_object(struct drm_gem_object *obj) { struct panfrost_gem_object *bo =3D to_panfrost_bo(obj); - struct panfrost_device *pfdev =3D obj->dev->dev_private; + struct panfrost_device *pfdev =3D to_panfrost_device(obj->dev); =20 /* * Make sure the BO is no longer inserted in the shrinker list before @@ -76,7 +76,7 @@ static void panfrost_gem_free_object(struct drm_gem_objec= t *obj) =20 for (i =3D 0; i < n_sgt; i++) { if (bo->sgts[i].sgl) { - dma_unmap_sgtable(pfdev->dev, &bo->sgts[i], + dma_unmap_sgtable(pfdev->base.dev, &bo->sgts[i], DMA_BIDIRECTIONAL, 0); sg_free_table(&bo->sgts[i]); } @@ -284,7 +284,7 @@ static const struct drm_gem_object_funcs panfrost_gem_f= uncs =3D { */ struct drm_gem_object *panfrost_gem_create_object(struct drm_device *dev, = size_t size) { - struct panfrost_device *pfdev =3D dev->dev_private; + struct panfrost_device *pfdev =3D to_panfrost_device(dev); struct panfrost_gem_object *obj; =20 obj =3D kzalloc(sizeof(*obj), GFP_KERNEL); diff --git a/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c b/drivers/gpu= /drm/panfrost/panfrost_gem_shrinker.c index 02b60ea1433a..2fe967a90bcb 100644 --- a/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c +++ b/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c @@ -97,7 +97,7 @@ panfrost_gem_shrinker_scan(struct shrinker *shrinker, str= uct shrink_control *sc) */ int panfrost_gem_shrinker_init(struct drm_device *dev) { - struct panfrost_device *pfdev =3D dev->dev_private; + struct panfrost_device *pfdev =3D to_panfrost_device(dev); =20 pfdev->shrinker =3D shrinker_alloc(0, "drm-panfrost"); if (!pfdev->shrinker) @@ -120,7 +120,7 @@ int panfrost_gem_shrinker_init(struct drm_device *dev) */ void panfrost_gem_shrinker_cleanup(struct drm_device *dev) { - struct panfrost_device *pfdev =3D dev->dev_private; + struct panfrost_device *pfdev =3D to_panfrost_device(dev); =20 if (pfdev->shrinker) shrinker_free(pfdev->shrinker); diff --git a/drivers/gpu/drm/panfrost/panfrost_gpu.c b/drivers/gpu/drm/panf= rost/panfrost_gpu.c index 174e190ba40f..f94337a6c302 100644 --- a/drivers/gpu/drm/panfrost/panfrost_gpu.c +++ b/drivers/gpu/drm/panfrost/panfrost_gpu.c @@ -36,12 +36,12 @@ static irqreturn_t panfrost_gpu_irq_handler(int irq, vo= id *data) u64 address =3D (u64) gpu_read(pfdev, GPU_FAULT_ADDRESS_HI) << 32; address |=3D gpu_read(pfdev, GPU_FAULT_ADDRESS_LO); =20 - dev_warn(pfdev->dev, "GPU Fault 0x%08x (%s) at 0x%016llx\n", + dev_warn(pfdev->base.dev, "GPU Fault 0x%08x (%s) at 0x%016llx\n", fault_status, panfrost_exception_name(fault_status & 0xFF), address); =20 if (state & GPU_IRQ_MULTIPLE_FAULT) - dev_warn(pfdev->dev, "There were multiple GPU faults - some have not be= en reported\n"); + dev_warn(pfdev->base.dev, "There were multiple GPU faults - some have n= ot been reported\n"); =20 gpu_write(pfdev, GPU_INT_MASK, 0); } @@ -72,13 +72,13 @@ int panfrost_gpu_soft_reset(struct panfrost_device *pfd= ev) val, val & GPU_IRQ_RESET_COMPLETED, 10, 10000); =20 if (ret) { - dev_err(pfdev->dev, "gpu soft reset timed out, attempting hard reset\n"); + dev_err(pfdev->base.dev, "gpu soft reset timed out, attempting hard rese= t\n"); =20 gpu_write(pfdev, GPU_CMD, GPU_CMD_HARD_RESET); ret =3D readl_relaxed_poll_timeout(pfdev->iomem + GPU_INT_RAWSTAT, val, val & GPU_IRQ_RESET_COMPLETED, 100, 10000); if (ret) { - dev_err(pfdev->dev, "gpu hard reset timed out\n"); + dev_err(pfdev->base.dev, "gpu hard reset timed out\n"); return ret; } } @@ -95,7 +95,7 @@ int panfrost_gpu_soft_reset(struct panfrost_device *pfdev) * All in-flight jobs should have released their cycle * counter references upon reset, but let us make sure */ - if (drm_WARN_ON(pfdev->ddev, atomic_read(&pfdev->cycle_counter.use_count)= !=3D 0)) + if (drm_WARN_ON(&pfdev->base, atomic_read(&pfdev->cycle_counter.use_count= ) !=3D 0)) atomic_set(&pfdev->cycle_counter.use_count, 0); =20 return 0; @@ -330,13 +330,13 @@ static void panfrost_gpu_init_features(struct panfros= t_device *pfdev) bitmap_from_u64(pfdev->features.hw_features, hw_feat); bitmap_from_u64(pfdev->features.hw_issues, hw_issues); =20 - dev_info(pfdev->dev, "mali-%s id 0x%x major 0x%x minor 0x%x status 0x%x", + dev_info(pfdev->base.dev, "mali-%s id 0x%x major 0x%x minor 0x%x status 0= x%x", name, gpu_id, major, minor, status); - dev_info(pfdev->dev, "features: %64pb, issues: %64pb", + dev_info(pfdev->base.dev, "features: %64pb, issues: %64pb", pfdev->features.hw_features, pfdev->features.hw_issues); =20 - dev_info(pfdev->dev, "Features: L2:0x%08x Shader:0x%08x Tiler:0x%08x Mem:= 0x%0x MMU:0x%08x AS:0x%x JS:0x%x", + dev_info(pfdev->base.dev, "Features: L2:0x%08x Shader:0x%08x Tiler:0x%08x= Mem:0x%0x MMU:0x%08x AS:0x%x JS:0x%x", pfdev->features.l2_features, pfdev->features.core_features, pfdev->features.tiler_features, @@ -345,7 +345,7 @@ static void panfrost_gpu_init_features(struct panfrost_= device *pfdev) pfdev->features.as_present, pfdev->features.js_present); =20 - dev_info(pfdev->dev, "shader_present=3D0x%0llx l2_present=3D0x%0llx", + dev_info(pfdev->base.dev, "shader_present=3D0x%0llx l2_present=3D0x%0llx", pfdev->features.shader_present, pfdev->features.l2_present); } =20 @@ -411,7 +411,7 @@ static u64 panfrost_get_core_mask(struct panfrost_devic= e *pfdev) */ core_mask =3D ~(pfdev->features.l2_present - 1) & (pfdev->features.l2_present - 2); - dev_info_once(pfdev->dev, "using only 1st core group (%lu cores from %lu)= \n", + dev_info_once(pfdev->base.dev, "using only 1st core group (%lu cores from= %lu)\n", hweight64(core_mask), hweight64(pfdev->features.shader_present)); =20 @@ -432,7 +432,7 @@ void panfrost_gpu_power_on(struct panfrost_device *pfde= v) val, val =3D=3D (pfdev->features.l2_present & core_mask), 10, 20000); if (ret) - dev_err(pfdev->dev, "error powering up gpu L2"); + dev_err(pfdev->base.dev, "error powering up gpu L2"); =20 gpu_write(pfdev, SHADER_PWRON_LO, pfdev->features.shader_present & core_mask); @@ -440,13 +440,13 @@ void panfrost_gpu_power_on(struct panfrost_device *pf= dev) val, val =3D=3D (pfdev->features.shader_present & core_mask), 10, 20000); if (ret) - dev_err(pfdev->dev, "error powering up gpu shader"); + dev_err(pfdev->base.dev, "error powering up gpu shader"); =20 gpu_write(pfdev, TILER_PWRON_LO, pfdev->features.tiler_present); ret =3D readl_relaxed_poll_timeout(pfdev->iomem + TILER_READY_LO, val, val =3D=3D pfdev->features.tiler_present, 10, 1000); if (ret) - dev_err(pfdev->dev, "error powering up gpu tiler"); + dev_err(pfdev->base.dev, "error powering up gpu tiler"); } =20 void panfrost_gpu_power_off(struct panfrost_device *pfdev) @@ -458,19 +458,19 @@ void panfrost_gpu_power_off(struct panfrost_device *p= fdev) ret =3D readl_relaxed_poll_timeout(pfdev->iomem + SHADER_PWRTRANS_LO, val, !val, 1, 2000); if (ret) - dev_err(pfdev->dev, "shader power transition timeout"); + dev_err(pfdev->base.dev, "shader power transition timeout"); =20 gpu_write(pfdev, TILER_PWROFF_LO, pfdev->features.tiler_present); ret =3D readl_relaxed_poll_timeout(pfdev->iomem + TILER_PWRTRANS_LO, val, !val, 1, 2000); if (ret) - dev_err(pfdev->dev, "tiler power transition timeout"); + dev_err(pfdev->base.dev, "tiler power transition timeout"); =20 gpu_write(pfdev, L2_PWROFF_LO, pfdev->features.l2_present); ret =3D readl_poll_timeout(pfdev->iomem + L2_PWRTRANS_LO, val, !val, 0, 2000); if (ret) - dev_err(pfdev->dev, "l2 power transition timeout"); + dev_err(pfdev->base.dev, "l2 power transition timeout"); } =20 void panfrost_gpu_suspend_irq(struct panfrost_device *pfdev) @@ -491,21 +491,22 @@ int panfrost_gpu_init(struct panfrost_device *pfdev) =20 panfrost_gpu_init_features(pfdev); =20 - err =3D dma_set_mask_and_coherent(pfdev->dev, - DMA_BIT_MASK(FIELD_GET(0xff00, pfdev->features.mmu_features))); + err =3D dma_set_mask_and_coherent(pfdev->base.dev, + DMA_BIT_MASK(FIELD_GET(0xff00, + pfdev->features.mmu_features))); if (err) return err; =20 - dma_set_max_seg_size(pfdev->dev, UINT_MAX); + dma_set_max_seg_size(pfdev->base.dev, UINT_MAX); =20 - pfdev->gpu_irq =3D platform_get_irq_byname(to_platform_device(pfdev->dev)= , "gpu"); + pfdev->gpu_irq =3D platform_get_irq_byname(to_platform_device(pfdev->base= .dev), "gpu"); if (pfdev->gpu_irq < 0) return pfdev->gpu_irq; =20 - err =3D devm_request_irq(pfdev->dev, pfdev->gpu_irq, panfrost_gpu_irq_han= dler, + err =3D devm_request_irq(pfdev->base.dev, pfdev->gpu_irq, panfrost_gpu_ir= q_handler, IRQF_SHARED, KBUILD_MODNAME "-gpu", pfdev); if (err) { - dev_err(pfdev->dev, "failed to request gpu irq"); + dev_err(pfdev->base.dev, "failed to request gpu irq"); return err; } =20 @@ -525,9 +526,9 @@ u32 panfrost_gpu_get_latest_flush_id(struct panfrost_de= vice *pfdev) =20 if (panfrost_has_hw_feature(pfdev, HW_FEATURE_FLUSH_REDUCTION)) { /* Flush reduction only makes sense when the GPU is kept powered on betw= een jobs */ - if (pm_runtime_get_if_in_use(pfdev->dev)) { + if (pm_runtime_get_if_in_use(pfdev->base.dev)) { flush_id =3D gpu_read(pfdev, GPU_LATEST_FLUSH_ID); - pm_runtime_put(pfdev->dev); + pm_runtime_put(pfdev->base.dev); return flush_id; } } diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panf= rost/panfrost_job.c index c47d14eabbae..a0123d0a1b7d 100644 --- a/drivers/gpu/drm/panfrost/panfrost_job.c +++ b/drivers/gpu/drm/panfrost/panfrost_job.c @@ -95,7 +95,7 @@ static struct dma_fence *panfrost_fence_create(struct pan= frost_device *pfdev, in if (!fence) return ERR_PTR(-ENOMEM); =20 - fence->dev =3D pfdev->ddev; + fence->dev =3D &pfdev->base; fence->queue =3D js_num; fence->seqno =3D ++js->queue[js_num].emit_seqno; dma_fence_init(&fence->base, &panfrost_fence_ops, &js->job_lock, @@ -206,7 +206,7 @@ static void panfrost_job_hw_submit(struct panfrost_job = *job, int js) =20 panfrost_devfreq_record_busy(&pfdev->pfdevfreq); =20 - ret =3D pm_runtime_get_sync(pfdev->dev); + ret =3D pm_runtime_get_sync(pfdev->base.dev); if (ret < 0) return; =20 @@ -257,7 +257,7 @@ static void panfrost_job_hw_submit(struct panfrost_job = *job, int js) } =20 job_write(pfdev, JS_COMMAND_NEXT(js), JS_COMMAND_START); - dev_dbg(pfdev->dev, + dev_dbg(pfdev->base.dev, "JS: Submitting atom %p to js[%d][%d] with head=3D0x%llx AS %d", job, js, subslot, jc_head, cfg & 0xf); } @@ -442,12 +442,12 @@ static void panfrost_job_handle_err(struct panfrost_d= evice *pfdev, bool signal_fence =3D true; =20 if (!panfrost_exception_is_fault(js_status)) { - dev_dbg(pfdev->dev, "js event, js=3D%d, status=3D%s, head=3D0x%x, tail= =3D0x%x", + dev_dbg(pfdev->base.dev, "js event, js=3D%d, status=3D%s, head=3D0x%x, t= ail=3D0x%x", js, exception_name, job_read(pfdev, JS_HEAD_LO(js)), job_read(pfdev, JS_TAIL_LO(js))); } else { - dev_err(pfdev->dev, "js fault, js=3D%d, status=3D%s, head=3D0x%x, tail= =3D0x%x", + dev_err(pfdev->base.dev, "js fault, js=3D%d, status=3D%s, head=3D0x%x, t= ail=3D0x%x", js, exception_name, job_read(pfdev, JS_HEAD_LO(js)), job_read(pfdev, JS_TAIL_LO(js))); @@ -479,7 +479,7 @@ static void panfrost_job_handle_err(struct panfrost_dev= ice *pfdev, if (signal_fence) dma_fence_signal_locked(job->done_fence); =20 - pm_runtime_put_autosuspend(pfdev->dev); + pm_runtime_put_autosuspend(pfdev->base.dev); =20 if (panfrost_exception_needs_reset(pfdev, js_status)) { atomic_set(&pfdev->reset.pending, 1); @@ -498,7 +498,7 @@ static void panfrost_job_handle_done(struct panfrost_de= vice *pfdev, panfrost_devfreq_record_idle(&pfdev->pfdevfreq); =20 dma_fence_signal_locked(job->done_fence); - pm_runtime_put_autosuspend(pfdev->dev); + pm_runtime_put_autosuspend(pfdev->base.dev); } =20 static void panfrost_job_handle_irq(struct panfrost_device *pfdev, u32 sta= tus) @@ -607,7 +607,7 @@ static void panfrost_job_handle_irqs(struct panfrost_de= vice *pfdev) u32 status =3D job_read(pfdev, JOB_INT_RAWSTAT); =20 while (status) { - pm_runtime_mark_last_busy(pfdev->dev); + pm_runtime_mark_last_busy(pfdev->base.dev); =20 spin_lock(&pfdev->js->job_lock); panfrost_job_handle_irq(pfdev, status); @@ -688,7 +688,7 @@ panfrost_reset(struct panfrost_device *pfdev, 10, 10000); =20 if (ret) - dev_err(pfdev->dev, "Soft-stop failed\n"); + dev_err(pfdev->base.dev, "Soft-stop failed\n"); =20 /* Handle the remaining interrupts before we reset. */ panfrost_job_handle_irqs(pfdev); @@ -706,7 +706,7 @@ panfrost_reset(struct panfrost_device *pfdev, if (pfdev->jobs[i][j]->requirements & PANFROST_JD_REQ_CYCLE_COUNT || pfdev->jobs[i][j]->is_profiled) panfrost_cycle_counter_put(pfdev->jobs[i][j]->pfdev); - pm_runtime_put_noidle(pfdev->dev); + pm_runtime_put_noidle(pfdev->base.dev); panfrost_devfreq_record_idle(&pfdev->pfdevfreq); } } @@ -774,11 +774,11 @@ static enum drm_gpu_sched_stat panfrost_job_timedout(= struct drm_sched_job synchronize_irq(pfdev->js->irq); =20 if (dma_fence_is_signaled(job->done_fence)) { - dev_warn(pfdev->dev, "unexpectedly high interrupt latency\n"); + dev_warn(pfdev->base.dev, "unexpectedly high interrupt latency\n"); return DRM_GPU_SCHED_STAT_NO_HANG; } =20 - dev_err(pfdev->dev, "gpu sched timeout, js=3D%d, config=3D0x%x, status=3D= 0x%x, head=3D0x%x, tail=3D0x%x, sched_job=3D%p", + dev_err(pfdev->base.dev, "gpu sched timeout, js=3D%d, config=3D0x%x, stat= us=3D0x%x, head=3D0x%x, tail=3D0x%x, sched_job=3D%p", js, job_read(pfdev, JS_CONFIG(js)), job_read(pfdev, JS_STATUS(js)), @@ -847,7 +847,7 @@ int panfrost_job_init(struct panfrost_device *pfdev) .credit_limit =3D 2, .timeout =3D msecs_to_jiffies(JOB_TIMEOUT_MS), .name =3D "pan_js", - .dev =3D pfdev->dev, + .dev =3D pfdev->base.dev, }; struct panfrost_job_slot *js; int ret, j; @@ -859,24 +859,25 @@ int panfrost_job_init(struct panfrost_device *pfdev) if (!panfrost_has_hw_feature(pfdev, HW_FEATURE_JOBCHAIN_DISAMBIGUATION)) args.credit_limit =3D 1; =20 - pfdev->js =3D js =3D devm_kzalloc(pfdev->dev, sizeof(*js), GFP_KERNEL); + js =3D devm_kzalloc(pfdev->base.dev, sizeof(*js), GFP_KERNEL); if (!js) return -ENOMEM; + pfdev->js =3D js; =20 INIT_WORK(&pfdev->reset.work, panfrost_reset_work); spin_lock_init(&js->job_lock); =20 - js->irq =3D platform_get_irq_byname(to_platform_device(pfdev->dev), "job"= ); + js->irq =3D platform_get_irq_byname(to_platform_device(pfdev->base.dev), = "job"); if (js->irq < 0) return js->irq; =20 - ret =3D devm_request_threaded_irq(pfdev->dev, js->irq, + ret =3D devm_request_threaded_irq(pfdev->base.dev, js->irq, panfrost_job_irq_handler, panfrost_job_irq_handler_thread, IRQF_SHARED, KBUILD_MODNAME "-job", pfdev); if (ret) { - dev_err(pfdev->dev, "failed to request job irq"); + dev_err(pfdev->base.dev, "failed to request job irq"); return ret; } =20 @@ -890,7 +891,7 @@ int panfrost_job_init(struct panfrost_device *pfdev) =20 ret =3D drm_sched_init(&js->queue[j].sched, &args); if (ret) { - dev_err(pfdev->dev, "Failed to create scheduler: %d.", ret); + dev_err(pfdev->base.dev, "Failed to create scheduler: %d.", ret); goto err_sched; } } diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panf= rost/panfrost_mmu.c index f6b91c052cfb..1d696eeea2fa 100644 --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c @@ -81,7 +81,7 @@ static int wait_ready(struct panfrost_device *pfdev, u32 = as_nr) if (ret) { /* The GPU hung, let's trigger a reset */ panfrost_device_schedule_reset(pfdev); - dev_err(pfdev->dev, "AS_ACTIVE bit stuck\n"); + dev_err(pfdev->base.dev, "AS_ACTIVE bit stuck\n"); } =20 return ret; @@ -222,7 +222,7 @@ static int mmu_cfg_init_aarch64_4k(struct panfrost_mmu = *mmu) struct io_pgtable_cfg *pgtbl_cfg =3D &mmu->pgtbl_cfg; struct panfrost_device *pfdev =3D mmu->pfdev; =20 - if (drm_WARN_ON(pfdev->ddev, pgtbl_cfg->arm_lpae_s1_cfg.ttbr & + if (drm_WARN_ON(&pfdev->base, pgtbl_cfg->arm_lpae_s1_cfg.ttbr & ~AS_TRANSTAB_AARCH64_4K_ADDR_MASK)) return -EINVAL; =20 @@ -253,7 +253,7 @@ static int panfrost_mmu_cfg_init(struct panfrost_mmu *m= mu, return mmu_cfg_init_mali_lpae(mmu); default: /* This should never happen */ - drm_WARN(pfdev->ddev, 1, "Invalid pgtable format"); + drm_WARN(&pfdev->base, 1, "Invalid pgtable format"); return -EINVAL; } } @@ -315,7 +315,9 @@ u32 panfrost_mmu_as_get(struct panfrost_device *pfdev, = struct panfrost_mmu *mmu) atomic_set(&mmu->as_count, 1); list_add(&mmu->list, &pfdev->as_lru_list); =20 - dev_dbg(pfdev->dev, "Assigned AS%d to mmu %p, alloc_mask=3D%lx", as, mmu,= pfdev->as_alloc_mask); + dev_dbg(pfdev->base.dev, + "Assigned AS%d to mmu %p, alloc_mask=3D%lx", + as, mmu, pfdev->as_alloc_mask); =20 panfrost_mmu_enable(pfdev, mmu); =20 @@ -381,13 +383,13 @@ static void panfrost_mmu_flush_range(struct panfrost_= device *pfdev, if (mmu->as < 0) return; =20 - pm_runtime_get_noresume(pfdev->dev); + pm_runtime_get_noresume(pfdev->base.dev); =20 /* Flush the PTs only if we're already awake */ - if (pm_runtime_active(pfdev->dev)) + if (pm_runtime_active(pfdev->base.dev)) mmu_hw_do_operation(pfdev, mmu, iova, size, AS_COMMAND_FLUSH_PT); =20 - pm_runtime_put_autosuspend(pfdev->dev); + pm_runtime_put_autosuspend(pfdev->base.dev); } =20 static int mmu_map_sg(struct panfrost_device *pfdev, struct panfrost_mmu *= mmu, @@ -402,7 +404,9 @@ static int mmu_map_sg(struct panfrost_device *pfdev, st= ruct panfrost_mmu *mmu, unsigned long paddr =3D sg_dma_address(sgl); size_t len =3D sg_dma_len(sgl); =20 - dev_dbg(pfdev->dev, "map: as=3D%d, iova=3D%llx, paddr=3D%lx, len=3D%zx",= mmu->as, iova, paddr, len); + dev_dbg(pfdev->base.dev, + "map: as=3D%d, iova=3D%llx, paddr=3D%lx, len=3D%zx", + mmu->as, iova, paddr, len); =20 while (len) { size_t pgcount, mapped =3D 0; @@ -462,7 +466,7 @@ void panfrost_mmu_unmap(struct panfrost_gem_mapping *ma= pping) if (WARN_ON(!mapping->active)) return; =20 - dev_dbg(pfdev->dev, "unmap: as=3D%d, iova=3D%llx, len=3D%zx", + dev_dbg(pfdev->base.dev, "unmap: as=3D%d, iova=3D%llx, len=3D%zx", mapping->mmu->as, iova, len); =20 while (unmapped_len < len) { @@ -559,7 +563,7 @@ static int panfrost_mmu_map_fault_addr(struct panfrost_= device *pfdev, int as, =20 bo =3D bomapping->obj; if (!bo->is_heap) { - dev_WARN(pfdev->dev, "matching BO is not heap type (GPU VA =3D %llx)", + dev_WARN(pfdev->base.dev, "matching BO is not heap type (GPU VA =3D %llx= )", bomapping->mmnode.start << PAGE_SHIFT); ret =3D -EINVAL; goto err_bo; @@ -626,7 +630,7 @@ static int panfrost_mmu_map_fault_addr(struct panfrost_= device *pfdev, int as, if (ret) goto err_unlock; =20 - ret =3D dma_map_sgtable(pfdev->dev, sgt, DMA_BIDIRECTIONAL, 0); + ret =3D dma_map_sgtable(pfdev->base.dev, sgt, DMA_BIDIRECTIONAL, 0); if (ret) goto err_map; =20 @@ -636,7 +640,7 @@ static int panfrost_mmu_map_fault_addr(struct panfrost_= device *pfdev, int as, bomapping->active =3D true; bo->heap_rss_size +=3D SZ_2M; =20 - dev_dbg(pfdev->dev, "mapped page fault @ AS%d %llx", as, addr); + dev_dbg(pfdev->base.dev, "mapped page fault @ AS%d %llx", as, addr); =20 out: dma_resv_unlock(obj->resv); @@ -662,10 +666,10 @@ static void panfrost_mmu_release_ctx(struct kref *kre= f) =20 spin_lock(&pfdev->as_lock); if (mmu->as >=3D 0) { - pm_runtime_get_noresume(pfdev->dev); - if (pm_runtime_active(pfdev->dev)) + pm_runtime_get_noresume(pfdev->base.dev); + if (pm_runtime_active(pfdev->base.dev)) panfrost_mmu_disable(pfdev, mmu->as); - pm_runtime_put_autosuspend(pfdev->dev); + pm_runtime_put_autosuspend(pfdev->base.dev); =20 clear_bit(mmu->as, &pfdev->as_alloc_mask); clear_bit(mmu->as, &pfdev->as_in_use_mask); @@ -726,7 +730,7 @@ struct panfrost_mmu *panfrost_mmu_ctx_create(struct pan= frost_device *pfdev) =20 if (pfdev->comp->gpu_quirks & BIT(GPU_QUIRK_FORCE_AARCH64_PGTABLE)) { if (!panfrost_has_hw_feature(pfdev, HW_FEATURE_AARCH64_MMU)) { - dev_err_once(pfdev->dev, + dev_err_once(pfdev->base.dev, "AARCH64_4K page table not supported\n"); return ERR_PTR(-EINVAL); } @@ -755,7 +759,7 @@ struct panfrost_mmu *panfrost_mmu_ctx_create(struct pan= frost_device *pfdev) .oas =3D pa_bits, .coherent_walk =3D pfdev->coherent, .tlb =3D &mmu_tlb_ops, - .iommu_dev =3D pfdev->dev, + .iommu_dev =3D pfdev->base.dev, }; =20 mmu->pgtbl_ops =3D alloc_io_pgtable_ops(fmt, &mmu->pgtbl_cfg, mmu); @@ -848,7 +852,7 @@ static irqreturn_t panfrost_mmu_irq_handler_thread(int = irq, void *data) =20 if (ret) { /* terminal fault, print info about the fault */ - dev_err(pfdev->dev, + dev_err(pfdev->base.dev, "Unhandled Page fault in AS%d at VA 0x%016llX\n" "Reason: %s\n" "raw fault status: 0x%X\n" @@ -896,18 +900,18 @@ int panfrost_mmu_init(struct panfrost_device *pfdev) { int err; =20 - pfdev->mmu_irq =3D platform_get_irq_byname(to_platform_device(pfdev->dev)= , "mmu"); + pfdev->mmu_irq =3D platform_get_irq_byname(to_platform_device(pfdev->base= .dev), "mmu"); if (pfdev->mmu_irq < 0) return pfdev->mmu_irq; =20 - err =3D devm_request_threaded_irq(pfdev->dev, pfdev->mmu_irq, + err =3D devm_request_threaded_irq(pfdev->base.dev, pfdev->mmu_irq, panfrost_mmu_irq_handler, panfrost_mmu_irq_handler_thread, IRQF_SHARED, KBUILD_MODNAME "-mmu", pfdev); =20 if (err) { - dev_err(pfdev->dev, "failed to request mmu irq"); + dev_err(pfdev->base.dev, "failed to request mmu irq"); return err; } =20 diff --git a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c b/drivers/gpu/drm/= panfrost/panfrost_perfcnt.c index 0dd62e8b2fa7..718eb44b40f8 100644 --- a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c +++ b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c @@ -84,11 +84,11 @@ static int panfrost_perfcnt_enable_locked(struct panfro= st_device *pfdev, else if (perfcnt->user) return -EBUSY; =20 - ret =3D pm_runtime_get_sync(pfdev->dev); + ret =3D pm_runtime_get_sync(pfdev->base.dev); if (ret < 0) goto err_put_pm; =20 - bo =3D drm_gem_shmem_create(pfdev->ddev, perfcnt->bosize); + bo =3D drm_gem_shmem_create(&pfdev->base, perfcnt->bosize); if (IS_ERR(bo)) { ret =3D PTR_ERR(bo); goto err_put_pm; @@ -175,7 +175,7 @@ static int panfrost_perfcnt_enable_locked(struct panfro= st_device *pfdev, err_put_bo: drm_gem_object_put(&bo->base); err_put_pm: - pm_runtime_put(pfdev->dev); + pm_runtime_put(pfdev->base.dev); return ret; } =20 @@ -203,7 +203,7 @@ static int panfrost_perfcnt_disable_locked(struct panfr= ost_device *pfdev, panfrost_mmu_as_put(pfdev, perfcnt->mapping->mmu); panfrost_gem_mapping_put(perfcnt->mapping); perfcnt->mapping =3D NULL; - pm_runtime_put_autosuspend(pfdev->dev); + pm_runtime_put_autosuspend(pfdev->base.dev); =20 return 0; } @@ -211,7 +211,7 @@ static int panfrost_perfcnt_disable_locked(struct panfr= ost_device *pfdev, int panfrost_ioctl_perfcnt_enable(struct drm_device *dev, void *data, struct drm_file *file_priv) { - struct panfrost_device *pfdev =3D dev->dev_private; + struct panfrost_device *pfdev =3D to_panfrost_device(dev); struct panfrost_perfcnt *perfcnt =3D pfdev->perfcnt; struct drm_panfrost_perfcnt_enable *req =3D data; int ret; @@ -238,7 +238,7 @@ int panfrost_ioctl_perfcnt_enable(struct drm_device *de= v, void *data, int panfrost_ioctl_perfcnt_dump(struct drm_device *dev, void *data, struct drm_file *file_priv) { - struct panfrost_device *pfdev =3D dev->dev_private; + struct panfrost_device *pfdev =3D to_panfrost_device(dev); struct panfrost_perfcnt *perfcnt =3D pfdev->perfcnt; struct drm_panfrost_perfcnt_dump *req =3D data; void __user *user_ptr =3D (void __user *)(uintptr_t)req->buf_ptr; @@ -273,12 +273,12 @@ void panfrost_perfcnt_close(struct drm_file *file_pri= v) struct panfrost_device *pfdev =3D pfile->pfdev; struct panfrost_perfcnt *perfcnt =3D pfdev->perfcnt; =20 - pm_runtime_get_sync(pfdev->dev); + pm_runtime_get_sync(pfdev->base.dev); mutex_lock(&perfcnt->lock); if (perfcnt->user =3D=3D pfile) panfrost_perfcnt_disable_locked(pfdev, file_priv); mutex_unlock(&perfcnt->lock); - pm_runtime_put_autosuspend(pfdev->dev); + pm_runtime_put_autosuspend(pfdev->base.dev); } =20 int panfrost_perfcnt_init(struct panfrost_device *pfdev) @@ -316,7 +316,7 @@ int panfrost_perfcnt_init(struct panfrost_device *pfdev) COUNTERS_PER_BLOCK * BYTES_PER_COUNTER; } =20 - perfcnt =3D devm_kzalloc(pfdev->dev, sizeof(*perfcnt), GFP_KERNEL); + perfcnt =3D devm_kzalloc(pfdev->base.dev, sizeof(*perfcnt), GFP_KERNEL); if (!perfcnt) return -ENOMEM; =20 --=20 2.51.0