From: "Dr. David Alan Gilbert" <linux@treblig.org>
To: Alex Deucher <alexdeucher@gmail.com>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
alexander.deucher@amd.com, harry.wentland@amd.com,
sunpeng.li@amd.com, siqueira@igalia.com,
christian.koenig@amd.com, airlied@gmail.com, simona@ffwll.ch,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] drm/radeon: Remove unused radeon_doorbell_free
Date: Mon, 12 May 2025 22:53:47 +0000 [thread overview]
Message-ID: <aCJ7-zRkkopc8OKZ@gallifrey> (raw)
In-Reply-To: <CADnq5_PECpX173wZOPV8VASyoQhDWkJnqvsh61zGwsiZqmNMBw@mail.gmail.com>
* Alex Deucher (alexdeucher@gmail.com) wrote:
> On Sun, May 11, 2025 at 8:13 AM Dr. David Alan Gilbert
> <linux@treblig.org> wrote:
> >
> > * Christophe JAILLET (christophe.jaillet@wanadoo.fr) wrote:
> > > Le 18/04/2025 à 02:21, linux@treblig.org a écrit :
> > > > From: "Dr. David Alan Gilbert" <linux@treblig.org>
> > > >
> > > > radeon_doorbell_free() was added in 2013 by
> > > > commit 75efdee11b5d ("drm/radeon: implement simple doorbell page
> > > > allocator")
> > > > but never used.
> > >
> > > Hi,
> > >
> > > I think than instead of being removed, it should be used in the error
> > > handling path of cik_init() and in cik_fini().
> >
> > OK, here's an RFC that builds; but if I understand correctly only
> > some devices run this code, and I'm not sure mine does;
> >
> > Thoughts?
> >
> > Dave
> >
> > From 15b3830b4ee3eb819f86198dcbc596428f9ee0d0 Mon Sep 17 00:00:00 2001
> > From: "Dr. David Alan Gilbert" <linux@treblig.org>
> > Date: Sun, 11 May 2025 02:35:41 +0100
> > Subject: [RFC PATCH] drm/radeon/cik: Clean up doorbells
> >
> > Free doorbells in the error paths of cik_init and in cik_fini.
> >
> > Suggested-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
> > ---
> > drivers/gpu/drm/radeon/cik.c | 38 ++++++++++++++++++++++++------------
> > 1 file changed, 26 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
> > index 11a492f21157..3caa5a100f97 100644
> > --- a/drivers/gpu/drm/radeon/cik.c
> > +++ b/drivers/gpu/drm/radeon/cik.c
> > @@ -8548,7 +8548,7 @@ int cik_suspend(struct radeon_device *rdev)
> > */
> > int cik_init(struct radeon_device *rdev)
> > {
> > - struct radeon_ring *ring;
> > + struct radeon_ring *ring, *ringCP1, *ringCP2;
>
> I'd prefer ring_cp1 and ring_cp2 for readability.
OK.
> > int r;
> >
> > /* Read BIOS */
> > @@ -8623,19 +8623,22 @@ int cik_init(struct radeon_device *rdev)
> > ring->ring_obj = NULL;
> > r600_ring_init(rdev, ring, 1024 * 1024);
> >
> > - ring = &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX];
> > - ring->ring_obj = NULL;
> > - r600_ring_init(rdev, ring, 1024 * 1024);
> > - r = radeon_doorbell_get(rdev, &ring->doorbell_index);
> > + ringCP1 = &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX];
> > + ringCP2 = &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX];
> > + ringCP1->ring_obj = NULL;
> > + ringCP2->ring_obj = NULL;
> > + ringCP1->doorbell_index = RADEON_MAX_DOORBELLS;
> > + ringCP2->doorbell_index = RADEON_MAX_DOORBELLS;
> > +
> > + r600_ring_init(rdev, ringCP1, 1024 * 1024);
> > + r = radeon_doorbell_get(rdev, &ringCP1->doorbell_index);
> > if (r)
> > return r;
> >
> > - ring = &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX];
> > - ring->ring_obj = NULL;
> > - r600_ring_init(rdev, ring, 1024 * 1024);
> > - r = radeon_doorbell_get(rdev, &ring->doorbell_index);
> > + r600_ring_init(rdev, ringCP2, 1024 * 1024);
> > + r = radeon_doorbell_get(rdev, &ringCP2->doorbell_index);
> > if (r)
> > - return r;
> > + goto out;
> >
> > ring = &rdev->ring[R600_RING_TYPE_DMA_INDEX];
> > ring->ring_obj = NULL;
> > @@ -8653,7 +8656,7 @@ int cik_init(struct radeon_device *rdev)
> >
> > r = r600_pcie_gart_init(rdev);
> > if (r)
> > - return r;
> > + goto out;
> >
> > rdev->accel_working = true;
> > r = cik_startup(rdev);
>
> I think you can drop the doorbells in the error case for cik_startup()
> as well since they won't be used in that case.
OK, can do that.
Thanks,
Dave
> Alex
>
> > @@ -8678,10 +8681,16 @@ int cik_init(struct radeon_device *rdev)
> > */
> > if (!rdev->mc_fw && !(rdev->flags & RADEON_IS_IGP)) {
> > DRM_ERROR("radeon: MC ucode required for NI+.\n");
> > - return -EINVAL;
> > + r = -EINVAL;
> > + goto out;
> > }
> >
> > return 0;
> > +
> > +out:
> > + radeon_doorbell_free(rdev, ringCP1->doorbell_index);
> > + radeon_doorbell_free(rdev, ringCP2->doorbell_index);
> > + return r;
> > }
> >
> > /**
> > @@ -8695,6 +8704,7 @@ int cik_init(struct radeon_device *rdev)
> > */
> > void cik_fini(struct radeon_device *rdev)
> > {
> > + struct radeon_ring *ring;
> > radeon_pm_fini(rdev);
> > cik_cp_fini(rdev);
> > cik_sdma_fini(rdev);
> > @@ -8708,6 +8718,10 @@ void cik_fini(struct radeon_device *rdev)
> > radeon_ib_pool_fini(rdev);
> > radeon_irq_kms_fini(rdev);
> > uvd_v1_0_fini(rdev);
> > + ring = &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX];
> > + radeon_doorbell_free(rdev, ring->doorbell_index);
> > + ring = &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX];
> > + radeon_doorbell_free(rdev, ring->doorbell_index);
> > radeon_uvd_fini(rdev);
> > radeon_vce_fini(rdev);
> > cik_pcie_gart_fini(rdev);
> > --
> > 2.49.0
> >
> >
> > --
> > -----Open up your eyes, open up your mind, open up your code -------
> > / Dr. David Alan Gilbert | Running GNU/Linux | Happy \
> > \ dave @ treblig.org | | In Hex /
> > \ _________________________|_____ http://www.treblig.org |_______/
--
-----Open up your eyes, open up your mind, open up your code -------
/ Dr. David Alan Gilbert | Running GNU/Linux | Happy \
\ dave @ treblig.org | | In Hex /
\ _________________________|_____ http://www.treblig.org |_______/
next prev parent reply other threads:[~2025-05-13 8:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-18 0:21 [PATCH 0/4] drm/amd & radeon deadcoding linux
2025-04-18 0:21 ` [PATCH 1/4] drm/radeon/radeon_audio: Remove unused r600_hdmi_audio_workaround linux
2025-04-18 0:21 ` [PATCH 2/4] drm/radeon: Remove unused radeon_doorbell_free linux
2025-04-18 5:52 ` Christophe JAILLET
2025-04-18 12:59 ` Alex Deucher
2025-04-24 14:50 ` Dr. David Alan Gilbert
2025-05-11 11:55 ` Dr. David Alan Gilbert
2025-05-12 15:43 ` Alex Deucher
2025-05-12 22:53 ` Dr. David Alan Gilbert [this message]
2025-05-14 1:16 ` Dr. David Alan Gilbert
2025-04-18 0:21 ` [PATCH 3/4] drm/radeon: Remove unused radeon_fence_wait_any linux
2025-04-18 0:21 ` [PATCH 4/4] drm/amd/display: Remove unused *vbios_smu_set_dprefclk linux
2025-04-18 13:25 ` Alex Deucher
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=aCJ7-zRkkopc8OKZ@gallifrey \
--to=linux@treblig.org \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=alexdeucher@gmail.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=dri-devel@lists.freedesktop.org \
--cc=harry.wentland@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=siqueira@igalia.com \
--cc=sunpeng.li@amd.com \
/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