All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v7 0/3] serial: 8250_pnp: Support configurable reg shift property
@ 2024-04-12  3:23 Guanbing Huang
  2024-04-12  3:24 ` [PATCH v7 1/3] PNP: Add dev_is_pnp() macro Guanbing Huang
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Guanbing Huang @ 2024-04-12  3:23 UTC (permalink / raw)
  To: gregkh, andriy.shevchenko, rafael.j.wysocki
  Cc: linux-acpi, tony, john.ogness, yangyicong, jirislaby,
	linux-kernel, linux-serial, lvjianmin, albanhuang, tombinfan

From: Guanbing Huang <albanhuang@tencent.com>

The 16550a serial port based on the ACPI table requires obtaining the
reg-shift attribute. In the ACPI scenario, If the reg-shift property
is not configured like in DTS, the 16550a serial driver cannot read or
write controller registers properly during initialization.

To address the issue of configuring the reg-shift property, the 
__uart_read_properties() universal interface is called to implement it.
Adaptation of PNP devices is done in the __uart_read_properties() function.

Guanbing Huang (3):
  PNP: Add dev_is_pnp() macro
  serial: port: Add support of PNP IRQ to __uart_read_properties()
  serial: 8250_pnp: Support configurable reg shift property

 drivers/tty/serial/8250/8250_pnp.c | 40 +++++++++++++++++++-----------
 drivers/tty/serial/serial_port.c   |  7 +++++-
 include/linux/pnp.h                |  4 +++
 3 files changed, 35 insertions(+), 16 deletions(-)

-- 
2.17.1


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

* [PATCH v7 1/3] PNP: Add dev_is_pnp() macro
  2024-04-12  3:23 [PATCH v7 0/3] serial: 8250_pnp: Support configurable reg shift property Guanbing Huang
@ 2024-04-12  3:24 ` Guanbing Huang
  2024-04-12 15:29   ` Andy Shevchenko
  2024-04-12  3:24 ` [PATCH v7 2/3] serial: port: Add support of PNP IRQ to __uart_read_properties() Guanbing Huang
  2024-04-12  3:24 ` [PATCH v7 3/3] serial: 8250_pnp: Support configurable reg shift property Guanbing Huang
  2 siblings, 1 reply; 6+ messages in thread
From: Guanbing Huang @ 2024-04-12  3:24 UTC (permalink / raw)
  To: gregkh, andriy.shevchenko, rafael.j.wysocki
  Cc: linux-acpi, tony, john.ogness, yangyicong, jirislaby,
	linux-kernel, linux-serial, lvjianmin, albanhuang, tombinfan

From: Guanbing Huang <albanhuang@tencent.com>

Add dev_is_pnp() macro to determine whether the device is a PNP device.

Signed-off-by: Guanbing Huang <albanhuang@tencent.com>
Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bing Fan <tombinfan@tencent.com>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202404100523.b06UvPSB-lkp@intel.com/
Tested-by: Linheng Du <dylanlhdu@tencent.com>
---
v6 -> v7: add a "Reviewed-by" tag and a "Reported-by" tag, fix build errors when CONFIG_PNP is not enabled
v5 -> v6: fix the issue that the cover letter is not chained with the patch series
v4 -> v5: change "pnp" in the commit message to uppercase

 include/linux/pnp.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/linux/pnp.h b/include/linux/pnp.h
index ddbe7c3ca4ce..82561242cda4 100644
--- a/include/linux/pnp.h
+++ b/include/linux/pnp.h
@@ -469,6 +469,8 @@ int compare_pnp_id(struct pnp_id *pos, const char *id);
 int pnp_register_driver(struct pnp_driver *drv);
 void pnp_unregister_driver(struct pnp_driver *drv);
 
+#define dev_is_pnp(d) ((d)->bus == &pnp_bus_type)
+
 #else
 
 /* device management */
@@ -500,6 +502,8 @@ static inline int compare_pnp_id(struct pnp_id *pos, const char *id) { return -E
 static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; }
 static inline void pnp_unregister_driver(struct pnp_driver *drv) { }
 
+#define dev_is_pnp(d) false
+
 #endif /* CONFIG_PNP */
 
 /**
-- 
2.17.1


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

* [PATCH v7 2/3] serial: port: Add support of PNP IRQ to __uart_read_properties()
  2024-04-12  3:23 [PATCH v7 0/3] serial: 8250_pnp: Support configurable reg shift property Guanbing Huang
  2024-04-12  3:24 ` [PATCH v7 1/3] PNP: Add dev_is_pnp() macro Guanbing Huang
