All of lore.kernel.org
 help / color / mirror / Atom feed
From: Danilo Krummrich <dakr@kernel.org>
To: Ben Skeggs <bskeggs@nvidia.com>
Cc: nouveau@lists.freedesktop.org
Subject: Re: [PATCH v2 02/37] drm/nouveau: handle pci/tegra drm_dev_{alloc, register} from common code
Date: Fri, 26 Jul 2024 17:41:05 +0200	[thread overview]
Message-ID: <ZqPDkZ2t5MjXX4Sx@cassiopeiae> (raw)
In-Reply-To: <9760d7df-dfbf-478e-9b0e-ddc7768b8de1@nvidia.com>

On Fri, Jul 26, 2024 at 02:27:53PM +1000, Ben Skeggs wrote:
> > > > > +
> > > > > +static struct nouveau_drm *
> > > > > +nouveau_drm_device_new(const struct drm_driver *drm_driver, struct device *parent,
> > > > > +		       struct nvkm_device *device)
> > > > > +{
> > > > > +	struct nouveau_drm *drm;
> > > > > +	int ret;
> > > > > +
> > > > > +	drm = kzalloc(sizeof(*drm), GFP_KERNEL);
> > > > > +	if (!drm)
> > > > > +		return ERR_PTR(-ENOMEM);
> > > > > +
> > > > > +	drm->dev = drm_dev_alloc(drm_driver, parent);
> > > > Since you're reworking this anyways, can we switch to devm_drm_dev_alloc()?
> > > > 
> > > > This also gets us rid of nouveau_drm_device_del().
> > > No, we can't.  I originally had this change as a cleanup patch in the series
> > > I posted implementing aux bus support.  However it turns out that in order
> > > to avoid breaking udev etc, we can't use the aux device as parent of the drm
> > Can you please expand a bit on what was breaking?
> 
> Sorry, I meant to say PRIME, not udev.  The device selection logic ties the
> DRM device back to its sysfs node, and doesn't understand the auxiliary
> bus.  So, if nouveau were to use its auxiliary device as parent of the DRM
> device, PRIME breaks.

The Vulkan device selector stuff looks like it should mostly work.

However, I guess you refer to the loader stuff in Mesa that uses
drmGetDevices2() from libdrm? This stuff indeed whitelists busses it accepts to
report DRM device from:

	{ "/pci", DRM_BUS_PCI },
	{ "/usb", DRM_BUS_USB },
	{ "/platform", DRM_BUS_PLATFORM },
	{ "/spi", DRM_BUS_PLATFORM },
	{ "/host1x", DRM_BUS_HOST1X },
	{ "/virtio", DRM_BUS_VIRTIO },

Not a big deal to just add it for a new driver, but obviously we can't just do
this for an existing one.

> Fortunately it didn't turn out to be necessary, and we
> can happily probe() against the auxiliary device and still use the PCI
> device as the DRM device's parent.

At a first glance, I guess this should work. But, before we introduce
workarounds like this one and add even more complexity, I wonder what's the
benefit of doing this for Nouveau in the first place? I think we agreed to this
split for Nova, for the reasons discussed in [1].

[1] https://lore.kernel.org/dri-devel/20240613170211.88779-1-bskeggs@nvidia.com/

> 
> > 
> > > device and instead have to continue passing the pci/platform device as we do
> > > now.
> > > 
> > > Using devm_drm_dev_alloc() with the pci device as parent would tie the
> > > lifetime of the drm device to the pci device, which is owned by nvkm (after
> > How does this tie the lifetime of the drm device to the pci device? It's the
> > other way around, the drm device takes a reference of its parent (i.e. the pci
> > device).
> > 
> > I don't think there's anything wrong with that.
> 
> My understanding is that devres will cleanup allocations when the driver
> detaches from the device.

Right, I think I took that too literally.

The lifetime of the DRM device (or more precisely one of its references) is
bound to the binding between the parent device and its corresponding driver.

But the lifetime of the parent device itself is bound to the DRM device.

So, yes this doesn't work, and proves the point that initializing the DRM device
with the parent's parent is just a workaround.

> With the auxdev changes, it's *NVKM* that's
> attached to the PCI device, not the DRM driver (which is attached to an
> auxiliary device instead).
> 
> This means that the devm_drm_dev_init_release() won't be called when the DRM
> driver detaches from its auxiliary device as it should, but when NVKM
> detaches from the PCI device, which isn't the most obvious and could lead to
> confusion.
> 
> It also entirely blows up in the split module case as nouveau.ko is unloaded
> already by the time NVKM detaches and drm_dev_put() gets called.
> 
> > 
> > > the auxdev series).  We could look at changing devm_drm_dev_alloc() of
> > > course, but I think that's best left until later.
> > I don't think that this is necessary.

  reply	other threads:[~2025-12-13 12:44 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-04 18:36 [PATCH v2 00/37] drm/nouveau: misc. cleanups and removal of unused apis Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 01/37] drm/nouveau: move nouveau_drm_device_fini() above init() Ben Skeggs
2024-07-09 14:48   ` Danilo Krummrich
2024-07-04 18:36 ` [PATCH v2 02/37] drm/nouveau: handle pci/tegra drm_dev_{alloc, register} from common code Ben Skeggs
2024-07-09 15:16   ` Danilo Krummrich
2024-07-18  7:14     ` Ben Skeggs
2024-07-19 11:10       ` Danilo Krummrich
2024-07-26  4:27         ` Ben Skeggs
2024-07-26 15:41           ` Danilo Krummrich [this message]
2024-07-26 13:07             ` Ben Skeggs
2024-07-27  1:54               ` Danilo Krummrich
2024-07-28 18:13               ` Jason Gunthorpe
2024-07-28 21:34                 ` Danilo Krummrich
2024-07-28 23:04                   ` Jason Gunthorpe
2024-07-29  0:55                     ` Danilo Krummrich
2024-07-04 18:36 ` [PATCH v2 03/37] drm/nouveau: replace drm_device* with nouveau_drm* as dev drvdata Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 04/37] drm/nouveau: create pci device once Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 05/37] drm/nouveau: store nvkm_device pointer in nouveau_drm Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 06/37] drm/nouveau: move allocation of root client out of nouveau_cli_init() Ben Skeggs
2024-07-09 15:33   ` Danilo Krummrich
2024-07-18  7:29     ` Ben Skeggs
2024-07-19 11:37       ` Danilo Krummrich
2024-07-26  4:29         ` Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 07/37] drm/nouveau: add nouveau_cli to nouveau_abi16 Ben Skeggs
2024-07-09 15:36   ` Danilo Krummrich
2024-07-04 18:36 ` [PATCH v2 08/37] drm/nouveau: handle limited nvif ioctl in abi16 Ben Skeggs
2024-07-09 16:03   ` Danilo Krummrich
2024-07-18  7:43     ` Ben Skeggs
2024-07-19 12:06       ` Danilo Krummrich
2024-07-04 18:36 ` [PATCH v2 09/37] drm/nouveau: remove abi16->device Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 10/37] drm/nouveau: remove abi16->handles Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 11/37] drm/nouveau/nvkm: remove detect/mmio/subdev_mask from device args Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 12/37] drm/nouveau/nvkm: remove perfmon Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 13/37] drm/nouveau/nvkm: remove nvkm_client_search() Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 14/37] drm/nouveau/nvif: remove support for userspace backends Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 15/37] drm/nouveau/nvif: remove route/token Ben Skeggs
2024-07-09 16:11   ` Danilo Krummrich
2024-07-18  7:52     ` Ben Skeggs
2024-07-19 12:12       ` Danilo Krummrich
2024-07-04 18:37 ` [PATCH v2 16/37] drm/nouveau/nvif: remove nvxx_object() Ben Skeggs
2024-07-09 16:14   ` Danilo Krummrich
2024-07-04 18:37 ` [PATCH v2 17/37] drm/nouveau/nvif: remove nvxx_client() Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 18/37] drm/nouveau/nvif: remove driver keep/fini Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 19/37] drm/nouveau/nvif: remove client device arg Ben Skeggs
2024-07-09 16:16   ` Danilo Krummrich
2024-07-04 18:37 ` [PATCH v2 20/37] drm/nouveau/nvif: remove client version Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 21/37] drm/nouveau/nvif: remove client devlist Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 22/37] drm/nouveau/nvif: remove client fini Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 23/37] drm/nouveau/nvif: remove device args Ben Skeggs
2024-07-09 16:18   ` Danilo Krummrich
2024-07-04 18:37 ` [PATCH v2 24/37] drm/nouveau: always map device Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 25/37] drm/nouveau/nvif: remove device rd/wr Ben Skeggs
2024-07-09 16:22   ` Danilo Krummrich
2024-07-04 18:37 ` [PATCH v2 26/37] drm/nouveau/nvif: remove disp chan rd/wr Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 27/37] drm/nouveau: move nvxx_* definitions to nouveau_drv.h Ben Skeggs
2024-07-09 16:31   ` Danilo Krummrich
2024-07-18  7:58     ` Ben Skeggs
2024-07-19 12:28       ` Danilo Krummrich
2024-07-26  4:35         ` Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 28/37] drm/nouveau: add nvif_mmu to nouveau_drm Ben Skeggs
2024-07-09 16:34   ` Danilo Krummrich
2024-07-18  8:10     ` Ben Skeggs
2024-07-19 12:47       ` Danilo Krummrich
2024-07-04 18:37 ` [PATCH v2 29/37] drm/nouveau: pass drm to nouveau_mem_new(), instead of cli Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 30/37] drm/nouveau: pass drm to nv50_dmac_create(), rather than device+disp Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 31/37] drm/nouveau: pass cli to nouveau_channel_new() instead of drm+device Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 32/37] drm/nouveau: remove nouveau_chan.device Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 33/37] drm/nouveau: remove chan->drm Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 34/37] drm/nouveau: remove master Ben Skeggs
2024-07-09 16:38   ` Danilo Krummrich
2024-07-18  8:12     ` Ben Skeggs
2024-07-19 12:49       ` Danilo Krummrich
2024-07-04 18:37 ` [PATCH v2 35/37] drm/nouveau: remove push pointer from nouveau_channel Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 36/37] drm/nouveau/kms: remove a few unused struct members and fn decls Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 37/37] drm/nouveau/kms: remove push pointer from nv50_dmac Ben Skeggs
2024-07-09 14:44 ` [PATCH v2 00/37] drm/nouveau: misc. cleanups and removal of unused apis Danilo Krummrich
2024-07-18  7:00   ` Ben Skeggs

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=ZqPDkZ2t5MjXX4Sx@cassiopeiae \
    --to=dakr@kernel.org \
    --cc=bskeggs@nvidia.com \
    --cc=nouveau@lists.freedesktop.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.