[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aCPvCyrpU9AgSvVd@gallifrey>
Date: Wed, 14 May 2025 01:16:59 +0000
From: "Dr. David Alan Gilbert" <linux@...blig.org>
To: Alex Deucher <alexdeucher@...il.com>
Cc: Christophe JAILLET <christophe.jaillet@...adoo.fr>,
alexander.deucher@....com, harry.wentland@....com,
sunpeng.li@....com, siqueira@...lia.com, christian.koenig@....com,
airlied@...il.com, simona@...ll.ch, amd-gfx@...ts.freedesktop.org,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/4] drm/radeon: Remove unused radeon_doorbell_free
* Dr. David Alan Gilbert (linux@...blig.org) wrote:
> * Alex Deucher (alexdeucher@...il.com) wrote:
> > On Sun, May 11, 2025 at 8:13 AM Dr. David Alan Gilbert
> > <linux@...blig.org> wrote:
> > >
> > > * Christophe JAILLET (christophe.jaillet@...adoo.fr) wrote:
> > > > Le 18/04/2025 à 02:21, linux@...blig.org a écrit :
> > > > > From: "Dr. David Alan Gilbert" <linux@...blig.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@...blig.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@...adoo.fr>
> > > Signed-off-by: Dr. David Alan Gilbert <linux@...blig.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.
V1 sent as message 20250514011610.136607-1-linux@...blig.org
Note this is still only build tested by me; so needs someone with
relevant hardware to give it a smoke test.
Dave
> 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 |_______/
>
--
-----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 |_______/
Powered by blists - more mailing lists