Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/drm2 Split drm_dev_alloc/register out of dr...
details: https://anonhg.NetBSD.org/src/rev/dae11305b5b9
branches: trunk
changeset: 1028453:dae11305b5b9
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Dec 19 11:05:12 2021 +0000
description:
Split drm_dev_alloc/register out of drm_pci_attach.
Needed by nouveau which needs to do
drm_dev_alloc
drm_pci_attach
nouveau_drm_device_init
drm_dev_register
diffstat:
sys/external/bsd/drm2/amdgpu/amdgpu_pci.c | 45 +++++++++++++++------
sys/external/bsd/drm2/dist/include/drm/drm_pci.h | 9 +--
sys/external/bsd/drm2/i915drm/i915_pci_autoconf.c | 46 +++++++++++++++------
sys/external/bsd/drm2/nouveau/nouveau_pci.c | 42 ++++++++++++++-----
sys/external/bsd/drm2/pci/drm_pci.c | 48 +++-------------------
sys/external/bsd/drm2/radeon/radeon_pci.c | 48 ++++++++++++++++------
6 files changed, 142 insertions(+), 96 deletions(-)
diffs (truncated from 491 to 300 lines):
diff -r 4718b66ff41d -r dae11305b5b9 sys/external/bsd/drm2/amdgpu/amdgpu_pci.c
--- a/sys/external/bsd/drm2/amdgpu/amdgpu_pci.c Sun Dec 19 11:05:05 2021 +0000
+++ b/sys/external/bsd/drm2/amdgpu/amdgpu_pci.c Sun Dec 19 11:05:12 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: amdgpu_pci.c,v 1.6 2021/12/19 10:32:59 riastradh Exp $ */
+/* $NetBSD: amdgpu_pci.c,v 1.7 2021/12/19 11:05:12 riastradh Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_pci.c,v 1.6 2021/12/19 10:32:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_pci.c,v 1.7 2021/12/19 11:05:12 riastradh Exp $");
#include <sys/types.h>
#include <sys/queue.h>
@@ -58,6 +58,8 @@
} sc_task_u;
struct drm_device *sc_drm_dev;
struct pci_dev sc_pci_dev;
+ bool sc_pci_attached;
+ bool sc_dev_registered;
};
static bool amdgpu_pci_lookup(const struct pci_attach_args *,
@@ -159,13 +161,29 @@
/* Initialize the Linux PCI device descriptor. */
linux_pci_dev_init(&sc->sc_pci_dev, self, device_parent(self), pa, 0);
+ sc->sc_drm_dev = drm_dev_alloc(amdgpu_drm_driver, self);
+ if (IS_ERR(sc->sc_drm_dev)) {
+ aprint_error_dev(self, "unable to create drm device: %ld\n",
+ PTR_ERR(sc->sc_drm_dev));
+ sc->sc_drm_dev = NULL;
+ goto out;
+ }
+
/* XXX errno Linux->NetBSD */
- error = -drm_pci_attach(self, pa, &sc->sc_pci_dev, amdgpu_drm_driver,
- flags, &sc->sc_drm_dev);
+ error = -drm_pci_attach(sc->sc_drm_dev, pa, &sc->sc_pci_dev);
if (error) {
aprint_error_dev(self, "unable to attach drm: %d\n", error);
goto out;
}
+ sc->sc_pci_attached = true;
+
+ /* XXX errno Linux->NetBSD */
+ error = -drm_dev_register(sc->sc_drm_dev, flags);
+ if (error) {
+ aprint_error_dev(self, "unable to register drm: %d\n", error);
+ return;
+ }
+ sc->sc_dev_registered = true;
while (!SIMPLEQ_EMPTY(&sc->sc_task_u.attach)) {
struct amdgpu_task *const task =
@@ -211,17 +229,18 @@
}
if (sc->sc_drm_dev == NULL)
- goto out;
- /* XXX errno Linux->NetBSD */
- error = -drm_pci_detach(sc->sc_drm_dev, flags);
- if (error)
- /* XXX Kinda too late to fail now... */
- return error;
+ goto out0;
+ if (!sc->sc_pci_attached)
+ goto out1;
+ if (!sc->sc_dev_registered)
+ goto out2;
+
+ drm_dev_unregister(sc->sc_drm_dev);
+out2: drm_pci_detach(sc->sc_drm_dev);
+out1: drm_dev_put(sc->sc_drm_dev);
sc->sc_drm_dev = NULL;
-
-out: linux_pci_dev_destroy(&sc->sc_pci_dev);
+out0: linux_pci_dev_destroy(&sc->sc_pci_dev);
pmf_device_deregister(self);
-
return 0;
}
diff -r 4718b66ff41d -r dae11305b5b9 sys/external/bsd/drm2/dist/include/drm/drm_pci.h
--- a/sys/external/bsd/drm2/dist/include/drm/drm_pci.h Sun Dec 19 11:05:05 2021 +0000
+++ b/sys/external/bsd/drm2/dist/include/drm/drm_pci.h Sun Dec 19 11:05:12 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: drm_pci.h,v 1.6 2021/12/19 10:51:39 riastradh Exp $ */
+/* $NetBSD: drm_pci.h,v 1.7 2021/12/19 11:05:12 riastradh Exp $ */
/*
* Internal Header for the Direct Rendering Manager
@@ -76,10 +76,9 @@
#ifdef __NetBSD__
int drm_pci_request_irq(struct drm_device *, int);
void drm_pci_free_irq(struct drm_device *);
-extern int drm_pci_attach(device_t, const struct pci_attach_args *,
- struct pci_dev *, struct drm_driver *, unsigned long,
- struct drm_device **);
-extern int drm_pci_detach(struct drm_device *, int);
+int drm_pci_attach(struct drm_device *, const struct pci_attach_args *,
+ struct pci_dev *);
+void drm_pci_detach(struct drm_device *);
int drm_pci_set_busid(struct drm_device *, struct drm_master *);
#endif
diff -r 4718b66ff41d -r dae11305b5b9 sys/external/bsd/drm2/i915drm/i915_pci_autoconf.c
--- a/sys/external/bsd/drm2/i915drm/i915_pci_autoconf.c Sun Dec 19 11:05:05 2021 +0000
+++ b/sys/external/bsd/drm2/i915drm/i915_pci_autoconf.c Sun Dec 19 11:05:12 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_pci_autoconf.c,v 1.3 2021/12/19 10:32:59 riastradh Exp $ */
+/* $NetBSD: i915_pci_autoconf.c,v 1.4 2021/12/19 11:05:12 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_pci_autoconf.c,v 1.3 2021/12/19 10:32:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_pci_autoconf.c,v 1.4 2021/12/19 11:05:12 riastradh Exp $");
#include <sys/types.h>
#include <sys/queue.h>
@@ -58,6 +58,8 @@
} sc_task_u;
struct drm_device *sc_drm_dev;
struct pci_dev sc_pci_dev;
+ bool sc_pci_attached;
+ bool sc_dev_registered;
};
static const struct intel_device_info *
@@ -177,13 +179,29 @@
/* Initialize the Linux PCI device descriptor. */
linux_pci_dev_init(&sc->sc_pci_dev, self, device_parent(self), pa, 0);
+ sc->sc_drm_dev = drm_dev_alloc(i915_drm_driver, self);
+ if (IS_ERR(sc->sc_drm_dev)) {
+ aprint_error_dev(self, "unable to create drm device: %ld\n",
+ PTR_ERR(sc->sc_drm_dev));
+ sc->sc_drm_dev = NULL;
+ return;
+ }
+
/* XXX errno Linux->NetBSD */
- error = -drm_pci_attach(self, pa, &sc->sc_pci_dev, i915_drm_driver,
- cookie, &sc->sc_drm_dev);
+ error = -drm_pci_attach(sc->sc_drm_dev, pa, &sc->sc_pci_dev);
if (error) {
aprint_error_dev(self, "unable to attach drm: %d\n", error);
return;
}
+ sc->sc_pci_attached = true;
+
+ /* XXX errno Linux->NetBSD */
+ error = -drm_dev_register(sc->sc_drm_dev, cookie);
+ if (error) {
+ aprint_error_dev(self, "unable to register drm: %d\n", error);
+ return;
+ }
+ sc->sc_dev_registered = true;
while (!SIMPLEQ_EMPTY(&sc->sc_task_u.attach)) {
struct i915drmkms_task *const task =
@@ -216,22 +234,24 @@
return error;
if (sc->sc_task_state == I915DRMKMS_TASK_ATTACH)
- goto out;
+ goto out0;
if (sc->sc_task_u.workqueue != NULL) {
workqueue_destroy(sc->sc_task_u.workqueue);
sc->sc_task_u.workqueue = NULL;
}
if (sc->sc_drm_dev == NULL)
- goto out;
- /* XXX errno Linux->NetBSD */
- error = -drm_pci_detach(sc->sc_drm_dev, flags);
- if (error)
- /* XXX Kinda too late to fail now... */
- return error;
+ goto out0;
+ if (!sc->sc_pci_attached)
+ goto out1;
+ if (!sc->sc_dev_registered)
+ goto out2;
+
+ drm_dev_unregister(sc->sc_drm_dev);
+out2: drm_pci_detach(sc->sc_drm_dev);
+out1: drm_dev_put(sc->sc_drm_dev);
sc->sc_drm_dev = NULL;
-
-out: linux_pci_dev_destroy(&sc->sc_pci_dev);
+out0: linux_pci_dev_destroy(&sc->sc_pci_dev);
pmf_device_deregister(self);
return 0;
}
diff -r 4718b66ff41d -r dae11305b5b9 sys/external/bsd/drm2/nouveau/nouveau_pci.c
--- a/sys/external/bsd/drm2/nouveau/nouveau_pci.c Sun Dec 19 11:05:05 2021 +0000
+++ b/sys/external/bsd/drm2/nouveau/nouveau_pci.c Sun Dec 19 11:05:12 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nouveau_pci.c,v 1.29 2021/12/19 10:51:59 riastradh Exp $ */
+/* $NetBSD: nouveau_pci.c,v 1.30 2021/12/19 11:05:13 riastradh Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_pci.c,v 1.29 2021/12/19 10:51:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_pci.c,v 1.30 2021/12/19 11:05:13 riastradh Exp $");
#ifdef _KERNEL_OPT
#if defined(__arm__) || defined(__aarch64__)
@@ -76,6 +76,8 @@
struct drm_device *sc_drm_dev;
struct pci_dev sc_pci_dev;
struct nvkm_device *sc_nv_dev;
+ bool sc_pci_attached;
+ bool sc_dev_registered;
};
static int nouveau_pci_match(device_t, cfdata_t, void *);
@@ -200,16 +202,33 @@
if (error) {
aprint_error_dev(self, "unable to create nouveau device: %d\n",
error);
+ sc->sc_nv_dev = NULL;
+ return;
+ }
+
+ sc->sc_drm_dev = drm_dev_alloc(nouveau_drm_driver_pci, self);
+ if (IS_ERR(sc->sc_drm_dev)) {
+ aprint_error_dev(self, "unable to create drm device: %ld\n",
+ PTR_ERR(sc->sc_drm_dev));
+ sc->sc_drm_dev = NULL;
return;
}
/* XXX errno Linux->NetBSD */
- error = -drm_pci_attach(self, pa, &sc->sc_pci_dev,
- nouveau_drm_driver_pci, 0, &sc->sc_drm_dev);
+ error = -drm_pci_attach(sc->sc_drm_dev, pa, &sc->sc_pci_dev);
if (error) {
aprint_error_dev(self, "unable to attach drm: %d\n", error);
return;
}
+ sc->sc_pci_attached = true;
+
+ /* XXX errno Linux->NetBSD */
+ error = -drm_dev_register(sc->sc_drm_dev, 0);
+ if (error) {
+ aprint_error_dev(self, "unable to register drm: %d\n", error);
+ return;
+ }
+ sc->sc_dev_registered = true;
while (!SIMPLEQ_EMPTY(&sc->sc_task_u.attach)) {
struct nouveau_pci_task *const task =
@@ -254,16 +273,17 @@
if (sc->sc_nv_dev == NULL)
goto out0;
-
if (sc->sc_drm_dev == NULL)
goto out1;
- /* XXX errno Linux->NetBSD */
- error = -drm_pci_detach(sc->sc_drm_dev, flags);
- if (error)
- /* XXX Kinda too late to fail now... */
- return error;
+ if (!sc->sc_pci_attached)
+ goto out2;
+ if (!sc->sc_dev_registered)
+ goto out3;
+
+ drm_dev_unregister(sc->sc_drm_dev);
+out3: drm_pci_detach(sc->sc_drm_dev);
+out2: drm_dev_put(sc->sc_drm_dev);
sc->sc_drm_dev = NULL;
-
out1: nvkm_device_del(&sc->sc_nv_dev);
out0: linux_pci_dev_destroy(&sc->sc_pci_dev);
pmf_device_deregister(self);
diff -r 4718b66ff41d -r dae11305b5b9 sys/external/bsd/drm2/pci/drm_pci.c
--- a/sys/external/bsd/drm2/pci/drm_pci.c Sun Dec 19 11:05:05 2021 +0000
+++ b/sys/external/bsd/drm2/pci/drm_pci.c Sun Dec 19 11:05:12 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: drm_pci.c,v 1.43 2021/12/19 11:01:22 riastradh Exp $ */
+/* $NetBSD: drm_pci.c,v 1.44 2021/12/19 11:05:13 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
Home |
Main Index |
Thread Index |
Old Index