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/pci drm: Remove local diffs for drm_pc...



details:   https://anonhg.NetBSD.org/src/rev/1d8f98b364ef
branches:  trunk
changeset: 1028488:1d8f98b364ef
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 11:09:47 2021 +0000

description:
drm: Remove local diffs for drm_pci_set_busid.

Instead, move it to its own file that can be safely used without
bringing in a link/run-time dependency on pci.

diffstat:

 sys/external/bsd/drm2/dist/drm/drm_ioctl.c       |   8 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_drv.c   |   5 +-
 sys/external/bsd/drm2/dist/include/drm/drm_drv.h |   4 +-
 sys/external/bsd/drm2/dist/include/drm/drm_pci.h |   3 +-
 sys/external/bsd/drm2/drm/files.drmkms           |   5 +-
 sys/external/bsd/drm2/include/linux/pci.h        |  11 +++-
 sys/external/bsd/drm2/linux/linux_pci.c          |  10 +---
 sys/external/bsd/drm2/nouveau/nouveau_pci.c      |   5 +-
 sys/external/bsd/drm2/pci/drm_pci.c              |  19 +------
 sys/external/bsd/drm2/pci/drm_pci_busid.c        |  62 ++++++++++++++++++++++++
 10 files changed, 89 insertions(+), 43 deletions(-)

diffs (297 lines):

diff -r de40c50af2d3 -r 1d8f98b364ef sys/external/bsd/drm2/dist/drm/drm_ioctl.c
--- a/sys/external/bsd/drm2/dist/drm/drm_ioctl.c        Sun Dec 19 11:09:34 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_ioctl.c        Sun Dec 19 11:09:47 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_ioctl.c,v 1.20 2021/12/19 10:51:39 riastradh Exp $ */
+/*     $NetBSD: drm_ioctl.c,v 1.21 2021/12/19 11:09:47 riastradh Exp $ */
 
 /*
  * Created: Fri Jan  8 09:01:26 1999 by faith%valinux.com@localhost
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_ioctl.c,v 1.20 2021/12/19 10:51:39 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_ioctl.c,v 1.21 2021/12/19 11:09:47 riastradh Exp $");
 
 #include <linux/export.h>
 #include <linux/nospec.h>
@@ -161,8 +161,8 @@
        if (master->unique != NULL)
                drm_unset_busid(dev, master);
 
-       if (dev->driver->set_busid) {
-               ret = dev->driver->set_busid(dev, master);
+       if (dev->dev && dev_is_pci(dev->dev)) {
+               ret = drm_pci_set_busid(dev, master);
                if (ret) {
                        drm_unset_busid(dev, master);
                        return ret;
diff -r de40c50af2d3 -r 1d8f98b364ef sys/external/bsd/drm2/dist/drm/i915/i915_drv.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c    Sun Dec 19 11:09:34 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c    Sun Dec 19 11:09:47 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_drv.c,v 1.26 2021/12/19 10:32:47 riastradh Exp $  */
+/*     $NetBSD: i915_drv.c,v 1.27 2021/12/19 11:09:47 riastradh Exp $  */
 
 /* i915_drv.c -- i830,i845,i855,i865,i915 driver -*- linux-c -*-
  */
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_drv.c,v 1.26 2021/12/19 10:32:47 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_drv.c,v 1.27 2021/12/19 11:09:47 riastradh Exp $");
 
 #include <linux/acpi.h>
 #include <linux/device.h>
@@ -50,7 +50,6 @@
 #include <drm/drm_irq.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/i915_drm.h>
-#include "../drm_internal.h"   /* drm_pci_set_busid */
 
 #include "display/intel_acpi.h"
 #include "display/intel_audio.h"