@ 2024-04-12  3:24 ` Guanbing Huang
  2024-04-12  3:24 ` [PATCH v7 3/3] serial: 8250_pnp: Support configurable reg shift property Guanbing Huang
  2 siblings, 0 replies; 6+ messages in thread
From: Guanbing Huang @ 2024-04-12  3:24 UTC (permalink / raw)
  To: gregkh, andriy.shevchenko, rafael.j.wysocki
  Cc: linux-acpi, tony, john.ogness, yangyicong, jirislaby,
	linux-kernel, linux-serial, lvjianmin, albanhuang, tombinfan

From: Guanbing Huang <albanhuang@tencent.com>

The function __uart_read_properties doesn't cover PNP devices, so add IRQ
processing for PNP devices in the branch.

Signed-off-by: Guanbing Huang <albanhuang@tencent.com>
Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bing Fan <tombinfan@tencent.com>
Tested-by: Linheng Du <dylanlhdu@tencent.com>
---
v6 -> v7: add a "Reviewed-by" tag
v5 -> v6: fix the issue that the cover letter is not chained with the patch series
v4 -> v5: change "pnp" and "irq" in the commit message to uppercase, modify the subject
          to start with "serial: port:", modify the location of the header file pnp.h 

 drivers/tty/serial/serial_port.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/serial_port.c b/drivers/tty/serial/serial_port.c
index 22b9eeb23e68..8504bae1d2c9 100644
--- a/drivers/tty/serial/serial_port.c
+++ b/drivers/tty/serial/serial_port.c
@@ -11,6 +11,7 @@
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/pnp.h>
 #include <linux/property.h>
 #include <linux/serial_core.h>
 #include <linux/spinlock.h>
@@ -221,7 +222,11 @@ static int __uart_read_properties(struct uart_port *port, bool use_defaults)
 
 	if (dev_is_platform(dev))
 		ret = platform_get_irq(to_platform_device(dev), 0);
-	else
+	else if (dev_is_pnp(dev)) {
+		ret = pnp_irq(to_pnp_dev(dev), 0);
+		if (ret < 0)
+			ret = -ENXIO;
+	} else
 		ret = fwnode_irq_get(dev_fwnode(dev), 0);
 	if (ret == -EPROBE_DEFER)
 		return ret;
-- 
2.17.1


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

* [PATCH v7 3/3] serial: 8250_pnp: Support configurable reg shift property
  2024-04-12  3:23 [PATCH v7 0/3] serial: 8250_pnp: Support configurable reg shift property Guanbing Huang
  2024-04-12  3:24 ` [PATCH v7 1/3] PNP: Add dev_is_pnp() macro Guanbing Huang
  2024-04-12  3:24 ` [PATCH v7 2/3] serial: port: Add support of PNP IRQ to __uart_read_properties() Guanbing Huang
