Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 Oct 2020 16:28:57 +0200
From:      =?UTF-8?B?VMSzbA==?= Coosemans <tijl@FreeBSD.org>
To:        x11@FreeBSD.org
Subject:   drm-current-kmod 5.4 missing 4.16 patches
Message-ID:  <20201004162857.7980a25d@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
--MP_/4EJTV+CgOyA6a4/Ci86x5UN
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi,

I noticed some patches that were applied to drm-current-kmod 4.16 are
missing from 5.4.  I went over this list (minus the upstream commits):
https://github.com/FreeBSDDesktop/kms-drm/compare/drm-v5.1...drm-v4.16

I attached the ones that were missing.  They have been reworked a bit to
apply to https://github.com/freebsd/drm-kmod/tree/5.4-lts

They don't apply to the master branch because it is missing things that
are in 5.4-lts.  In fact master is currently 273 commits behind 5.4-lts
which in turn is 49 commits behind master.  You seem to be applying
patches to both branches instead of applying them to one branch and then
merging the branches.  If you happen to forget about the other branch
that's how patches get lost.

--MP_/4EJTV+CgOyA6a4/Ci86x5UN
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename=0001-radeon-default-hw_i2c-to-zero-like-Linux.patch

>From 22506b3c0bb46aef46c6a5b97f3a4bacd3b7c89c Mon Sep 17 00:00:00 2001
From: Tijl Coosemans <tijl@coosemans.org>
Date: Sun, 27 Sep 2020 20:05:50 +0200
Subject: [PATCH 1/6] radeon: default hw_i2c to zero like Linux

I2C support on older cards appears to be broken.  This reverts
https://github.com/FreeBSDDesktop/DEPRECATED-freebsd-base-graphics/commit/eecaad151b81f6ef1809ee274d02bef52460e755
jkim said he no longer needs it:
https://github.com/FreeBSDDesktop/kms-drm/issues/19#issuecomment-376715938

This was part of
https://github.com/FreeBSDDesktop/kms-drm/commit/099f5310bd12ecdc4967053e258cdbad80ab02d8
---
 drivers/gpu/drm/radeon/radeon_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 09fa9675c..3fa7efd00 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -194,7 +194,7 @@ int radeon_connector_table = 0;
 int radeon_tv = 1;
 int radeon_audio = -1;
 int radeon_disp_priority = 0;
-int radeon_hw_i2c = 1;
+int radeon_hw_i2c = 0;
 int radeon_pcie_gen2 = -1;
 int radeon_msi = -1;
 int radeon_lockup_timeout = 10000;
-- 
2.28.0


--MP_/4EJTV+CgOyA6a4/Ci86x5UN
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename=0002-linuxkpi-implement-kernel_fpu_begin-end-for-i386.patch

>From 6721f4805dd66738ad29731dd5a882dea48574fb Mon Sep 17 00:00:00 2001
From: Tijl Coosemans <tijl@coosemans.org>
Date: Sun, 27 Sep 2020 20:30:23 +0200
Subject: [PATCH 2/6] linuxkpi: implement kernel_fpu_begin/end for i386

This was part of
https://github.com/FreeBSDDesktop/kms-drm/commit/099f5310bd12ecdc4967053e258cdbad80ab02d8
---
 linuxkpi/gplv2/include/asm/fpu/api.h | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/linuxkpi/gplv2/include/asm/fpu/api.h b/linuxkpi/gplv2/include/asm/fpu/api.h
index 8af928b23..ca60f6016 100644
--- a/linuxkpi/gplv2/include/asm/fpu/api.h
+++ b/linuxkpi/gplv2/include/asm/fpu/api.h
@@ -2,19 +2,10 @@
 #define _ASM_X86_FPU_API_H
 
 #if defined(__i386__)
-
-/*
- * Allow build on i386. Use of these functions by i915
- * is disabled since CONFIG_AS_MOVNTDQA is amd64 only.
- * Other users are amdgpu, assume no one is using amdgpu
- * driver on 32bit hardware...
- */
-#define	kernel_fpu_begin()
-#define	kernel_fpu_end()
-
+#include <machine/npx.h>
 #else
