RE: [PATCH] serial: uartlite: Use dynamic allocation for major number

From: Guntupalli, Manikanta
Date: Fri Nov 10 2023 - 12:57:42 EST


Hi Greg,

> -----Original Message-----
> From: Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx>
> Sent: Thursday, November 9, 2023 6:50 PM
> To: Guntupalli, Manikanta <manikanta.guntupalli@xxxxxxx>
> Cc: git (AMD-Xilinx) <git@xxxxxxx>; Simek, Michal
> <michal.simek@xxxxxxx>; jacmet@xxxxxxxxxx; jirislaby@xxxxxxxxxx; linux-
> serial@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; Pandey, Radhey Shyam
> <radhey.shyam.pandey@xxxxxxx>; Goud, Srinivas
> <srinivas.goud@xxxxxxx>; Datta, Shubhrajyoti
> <shubhrajyoti.datta@xxxxxxx>; manion05gk@xxxxxxxxx
> Subject: Re: [PATCH] serial: uartlite: Use dynamic allocation for major number
>
> On Thu, Nov 09, 2023 at 06:06:40PM +0530, Manikanta Guntupalli wrote:
> > Device number 204 has a range of minors on major number.
> > uart_register_driver is failing due to lack of minor numbers when more
> > number of uart ports used.
>
> So you need more than the 4 allocated to you?
Yes, we have a customer who has 32 uartlite instances in his board.
>
> > So, use dynamic allocation
> > for major number to avoid minor number limitation on 204 major number.
> >
> > https://docs.kernel.org/arch/arm/sa1100/serial_uart.html
>
> What does this break by doing this?
uart_register_driver() is failing due to lack of minor numbers when the customer
has 32 uartlite instances in his board.
>
> Also, you forgot to update the documentation :(
We will update the documentation.
>
> And how was this tested?
We tested on both ZCU106 AMD/Xilinx evaluation board with 32 uartlite instances with customer design.

>What about older systems with static device nodes,
> are you sure none are out there for this old hardware anymore?
Shall we use below approach to support both legacy hardware and hardware with more number of uartlite instances use case. Please suggest.
diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index 404c14acafa5..517f1f34143d 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -24,8 +24,13 @@
#include <linux/pm_runtime.h>

#define ULITE_NAME "ttyUL"
+#if (CONFIG_SERIAL_UARTLITE_NR_UARTS > 4)
+#define ULITE_MAJOR 0 /* use dynamic node allocation */
+#define ULITE_MINOR 0
+#else
#define ULITE_MAJOR 204
#define ULITE_MINOR 187
+#endif
#define ULITE_NR_UARTS CONFIG_SERIAL_UARTLITE_NR_UARTS


Thanks,
Manikanta.