Module Name:    src
Committed By:   riastradh
Date:           Sun Dec 19 11:09:48 UTC 2021

Modified Files:
        src/sys/external/bsd/drm2/dist/drm: drm_ioctl.c
        src/sys/external/bsd/drm2/dist/drm/i915: i915_drv.c
        src/sys/external/bsd/drm2/dist/include/drm: drm_drv.h drm_pci.h
        src/sys/external/bsd/drm2/drm: files.drmkms
        src/sys/external/bsd/drm2/include/linux: pci.h
        src/sys/external/bsd/drm2/linux: linux_pci.c
        src/sys/external/bsd/drm2/nouveau: nouveau_pci.c
        src/sys/external/bsd/drm2/pci: drm_pci.c
Added Files:
        src/sys/external/bsd/drm2/pci: drm_pci_busid.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/external/bsd/drm2/dist/drm/drm_ioctl.c
cvs rdiff -u -r1.26 -r1.27 src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c
cvs rdiff -u -r1.7 -r1.8 src/sys/external/bsd/drm2/dist/include/drm/drm_drv.h \
    src/sys/external/bsd/drm2/dist/include/drm/drm_pci.h
cvs rdiff -u -r1.65 -r1.66 src/sys/external/bsd/drm2/drm/files.drmkms
cvs rdiff -u -r1.47 -r1.48 src/sys/external/bsd/drm2/include/linux/pci.h
cvs rdiff -u -r1.17 -r1.18 src/sys/external/bsd/drm2/linux/linux_pci.c
cvs rdiff -u -r1.31 -r1.32 src/sys/external/bsd/drm2/nouveau/nouveau_pci.c
cvs rdiff -u -r1.44 -r1.45 src/sys/external/bsd/drm2/pci/drm_pci.c
cvs rdiff -u -r0 -r1.1 src/sys/external/bsd/drm2/pci/drm_pci_busid.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/dist/drm/drm_ioctl.c
diff -u src/sys/external/bsd/drm2/dist/drm/drm_ioctl.c:1.20 src/sys/external/bsd/drm2/dist/drm/drm_ioctl.c:1.21
--- src/sys/external/bsd/drm2/dist/drm/drm_ioctl.c:1.20	Sun Dec 19 10:51:39 2021
+++ src/sys/external/bsd/drm2/dist/drm/drm_ioctl.c	Sun Dec 19 11:09:47 2021
@@ -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 [email protected]
@@ -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 @@ static int drm_set_busid(struct drm_devi
 	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;

Index: src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c:1.26 src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c:1.27
--- src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c:1.26	Sun Dec 19 10:32:47 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c	Sun Dec 19 11:09:47 2021
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: i915_drv.c,v
 #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"

Index: src/sys/external/bsd/drm2/dist/include/drm/drm_drv.h
diff -u src/sys/external/bsd/drm2/dist/include/drm/drm_drv.h:1.7 src/sys/external/bsd/drm2/dist/include/drm/drm_drv.h:1.8
--- src/sys/external/bsd/drm2/dist/include/drm/drm_drv.h:1.7	Sun Dec 19 10:51:39 2021
+++ src/sys/external/bsd/drm2/dist/include/drm/drm_drv.h	Sun Dec 19 11:09:47 2021
@@ -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 dma_buf_attachment;
 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 @@ struct drm_driver {
 	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;
 };
 
Index: src/sys/external/bsd/drm2/dist/include/drm/drm_pci.h
diff -u src/sys/external/bsd/drm2/dist/include/drm/drm_pci.h:1.7 src/sys/external/bsd/drm2/dist/include/drm/drm_pci.h:1.8
--- src/sys/external/bsd/drm2/dist/include/drm/drm_pci.h:1.7	Sun Dec 19 11:05:12 2021
+++ src/sys/external/bsd/drm2/dist/include/drm/drm_pci.h	Sun Dec 19 11:09:47 2021
@@ -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 @@ void drm_pci_free_irq(struct drm_device 
 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_ */

Index: src/sys/external/bsd/drm2/drm/files.drmkms
diff -u src/sys/external/bsd/drm2/drm/files.drmkms:1.65 src/sys/external/bsd/drm2/drm/files.drmkms:1.66
--- src/sys/external/bsd/drm2/drm/files.drmkms:1.65	Sun Dec 19 11:03:09 2021
+++ src/sys/external/bsd/drm2/drm/files.drmkms	Sun Dec 19 11:09:47 2021
@@ -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_module.c	
 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

Index: src/sys/external/bsd/drm2/include/linux/pci.h
diff -u src/sys/external/bsd/drm2/include/linux/pci.h:1.47 src/sys/external/bsd/drm2/include/linux/pci.h:1.48
--- src/sys/external/bsd/drm2/include/linux/pci.h:1.47	Sun Dec 19 10:57:42 2021
+++ src/sys/external/bsd/drm2/include/linux/pci.h	Sun Dec 19 11:09:47 2021
@@ -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_iounmap(struct pci_dev *, void
 
 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_ */

Index: src/sys/external/bsd/drm2/linux/linux_pci.c
diff -u src/sys/external/bsd/drm2/linux/linux_pci.c:1.17 src/sys/external/bsd/drm2/linux/linux_pci.c:1.18
--- src/sys/external/bsd/drm2/linux/linux_pci.c:1.17	Sun Dec 19 10:59:48 2021
+++ src/sys/external/bsd/drm2/linux/linux_pci.c	Sun Dec 19 11:09:48 2021
@@ -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 @@ linux_pci_dev_destroy(struct pci_dev *pd
 	KASSERT(pdev->pd_saved_state == NULL);
 	KASSERT(pdev->pd_intr_handles == NULL);
 }
-
-bool
-dev_is_pci(struct pci_dev *pdev)
-{
-	return pdev != NULL;
-}

Index: src/sys/external/bsd/drm2/nouveau/nouveau_pci.c
diff -u src/sys/external/bsd/drm2/nouveau/nouveau_pci.c:1.31 src/sys/external/bsd/drm2/nouveau/nouveau_pci.c:1.32
--- src/sys/external/bsd/drm2/nouveau/nouveau_pci.c:1.31	Sun Dec 19 11:05:20 2021
+++ src/sys/external/bsd/drm2/nouveau/nouveau_pci.c	Sun Dec 19 11:09:48 2021
@@ -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 @@ nouveau_pci_modcmd(modcmd_t cmd, void *a
 	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 */

Index: src/sys/external/bsd/drm2/pci/drm_pci.c
diff -u src/sys/external/bsd/drm2/pci/drm_pci.c:1.44 src/sys/external/bsd/drm2/pci/drm_pci.c:1.45
--- src/sys/external/bsd/drm2/pci/drm_pci.c:1.44	Sun Dec 19 11:05:13 2021
+++ src/sys/external/bsd/drm2/pci/drm_pci.c	Sun Dec 19 11:09:48 2021
@@ -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 @@ drm_pci_free_irq(struct drm_device *dev)
 	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;
-}

Added files:

Index: src/sys/external/bsd/drm2/pci/drm_pci_busid.c
diff -u /dev/null src/sys/external/bsd/drm2/pci/drm_pci_busid.c:1.1
--- /dev/null	Sun Dec 19 11:09:48 2021
+++ src/sys/external/bsd/drm2/pci/drm_pci_busid.c	Sun Dec 19 11:09:48 2021
@@ -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;
+}

Reply via email to