diff -r de40c50af2d3 -r 1d8f98b364ef sys/external/bsd/drm2/dist/include/drm/drm_drv.h
--- a/sys/external/bsd/drm2/dist/include/drm/drm_drv.h  Sun Dec 19 11:09:34 2021 +0000
+++ b/sys/external/bsd/drm2/dist/include/drm/drm_drv.h  Sun Dec 19 11:09:47 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_drv.h,v 1.7 2021/12/19 10:51:39 riastradh Exp $    */
+/*     $NetBSD: drm_drv.h,v 1.8 2021/12/19 11:09:47 riastradh Exp $    */
 
 /*
  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -43,7 +43,6 @@
 struct drm_display_mode;
 struct drm_mode_create_dumb;
 struct drm_printer;
-struct drm_unique;
 
 /**
  * enum drm_driver_feature - feature flags
@@ -800,7 +799,6 @@
        int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
        int (*dma_quiescent) (struct drm_device *);
        int (*context_dtor) (struct drm_device *dev, int context);
-       int (*set_busid)(struct drm_device *dev, struct drm_master *master);
        int dev_priv_size;
 };
 
diff -r de40c50af2d3 -r 1d8f98b364ef 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:09:34 2021 +0000
+++ b/sys/external/bsd/drm2/dist/include/drm/drm_pci.h  Sun Dec 19 11:09:47 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_pci.h,v 1.7 2021/12/19 11:05:12 riastradh Exp $    */
+/*     $NetBSD: drm_pci.h,v 1.8 2021/12/19 11:09:47 riastradh Exp $    */
 
 /*
  * Internal Header for the Direct Rendering Manager
@@ -79,7 +79,6 @@
 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
 
 #endif /* _DRM_PCI_H_ */
diff -r de40c50af2d3 -r 1d8f98b364ef sys/external/bsd/drm2/drm/files.drmkms
--- a/sys/external/bsd/drm2/drm/files.drmkms    Sun Dec 19 11:09:34 2021 +0000
+++ b/sys/external/bsd/drm2/drm/files.drmkms    Sun Dec 19 11:09:47 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.drmkms,v 1.65 2021/12/19 11:03:09 riastradh Exp $
+#      $NetBSD: files.drmkms,v 1.66 2021/12/19 11:09:47 riastradh Exp $
 
 version        20180827
 
@@ -60,6 +60,9 @@
 file   external/bsd/drm2/drm/drm_stub.c                !drmkms & !drmbase
 file   external/bsd/drm2/drm/drm_sysctl.c              drmkms
 
+# pci bus ids -- doesn't depend on all of pci, just the header files
+file   external/bsd/drm2/pci/drm_pci_busid.c           drmkms
+
 # Generic, unaccelerated kms framebuffer.
 define drmfb: genfb
 file   external/bsd/drm2/drm/drmfb.c                   drmfb
diff -r de40c50af2d3 -r 1d8f98b364ef sys/external/bsd/drm2/include/linux/pci.h
--- a/sys/external/bsd/drm2/include/linux/pci.h Sun Dec 19 11:09:34 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/pci.h Sun Dec 19 11:09:47 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci.h,v 1.47 2021/12/19 10:57:42 riastradh Exp $       */
+/*     $NetBSD: pci.h,v 1.48 2021/12/19 11:09:47 riastradh Exp $       */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -308,6 +308,13 @@
 
 void           pci_save_state(struct pci_dev *);
 void           pci_restore_state(struct pci_dev *);
-bool           dev_is_pci(struct pci_dev *);
+
+static inline bool
+dev_is_pci(struct device *dev)
+{
+       struct device *parent = device_parent(dev);
+
+       return parent && device_is_a(parent, "pci");
+}
 
 #endif  /* _LINUX_PCI_H_ */
