Skip to content

Commit 2bf95a9

Browse files
ij-intelgregkh
authored andcommitted
serial: 8250: Fix 8250_rsa symbol loop
Depmod fails for a kernel made with: make allnoconfig echo -e "CONFIG_MODULES=y\nCONFIG_SERIAL_8250=m\nCONFIG_SERIAL_8250_EXTENDED=y\nCONFIG_SERIAL_8250_RSA=y" >> .config make olddefconfig ...due to a dependency loop: depmod: ERROR: Cycle detected: 8250 -> 8250_base -> 8250 depmod: ERROR: Found 2 modules in dependency cycles! This is caused by the move of 8250 RSA code from 8250_port.c (in 8250_base.ko) into 8250_rsa.c (in 8250.ko) by the commit 5a128fb ("serial: 8250: move RSA functions to 8250_rsa.c"). The commit b20d657 ("serial: 8250: export RSA functions") tried to fix a missing symbol issue with EXPORTs but those then cause this dependency cycle. Break dependency loop by moving 8250_rsa.o from 8250.ko to 8250_base.ko and by passing univ8250_port_base_ops to univ8250_rsa_support() that can make a local copy of it. Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Reported-by: Alex Davis <alex47794@gmail.com> Fixes: 5a128fb ("serial: 8250: move RSA functions to 8250_rsa.c") Fixes: b20d657 ("serial: 8250: export RSA functions") Cc: stable <stable@kernel.org> Link: https://lore.kernel.org/all/87frc3sd8d.fsf@posteo.net/ Link: https://lore.kernel.org/all/CADiockCvM6v+d+UoFZpJSMoLAdpy99_h-hJdzUsdfaWGn3W7-g@mail.gmail.com/ Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Jiri Slaby <jirislaby@kernel.org> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://patch.msgid.link/20251110105043.4062-1-ilpo.jarvinen@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent eb4917f commit 2bf95a9

4 files changed

Lines changed: 21 additions & 13 deletions

File tree

drivers/tty/serial/8250/8250.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,13 @@ static inline void serial8250_pnp_exit(void) { }
322322
#endif
323323

324324
#ifdef CONFIG_SERIAL_8250_RSA
325-
void univ8250_rsa_support(struct uart_ops *ops);
325+
void univ8250_rsa_support(struct uart_ops *ops, const struct uart_ops *core_ops);
326326
void rsa_enable(struct uart_8250_port *up);
327327
void rsa_disable(struct uart_8250_port *up);
328328
void rsa_autoconfig(struct uart_8250_port *up);
329329
void rsa_reset(struct uart_8250_port *up);
330330
#else
331-
static inline void univ8250_rsa_support(struct uart_ops *ops) { }
331+
static inline void univ8250_rsa_support(struct uart_ops *ops, const struct uart_ops *core_ops) { }
332332
static inline void rsa_enable(struct uart_8250_port *up) {}
333333
static inline void rsa_disable(struct uart_8250_port *up) {}
334334
static inline void rsa_autoconfig(struct uart_8250_port *up) {}

drivers/tty/serial/8250/8250_platform.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static void __init __serial8250_isa_init_ports(void)
7575

7676
/* chain base port ops to support Remote Supervisor Adapter */
7777
univ8250_port_ops = *univ8250_port_base_ops;
78-
univ8250_rsa_support(&univ8250_port_ops);
78+
univ8250_rsa_support(&univ8250_port_ops, univ8250_port_base_ops);
7979

8080
if (share_irqs)
8181
irqflag = IRQF_SHARED;

drivers/tty/serial/8250/8250_rsa.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
static unsigned long probe_rsa[PORT_RSA_MAX];
1515
static unsigned int probe_rsa_count;
1616

17+
static const struct uart_ops *core_port_base_ops;
18+
1719
static int rsa8250_request_resource(struct uart_8250_port *up)
1820
{
1921
struct uart_port *port = &up->port;
@@ -67,7 +69,7 @@ static void univ8250_config_port(struct uart_port *port, int flags)
6769
}
6870
}
6971

70-
univ8250_port_base_ops->config_port(port, flags);
72+
core_port_base_ops->config_port(port, flags);
7173

7274
if (port->type != PORT_RSA && up->probe & UART_PROBE_RSA)
7375
rsa8250_release_resource(up);
@@ -78,11 +80,11 @@ static int univ8250_request_port(struct uart_port *port)
7880
struct uart_8250_port *up = up_to_u8250p(port);
7981
int ret;
8082