-
 #include <machine/fpu.h>
+#endif
 
 static struct fpu_kern_ctx *__fpu_ctx;
 
@@ -26,6 +17,5 @@ static struct fpu_kern_ctx *__fpu_ctx;
 #define	kernel_fpu_end()			\
 	fpu_kern_leave(curthread, __fpu_ctx);	\
 	fpu_kern_free_ctx(__fpu_ctx);
-#endif
 
 #endif /* _ASM_X86_FPU_API_H */
-- 
2.28.0


--MP_/4EJTV+CgOyA6a4/Ci86x5UN
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename=0003-drm-AGP-aperture-size-should-be-in-MiB-instead-of-by.patch

>From d9cef5ad20d50cc2dae5e8a804418f6735768077 Mon Sep 17 00:00:00 2001
From: Tijl Coosemans <tijl@coosemans.org>
Date: Wed, 30 Sep 2020 17:35:48 +0200
Subject: [PATCH 3/6] drm: AGP aperture size should be in MiB instead of bytes

Code that uses the AGP aperture size has been made buildable on FreeBSD
by replacing the Linux aper_size with the FreeBSD ai_aperture_size but
the former is in MiB while the latter is in bytes.  Instead of making
more changes to the code, make it unmodified from Linux again and
transform the FreeBSD struct agp_info into a Linux compatible struct
agp_kern_info in drm_agp_init.

This was part of
https://github.com/FreeBSDDesktop/kms-drm/commit/099f5310bd12ecdc4967053e258cdbad80ab02d8
---
 drivers/gpu/drm/drm_agpsupport.c           | 59 +++++++++++++++-------
 drivers/gpu/drm/drm_bufs.c                 |  2 -
 drivers/gpu/drm/drm_os_freebsd.h           |  1 -
 drivers/gpu/drm/drm_pci.c                  |  2 -
 drivers/gpu/drm/radeon/radeon_agp.c        |  3 --
 drivers/gpu/drm/radeon/radeon_drv.c        |  2 -
 include/drm/drm_agpsupport.h               |  4 --
 linuxkpi/dummy/include/linux/agp_backend.h |  0
 linuxkpi/gplv2/include/linux/agp_backend.h | 32 ++++++++++++
 9 files changed, 74 insertions(+), 31 deletions(-)
 delete mode 100644 linuxkpi/dummy/include/linux/agp_backend.h
 create mode 100644 linuxkpi/gplv2/include/linux/agp_backend.h

diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
index 284904a4c..bfb7f53ac 100644
--- a/drivers/gpu/drm/drm_agpsupport.c
+++ b/drivers/gpu/drm/drm_agpsupport.c
@@ -59,22 +59,26 @@
  */
 int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info)
 {
-	DRM_AGP_KERN *kern;
+	struct agp_kern_info *kern;
 
 	if (!dev->agp || !dev->agp->acquired)
 		return -EINVAL;
 
 	kern = &dev->agp->agp_info;
-	agp_get_info(dev->agp->bridge, kern);
-	info->agp_version_major = 1;
-	info->agp_version_minor = 0;
-	info->mode              = kern->ai_mode;
-	info->aperture_base     = kern->ai_aperture_base;
-	info->aperture_size     = kern->ai_aperture_size;
-	info->memory_allowed    = kern->ai_memory_allowed;
-	info->memory_used       = kern->ai_memory_used;
-	info->id_vendor         = kern->ai_devid & 0xffff;
-	info->id_device         = kern->ai_devid >> 16;
+	info->agp_version_major = kern->version.major;
+	info->agp_version_minor = kern->version.minor;
+	info->mode = kern->mode;
+	info->aperture_base = kern->aper_base;
+	info->aperture_size = kern->aper_size * 1024 * 1024;
+	info->memory_allowed = kern->max_memory << PAGE_SHIFT;
+	info->memory_used = kern->current_memory << PAGE_SHIFT;
+#ifdef __linux__
+	info->id_vendor = kern->device->vendor;
+	info->id_device = kern->device->device;
+#else
+	info->id_vendor = kern->vendor;
+	info->id_device = kern->device;
+#endif
 
 	return 0;
 }