diff -r de40c50af2d3 -r 1d8f98b364ef sys/external/bsd/drm2/linux/linux_pci.c
--- a/sys/external/bsd/drm2/linux/linux_pci.c   Sun Dec 19 11:09:34 2021 +0000
+++ b/sys/external/bsd/drm2/linux/linux_pci.c   Sun Dec 19 11:09:47 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_pci.c,v 1.17 2021/12/19 10:59:48 riastradh Exp $ */
+/*     $NetBSD: linux_pci.c,v 1.18 2021/12/19 11:09:48 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_pci.c,v 1.17 2021/12/19 10:59:48 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_pci.c,v 1.18 2021/12/19 11:09:48 riastradh Exp $");
 
 #if NACPICA > 0
 #include <dev/acpi/acpivar.h>
@@ -789,9 +789,3 @@
        KASSERT(pdev->pd_saved_state == NULL);
        KASSERT(pdev->pd_intr_handles == NULL);
 }
-
-bool
-dev_is_pci(struct pci_dev *pdev)
-{
-       return pdev != NULL;
-}
diff -r de40c50af2d3 -r 1d8f98b364ef sys/external/bsd/drm2/nouveau/nouveau_pci.c
--- a/sys/external/bsd/drm2/nouveau/nouveau_pci.c       Sun Dec 19 11:09:34 2021 +0000
+++ b/sys/external/bsd/drm2/nouveau/nouveau_pci.c       Sun Dec 19 11:09:47 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_pci.c,v 1.31 2021/12/19 11:05:20 riastradh Exp $       */
+/*     $NetBSD: nouveau_pci.c,v 1.32 2021/12/19 11:09:48 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.31 2021/12/19 11:05:20 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_pci.c,v 1.32 2021/12/19 11:09:48 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #if defined(__arm__) || defined(__aarch64__)
@@ -358,7 +358,6 @@
        switch (cmd) {
        case MODULE_CMD_INIT:
                *nouveau_drm_driver_pci = *nouveau_drm_driver_stub;
-               nouveau_drm_driver_pci->set_busid = drm_pci_set_busid;
                nouveau_drm_driver_pci->request_irq = drm_pci_request_irq;
                nouveau_drm_driver_pci->free_irq = drm_pci_free_irq;
 #if 0          /* XXX nouveau acpi */
diff -r de40c50af2d3 -r 1d8f98b364ef sys/external/bsd/drm2/pci/drm_pci.c
--- a/sys/external/bsd/drm2/pci/drm_pci.c       Sun Dec 19 11:09:34 2021 +0000
+++ b/sys/external/bsd/drm2/pci/drm_pci.c       Sun Dec 19 11:09:47 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_pci.c,v 1.44 2021/12/19 11:05:13 riastradh Exp $   */
+/*     $NetBSD: drm_pci.c,v 1.45 2021/12/19 11:09:48 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.44 2021/12/19 11:05:13 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_pci.c,v 1.45 2021/12/19 11:09:48 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/errno.h>
@@ -226,18 +226,3 @@
        kmem_free(cookie, sizeof(*cookie));
        dev->irq_cookie = NULL;
 }
-
-int
-drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
-{
-       const struct pci_attach_args *const pa = &dev->pdev->pd_pa;
-
-       master->unique = kasprintf(GFP_KERNEL, "pci:%04x:%02x:%02x.%d",
-           device_unit(device_parent(dev->dev)),
-           pa->pa_bus, pa->pa_device, pa->pa_function);
-       if (master->unique == NULL)
-               return -ENOMEM;
-       master->unique_len = strlen(master->unique);
-
-       return 0;
-}
diff -r de40c50af2d3 -r 1d8f98b364ef sys/external/bsd/drm2/pci/drm_pci_busid.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/external/bsd/drm2/pci/drm_pci_busid.c Sun Dec 19 11:09:47 2021 +0000
@@ -0,0 +1,62 @@
+/*     $NetBSD: drm_pci_busid.c,v 1.1 2021/12/19 11:09:48 riastradh Exp $      */
+
+/*-
+ * Copyright (c) 2020 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: drm_pci_busid.c,v 1.1 2021/12/19 11:09:48 riastradh Exp $");
+
+#include <sys/types.h>
+#include <sys/device.h>
+#include <sys/errno.h>
+
+#include <lib/libkern/libkern.h>
+
+#include <dev/pci/pcivar.h>
+
+#include <linux/kernel.h>
+#include <linux/pci.h>
+
+#include <drm/drm_auth.h>
+#include <drm/drm_device.h>
+#include "../dist/drm/drm_internal.h"
+
+int
+drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
+{
+       const struct pci_attach_args *const pa = &dev->pdev->pd_pa;
+
+       KASSERT(dev_is_pci(dev->dev));
+
+       master->unique = kasprintf(GFP_KERNEL, "pci:%04x:%02x:%02x.%d",
+           device_unit(device_parent(dev->dev)),
+           pa->pa_bus, pa->pa_device, pa->pa_function);
+       if (master->unique == NULL)
+               return -ENOMEM;
+       master->unique_len = strlen(master->unique);
+
+       return 0;
+}



Home | Main Index | Thread Index | Old Index