linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/7] serial: 8250_exar: A few updates to the driver
@ 2024-02-19 15:04 Andy Shevchenko
  2024-02-19 15:04 ` [PATCH v2 1/7] serial: 8250_exar: Don't remove GPIO device on suspend Andy Shevchenko
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Andy Shevchenko @ 2024-02-19 15:04 UTC (permalink / raw)
  To: Andy Shevchenko, Greg Kroah-Hartman, linux-kernel, linux-serial
  Cc: Jiri Slaby

A few updates to the 8250 Exar driver as per new in-kernel APIs
appeared.

In v2:
- fixed link error, i.e. missing imported namespace (LKP, Greg)
- added a couple of new patches at the beginning of the series

Andy Shevchenko (7):
  serial: 8250_exar: Don't remove GPIO device on suspend
  serial: 8250_exar: Use dev_get_drvdata() directly in PM callbacks
  serial: 8250_exar: Clear interrupts before registering handler
  serial: 8250_exar: Use generic function to set firmware node
  serial: 8250_exar: switch to DEFINE_SIMPLE_DEV_PM_OPS()
  serial: 8250_exar: Use 8250 PCI library to map and assign resources
  serial: 8250_exar: Don't use "proxy" headers

 drivers/tty/serial/8250/8250_exar.c | 52 +++++++++++++++--------------
 drivers/tty/serial/8250/Kconfig     |  1 +
 2 files changed, 28 insertions(+), 25 deletions(-)

-- 
2.43.0.rc1.1.gbec44491f096


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

* [PATCH v2 1/7] serial: 8250_exar: Don't remove GPIO device on suspend
  2024-02-19 15:04 [PATCH v2 0/7] serial: 8250_exar: A few updates to the driver Andy Shevchenko
@ 2024-02-19 15:04 ` Andy Shevchenko
  2024-02-19 15:04 ` [PATCH v2 2/7] serial: 8250_exar: Use dev_get_drvdata() directly in PM callbacks Andy Shevchenko
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2024-02-19 15:04 UTC (permalink / raw)
  To: Andy Shevchenko, Greg Kroah-Hartman, linux-kernel, linux-serial
  Cc: Jiri Slaby

It seems a copy&paste mistake that suspend callback removes the GPIO
device. There is no counterpart of this action, means once suspended
there is no more GPIO device available untile full unbind-bind cycle
is performed. Remove suspicious GPIO device removal in suspend.

Fixes: d0aeaa83f0b0 ("serial: exar: split out the exar code from 8250_pci")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/tty/serial/8250/8250_exar.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index 1be838122bca..6580265e1763 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -741,6 +741,7 @@ static void exar_pci_remove(struct pci_dev *pcidev)
 	for (i = 0; i < priv->nr; i++)
 		serial8250_unregister_port(priv->line[i]);
 
+	/* Ensure that every init quirk is properly torn down */
 	if (priv->board->exit)
 		priv->board->exit(pcidev);
 }
@@ -755,10 +756,6 @@ static int __maybe_unused exar_suspend(struct device *dev)
 		if (priv->line[i] >= 0)
 			serial8250_suspend_port(priv->line[i]);
 
-	/* Ensure that every init quirk is properly torn down */
-	if (priv->board->exit)
-		priv->board->exit(pcidev);
-
 	return 0;
 }
 
-- 
2.43.0.rc1.1.gbec44491f096


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

* [PATCH v2 2/7] serial: 8250_exar: Use dev_get_drvdata() directly in PM callbacks
  2024-02-19 15:04 [PATCH v2 0/7] serial: 8250_exar: A few updates to the driver Andy Shevchenko
  2024-02-19 15:04 ` [PATCH v2 1/7] serial: 8250_exar: Don't remove GPIO device on suspend Andy Shevchenko
@ 2024-02-19 15:04 ` Andy Shevchenko
  2024-02-19 15:04 ` [PATCH v2 3/7] serial: 8250_exar: Clear interrupts before registering handler Andy Shevchenko
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2024-02-19 15:04 UTC (permalink / raw)
  To: Andy Shevchenko, Greg Kroah-Hartman, linux-kernel, linux-serial
  Cc: Jiri Slaby