@ 2024-04-12  3:24 ` Guanbing Huang
  2 siblings, 0 replies; 6+ messages in thread
From: Guanbing Huang @ 2024-04-12  3:24 UTC (permalink / raw)
  To: gregkh, andriy.shevchenko, rafael.j.wysocki
  Cc: linux-acpi, tony, john.ogness, yangyicong, jirislaby,
	linux-kernel, linux-serial, lvjianmin, albanhuang, tombinfan

From: Guanbing Huang <albanhuang@tencent.com>

The 16550a serial port based on the ACPI table requires obtaining the
reg-shift attribute. In the ACPI scenario, If the reg-shift property
is not configured like in DTS, the 16550a serial driver cannot read or
write controller registers properly during initialization.

Signed-off-by: Guanbing Huang <albanhuang@tencent.com>
Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bing Fan <tombinfan@tencent.com>
Tested-by: Linheng Du <dylanlhdu@tencent.com>
---
v6 -> v7: add a "Reviewed-by" tag
v5 -> v6: fix the issue that the cover letter is not chained with the patch series
v4 -> v5: modify to obtain the value of mapsize through the pnp_mem_len function,
          add annotations for the iotype variable, delete excess uart.port.flags operation
v3 -> v4: dependent on two pre patches: "pnp: Add dev_is_pnp() macro" and
          "serial: 8250_port: Add support of pnp irq to  __uart_read_properties()",
          the iotype is reserved, the mapsize is initialized, fix the UPF_SHARE_IRQ
	  flag, check for IRQ being absent
v2 -> v3: switch to use uart_read_port_properties(), change "Signed-off-by" to "Reviewed-by" and "Tested-by"
v1 -> v2: change the names after "Signed off by" to the real names

 drivers/tty/serial/8250/8250_pnp.c | 40 +++++++++++++++++++-----------
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_pnp.c b/drivers/tty/serial/8250/8250_pnp.c
index 1974bbadc975..8f72a7de1d1d 100644
--- a/drivers/tty/serial/8250/8250_pnp.c
+++ b/drivers/tty/serial/8250/8250_pnp.c
@@ -435,6 +435,7 @@ serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
 {
 	struct uart_8250_port uart, *port;
 	int ret, line, flags = dev_id->driver_data;
+	unsigned char iotype;
 
 	if (flags & UNKNOWN_DEV) {
 		ret = serial_pnp_guess_board(dev);
@@ -443,37 +444,46 @@ serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
 	}
 
 	memset(&uart, 0, sizeof(uart));
-	if (pnp_irq_valid(dev, 0))
-		uart.port.irq = pnp_irq(dev, 0);
 	if ((flags & CIR_PORT) && pnp_port_valid(dev, 2)) {
 		uart.port.iobase = pnp_port_start(dev, 2);
-		uart.port.iotype = UPIO_PORT;
+		iotype = UPIO_PORT;
 	} else if (pnp_port_valid(dev, 0)) {
 		uart.port.iobase = pnp_port_start(dev, 0);
-		uart.port.iotype = UPIO_PORT;
+		iotype = UPIO_PORT;
 	} else if (pnp_mem_valid(dev, 0)) {
 		uart.port.mapbase = pnp_mem_start(dev, 0);
-		uart.port.iotype = UPIO_MEM;
+		uart.port.mapsize = pnp_mem_len(dev, 0);
+		iotype = UPIO_MEM;
 		uart.port.flags = UPF_IOREMAP;
 	} else
 		return -ENODEV;
 
-	dev_dbg(&dev->dev,
-		 "Setup PNP port: port %#lx, mem %#llx, irq %u, type %u\n",
-		 uart.port.iobase, (unsigned long long)uart.port.mapbase,
-		 uart.port.irq, uart.port.iotype);
+	uart.port.uartclk = 1843200;
+	uart.port.dev = &dev->dev;
+	uart.port.flags |= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
+
+	ret = uart_read_port_properties(&uart.port);
+	/* no interrupt -> fall back to polling */
+	if (ret == -ENXIO)
+		ret = 0;
+	if (ret)
+		return ret;
+
+	/*
+	 * The previous call may not set iotype correctly when reg-io-width
+	 * property is absent and it doesn't support IO port resource.
+	 */
+	uart.port.iotype = iotype;
 
 	if (flags & CIR_PORT) {
 		uart.port.flags |= UPF_FIXED_PORT | UPF_FIXED_TYPE;
 		uart.port.type = PORT_8250_CIR;
 	}
 
-	uart.port.flags |= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
-	if (pnp_irq_flags(dev, 0) & IORESOURCE_IRQ_SHAREABLE)
-		uart.port.flags |= UPF_SHARE_IRQ;
-	uart.port.uartclk = 1843200;
-	device_property_read_u32(&dev->dev, "clock-frequency", &uart.port.uartclk);
-	uart.port.dev = &dev->dev;
+	dev_dbg(&dev->dev,
+		 "Setup PNP port: port %#lx, mem %#llx, size %#llx, irq %u, type %u\n",
+		 uart.port.iobase, (unsigned long long)uart.port.mapbase,
+		 (unsigned long long)uart.port.mapsize, uart.port.irq, uart.port.iotype);
 
 	line = serial8250_register_8250_port(&uart);
 	if (line < 0 || (flags & CIR_PORT))
-- 
2.17.1


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

* Re: [PATCH v7 1/3] PNP: Add dev_is_pnp() macro
  2024-04-12  3:24 ` [PATCH v7 1/3] PNP: Add dev_is_pnp() macro Guanbing Huang
