Commit 6777264d authored by Ben Skeggs's avatar Ben Skeggs Committed by Danilo Krummrich

drm/nouveau: store nvkm_device pointer in nouveau_drm

There's various different places in the drm code that get at the
nvkm_device via various creative (and not very type-safe) means.

One of those being via nvif_device.object.priv.

Another patch series is going to entirely remove the ioctl-like
interfaces beween the drm code and nvkm, and that field will no
longer exist.

This provides a safer replacement for accessing the nvkm_device,
and will used more in upcoming patches to cleanup other cases.

v2:
- fixup printk macros to not oops if used before client ctor
Signed-off-by: default avatarBen Skeggs <bskeggs@nvidia.com>
Signed-off-by: default avatarDanilo Krummrich <dakr@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240726043828.58966-6-bskeggs@nvidia.com
parent c0bfe343
......@@ -751,6 +751,8 @@ nouveau_drm_device_new(const struct drm_driver *drm_driver, struct device *paren
if (!drm)
return ERR_PTR(-ENOMEM);
drm->nvkm = device;
drm->dev = drm_dev_alloc(drm_driver, parent);
if (IS_ERR(drm->dev)) {
ret = PTR_ERR(drm->dev);
......@@ -888,14 +890,10 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
void
nouveau_drm_device_remove(struct nouveau_drm *drm)
{
struct nvkm_client *client;
struct nvkm_device *device;
struct nvkm_device *device = drm->nvkm;
drm_dev_unplug(drm->dev);
client = nvxx_client(&drm->client.base);
device = nvkm_device_find(client->device);
nouveau_drm_device_fini(drm);
nouveau_drm_device_del(drm);
nvkm_device_del(&device);
......
......@@ -201,6 +201,7 @@ u_memcpya(uint64_t user, unsigned int nmemb, unsigned int size)
#include <nvif/parent.h>
struct nouveau_drm {
struct nvkm_device *nvkm;
struct nvif_parent parent;
struct nouveau_cli master;
struct nouveau_cli client;
......@@ -332,18 +333,21 @@ void nouveau_drm_device_remove(struct nouveau_drm *);
dev_##l(_cli->drm->dev->dev, "%s: "f, _cli->name, ##a); \
} while(0)
#define NV_FATAL(drm,f,a...) NV_PRINTK(crit, &(drm)->client, f, ##a)
#define NV_ERROR(drm,f,a...) NV_PRINTK(err, &(drm)->client, f, ##a)
#define NV_WARN(drm,f,a...) NV_PRINTK(warn, &(drm)->client, f, ##a)
#define NV_INFO(drm,f,a...) NV_PRINTK(info, &(drm)->client, f, ##a)
#define NV_PRINTK_(l,drm,f,a...) do { \
dev_##l((drm)->nvkm->dev, "drm: "f, ##a); \
} while(0)
#define NV_FATAL(drm,f,a...) NV_PRINTK_(crit, (drm), f, ##a)
#define NV_ERROR(drm,f,a...) NV_PRINTK_(err, (drm), f, ##a)
#define NV_WARN(drm,f,a...) NV_PRINTK_(warn, (drm), f, ##a)
#define NV_INFO(drm,f,a...) NV_PRINTK_(info, (drm), f, ##a)
#define NV_DEBUG(drm,f,a...) do { \
if (drm_debug_enabled(DRM_UT_DRIVER)) \
NV_PRINTK(info, &(drm)->client, f, ##a); \
NV_PRINTK_(info, (drm), f, ##a); \
} while(0)
#define NV_ATOMIC(drm,f,a...) do { \
if (drm_debug_enabled(DRM_UT_ATOMIC)) \
NV_PRINTK(info, &(drm)->client, f, ##a); \
NV_PRINTK_(info, (drm), f, ##a); \
} while(0)
#define NV_PRINTK_ONCE(l,c,f,a...) NV_PRINTK(l##_once,c,f, ##a)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment