All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] serial: qcom-geni: Remove alias dependency from qcom serial driver
@ 2025-03-04  7:14 Viken Dadhaniya
  2025-03-04 17:45 ` Bjorn Andersson
  2025-03-05 11:10 ` kernel test robot
  0 siblings, 2 replies; 6+ messages in thread
From: Viken Dadhaniya @ 2025-03-04  7:14 UTC (permalink / raw)
  To: gregkh, jirislaby, johan+linaro, dianders, konradybcio,
	linux-arm-msm, linux-kernel, linux-serial
  Cc: quic_msavaliy, quic_anupkulk, Viken Dadhaniya

Remove the dependency on aliases in the device tree configuration for the
qcom serial driver. Currently, the absence of an alias results in an
invalid line number, causing the driver probe to fail for geni serial.

To prevent probe failures, implement logic to dynamically assign line
numbers if an alias is not present in the device tree for non-console
ports.

Signed-off-by: Viken Dadhaniya <quic_vdadhani@quicinc.com>
---
 drivers/tty/serial/qcom_geni_serial.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
index a80ce7aaf309..2457f39dfc84 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -98,6 +98,8 @@
 
 #define DMA_RX_BUF_SIZE		2048
 
+static DEFINE_IDR(port_idr);
+
 struct qcom_geni_device_data {
 	bool console;
 	enum geni_se_xfer_mode mode;
@@ -253,10 +255,25 @@ static struct qcom_geni_serial_port *get_port_from_line(int line, bool console)
 	struct qcom_geni_serial_port *port;
 	int nr_ports = console ? GENI_UART_CONS_PORTS : GENI_UART_PORTS;
 
-	if (line < 0 || line >= nr_ports)
-		return ERR_PTR(-ENXIO);
+	if (console) {
+		if (line < 0 || line >= nr_ports)
+			return ERR_PTR(-ENXIO);
+
+		port = &qcom_geni_console_port;
+	} else {
+		int max_alias_num = of_alias_get_highest_id("serial");
+
+		if (line < 0 || line >= nr_ports)
+			line = idr_alloc(&port_idr, (void *)port, max_alias_num + 1, nr_ports,
+					 GFP_KERNEL);
+		else
+			line = idr_alloc(&port_idr, (void *)port, line, nr_ports, GFP_KERNEL);
+
+		if (line < 0)
+			return ERR_PTR(-ENXIO);
 
-	port = console ? &qcom_geni_console_port : &qcom_geni_uart_ports[line];
+		port = &qcom_geni_uart_ports[line];
+	}
 	return port;
 }
 
@@ -1761,6 +1778,7 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
 						port->wakeup_irq);
 		if (ret) {
 			device_init_wakeup(&pdev->dev, false);
+			idr_remove(&port_idr, uport->line);
 			uart_remove_one_port(drv, uport);
 			return ret;
 		}