@@ -418,15 +422,37 @@ int drm_agp_free_ioctl(struct drm_device *dev, void *data,
  */
 struct drm_agp_head *drm_agp_init(struct drm_device *dev)
 {
+#ifdef __FreeBSD__
+	struct agp_info agp_info;
+#endif
 	struct drm_agp_head *head = NULL;
 
 	head = kzalloc(sizeof(*head), GFP_KERNEL);
 	if (!head)
 		return NULL;
 
+#ifdef __FreeBSD__
 	head->bridge = agp_find_device();
 	if (!head->bridge) {
-#ifdef __linux__
+		kfree(head);
+		return NULL;
+	} else {
+		agp_get_info(head->bridge, &agp_info);
+		head->agp_info.version.major = 1;
+		head->agp_info.version.minor = 0;
+		head->agp_info.vendor = agp_info.ai_devid & 0xffff;
+		head->agp_info.device = agp_info.ai_devid >> 16;
+		head->agp_info.mode = agp_info.ai_mode;
+		head->agp_info.aper_base = agp_info.ai_aperture_base;
+		head->agp_info.aper_size = agp_info.ai_aperture_size >> 20;
+		head->agp_info.max_memory = agp_info.ai_memory_allowed >> PAGE_SHIFT;
+		head->agp_info.current_memory = agp_info.ai_memory_used >> PAGE_SHIFT;
+		head->agp_info.cant_use_aperture = 0;
+		head->agp_info.page_mask = ~0UL;
+	}
+#else
+	head->bridge = agp_find_bridge(dev->pdev);
+	if (!head->bridge) {
 		head->bridge = agp_backend_acquire(dev->pdev);
 		if (!head->bridge) {
 			kfree(head);
@@ -438,15 +464,14 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
 		agp_copy_info(head->bridge, &head->agp_info);
 	}
 	if (head->agp_info.chipset == NOT_SUPPORTED) {
-#endif
 		kfree(head);
 		return NULL;
-	} else {
-		agp_get_info(head->bridge, &head->agp_info);
 	}
+#endif
 	INIT_LIST_HEAD(&head->memory);
-	head->cant_use_aperture = 0;
-	head->base = head->agp_info.ai_aperture_base;
+	head->cant_use_aperture = head->agp_info.cant_use_aperture;
+	head->page_mask = head->agp_info.page_mask;
+	head->base = head->agp_info.aper_base;
 	return head;
 }
 
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 3e4a08e5d..443f98b97 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -73,8 +73,6 @@
 #endif
 
 #include "drm_legacy.h"
-#define aper_size ai_aperture_size
-
 
 static struct drm_map_list *drm_find_matching_map(struct drm_device *dev,
 						  struct drm_local_map *map)
diff --git a/drivers/gpu/drm/drm_os_freebsd.h b/drivers/gpu/drm/drm_os_freebsd.h
index 6350f6944..c947b9442 100644
--- a/drivers/gpu/drm/drm_os_freebsd.h
+++ b/drivers/gpu/drm/drm_os_freebsd.h
@@ -97,7 +97,6 @@ do {								\
 #define	KTR_DRM		KTR_DEV
 #define	KTR_DRM_REG	KTR_SPARE3
 
-#define	DRM_AGP_KERN	struct agp_info
 #define	DRM_AGP_MEM	void
 
 #define	get_unaligned(ptr)                                              \
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 11b863206..d01181d29 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -39,8 +39,6 @@
 
 #ifdef __FreeBSD__
 #include <asm/mtrr.h>	/* Needed for arch_phys_wc_* */
-#define aper_base ai_aperture_base
-#define aper_size ai_aperture_size
 
 static void
 drm_pci_busdma_callback(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
diff --git a/drivers/gpu/drm/radeon/radeon_agp.c b/drivers/gpu/drm/radeon/radeon_agp.c
index ac8109186..4de16f3ba 100644
--- a/drivers/gpu/drm/radeon/radeon_agp.c
+++ b/drivers/gpu/drm/radeon/radeon_agp.c
@@ -30,9 +30,6 @@
 #include <drm/drm_pci.h>
 #include <drm/radeon_drm.h>
 
-#define aper_base ai_aperture_base
-#define aper_size ai_aperture_size
-
 #include "radeon.h"
 
 #if IS_ENABLED(CONFIG_AGP)
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 3fa7efd00..0ad6e0aa4 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -59,8 +59,6 @@ SYSCTL_NODE(_hw, OID_AUTO, radeonkms,
 
 
 #include <asm/mtrr.h>	/* Needed for arch_phys_wc_* */
-#define aper_base ai_aperture_base
-#define aper_size ai_aperture_size
 #endif
 
 /*
diff --git a/include/drm/drm_agpsupport.h b/include/drm/drm_agpsupport.h
index 0d4caaee3..8f5bbd7c9 100644
--- a/include/drm/drm_agpsupport.h
+++ b/include/drm/drm_agpsupport.h
@@ -19,11 +19,7 @@ struct drm_device;
 struct drm_file;
 
 struct drm_agp_head {
-#ifdef __linux__
 	struct agp_kern_info agp_info;
-#elif defined(__FreeBSD__)
-	DRM_AGP_KERN agp_info;
-#endif
 	struct list_head memory;
 	unsigned long mode;
 #ifdef __linux__
diff --git a/linuxkpi/dummy/include/linux/agp_backend.h b/linuxkpi/dummy/include/linux/agp_backend.h
deleted file mode 100644
index e69de29bb..000000000
diff --git a/linuxkpi/gplv2/include/linux/agp_backend.h b/linuxkpi/gplv2/include/linux/agp_backend.h
new file mode 100644
index 000000000..3ece372a0
--- /dev/null
+++ b/linuxkpi/gplv2/include/linux/agp_backend.h
@@ -0,0 +1,32 @@
+#ifndef _LINUX_GPLV2_AGP_BACKEND_H_
+#define	_LINUX_GPLV2_AGP_BACKEND_H_
+
+#include <linux/types.h>
+
+struct agp_version {
+	u16 major;
+	u16 minor;
+};
+
+struct agp_kern_info {
+	struct agp_version version;
+#ifdef __linux__
+	struct pci_dev *device;
+	enum chipset_type chipset;
+#else
+	u16 vendor;
+	u16 device;
+#endif
+	unsigned long mode;
+	unsigned long aper_base;
+	size_t aper_size;
+	int max_memory;		/* In pages */
+	int current_memory;
+	bool cant_use_aperture;
+	unsigned long page_mask;
+#ifdef __linux__
+	const struct vm_operations_struct *vm_ops;
+#endif
+};
+
+#endif /* _LINUX_GPLV2_AGP_BACKEND_H_ */
-- 
2.28.0


--MP_/4EJTV+CgOyA6a4/Ci86x5UN
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename=0004-drm-Register-the-AGP-aperture-address-range-with-the.patch

>From 823b326ae146f25309cfd275e89ac18d6c65f2d3 Mon Sep 17 00:00:00 2001
From: Tijl Coosemans <tijl@coosemans.org>
Date: Sat, 3 Oct 2020 11:59:55 +0200
Subject: [PATCH 4/6] drm: Register the AGP aperture address range with the VM
 subsystem

The AGP device provides a range of (physical) addresses that can be mapped
to real physical memory.  The GPU uses this as a primitive virtual address
space.  When the CPU wants to map a page that has been mapped by the AGP
device it should use the AGP address instead of the real physical address
so GPU accesses trigger CPU cache flushes.  On FreeBSD such fictitious
physical addresses have to be registered to allow them to be mapped.

This was taken from drm-legacy.

This was part of:
https://github.com/FreeBSDDesktop/kms-drm/commit/099f5310bd12ecdc4967053e258cdbad80ab02d8
---
 drivers/gpu/drm/drm_pci.c           | 14 ++++++++++++++
 drivers/gpu/drm/radeon/radeon_drv.c | 19 ++++++++++++++++++-
 drivers/gpu/drm/radeon/radeon_kms.c | 10 ++++++++++
 3 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index d01181d29..d39d852af 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -38,6 +38,7 @@
 
 
 #ifdef __FreeBSD__
+#include <vm/vm_phys.h>
 #include <asm/mtrr.h>	/* Needed for arch_phys_wc_* */
 
 static void
@@ -271,6 +272,13 @@ static void drm_pci_agp_init(struct drm_device *dev)
 		if (pci_find_capability(dev->pdev, PCI_CAP_ID_AGP))
 			dev->agp = drm_agp_init(dev);
 		if (dev->agp) {
+#ifdef __FreeBSD__
+			vm_phys_fictitious_reg_range(
+				dev->agp->agp_info.aper_base,
+				dev->agp->agp_info.aper_base +
+				dev->agp->agp_info.aper_size * 1024 * 1024,
+				VM_MEMATTR_WRITE_COMBINING);
+#endif
 			dev->agp->agp_mtrr = arch_phys_wc_add(
 				dev->agp->agp_info.aper_base,
 				dev->agp->agp_info.aper_size *
@@ -283,6 +291,12 @@ void drm_pci_agp_destroy(struct drm_device *dev)
 {
 	if (dev->agp) {
 		arch_phys_wc_del(dev->agp->agp_mtrr);
+#ifdef __FreeBSD__
+		vm_phys_fictitious_unreg_range(
+			dev->agp->agp_info.aper_base,
+			dev->agp->agp_info.aper_base +
+			dev->agp->agp_info.aper_size * 1024 * 1024);
+#endif
 		drm_legacy_agp_clear(dev);
 		kfree(dev->agp);
 		dev->agp = NULL;
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 0ad6e0aa4..a4d1f85e3 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -57,7 +57,7 @@ SYSCTL_NODE(_hw, OID_AUTO, radeonkms,
     CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
     DRIVER_DESC " parameters");
 
-
+#include <vm/vm_phys.h>
 #include <asm/mtrr.h>	/* Needed for arch_phys_wc_* */
 #endif
 
@@ -389,6 +389,13 @@ static int radeon_pci_probe(struct pci_dev *pdev,
 	if (pci_find_capability(dev->pdev, PCI_CAP_ID_AGP))
 		dev->agp = drm_agp_init(dev);
 	if (dev->agp) {
+#ifdef __FreeBSD__
+		vm_phys_fictitious_reg_range(
+			dev->agp->agp_info.aper_base,
+			dev->agp->agp_info.aper_base +
+			dev->agp->agp_info.aper_size * 1024 * 1024,
+			VM_MEMATTR_WRITE_COMBINING);
+#endif
 		dev->agp->agp_mtrr = arch_phys_wc_add(
 			dev->agp->agp_info.aper_base,
 			dev->agp->agp_info.aper_size *
@@ -403,7 +410,17 @@ static int radeon_pci_probe(struct pci_dev *pdev,
 
 err_agp:
 	if (dev->agp)
+#ifdef __FreeBSD__
+	{
+#endif
 		arch_phys_wc_del(dev->agp->agp_mtrr);
+#ifdef __FreeBSD__
+		vm_phys_fictitious_unreg_range(
+			dev->agp->agp_info.aper_base,
+			dev->agp->agp_info.aper_base +
+			dev->agp->agp_info.aper_size * 1024 * 1024);
+	}
+#endif
 	kfree(dev->agp);
 	pci_disable_device(pdev);
 err_free:
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 709c4ef5e..768b138db 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -79,7 +79,17 @@ void radeon_driver_unload_kms(struct drm_device *dev)
 	radeon_device_fini(rdev);
 
 	if (dev->agp)
+#ifdef __FreeBSD__
+	{
+#endif
 		arch_phys_wc_del(dev->agp->agp_mtrr);
+#ifdef __FreeBSD__
+		vm_phys_fictitious_unreg_range(
+			dev->agp->agp_info.aper_base,
+			dev->agp->agp_info.aper_base +
+			dev->agp->agp_info.aper_size * 1024 * 1024);
+	}
+#endif
 	kfree(dev->agp);
 	dev->agp = NULL;
 
-- 
2.28.0


--MP_/4EJTV+CgOyA6a4/Ci86x5UN
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename=0005-linuxkpi-Mute-unimplemented-warnings.patch

>From 813a1f4f4f365ff7bc790d358aa941fcb6fcc1a7 Mon Sep 17 00:00:00 2001
From: Johannes Lundberg <johalun0@gmail.com>
Date: Wed, 13 Feb 2019 18:40:24 +0000
Subject: [PATCH 5/6] linuxkpi: Mute unimplemented warnings

This was
https://github.com/FreeBSDDesktop/kms-drm/commit/7f7f973eccff8fd7d8255211f1b30c05a95bc85f
---
 linuxkpi/gplv2/include/linux/compiler.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linuxkpi/gplv2/include/linux/compiler.h b/linuxkpi/gplv2/include/linux/compiler.h
index 4cef5c52d..e8d76cfde 100644
--- a/linuxkpi/gplv2/include/linux/compiler.h
+++ b/linuxkpi/gplv2/include/linux/compiler.h
@@ -13,7 +13,7 @@
 #define	outl(a,b) outl(b,a)
 
 #ifndef PRINT_UNIMPLEMENTED
-#define PRINT_UNIMPLEMENTED 1
+#define PRINT_UNIMPLEMENTED 0
 #endif
 
 #define	UNIMPLEMENTED_ONCE() do {		\
-- 
2.28.0


--MP_/4EJTV+CgOyA6a4/Ci86x5UN
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename=0006-linuxkpi-Allow-recursive-calls-to-i2c_transfer.patch

>From c72d079b998b5da5ac6728cbf98e98d84376305f Mon Sep 17 00:00:00 2001
From: Johannes Lundberg <johalun0@gmail.com>
Date: Sat, 2 Mar 2019 18:40:50 +0000
Subject: [PATCH 6/6] linuxkpi: Allow recursive calls to i2c_transfer

Fixes https://github.com/FreeBSDDesktop/kms-drm/issues/134

This was
https://github.com/FreeBSDDesktop/kms-drm/commit/78e51d0a8042d1bd2f5f6c0d70542e97269daa5d
---
 linuxkpi/gplv2/include/linux/i2c.h |  5 ++---
 linuxkpi/gplv2/src/linux_i2c.c     | 12 ++++++++++++
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/linuxkpi/gplv2/include/linux/i2c.h b/linuxkpi/gplv2/include/linux/i2c.h
index a31addc16..9bd398075 100644
--- a/linuxkpi/gplv2/include/linux/i2c.h
+++ b/linuxkpi/gplv2/include/linux/i2c.h
@@ -225,11 +225,10 @@ extern int i2c_register_driver(struct module *, struct i2c_driver *);
 extern void i2c_del_driver(struct i2c_driver *);
 
 
+extern int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
+                        int num);
 extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
                         int num);
-// XXX: locked or unlocked, does it matter since we have our own lock
-// and don't lock with provided lock_bus function?
-#define	__i2c_transfer(a, m, n)	i2c_transfer(a, m, n)
 
 static inline void
 i2c_unregister_device(struct i2c_client *client)
diff --git a/linuxkpi/gplv2/src/linux_i2c.c b/linuxkpi/gplv2/src/linux_i2c.c
index ea0cb3634..a0d281d1c 100644
--- a/linuxkpi/gplv2/src/linux_i2c.c
+++ b/linuxkpi/gplv2/src/linux_i2c.c
@@ -564,6 +564,18 @@ linux_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 	return (rc);
 }
 
+int
+__i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
+{
+	int rc;
+
+	if (adap->algo->master_xfer == NULL)
+		return (-EOPNOTSUPP);
+
+	rc = linux_i2c_transfer(adap, msgs, num);
+	return (rc);
+}
+
 int
 i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 {
-- 
2.28.0


--MP_/4EJTV+CgOyA6a4/Ci86x5UN--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20201004162857.7980a25d>