dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Alex Deucher <alexdeucher@gmail.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: "Evan Quan" <evan.quan@amd.com>, "chen gong" <curry.gong@amd.com>,
	"Bokun Zhang" <Bokun.Zhang@amd.com>,
	"Intel Graphics Development" <intel-gfx@lists.freedesktop.org>,
	"Wenhui Sheng" <Wenhui.Sheng@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	"Monk Liu" <Monk.Liu@amd.com>,
	"Luben Tuikov" <luben.tuikov@amd.com>,
	"Stanley.Yang" <Stanley.Yang@amd.com>,
	"DRI Development" <dri-devel@lists.freedesktop.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Daniel Vetter" <daniel.vetter@intel.com>,
	"Yintian Tao" <yttao@amd.com>,
	"Hawking Zhang" <Hawking.Zhang@amd.com>,
	"Felix Kuehling" <Felix.Kuehling@amd.com>,
	"Dennis Li" <Dennis.Li@amd.com>, shaoyunl <shaoyun.liu@amd.com>
Subject: Re: [PATCH 3/5] drm/amdgpu: Paper over the drm_driver mangling for virt
Date: Tue, 3 Nov 2020 11:49:40 -0500	[thread overview]
Message-ID: <CADnq5_M+Qp7dz+1xrM0+U4KgUYN5Gh5zyoyAVBVSxsCgsvM7HA@mail.gmail.com> (raw)
In-Reply-To: <CAKMK7uFwMkg6ZpQnE9HEH9vagzDJ5MCrSyGcsJOsC1JVLSO-ww@mail.gmail.com>

