1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
From abd56ce8511012a39025b2cca7dd46af898fed43 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian@centricular.com>
Date: Tue, 10 Sep 2024 10:28:52 +0300
Subject: [PATCH] linux_driver: Fix build with kernel 6.10 and newer
circ_buf is not used anymore for serial IO and is replaced by kfifo.
---
driver/linux/buildenv.h | 4 ++++
driver/linux/ntv2serial.c | 20 ++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/driver/linux/buildenv.h b/driver/linux/buildenv.h
index 053bd695f..81ae2c7bb 100644
--- a/driver/linux/buildenv.h
+++ b/driver/linux/buildenv.h
@@ -19,6 +19,10 @@
#include <linux/version.h>
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,10,0))
+ #define KERNEL_6_10_0_SERIAL_KFIFO
+#endif
+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,5,0))
#define KERNEL_6_5_0_GET_USER_PAGES
#endif
diff --git a/driver/linux/ntv2serial.c b/driver/linux/ntv2serial.c
index b2f5d577a..85788a5cf 100644
--- a/driver/linux/ntv2serial.c
+++ b/driver/linux/ntv2serial.c
@@ -571,7 +571,11 @@ static bool ntv2_serial_receive(struct ntv2_serial *ntv2_ser)
static bool ntv2_serial_transmit(struct ntv2_serial *ntv2_ser)
{
struct uart_port *port = &ntv2_ser->uart_port;
+#if defined(KERNEL_6_10_0_SERIAL_KFIFO)
+ struct tty_port *tport = &port->state->port;
+#else
struct circ_buf *xmit = &port->state->xmit;
+#endif
u32 full = ntv2_kona_fld_serial_tx_full;
u32 status;
@@ -588,6 +592,21 @@ static bool ntv2_serial_transmit(struct ntv2_serial *ntv2_ser)
return true;
}
+#if defined(KERNEL_6_10_0_SERIAL_KFIFO)
+ if (uart_tx_stopped(port))
+ return false;
+
+ /* tx data */
+ u8 ch = kfifo_get(&tport->xmit_fifo, &ch);
+ NTV2_MSG_SERIAL_STREAM("%s: uart tx %02x\n", ntv2_ser->name, ch);
+ ntv2WriteRegister32(ntv2_ser->uart_reg + ntv2_kona_reg_serial_tx, (u32)ch);
+ kfifo_skip_count(&tport->xmit_fifo, 1);
+ port->icount.tx++;
+
+ /* wake up */
+ if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
+ uart_write_wakeup(port);
+#else
if (uart_circ_empty(xmit) || uart_tx_stopped(port))
return false;
@@ -600,6 +619,7 @@ static bool ntv2_serial_transmit(struct ntv2_serial *ntv2_ser)
/* wake up */
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
uart_write_wakeup(port);
+#endif
return true;
}
|