PM callbacks take struct device pointer as a parameter, use
dev_get_drvdata() to retrieve it instead of unneeded double
loop of referencing via pci_get_drvdata(to_pci_dev(dev)).

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/tty/serial/8250/8250_exar.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index 6580265e1763..28478b9c537b 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -748,8 +748,7 @@ static void exar_pci_remove(struct pci_dev *pcidev)
 
 static int __maybe_unused exar_suspend(struct device *dev)
 {
-	struct pci_dev *pcidev = to_pci_dev(dev);
-	struct exar8250 *priv = pci_get_drvdata(pcidev);
+	struct exar8250 *priv = dev_get_drvdata(dev);
 	unsigned int i;
 
 	for (i = 0; i < priv->nr; i++)
-- 
2.43.0.rc1.1.gbec44491f096


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

* [PATCH v2 3/7] serial: 8250_exar: Clear interrupts before registering handler
  2024-02-19 15:04 [PATCH v2 0/7] serial: 8250_exar: A few updates to the driver Andy Shevchenko
  2024-02-19 15:04 ` [PATCH v2 1/7] serial: 8250_exar: Don't remove GPIO device on suspend Andy Shevchenko
  2024-02-19 15:04 ` [PATCH v2 2/7] serial: 8250_exar: Use dev_get_drvdata() directly in PM callbacks Andy Shevchenko
@ 2024-02-19 15:04 ` Andy Shevchenko
  2024-02-19 15:05 ` [PATCH v2 4/7] serial: 8250_exar: Use generic function to set firmware node Andy Shevchenko
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2024-02-19 15:04 UTC (permalink / raw)
  To: Andy Shevchenko, Greg Kroah-Hartman, linux-kernel, linux-serial
  Cc: Jiri Slaby

While now there is no issue if IRQ is fired before we clearing
the interrupts as the handler does the same, but strictly speaking
it might be problematic if IRQ handler wants to do something more.

Move clearing interrupt code to be called before registering the
IRQ handler.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/tty/serial/8250/8250_exar.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index 28478b9c537b..c7afa06a420e 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -701,14 +701,14 @@ exar_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
 	uart.port.irq = pci_irq_vector(pcidev, 0);
 	uart.port.dev = &pcidev->dev;
 
+	/* Clear interrupts */
+	exar_misc_clear(priv);
+
 	rc = devm_request_irq(&pcidev->dev, uart.port.irq, exar_misc_handler,
 			 IRQF_SHARED, "exar_uart", priv);
 	if (rc)
 		return rc;
 
-	/* Clear interrupts */
-	exar_misc_clear(priv);
-
 	for (i = 0; i < nr_ports && i < maxnr; i++) {
 		rc = board->setup(priv, pcidev, &uart, i);
 		if (rc) {
-- 
2.43.0.rc1.1.gbec44491f096


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

* [PATCH v2 4/7] serial: 8250_exar: Use generic function to set firmware node
  2024-02-19 15:04 [PATCH v2 0/7] serial: 8250_exar: A few updates to the driver Andy Shevchenko
                   ` (2 preceding siblings ...)
  2024-02-19 15:04 ` [PATCH v2 3/7] serial: 8250_exar: Clear interrupts before registering handler Andy Shevchenko
@ 2024-02-19 15:05 ` Andy Shevchenko
  2024-02-19 15:05 ` [PATCH v2 5/7] serial: 8250_exar: switch to DEFINE_SIMPLE_DEV_PM_OPS() Andy Shevchenko
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2024-02-19 15:05 UTC (permalink / raw)
  To: Andy Shevchenko, Greg Kroah-Hartman, linux-kernel, linux-serial
  Cc: Jiri Slaby

Use generic function to set firmware node instead of ACPI specific one.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/tty/serial/8250/8250_exar.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index c7afa06a420e..2a0c1f7e87f5 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -6,12 +6,12 @@
  *
  *  Copyright (C) 2017 Sudip Mukherjee, All Rights Reserved.
  */
-#include <linux/acpi.h>
 #include <linux/dmi.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/platform_device.h>
 #include <linux/property.h>
 #include <linux/serial_core.h>
 #include <linux/serial_reg.h>
@@ -363,7 +363,7 @@ static struct platform_device *__xr17v35x_register_gpio(struct pci_dev *pcidev,
 		return NULL;
 
 	pdev->dev.parent = &pcidev->dev;
-	ACPI_COMPANION_SET(&pdev->dev, ACPI_COMPANION(&pcidev->dev));
+	device_set_node(&pdev->dev, dev_fwnode(&pcidev->dev));
 
 	if (device_add_software_node(&pdev->dev, node) < 0 ||
 	    platform_device_add(pdev) < 0) {
-- 
2.43.0.rc1.1.gbec44491f096


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

* [PATCH v2 5/7] serial: 8250_exar: switch to DEFINE_SIMPLE_DEV_PM_OPS()
  2024-02-19 15:04 [PATCH v2 0/7] serial: 8250_exar: A few updates to the driver Andy Shevchenko
                   ` (3 preceding siblings ...)
  2024-02-19 15:05 ` [PATCH v2 4/7] serial: 8250_exar: Use generic function to set firmware node Andy Shevchenko
@ 2024-02-19 15:05 ` Andy Shevchenko
  2024-02-19 15:05 ` [PATCH v2 6/7] serial: 8250_exar: Use 8250 PCI library to map and assign resources Andy Shevchenko
  2024-02-19 15:05 ` [PATCH v2 7/7] serial: 8250_exar: Don't use "proxy" headers Andy Shevchenko
  6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2024-02-19 15:05 UTC (permalink / raw)
  To: Andy Shevchenko, Greg Kroah-Hartman, linux-kernel, linux-serial
  Cc: Jiri Slaby

SIMPLE_DEV_PM_OPS() is deprecated, replace it with DEFINE_SIMPLE_DEV_PM_OPS()
and use pm_sleep_ptr() for setting the driver's PM routines. We can now
remove the __maybe_unused qualifier in the suspend and resume functions.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/tty/serial/8250/8250_exar.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index 2a0c1f7e87f5..53c5ff49e83c 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 #include <linux/property.h>
 #include <linux/serial_core.h>
 #include <linux/serial_reg.h>
@@ -746,7 +747,7 @@ static void exar_pci_remove(struct pci_dev *pcidev)
 		priv->board->exit(pcidev);
 }
 
-static int __maybe_unused exar_suspend(struct device *dev)
+static int exar_suspend(struct device *dev)
 {
 	struct exar8250 *priv = dev_get_drvdata(dev);
 	unsigned int i;
@@ -758,7 +759,7 @@ static int __maybe_unused exar_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused exar_resume(struct device *dev)
+static int exar_resume(struct device *dev)
 {
 	struct exar8250 *priv = dev_get_drvdata(dev);
 	unsigned int i;
@@ -772,7 +773,7 @@ static int __maybe_unused exar_resume(struct device *dev)
 	return 0;
 }
 
-static SIMPLE_DEV_PM_OPS(exar_pci_pm, exar_suspend, exar_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(exar_pci_pm, exar_suspend, exar_resume);
 
 static const struct exar8250_board pbn_fastcom335_2 = {
 	.num_ports	= 2,
@@ -922,7 +923,7 @@ static struct pci_driver exar_pci_driver = {
 	.probe		= exar_pci_probe,
 	.remove		= exar_pci_remove,
 	.driver         = {
-		.pm     = &exar_pci_pm,
+		.pm     = pm_sleep_ptr(&exar_pci_pm),
 	},
 	.id_table	= exar_pci_tbl,
 };
-- 
2.43.0.rc1.1.gbec44491f096


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

* [PATCH v2 6/7] serial: 8250_exar: Use 8250 PCI library to map and assign resources
  2024-02-19 15:04 [PATCH v2 0/7] serial: 8250_exar: A few updates to the driver Andy Shevchenko
                   ` (4 preceding siblings ...)
  2024-02-19 15:05 ` [PATCH v2 5/7] serial: 8250_exar: switch to DEFINE_SIMPLE_DEV_PM_OPS() Andy Shevchenko
@ 2024-02-19 15:05 ` Andy Shevchenko
  2024-02-19 15:05 ` [PATCH v2 7/7] serial: 8250_exar: Don't use "proxy" headers Andy Shevchenko
  6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2024-02-19 15:05 UTC (permalink / raw)
  To: Andy Shevchenko, Greg Kroah-Hartman, linux-kernel, linux-serial
  Cc: Jiri Slaby

8250 PCI library provides a common code to map and assign resources.
Use it in order to deduplicate existing code and support IO port
variants.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/tty/serial/8250/8250_exar.c | 11 ++++++-----
 drivers/tty/serial/8250/Kconfig     |  1 +
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index 53c5ff49e83c..cf1abe2fc28a 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -24,6 +24,7 @@
 #include <asm/byteorder.h>
 
 #include "8250.h"
+#include "8250_pcilib.h"
 
 #define PCI_DEVICE_ID_ACCESSIO_COM_2S		0x1052
 #define PCI_DEVICE_ID_ACCESSIO_COM_4S		0x105d
@@ -219,13 +220,12 @@ static int default_setup(struct exar8250 *priv, struct pci_dev *pcidev,
 			 struct uart_8250_port *port)
 {
 	const struct exar8250_board *board = priv->board;
-	unsigned int bar = 0;
 	unsigned char status;
+	int err;
 
-	port->port.iotype = UPIO_MEM;
-	port->port.mapbase = pci_resource_start(pcidev, bar) + offset;
-	port->port.membase = priv->virt + offset;
-	port->port.regshift = board->reg_shift;
+	err = serial8250_pci_setup_port(pcidev, port, 0, offset, board->reg_shift);
+	if (err)
+		return err;
 
 	/*
 	 * XR17V35x UARTs have an extra divisor register, DLD that gets enabled
@@ -929,6 +929,7 @@ static struct pci_driver exar_pci_driver = {
 };
 module_pci_driver(exar_pci_driver);
 
+MODULE_IMPORT_NS(SERIAL_8250_PCI);
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Exar Serial Driver");
 MODULE_AUTHOR("Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>");
diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig
index 8b9a2c4902e2..47ff50763c04 100644
--- a/drivers/tty/serial/8250/Kconfig
+++ b/drivers/tty/serial/8250/Kconfig
@@ -149,6 +149,7 @@ config SERIAL_8250_PCI
 config SERIAL_8250_EXAR
 	tristate "8250/16550 Exar/Commtech PCI/PCIe device support"
 	depends on SERIAL_8250 && PCI
+	select SERIAL_8250_PCILIB
 	default SERIAL_8250
 	help
 	  This builds support for XR17C1xx, XR17V3xx and some Commtech
-- 
2.43.0.rc1.1.gbec44491f096


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

* [PATCH v2 7/7] serial: 8250_exar: Don't use "proxy" headers
  2024-02-19 15:04 [PATCH v2 0/7] serial: 8250_exar: A few updates to the driver Andy Shevchenko
                   ` (5 preceding siblings ...)
  2024-02-19 15:05 ` [PATCH v2 6/7] serial: 8250_exar: Use 8250 PCI library to map and assign resources Andy Shevchenko
@ 2024-02-19 15:05 ` Andy Shevchenko
  6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2024-02-19 15:05 UTC (permalink / raw)
  To: Andy Shevchenko, Greg Kroah-Hartman, linux-kernel, linux-serial
  Cc: Jiri Slaby

Update header inclusions to follow IWYU (Include What You Use)
principle.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/tty/serial/8250/8250_exar.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index cf1abe2fc28a..2df2c9ea7b34 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -6,20 +6,24 @@
  *
  *  Copyright (C) 2017 Sudip Mukherjee, All Rights Reserved.
  */
+#include <linux/bits.h>
+#include <linux/delay.h>
+#include <linux/device.h>
 #include <linux/dmi.h>
+#include <linux/interrupt.h>
 #include <linux/io.h>
-#include <linux/kernel.h>
+#include <linux/math.h>
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
 #include <linux/pm.h>
 #include <linux/property.h>
+#include <linux/string.h>
+#include <linux/types.h>
+
+#include <linux/serial_8250.h>
 #include <linux/serial_core.h>
 #include <linux/serial_reg.h>
-#include <linux/slab.h>
-#include <linux/string.h>
-#include <linux/tty.h>
-#include <linux/delay.h>
 
 #include <asm/byteorder.h>
 
-- 
2.43.0.rc1.1.gbec44491f096


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

end of thread, other threads:[~2024-02-19 15:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-19 15:04 [PATCH v2 0/7] serial: 8250_exar: A few updates to the driver Andy Shevchenko
2024-02-19 15:04 ` [PATCH v2 1/7] serial: 8250_exar: Don't remove GPIO device on suspend Andy Shevchenko
2024-02-19 15:04 ` [PATCH v2 2/7] serial: 8250_exar: Use dev_get_drvdata() directly in PM callbacks Andy Shevchenko
2024-02-19 15:04 ` [PATCH v2 3/7] serial: 8250_exar: Clear interrupts before registering handler Andy Shevchenko
2024-02-19 15:05 ` [PATCH v2 4/7] serial: 8250_exar: Use generic function to set firmware node Andy Shevchenko
2024-02-19 15:05 ` [PATCH v2 5/7] serial: 8250_exar: switch to DEFINE_SIMPLE_DEV_PM_OPS() Andy Shevchenko
2024-02-19 15:05 ` [PATCH v2 6/7] serial: 8250_exar: Use 8250 PCI library to map and assign resources Andy Shevchenko
2024-02-19 15:05 ` [PATCH v2 7/7] serial: 8250_exar: Don't use "proxy" headers Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).