From: Wu Hoi Pok <wuhoipok@gmail.com>
Cc: "Thomas Zimmermann" <tzimmermann@suse.de>,
"Wu Hoi Pok" <wuhoipok@gmail.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"Pan, Xinhui" <Xinhui.Pan@amd.com>,
"David Airlie" <airlied@gmail.com>,
"Daniel Vetter" <daniel@ffwll.ch>,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v3 6/6] drm/radeon: change drm_dev_alloc to devm_drm_dev_alloc
Date: Sun, 30 Jun 2024 12:59:22 -0400 [thread overview]
Message-ID: <20240630165949.117634-7-wuhoipok@gmail.com> (raw)
In-Reply-To: <20240630165949.117634-1-wuhoipok@gmail.com>
"drm_dev_alloc" is deprecated, in order to use the newer "devm_drm_dev_alloc",
the "drm_device" is stored inside "radeon_device", by changing "rdev_to_drm(rdev)"
other functions still gain access to the member "drm_device". Also, "devm_drm_dev_alloc"
is now allocating "radeon_device", allocation inside "radeon_driver_load_kms" has to be
removed.
In "radeon_device_init", it originally assigned "rdev->dev" etc. However it is already
done right after "devm_drm_dev_alloc" as you can see down below. It is better remove them.
Signed-off-by: Wu Hoi Pok <wuhoipok@gmail.com>
---
drivers/gpu/drm/radeon/radeon.h | 4 ++--
drivers/gpu/drm/radeon/radeon_device.c | 3 ---
drivers/gpu/drm/radeon/radeon_drv.c | 12 +++++++++---
drivers/gpu/drm/radeon/radeon_kms.c | 8 +-------
4 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index ae35c102a487..fd8a4513025f 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -2297,7 +2297,7 @@ typedef void (*radeon_wreg_t)(struct radeon_device*, uint32_t, uint32_t);
struct radeon_device {
struct device *dev;
- struct drm_device *ddev;
+ struct drm_device ddev;
struct pci_dev *pdev;
#ifdef __alpha__
struct pci_controller *hose;
@@ -2478,7 +2478,7 @@ void cik_mm_wdoorbell(struct radeon_device *rdev, u32 index, u32 v);
static inline struct drm_device *rdev_to_drm(struct radeon_device *rdev)
{
- return rdev->ddev;
+ return &rdev->ddev;
}
/*
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 32851632643d..554b236c2328 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1285,9 +1285,6 @@ int radeon_device_init(struct radeon_device *rdev,
bool runtime = false;
rdev->shutdown = false;
- rdev->dev = &pdev->dev;
- rdev->ddev = ddev;
- rdev->pdev = pdev;
rdev->flags = flags;
rdev->family = flags & RADEON_FAMILY_MASK;
rdev->is_atom_bios = false;
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 7b8aa8406751..f36aa71c57c7 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -260,6 +260,7 @@ static int radeon_pci_probe(struct pci_dev *pdev,
{
unsigned long flags = 0;
struct drm_device *ddev;
+ struct radeon_device *rdev;
int ret;
if (!ent)
@@ -300,9 +301,14 @@ static int radeon_pci_probe(struct pci_dev *pdev,
if (ret)
return ret;
- ddev = drm_dev_alloc(&kms_driver, &pdev->dev);
- if (IS_ERR(ddev))
- return PTR_ERR(ddev);
+ rdev = devm_drm_dev_alloc(&pdev->dev, &kms_driver, typeof(*rdev), ddev);
+ if (IS_ERR(rdev))
+ return PTR_ERR(rdev);
+
+ rdev->dev = &pdev->dev;
+ rdev->pdev = pdev;
+ ddev = rdev_to_drm(rdev);
+ ddev->dev_private = rdev;
ret = pci_enable_device(pdev);
if (ret)
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index a16590c6247f..645e33bf7947 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -104,15 +104,9 @@ void radeon_driver_unload_kms(struct drm_device *dev)
int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags)
{
struct pci_dev *pdev = to_pci_dev(dev->dev);
- struct radeon_device *rdev;
+ struct radeon_device *rdev = dev->dev_private;
int r, acpi_status;
- rdev = kzalloc(sizeof(struct radeon_device), GFP_KERNEL);
- if (rdev == NULL) {
- return -ENOMEM;
- }
- dev->dev_private = (void *)rdev;
-
#ifdef __alpha__
rdev->hose = pdev->sysdata;
#endif
--
2.45.2
next prev parent reply other threads:[~2024-06-30 17:00 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-30 16:59 [PATCH v3 0/6] drm/radeon: remove load callback & drm_dev_alloc Wu Hoi Pok
2024-06-30 16:59 ` [PATCH v3 1/6] drm/radeon: change variable name "dev" to "ddev" for consistency Wu Hoi Pok
2024-07-03 8:42 ` Thomas Zimmermann
2024-06-30 16:59 ` [PATCH v3 2/6] drm/radeon: remove load callback from kms_driver Wu Hoi Pok
2024-07-03 8:43 ` Thomas Zimmermann
2024-09-19 16:56 ` Arthur Marsh
2024-09-24 2:08 ` radeon ARUBA NULL pointer dereference Arthur Marsh
2024-09-24 12:20 ` Thomas Zimmermann
2024-09-24 12:42 ` Thomas Zimmermann
2024-09-24 14:22 ` Alex Deucher
2024-09-24 19:30 ` Ewan Milne
2024-09-25 18:13 ` Ewan Milne
2024-09-25 0:22 ` NULL pointer dereference after ib test on ring 7 succeeded Arthur Marsh
2024-09-25 8:02 ` Thomas Zimmermann
2024-09-30 15:25 ` NULL pointer dereference with kernel 6.12.0-rc1 and ARUBA GPU Arthur Marsh
2024-09-30 17:54 ` Christian König
2024-10-07 12:44 ` Thomas Zimmermann
2024-06-30 16:59 ` [PATCH v3 3/6] drm/radeon: use variable flags as parameter Wu Hoi Pok
2024-07-03 8:44 ` Thomas Zimmermann
2024-06-30 16:59 ` [PATCH v3 4/6] drm/radeon: add helper rdev_to_drm(rdev) Wu Hoi Pok
2024-07-03 8:44 ` Thomas Zimmermann
2024-06-30 16:59 ` [PATCH v3 5/6] drm/radeon: change rdev->ddev to rdev_to_drm(rdev) Wu Hoi Pok
2024-07-03 8:46 ` Thomas Zimmermann
2024-06-30 16:59 ` Wu Hoi Pok [this message]
2024-07-03 8:47 ` [PATCH v3 6/6] drm/radeon: change drm_dev_alloc to devm_drm_dev_alloc Thomas Zimmermann
2024-07-08 20:04 ` Alex Deucher
2024-07-03 8:52 ` [PATCH v3 0/6] drm/radeon: remove load callback & drm_dev_alloc Thomas Zimmermann
2024-07-04 4:58 ` Hoi Pok Wu
2024-07-04 13:02 ` Christian König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240630165949.117634-7-wuhoipok@gmail.com \
--to=wuhoipok@gmail.com \
--cc=Xinhui.Pan@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®