81-
ret = univ8250_port_base_ops->request_port(port);
83+
ret = core_port_base_ops->request_port(port);
8284
if (ret == 0 && port->type == PORT_RSA) {
8385
ret = rsa8250_request_resource(up);
8486
if (ret < 0)
85-
univ8250_port_base_ops->release_port(port);
87+
core_port_base_ops->release_port(port);
8688
}
8789

8890
return ret;
@@ -94,15 +96,25 @@ static void univ8250_release_port(struct uart_port *port)
9496

9597
if (port->type == PORT_RSA)
9698
rsa8250_release_resource(up);
97-
univ8250_port_base_ops->release_port(port);
99+
core_port_base_ops->release_port(port);
98100
}
99101

100-
void univ8250_rsa_support(struct uart_ops *ops)
102+
/*
103+
* It is not allowed to directly reference any symbols from 8250.ko here as
104+
* that would result in a dependency loop between the 8250.ko and
105+
* 8250_base.ko modules. This function is called from 8250.ko and is used to
106+
* break the symbolic dependency cycle. Anything that is needed from 8250.ko
107+
* has to be passed as pointers to this function which then can adjust those
108+
* variables on 8250.ko side or store them locally as needed.
109+
*/
110+
void univ8250_rsa_support(struct uart_ops *ops, const struct uart_ops *core_ops)
101111
{
112+
core_port_base_ops = core_ops;
102113
ops->config_port = univ8250_config_port;
103114
ops->request_port = univ8250_request_port;
104115
ops->release_port = univ8250_release_port;
105116
}
117+
EXPORT_SYMBOL_FOR_MODULES(univ8250_rsa_support, "8250");
106118

107119
module_param_hw_array(probe_rsa, ulong, ioport, &probe_rsa_count, 0444);
108120
MODULE_PARM_DESC(probe_rsa, "Probe I/O ports for RSA");
@@ -146,7 +158,6 @@ void rsa_enable(struct uart_8250_port *up)
146158
if (up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16)
147159
serial_out(up, UART_RSA_FRR, 0);
148160
}
149-
EXPORT_SYMBOL_FOR_MODULES(rsa_enable, "8250_base");
150161

151162
/*
152163
* Attempts to turn off the RSA FIFO and resets the RSA board back to 115kbps compat mode. It is
@@ -178,7 +189,6 @@ void rsa_disable(struct uart_8250_port *up)
178189
if (result)
179190
up->port.uartclk = SERIAL_RSA_BAUD_BASE_LO * 16;
180191
}
181-
EXPORT_SYMBOL_FOR_MODULES(rsa_disable, "8250_base");
182192

183193
void rsa_autoconfig(struct uart_8250_port *up)
184194
{
@@ -191,7 +201,6 @@ void rsa_autoconfig(struct uart_8250_port *up)
191201
if (__rsa_enable(up))
192202
up->port.type = PORT_RSA;
193203
}
194-
EXPORT_SYMBOL_FOR_MODULES(rsa_autoconfig, "8250_base");
195204

196205
void rsa_reset(struct uart_8250_port *up)
197206
{
@@ -200,7 +209,6 @@ void rsa_reset(struct uart_8250_port *up)
200209

201210
serial_out(up, UART_RSA_FRR, 0);
202211
}
203-
EXPORT_SYMBOL_FOR_MODULES(rsa_reset, "8250_base");
204212

205213
#ifdef CONFIG_SERIAL_8250_DEPRECATED_OPTIONS
206214
#ifndef MODULE

drivers/tty/serial/8250/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ obj-$(CONFIG_SERIAL_8250) += 8250.o
77
8250-y := 8250_core.o
88
8250-y += 8250_platform.o
99
8250-$(CONFIG_SERIAL_8250_PNP) += 8250_pnp.o
10-
8250-$(CONFIG_SERIAL_8250_RSA) += 8250_rsa.o
1110

1211
obj-$(CONFIG_SERIAL_8250) += 8250_base.o
1312
8250_base-y := 8250_port.o
1413
8250_base-$(CONFIG_SERIAL_8250_DMA) += 8250_dma.o
1514
8250_base-$(CONFIG_SERIAL_8250_DWLIB) += 8250_dwlib.o
1615
8250_base-$(CONFIG_SERIAL_8250_FINTEK) += 8250_fintek.o
1716
8250_base-$(CONFIG_SERIAL_8250_PCILIB) += 8250_pcilib.o
17+
8250_base-$(CONFIG_SERIAL_8250_RSA) += 8250_rsa.o
1818

1919
obj-$(CONFIG_SERIAL_8250_CONSOLE) += 8250_early.o
2020

0 commit comments

Comments
 (0)