@@ -1772,10 +1790,12 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
 static void qcom_geni_serial_remove(struct platform_device *pdev)
 {
 	struct qcom_geni_serial_port *port = platform_get_drvdata(pdev);
+	struct uart_port *uport = &port->uport;
 	struct uart_driver *drv = port->private_data.drv;
 
 	dev_pm_clear_wake_irq(&pdev->dev);
 	device_init_wakeup(&pdev->dev, false);
+	idr_remove(&port_idr, uport->line);
 	uart_remove_one_port(drv, &port->uport);
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* Re: [PATCH v1] serial: qcom-geni: Remove alias dependency from qcom serial driver
@ 2025-03-07 11:15 kernel test robot
  0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2025-03-07 11:15 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20250304071423.4033565-1-quic_vdadhani@quicinc.com>
References: <20250304071423.4033565-1-quic_vdadhani@quicinc.com>
TO: Viken Dadhaniya <quic_vdadhani@quicinc.com>
TO: gregkh@linuxfoundation.org
TO: jirislaby@kernel.org
TO: johan+linaro@kernel.org
TO: dianders@chromium.org
TO: konradybcio@kernel.org
TO: linux-arm-msm@vger.kernel.org
TO: linux-kernel@vger.kernel.org
TO: linux-serial@vger.kernel.org
CC: quic_msavaliy@quicinc.com
CC: quic_anupkulk@quicinc.com
CC: Viken Dadhaniya <quic_vdadhani@quicinc.com>

Hi Viken,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tty/tty-testing]
[also build test WARNING on tty/tty-next tty/tty-linus usb/usb-testing usb/usb-next usb/usb-linus linus/master v6.14-rc5 next-20250306]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Viken-Dadhaniya/serial-qcom-geni-Remove-alias-dependency-from-qcom-serial-driver/20250304-152222
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
patch link:    https://lore.kernel.org/r/20250304071423.4033565-1-quic_vdadhani%40quicinc.com
patch subject: [PATCH v1] serial: qcom-geni: Remove alias dependency from qcom serial driver
:::::: branch date: 3 days ago
:::::: commit date: 3 days ago
config: sh-randconfig-r073-20250307 (https://download.01.org/0day-ci/archive/20250307/202503071840.r1EddvYl-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 14.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202503071840.r1EddvYl-lkp@intel.com/

New smatch warnings:
drivers/tty/serial/qcom_geni_serial.c:267 get_port_from_line() error: uninitialized symbol 'port'.

Old smatch warnings:
drivers/tty/serial/qcom_geni_serial.c:270 get_port_from_line() error: uninitialized symbol 'port'.

vim +/port +267 drivers/tty/serial/qcom_geni_serial.c

c4f528795d1add Karthikeyan Ramasubramanian 2018-03-14  252  
8a8a66a1a18a1d Girish Mahadevan            2018-07-13  253  static struct qcom_geni_serial_port *get_port_from_line(int line, bool console)
c4f528795d1add Karthikeyan Ramasubramanian 2018-03-14  254  {
8a8a66a1a18a1d Girish Mahadevan            2018-07-13  255  	struct qcom_geni_serial_port *port;
8a8a66a1a18a1d Girish Mahadevan            2018-07-13  256  	int nr_ports = console ? GENI_UART_CONS_PORTS : GENI_UART_PORTS;
8a8a66a1a18a1d Girish Mahadevan            2018-07-13  257  
27911ad181d5ce Viken Dadhaniya             2025-03-04  258  	if (console) {
8a8a66a1a18a1d Girish Mahadevan            2018-07-13  259  		if (line < 0 || line >= nr_ports)
c4f528795d1add Karthikeyan Ramasubramanian 2018-03-14  260  			return ERR_PTR(-ENXIO);
8a8a66a1a18a1d Girish Mahadevan            2018-07-13  261  
27911ad181d5ce Viken Dadhaniya             2025-03-04  262  		port = &qcom_geni_console_port;
27911ad181d5ce Viken Dadhaniya             2025-03-04  263  	} else {
27911ad181d5ce Viken Dadhaniya             2025-03-04  264  		int max_alias_num = of_alias_get_highest_id("serial");
27911ad181d5ce Viken Dadhaniya             2025-03-04  265  
27911ad181d5ce Viken Dadhaniya             2025-03-04  266  		if (line < 0 || line >= nr_ports)
27911ad181d5ce Viken Dadhaniya             2025-03-04 @267  			line = idr_alloc(&port_idr, (void *)port, max_alias_num + 1, nr_ports,
27911ad181d5ce Viken Dadhaniya             2025-03-04  268  					 GFP_KERNEL);
27911ad181d5ce Viken Dadhaniya             2025-03-04  269  		else
27911ad181d5ce Viken Dadhaniya             2025-03-04  270  			line = idr_alloc(&port_idr, (void *)port, line, nr_ports, GFP_KERNEL);
27911ad181d5ce Viken Dadhaniya             2025-03-04  271  
27911ad181d5ce Viken Dadhaniya             2025-03-04  272  		if (line < 0)
27911ad181d5ce Viken Dadhaniya             2025-03-04  273  			return ERR_PTR(-ENXIO);
27911ad181d5ce Viken Dadhaniya             2025-03-04  274  
27911ad181d5ce Viken Dadhaniya             2025-03-04  275  		port = &qcom_geni_uart_ports[line];
27911ad181d5ce Viken Dadhaniya             2025-03-04  276  	}
8a8a66a1a18a1d Girish Mahadevan            2018-07-13  277  	return port;
c4f528795d1add Karthikeyan Ramasubramanian 2018-03-14  278  }
c4f528795d1add Karthikeyan Ramasubramanian 2018-03-14  279  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-03-27  7:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-04  7:14 [PATCH v1] serial: qcom-geni: Remove alias dependency from qcom serial driver Viken Dadhaniya
2025-03-04 17:45 ` Bjorn Andersson
2025-03-07  6:52   ` Greg KH
2025-03-27  7:12   ` Viken Dadhaniya
2025-03-05 11:10 ` kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2025-03-07 11:15 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.