Bug 247775

Summary: linuxkpi: drm-devel-kmod fails to build
Product: Base System Reporter: Piotr Kubaj <pkubaj>
Component: miscAssignee: Hans Petter Selasky <hselasky>
Status: Closed FIXED    
Severity: Affects Only Me CC: hselasky, lwhsu, powerpc
Priority: --- Keywords: patch
Version: CURRENT   
Hardware: powerpc   
OS: Any   

Description Piotr Kubaj freebsd_committer freebsd_triage 2020-07-05 12:54:59 UTC
On powerpc64:
cc  -O2 -pipe -fno-strict-aliasing '-DKBUILD_MODNAME="drm"' '-DLINUXKPI_PARAM_PREFIX=drm_' -DDRM_SYSCTL_PARAM_PREFIX=_dri -DLINUXKPI_VERSION=50000 -DCONFIG_DRM_AMDGPU_CIK -DCONFIG_DRM_AMDGPU_SI -DCONFIG_DRM_AMD_DC -DCONFIG_DRM_AMD_DC_FBC -DCONFIG_DRM_AMD_POWERPLAY -DCONFIG_DRM_I915_ALPHA_SUPPORT -DCONFIG_DRM_I915_FORCE_PROBE='"*"' -DCONFIG_DRM_I915_CAPTURE_ERROR -DCONFIG_DRM_I915_SPIN_REQUEST=5 -DCONFIG_DRM_I915_USERFAULT_AUTOSUSPEND=250 -DCONFIG_DRM_LOAD_EDID_FIRMWARE -DCONFIG_DRM_MIPI_DSI -DCONFIG_DRM_PANEL_ORIENTATION_QUIRKS -DCONFIG_DRM_VMWGFX_FBCON -DCONFIG_DRM_FBDEV_EMULATION -DCONFIG_DRM_FBDEV_OVERALLOC=100 -DCONFIG_DRM_LEGACY -DCONFIG_DRM_VM -DCONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG -DCONFIG_BACKLIGHT_CLASS_DEVICE -DCONFIG_DMI -DCONFIG_FB -DCONFIG_MTRR -DCONFIG_PCI -DCONFIG_PM -DCONFIG_SMP  -Werror -D_KERNEL -DKLD_MODULE -nostdinc  -I/tmp/usr/ports/graphics/drm-devel-kmod/work/drm-kmod-drm_v5.3_1/linuxkpi/gplv2/include -I/usr/src/sys/compat/linuxkpi/common/include -I/tmp/usr/ports/graphics/drm-devel-kmod/work/drm-kmod-drm_v5.3_1/linuxkpi/dummy/include -I/tmp/usr/ports/graphics/drm-devel-kmod/work/drm-kmod-drm_v5.3_1/drivers/gpu/drm -I/tmp/usr/ports/graphics/drm-devel-kmod/work/drm-kmod-drm_v5.3_1/include -I/tmp/usr/ports/graphics/drm-devel-kmod/work/drm-kmod-drm_v5.3_1/include/drm -I/tmp/usr/ports/graphics/drm-devel-kmod/work/drm-kmod-drm_v5.3_1/include/uapi -I/tmp/usr/ports/graphics/drm-devel-kmod/work/drm-kmod-drm_v5.3_1/drivers/gpu -include /tmp/usr/ports/graphics/drm-devel-kmod/work/drm-kmod-drm_v5.3_1/drm/opt_global.h -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fPIC -mlongcall -fno-omit-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/powerpc/include     -MD  -MF.depend.drm_print.o -MTdrm_print.o -mno-altivec -msoft-float -mabi=elfv2 -ffreestanding -fwrapv -fstack-protector -Wno-cast-qual -Wno-pointer-arith -Wno-pointer-sign -Wno-format -Wno-expansion-to-defined -Wno-format-zero-length     -std=iso9899:1999 -c /tmp/usr/ports/graphics/drm-devel-kmod/work/drm-kmod-drm_v5.3_1/drivers/gpu/drm/drm_print.c -o drm_print.o
In file included from /tmp/usr/ports/graphics/drm-devel-kmod/work/drm-kmod-drm_v5.3_1/drivers/gpu/drm/drm_print.c:34:
In file included from /tmp/usr/ports/graphics/drm-devel-kmod/work/drm-kmod-drm_v5.3_1/linuxkpi/gplv2/include/linux/io.h:4:
In file included from /usr/src/sys/compat/linuxkpi/common/include/linux/io.h:34:
In file included from ./machine/vm.h:34:
In file included from ./machine/pte.h:210:
./machine/tlb.h:176:15: error: unknown type name 'uintptr_t'
void tlb_lock(uintptr_t *);
              ^