@ 2024-04-12 15:29   ` Andy Shevchenko
  2024-04-12 15:52     ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2024-04-12 15:29 UTC (permalink / raw)
  To: Guanbing Huang
  Cc: gregkh, rafael.j.wysocki, linux-acpi, tony, john.ogness,
	yangyicong, jirislaby, linux-kernel, linux-serial, lvjianmin,
	albanhuang, tombinfan

On Fri, Apr 12, 2024 at 11:24:12AM +0800, Guanbing Huang wrote:

...

> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

I haven't given this tag _explicitly_ as it's a new code and I answered in
the previous email that I will give one for the new version.

...

> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202404100523.b06UvPSB-lkp@intel.com/

No, the new feature can't be reported.

...

Please, try again.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v7 1/3] PNP: Add dev_is_pnp() macro
  2024-04-12 15:29   ` Andy Shevchenko
@ 2024-04-12 15:52     ` Andy Shevchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-04-12 15:52 UTC (permalink / raw)
  To: Guanbing Huang
  Cc: gregkh, rafael.j.wysocki, linux-acpi, tony, john.ogness,
	yangyicong, jirislaby, linux-kernel, linux-serial, lvjianmin,
	albanhuang, tombinfan

On Fri, Apr 12, 2024 at 06:29:56PM +0300, Andy Shevchenko wrote:
> On Fri, Apr 12, 2024 at 11:24:12AM +0800, Guanbing Huang wrote:

...

> > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> I haven't given this tag _explicitly_ as it's a new code and I answered in
> the previous email that I will give one for the new version.
> 
> ...
> 
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202404100523.b06UvPSB-lkp@intel.com/
> 
> No, the new feature can't be reported.
> 
> ...
> 
> Please, try again.

To clarify, remove the above lines from your first commit.
If you want, you may leave my Rb tags in the patches 2 & 3
as code wasn't changed there.

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2024-04-12 15:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-12  3:23 [PATCH v7 0/3] serial: 8250_pnp: Support configurable reg shift property Guanbing Huang
2024-04-12  3:24 ` [PATCH v7 1/3] PNP: Add dev_is_pnp() macro Guanbing Huang
2024-04-12 15:29   ` Andy Shevchenko
2024-04-12 15:52     ` Andy Shevchenko
2024-04-12  3:24 ` [PATCH v7 2/3] serial: port: Add support of PNP IRQ to __uart_read_properties() Guanbing Huang
2024-04-12  3:24 ` [PATCH v7 3/3] serial: 8250_pnp: Support configurable reg shift property Guanbing Huang

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.