git: 600f16129510 - main - linuxkpi: Add non-atomic readq()/writeq()

From: Felix Palmen <zirias_at_FreeBSD.org>
Date: Fri, 09 Sep 2022 15:00:28 UTC
The branch main has been updated by zirias (ports committer):

URL: https://cgit.FreeBSD.org/src/commit/?id=600f161295107d4d26f9a0551fc8160ee9dd0dd5

commit 600f161295107d4d26f9a0551fc8160ee9dd0dd5
Author:     Felix Palmen <zirias@FreeBSD.org>
AuthorDate: 2022-09-09 14:01:22 +0000
Commit:     Felix Palmen <zirias@FreeBSD.org>
CommitDate: 2022-09-09 14:59:41 +0000

    linuxkpi: Add non-atomic readq()/writeq()
    
    The non-atomic versions are required by drm-510-kmod to build on 32-bit
    architectures.
    
    Approved by:            hselasky, manu, tcberner (mentor)
    Differential Revision:  https://reviews.freebsd.org/D36507
---
 .../common/include/linux/io-64-nonatomic-lo-hi.h   | 65 ++++++++++++++++++++++
 .../dummy/include/linux/io-64-nonatomic-lo-hi.h    |  0
 2 files changed, 65 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/io-64-nonatomic-lo-hi.h b/sys/compat/linuxkpi/common/include/linux/io-64-nonatomic-lo-hi.h
new file mode 100644
index 000000000000..c9cf0befec79
--- /dev/null
+++ b/sys/compat/linuxkpi/common/include/linux/io-64-nonatomic-lo-hi.h
@@ -0,0 +1,65 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2022 Felix Palmen
+ *
+ * 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 AUTHOR 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 AUTHOR 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.
+ */
+#ifndef	_LINUXKPI_LINUX_IO_64_NONATOMIC_LO_HI_H_
+#define	_LINUXKPI_LINUX_IO_64_NONATOMIC_LO_HI_H_
+
+#include <linux/io.h>
+
+static inline uint64_t
+lo_hi_readq(const volatile void *addr)
+{
+	const volatile uint32_t *p = addr;
+	uint32_t l, h;
+
+	__io_br();
+	l = le32toh(__raw_readl(p));
+	h = le32toh(__raw_readl(p + 1));
+	__io_ar();
+
+	return (l + ((uint64_t)h << 32));
+}
+
+static inline void
+lo_hi_writeq(uint64_t v, volatile void *addr)
+{
+	volatile uint32_t *p = addr;
+
+	__io_bw();
+	__raw_writel(htole32(v), p);
+	__raw_writel(htole32(v >> 32), p + 1);
+	__io_aw();
+}
+
+#ifndef readq
+#define readq(addr)	lo_hi_readq(addr)
+#endif
+
+#ifndef writeq
+#define writeq(v, addr)	lo_hi_writeq(v, addr)
+#endif
+
+#endif	/* _LINUXKPI_LINUX_IO_64_NONATOMIC_LO_HI_H_ */
diff --git a/sys/compat/linuxkpi/dummy/include/linux/io-64-nonatomic-lo-hi.h b/sys/compat/linuxkpi/dummy/include/linux/io-64-nonatomic-lo-hi.h
deleted file mode 100644
index e69de29bb2d1..000000000000