./machine/tlb.h:177:17: error: unknown type name 'uintptr_t'
void tlb_unlock(uintptr_t *);
                ^
./machine/tlb.h:179:21: error: a parameter list without types is only allowed in a function definition
int  tlb1_set_entry(vm_offset_t, vm_paddr_t, vm_size_t, uint32_t);
                    ^
In file included from /tmp/usr/ports/graphics/drm-devel-kmod/work/drm-kmod-drm_v5.3_1/drivers/gpu/drm/drm_print.c:34:
In file included from /tmp/usr/ports/graphics/drm-devel-kmod/work/drm-kmod-drm_v5.3_1/linuxkpi/gplv2/include/linux/io.h:4:
In file included from /usr/src/sys/compat/linuxkpi/common/include/linux/io.h:34:
In file included from ./machine/vm.h:34:
./machine/pte.h:227:9: error: unknown type name 'uint64_t'
typedef uint64_t pte_t;
        ^


sys/types.h should be before machine/vm.h. The following patch fixes drm-devel-kmod and should have no negative effects:
Index: /usr/src/sys/compat/linuxkpi/common/include/linux/io.h
===================================================================
--- /usr/src/sys/compat/linuxkpi/common/include/linux/io.h      (revision 362914)
+++ /usr/src/sys/compat/linuxkpi/common/include/linux/io.h      (working copy)
@@ -31,9 +31,9 @@
 #ifndef        _LINUX_IO_H_
 #define        _LINUX_IO_H_

+#include <sys/types.h>
 #include <machine/vm.h>
 #include <sys/endian.h>
-#include <sys/types.h>

 #include <linux/compiler.h>
 #include <linux/types.h>
Comment 1 Hans Petter Selasky freebsd_committer freebsd_triage 2020-07-05 19:39:23 UTC
Committed with some modifications.

Thank you!

--HPS
Comment 2 commit-hook freebsd_committer freebsd_triage 2020-07-05 19:39:24 UTC
A commit references this bug:

Author: hselasky
Date: Sun Jul  5 19:38:36 UTC 2020
New revision: 362946
URL: https://svnweb.freebsd.org/changeset/base/362946

Log:
  Fix include file order in io.h in the LinuxKPI.
  Make sure sys/types.h is included before machine/vm.h.

  PR:		247775
  Submitted by:	pkubaj@
  MFC after:	1 week
  Sponsored by:	Mellanox Technologies

Changes:
  head/sys/compat/linuxkpi/common/include/linux/io.h
Comment 3 commit-hook freebsd_committer freebsd_triage 2020-07-13 15:28:45 UTC
A commit references this bug:

Author: hselasky
Date: Mon Jul 13 15:28:06 UTC 2020
New revision: 363148
URL: https://svnweb.freebsd.org/changeset/base/363148

Log:
  MFC r362946:
  Fix include file order in io.h in the LinuxKPI.
  Make sure sys/types.h is included before machine/vm.h.

  PR:		247775
  Submitted by:	pkubaj@
  Sponsored by:	Mellanox Technologies

Changes:
_U  stable/12/
  stable/12/sys/compat/linuxkpi/common/include/linux/io.h
Comment 4 commit-hook freebsd_committer freebsd_triage 2020-07-13 15:29:47 UTC
A commit references this bug:

Author: hselasky
Date: Mon Jul 13 15:29:11 UTC 2020
New revision: 363149
URL: https://svnweb.freebsd.org/changeset/base/363149

Log:
  MFC r362946:
  Fix include file order in io.h in the LinuxKPI.
  Make sure sys/types.h is included before machine/vm.h.

  PR:		247775
  Submitted by:	pkubaj@
  Sponsored by:	Mellanox Technologies

Changes:
_U  stable/11/
  stable/11/sys/compat/linuxkpi/common/include/linux/io.h