Commit Graph

17 Commits

Author SHA1 Message Date
Hans Petter Selasky
4d83500fda Use DEVICE memory instead of UNCACHEABLE on aarch64 in ioremap() in the LinuxKPI.
This fixes system hangs on reading device registers on aarch64.

Tested with:	Marvell MACCHIATObin (Armada8k) + mlx4en, amdgpu
Submitted by:	Greg V <greg@unrelenting.technology>
Differential Revision:	https://reviews.freebsd.org/D20789
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2019-09-02 08:34:45 +00:00
Justin Hibbits
937a05ba81 Add necessary bits for Linux KPI to work correctly on powerpc
PowerPC, and possibly other architectures, use different address ranges for
PCI space vs physical address space, which is only mapped at resource
activation time, when the BAR gets written.  The DRM kernel modules do not
activate the rman resources, soas not to waste KVA, instead only mapping
parts of the PCI memory at a time.  This introduces a
BUS_TRANSLATE_RESOURCE() method, implemented in the Open Firmware/FDT PCI
driver, to perform this necessary translation without activating the
resource.

In addition to system KPI changes, LinuxKPI is updated to handle a
big-endian host, by adding proper endian swaps to the I/O functions.

Submitted by:	mmacy
Reported by:	hselasky
Differential Revision:	https://reviews.freebsd.org/D21096
2019-08-04 19:28:10 +00:00
Ed Maste
ff9be73ee3 Enable ioremap for aarch64 in the LinuxKPI
Required for Mellanox drivers (e.g. on Ampere eMAG at Packet.com).

PR:		237055
Submitted by:	Greg V <greg@unrelenting.technology>
Reviewed by:	hselasky
Differential Revision:	https://reviews.freebsd.org/D19987
2019-04-20 15:57:05 +00:00
Tijl Coosemans
642909fdfb Define linuxkpi readq for 64-bit architectures. It is used by drm-kmod.
Currently the compiler picks up the definition in machine/cpufunc.h.

Add compiler memory barriers to read* and write*.  The Linux x86
implementation of these functions uses inline asm with "memory" clobber.
The Linux x86 implementation of read_relaxed* and write_relaxed* uses the
same inline asm without "memory" clobber.

Implement ioread* and iowrite* in terms of read* and write* so they also
have memory barriers.

Qualify the addr parameter in write* as volatile.

Like Linux, define macros with the same name as the inline functions.

Only define 64-bit versions on 64-bit architectures because generally
32-bit architectures can't do atomic 64-bit loads and stores.

Regroup the functions a bit and add brief comments explaining what they do:
- __raw_read*, __raw_write*: atomic, no barriers, no byte swapping
- read_relaxed*, write_relaxed*: atomic, no barriers, little-endian
- read*, write*: atomic, with barriers, little-endian

Add a comment that says our implementation of ioread* and iowrite*
only handles MMIO and does not support port IO.

Reviewed by:	hselasky
MFC after:	3 days
2018-10-22 20:55:35 +00:00
Ed Maste
8363051739 linuxkpi whitespace cleanup
Reviewed by:	hselasky, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D14807
2018-03-23 15:50:01 +00:00
Hans Petter Selasky
6c51dfb060 Implement writel_relaxed() in the LinuxKPI.
MFC after:	1 week
Submitted by:	Johannes Lundberg <johalun0@gmail.com>
Sponsored by:	Mellanox Technologies
Sponsored by:	Limelight Networks
2018-03-04 18:17:54 +00:00
Hans Petter Selasky
62d08fae13 Implement ioread16be() in the LinuxKPI.
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2017-11-01 12:34:18 +00:00
Justin Hibbits
864092bcaa Remove ARM and MIPS from linuxkpi ioremap_attr definition
ARM and MIPS fail universe builds.

ARM and MIPS are missing the following:
* VM_MEMATTR_WRITE_THROUGH
* VM_MEMATTR_WRITE_COMBINING

Pointy-hat to:	jhibbits
2017-06-08 02:44:34 +00:00
Justin Hibbits
287e7a861a Add more #ifdef arch checks to the linuxkpi
arm, mips, and powerpc all implement pmap_mapdev_attr() and pmap_unmapdev(),
so add those archs to the checks.  powerpc also includes the atomic_swap_*()
functions, so add that to the supported list as well.  Not tested except by
compiling powerpc.

Reviewed by:	markj
2017-06-07 18:08:11 +00:00
Mark Johnston
cb564d2436 Add some miscellaneous definitions to support DRM drivers.
Reviewed by:	hselasky
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D10985
2017-05-30 17:16:08 +00:00
Kevin Lo
8636496407 Add __iowrite32_copy() to the Linux kernel compatibility layer.
Reviewed by:	hselasky
2016-05-24 09:23:04 +00:00
Hans Petter Selasky
94a201be43 Implement "_outb()" to the LinuxKPI for i386 and amd64 only.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-23 11:53:00 +00:00
Hans Petter Selasky
f2dbb750f4 Implement ioremap_wt() and use that in the MEMREMAP_WT case for i386
and amd64.

Suggested by:	cem @
Discussed with:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-10 17:51:17 +00:00
Hans Petter Selasky
684a5fef01 Add more LinuxKPI I/O functions.
Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2016-05-10 12:04:57 +00:00
Hans Petter Selasky
86845417d1 Build fixes:
- Add some missing I/O functions for non-i386 and amd64 platforms.
- Stub ioremap() to NULL using a macro to ensure non-existing memory
  attributes are not referred when they do not exist.
- Add more header files to linux/list.h to resolve driver compilation
  issues on Sparc64 and PowerPC platforms.

Sponsored by:	Mellanox Technologies
2015-11-12 09:18:22 +00:00
Hans Petter Selasky
8e7baabc9f Make all the LinuxKPI include files compile standalone.
Sponsored by:	Mellanox Technologies
2015-11-03 12:37:55 +00:00
Hans Petter Selasky
8d59ecb214 Finish process of moving the LinuxKPI module into the default kernel build.
- Move all files related to the LinuxKPI into sys/compat/linuxkpi and
  its subfolders.
- Update sys/conf/files and some Makefiles to use new file locations.
- Added description of COMPAT_LINUXKPI to sys/conf/NOTES which in turn
  adds the LinuxKPI to all LINT builds.
- The LinuxKPI can be added to the kernel by setting the
  COMPAT_LINUXKPI option. The OFED kernel option no longer builds the
  LinuxKPI into the kernel. This was done to keep the build rules for
  the LinuxKPI in sys/conf/files simple.
- Extend the LinuxKPI module to include support for USB by moving the
  Linux USB compat from usb.ko to linuxkpi.ko.
- Bump the FreeBSD_version.
- A universe kernel build has been done.

Reviewed by:	np @ (cxgb and cxgbe related changes only)
Sponsored by:	Mellanox Technologies
2015-10-29 08:28:39 +00:00