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 Adapt drmkms_pci module initialization...



details:   https://anonhg.NetBSD.org/src/rev/486f491a4902
branches:  trunk
changeset: 336558:486f491a4902
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri Mar 06 01:24:24 2015 +0000

description:
Adapt drmkms_pci module initialization to work as builtin, for agp.

diffstat:

 sys/external/bsd/drm2/dist/include/drm/drmP.h |   1 +
 sys/external/bsd/drm2/pci/drm_pci.c           |  10 ++++-
 sys/external/bsd/drm2/pci/drm_pci_module.c    |  44 ++++++++++++++++++++++++--
 3 files changed, 49 insertions(+), 6 deletions(-)

diffs (120 lines):

diff -r 794cc329f605 -r 486f491a4902 sys/external/bsd/drm2/dist/include/drm/drmP.h
--- a/sys/external/bsd/drm2/dist/include/drm/drmP.h     Fri Mar 06 00:44:04 2015 +0000
+++ b/sys/external/bsd/drm2/dist/include/drm/drmP.h     Fri Mar 06 01:24:24 2015 +0000
@@ -1751,6 +1751,7 @@
 extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
 extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
 #ifdef __NetBSD__
+extern int drmkms_pci_agp_guarantee_initialized(void);
 extern int drm_pci_attach(device_t, const struct pci_attach_args *,
     struct pci_dev *, struct drm_driver *, unsigned long,
     struct drm_device **);
diff -r 794cc329f605 -r 486f491a4902 sys/external/bsd/drm2/pci/drm_pci.c
--- a/sys/external/bsd/drm2/pci/drm_pci.c       Fri Mar 06 00:44:04 2015 +0000
+++ b/sys/external/bsd/drm2/pci/drm_pci.c       Fri Mar 06 01:24:24 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_pci.c,v 1.9 2015/01/01 01:15:43 mrg Exp $  */
+/*     $NetBSD: drm_pci.c,v 1.10 2015/03/06 01:24:24 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_pci.c,v 1.9 2015/01/01 01:15:43 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_pci.c,v 1.10 2015/03/06 01:24:24 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/errno.h>
@@ -94,6 +94,12 @@
        unsigned int unit;
        int ret;
 
+       /* Ensure the drm agp hooks are installed.  */
+       /* XXX errno NetBSD->Linux */
+       ret = -drmkms_pci_agp_guarantee_initialized();
+       if (ret)
+               goto fail0;
+
        /* Initialize the Linux PCI device descriptor.  */
        linux_pci_dev_init(pdev, self, pa, 0);
 
diff -r 794cc329f605 -r 486f491a4902 sys/external/bsd/drm2/pci/drm_pci_module.c
--- a/sys/external/bsd/drm2/pci/drm_pci_module.c        Fri Mar 06 00:44:04 2015 +0000
+++ b/sys/external/bsd/drm2/pci/drm_pci_module.c        Fri Mar 06 01:24:24 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_pci_module.c,v 1.3 2014/11/22 19:18:07 riastradh Exp $     */
+/*     $NetBSD: drm_pci_module.c,v 1.4 2015/03/06 01:24:24 riastradh Exp $     */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,9 +30,10 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_pci_module.c,v 1.3 2014/11/22 19:18:07 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_pci_module.c,v 1.4 2015/03/06 01:24:24 riastradh Exp $");
 
 #include <sys/module.h>
+#include <sys/once.h>
 
 #include <drm/drmP.h>
 
@@ -52,19 +53,54 @@
 };
 
 static int
+drmkms_pci_agp_init(void)
+{
+       int error;
+
+       error = drm_agp_register(&drmkms_pci_agp_hooks);
+       if (error)
+               return error;
+
+       return 0;
+}
+
+int
+drmkms_pci_agp_guarantee_initialized(void)
+{
+#ifdef _MODULE
+       return 0;
+#else
+       static ONCE_DECL(drmkms_pci_agp_init_once);
+
+       return RUN_ONCE(&drmkms_pci_agp_init_once, &drmkms_pci_agp_init);
+#endif
+}
+
+static void
+drmkms_pci_agp_fini(void)
+{
+
+       drm_agp_deregister(&drmkms_pci_agp_hooks);
+}
+
+static int
 drmkms_pci_modcmd(modcmd_t cmd, void *arg __unused)
 {
        int error;
 
        switch (cmd) {
        case MODULE_CMD_INIT:
-               error = drm_agp_register(&drmkms_pci_agp_hooks);
+#ifdef _MODULE
+               error = drmkms_pci_agp_init();
+#else
+               error = drmkms_pci_agp_guarantee_initialized();
+#endif
                if (error)
                        return error;
                return 0;
 
        case MODULE_CMD_FINI:
-               drm_agp_deregister(&drmkms_pci_agp_hooks);
+               drmkms_pci_agp_fini();
                return 0;
 
        default:



Home | Main Index | Thread Index | Old Index