On Sun, Nov 1, 2020 at 5:01 AM Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
>
> On Sat, Oct 31, 2020 at 2:57 PM Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> >
> > On Fri, Oct 30, 2020 at 7:47 PM Alex Deucher <alexdeucher@gmail.com> wrote:
> > >
> > > On Fri, Oct 30, 2020 at 6:11 AM Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> > > >
> > > > Prep work to make drm_device->driver const.
> > > >
> > > > Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > > Cc: Alex Deucher <alexander.deucher@amd.com>
> > > > Cc: "Christian König" <christian.koenig@amd.com>
> > > > Cc: Evan Quan <evan.quan@amd.com>
> > > > Cc: Felix Kuehling <Felix.Kuehling@amd.com>
> > > > Cc: Hawking Zhang <Hawking.Zhang@amd.com>
> > > > Cc: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
> > > > Cc: Luben Tuikov <luben.tuikov@amd.com>
> > > > Cc: Thomas Zimmermann <tzimmermann@suse.de>
> > > > Cc: Monk Liu <Monk.Liu@amd.com>
> > > > Cc: Yintian Tao <yttao@amd.com>
> > > > Cc: Dennis Li <Dennis.Li@amd.com>
> > > > Cc: shaoyunl <shaoyun.liu@amd.com>
> > > > Cc: Bokun Zhang <Bokun.Zhang@amd.com>
> > > > Cc: "Stanley.Yang" <Stanley.Yang@amd.com>
> > > > Cc: Wenhui Sheng <Wenhui.Sheng@amd.com>
> > > > Cc: chen gong <curry.gong@amd.com>
> > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > > ---
> > > >  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c  |  8 ++++----
> > > >  drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 12 +++++++++++-
> > > >  2 files changed, 15 insertions(+), 5 deletions(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> > > > index 024c3b70b1aa..3d337f13ae4e 100644
> > > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> > > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> > > > @@ -1093,7 +1093,7 @@ static const struct pci_device_id pciidlist[] = {
> > > >
> > > >  MODULE_DEVICE_TABLE(pci, pciidlist);
> > > >
> > > > -static struct drm_driver kms_driver;
> > > > +struct drm_driver amdgpu_kms_driver;
> > > >
> > > >  static int amdgpu_pci_probe(struct pci_dev *pdev,
> > > >                             const struct pci_device_id *ent)
> > > > @@ -1164,7 +1164,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
> > > >         if (ret)
> > > >                 return ret;
> > > >
> > > > -       adev = devm_drm_dev_alloc(&pdev->dev, &kms_driver, typeof(*adev), ddev);
> > > > +       adev = devm_drm_dev_alloc(&pdev->dev, &amdgpu_kms_driver, typeof(*adev), ddev);
> > > >         if (IS_ERR(adev))
> > > >                 return PTR_ERR(adev);
> > > >
> > > > @@ -1508,7 +1508,7 @@ int amdgpu_file_to_fpriv(struct file *filp, struct amdgpu_fpriv **fpriv)
> > > >         return 0;
> > > >  }
> > > >
> > > > -static struct drm_driver kms_driver = {
> > > > +struct drm_driver amdgpu_kms_driver = {
> > > >         .driver_features =
> > > >             DRIVER_ATOMIC |
> > > >             DRIVER_GEM |
> > > > @@ -1571,7 +1571,7 @@ static int __init amdgpu_init(void)
> > > >                 goto error_fence;
> > > >
> > > >         DRM_INFO("amdgpu kernel modesetting enabled.\n");
> > > > -       kms_driver.num_ioctls = amdgpu_max_kms_ioctl;
> > > > +       amdgpu_kms_driver.num_ioctls = amdgpu_max_kms_ioctl;
> > > >         amdgpu_register_atpx_handler();
> > > >
> > > >         /* Ignore KFD init failures. Normal when CONFIG_HSA_AMD is not set. */
> > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> > > > index d0aea5e39531..dde4c449c284 100644
> > > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> > > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> > > > @@ -45,13 +45,23 @@ bool amdgpu_virt_mmio_blocked(struct amdgpu_device *adev)
> > > >         return RREG32_NO_KIQ(0xc040) == 0xffffffff;
> > > >  }
> > > >
> > > > +extern struct drm_driver amdgpu_kms_driver;
> > > > +
> > > >  void amdgpu_virt_init_setting(struct amdgpu_device *adev)
> > > >  {
> > > >         /* enable virtual display */
> > > >         if (adev->mode_info.num_crtc == 0)
> > > >                 adev->mode_info.num_crtc = 1;
> > > >         adev->enable_virtual_display = true;
> > > > -       adev_to_drm(adev)->driver->driver_features &= ~DRIVER_ATOMIC;
> > > > +
> > > > +       /*
> > > > +        * FIXME: Either make virt support atomic or make sure you have two
> > > > +        * drm_driver structs, these kind of tricks are only ok when there's
> > > > +        * guaranteed only a single device per system. This should also be done
> > > > +        * before struct drm_device is initialized.
> > > > +        */
> > > > +       amdgpu_kms_driver.driver_features &= ~DRIVER_ATOMIC;
> > >
> > > There is additional DRIVER_ATOMIC in amdgpu_pci_probe() for older
> > > chips without atomic support.
> >
> > That would need to be fixed for making the amdgpu drm_driver
> > structures constant, but that's not what I'm doing here. I'm only
> > removing the usage of the drm_device->driver pointer, to allow that to
> > become constant. Untangling the flow to make the amdgpu_kms_driver
> > const looked a bit more involved than just a  simple patch.
>
> On second look, this changes the drm_device->driver_features flag,
> which was added to avoid having to change the drm_driver one. So
> that's actually all ok (and just the virt code here is broken). But
> amdgpu also updates num_ioctl and other stuff, and that's a fairly
> invasive patch.

We don't change the number of ioctls:
const int amdgpu_max_kms_ioctl = ARRAY_SIZE(amdgpu_ioctls_kms);
So I think the only thing here is the driver features flag for the
virt display code, or am I missing something?

Alex


>
> I'm also not sure whether this code here can just be switched over
> from drm_driver->driver_features to drm_device->driver_features. So
> given all this, ok as-is and you guys figure out how to patch this
> properly, or want me to change something in this patch?
>
> Cheers, Daniel
>
> >
> > > Alex
> > >
> > > > +
> > > >         adev->cg_flags = 0;
> > > >         adev->pg_flags = 0;
> > > >  }
> > > > --
> > > > 2.28.0
> > > >
> > > > _______________________________________________
> > > > dri-devel mailing list
> > > > dri-devel@lists.freedesktop.org
> > > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> >
> >
> >
> > --
> > Daniel Vetter
> > Software Engineer, Intel Corporation
> > http://blog.ffwll.ch
>
>
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-11-03 16:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-30 10:11 [PATCH 1/5] drm/radeon: Stop changing the drm_driver struct Daniel Vetter
2020-10-30 10:11 ` [PATCH 2/5] drm: Compile out legacy chunks from struct drm_device Daniel Vetter
2020-10-30 18:22   ` Alex Deucher
2020-10-30 10:11 ` [PATCH 3/5] drm/amdgpu: Paper over the drm_driver mangling for virt Daniel Vetter
2020-10-30 10:41   ` Liu, Monk
2020-10-30 12:04     ` Daniel Vetter
2020-10-31  5:09       ` Luben Tuikov
2020-11-01  9:59         ` Daniel Vetter
2020-10-30 18:47   ` Alex Deucher
2020-10-31 13:57     ` Daniel Vetter
2020-11-01 10:01       ` Daniel Vetter
2020-11-03 16:49         ` Alex Deucher [this message]
2020-11-04  9:31           ` Daniel Vetter
2020-10-30 10:11 ` [PATCH 4/5] drm: Allow const struct drm_driver Daniel Vetter
2020-10-30 18:53   ` Alex Deucher
2020-10-30 10:11 ` [PATCH 5/5] drm/<drivers>: Constify " Daniel Vetter
2020-10-30 18:53   ` Alex Deucher
2020-10-30 18:21 ` [PATCH 1/5] drm/radeon: Stop changing the drm_driver struct Alex Deucher
  -- strict thread matches above, loose matches on Subject: below --
2020-10-23 12:28 Daniel Vetter
2020-10-23 12:28 ` [PATCH 3/5] drm/amdgpu: Paper over the drm_driver mangling for virt Daniel Vetter

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=CADnq5_M+Qp7dz+1xrM0+U4KgUYN5Gh5zyoyAVBVSxsCgsvM7HA@mail.gmail.com \
    --to=alexdeucher@gmail.com \
    --cc=Bokun.Zhang@amd.com \
    --cc=Dennis.Li@amd.com \
    --cc=Felix.Kuehling@amd.com \
    --cc=Hawking.Zhang@amd.com \
    --cc=Monk.Liu@amd.com \
    --cc=Stanley.Yang@amd.com \
    --cc=Wenhui.Sheng@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=christian.koenig@amd.com \
    --cc=curry.gong@amd.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=evan.quan@amd.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=luben.tuikov@amd.com \
    --cc=shaoyun.liu@amd.com \
    --cc=tzimmermann@suse.de \
    --cc=yttao@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;
as well as URLs for NNTP newsgroup(s).