2020-06-15 12:47:43

by Tamseel Shams

[permalink] [raw]
Subject: [RFC PATCH] serial: samsung: Re-factors UART IRQ resource for various Samsung SoC

In few older Samsung SoCs like s3c2410, s3c2412
and s3c2440, UART IP is having 2 interrupt lines.
However, in other SoCs like s3c6400, s5pv210,
exynos5433, and exynos4210 UART is having only 1
interrupt line. Due to this, "platform_get_irq(platdev, 1)"
call in the driver gives the following warning:
"IRQ index 1 not found" on recent platforms.

This patch re-factors the IRQ resources handling for
each platform and hence fixing the above warnings seen
on some platforms.

Signed-off-by: Tamseel Shams <[email protected]>
---
drivers/tty/serial/samsung_tty.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
index 6ef614d8648c..078dcb3e316f 100644
--- a/drivers/tty/serial/samsung_tty.c
+++ b/drivers/tty/serial/samsung_tty.c
@@ -60,6 +60,7 @@ struct s3c24xx_uart_info {
char *name;
unsigned int type;
unsigned int fifosize;
+ unsigned int irq_cnt;
unsigned long rx_fifomask;
unsigned long rx_fifoshift;
unsigned long rx_fifofull;
@@ -1908,12 +1909,17 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
else {
port->irq = ret;
ourport->rx_irq = ret;
- ourport->tx_irq = ret + 1;
+ if (ourport->info->irq_cnt == 1)
+ ourport->tx_irq = ret;
+ else
+ ourport->tx_irq = ret + 1;
}

- ret = platform_get_irq(platdev, 1);
- if (ret > 0)
- ourport->tx_irq = ret;
+ if (ourport->info->irq_cnt != 1) {
+ ret = platform_get_irq(platdev, 1);
+ if (ret > 0)
+ ourport->tx_irq = ret;
+ }
/*
* DMA is currently supported only on DT platforms, if DMA properties
* are specified.
@@ -2387,6 +2393,7 @@ static struct s3c24xx_serial_drv_data s3c2410_serial_drv_data = {
.name = "Samsung S3C2410 UART",
.type = PORT_S3C2410,
.fifosize = 16,
+ .irq_cnt = 2,
.rx_fifomask = S3C2410_UFSTAT_RXMASK,
.rx_fifoshift = S3C2410_UFSTAT_RXSHIFT,
.rx_fifofull = S3C2410_UFSTAT_RXFULL,
@@ -2414,6 +2421,7 @@ static struct s3c24xx_serial_drv_data s3c2412_serial_drv_data = {
.name = "Samsung S3C2412 UART",
.type = PORT_S3C2412,
.fifosize = 64,
+ .irq_cnt = 2,
.has_divslot = 1,
.rx_fifomask = S3C2440_UFSTAT_RXMASK,
.rx_fifoshift = S3C2440_UFSTAT_RXSHIFT,
@@ -2443,6 +2451,7 @@ static struct s3c24xx_serial_drv_data s3c2440_serial_drv_data = {
.name = "Samsung S3C2440 UART",
.type = PORT_S3C2440,
.fifosize = 64,
+ .irq_cnt = 2,
.has_divslot = 1,
.rx_fifomask = S3C2440_UFSTAT_RXMASK,
.rx_fifoshift = S3C2440_UFSTAT_RXSHIFT,
@@ -2471,6 +2480,7 @@ static struct s3c24xx_serial_drv_data s3c6400_serial_drv_data = {
.name = "Samsung S3C6400 UART",
.type = PORT_S3C6400,
.fifosize = 64,
+ .irq_cnt = 1,
.has_divslot = 1,
.rx_fifomask = S3C2440_UFSTAT_RXMASK,
.rx_fifoshift = S3C2440_UFSTAT_RXSHIFT,
@@ -2498,6 +2508,7 @@ static struct s3c24xx_serial_drv_data s5pv210_serial_drv_data = {
.info = &(struct s3c24xx_uart_info) {
.name = "Samsung S5PV210 UART",
.type = PORT_S3C6400,
+ .irq_cnt = 1,
.has_divslot = 1,
.rx_fifomask = S5PV210_UFSTAT_RXMASK,
.rx_fifoshift = S5PV210_UFSTAT_RXSHIFT,
@@ -2526,6 +2537,7 @@ static struct s3c24xx_serial_drv_data s5pv210_serial_drv_data = {
.info = &(struct s3c24xx_uart_info) { \
.name = "Samsung Exynos UART", \
.type = PORT_S3C6400, \
+ .irq_cnt = 1, \
.has_divslot = 1, \
.rx_fifomask = S5PV210_UFSTAT_RXMASK, \
.rx_fifoshift = S5PV210_UFSTAT_RXSHIFT, \
--
2.17.1


2020-06-15 12:56:06

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [RFC PATCH] serial: samsung: Re-factors UART IRQ resource for various Samsung SoC

On Mon, Jun 15, 2020 at 05:56:09PM +0530, Tamseel Shams wrote:
> In few older Samsung SoCs like s3c2410, s3c2412
> and s3c2440, UART IP is having 2 interrupt lines.
> However, in other SoCs like s3c6400, s5pv210,
> exynos5433, and exynos4210 UART is having only 1
> interrupt line. Due to this, "platform_get_irq(platdev, 1)"
> call in the driver gives the following warning:
> "IRQ index 1 not found" on recent platforms.
>
> This patch re-factors the IRQ resources handling for
> each platform and hence fixing the above warnings seen
> on some platforms.
>
> Signed-off-by: Tamseel Shams <[email protected]>
> ---
> drivers/tty/serial/samsung_tty.c | 20 ++++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)

RFC means "I do not trust this so I don't want anyone to merge it", so
I'll just delete it from my queue and wait for you to come up with
something that you feel confident with :)

thanks,

greg k-h

2020-06-15 13:18:25

by Robin Murphy

[permalink] [raw]
Subject: Re: [RFC PATCH] serial: samsung: Re-factors UART IRQ resource for various Samsung SoC

On 2020-06-15 13:26, Tamseel Shams wrote:
> In few older Samsung SoCs like s3c2410, s3c2412
> and s3c2440, UART IP is having 2 interrupt lines.
> However, in other SoCs like s3c6400, s5pv210,
> exynos5433, and exynos4210 UART is having only 1
> interrupt line. Due to this, "platform_get_irq(platdev, 1)"
> call in the driver gives the following warning:
> "IRQ index 1 not found" on recent platforms.
>
> This patch re-factors the IRQ resources handling for
> each platform and hence fixing the above warnings seen
> on some platforms.
>
> Signed-off-by: Tamseel Shams <[email protected]>
> ---
> drivers/tty/serial/samsung_tty.c | 20 ++++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
> index 6ef614d8648c..078dcb3e316f 100644
> --- a/drivers/tty/serial/samsung_tty.c
> +++ b/drivers/tty/serial/samsung_tty.c
> @@ -60,6 +60,7 @@ struct s3c24xx_uart_info {
> char *name;
> unsigned int type;
> unsigned int fifosize;
> + unsigned int irq_cnt;
> unsigned long rx_fifomask;
> unsigned long rx_fifoshift;
> unsigned long rx_fifofull;
> @@ -1908,12 +1909,17 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
> else {
> port->irq = ret;
> ourport->rx_irq = ret;
> - ourport->tx_irq = ret + 1;
> + if (ourport->info->irq_cnt == 1)
> + ourport->tx_irq = ret;
> + else
> + ourport->tx_irq = ret + 1;
> }
>
> - ret = platform_get_irq(platdev, 1);
> - if (ret > 0)
> - ourport->tx_irq = ret;
> + if (ourport->info->irq_cnt != 1) {
> + ret = platform_get_irq(platdev, 1);
> + if (ret > 0)
> + ourport->tx_irq = ret;

FWIW, if you're not going to do anything in the error case then you may
as well just call platform_get_irq_optional() unconditionally.

Robin.

> + }
> /*
> * DMA is currently supported only on DT platforms, if DMA properties
> * are specified.
> @@ -2387,6 +2393,7 @@ static struct s3c24xx_serial_drv_data s3c2410_serial_drv_data = {
> .name = "Samsung S3C2410 UART",
> .type = PORT_S3C2410,
> .fifosize = 16,
> + .irq_cnt = 2,
> .rx_fifomask = S3C2410_UFSTAT_RXMASK,
> .rx_fifoshift = S3C2410_UFSTAT_RXSHIFT,
> .rx_fifofull = S3C2410_UFSTAT_RXFULL,
> @@ -2414,6 +2421,7 @@ static struct s3c24xx_serial_drv_data s3c2412_serial_drv_data = {
> .name = "Samsung S3C2412 UART",
> .type = PORT_S3C2412,
> .fifosize = 64,
> + .irq_cnt = 2,
> .has_divslot = 1,
> .rx_fifomask = S3C2440_UFSTAT_RXMASK,
> .rx_fifoshift = S3C2440_UFSTAT_RXSHIFT,
> @@ -2443,6 +2451,7 @@ static struct s3c24xx_serial_drv_data s3c2440_serial_drv_data = {
> .name = "Samsung S3C2440 UART",
> .type = PORT_S3C2440,
> .fifosize = 64,
> + .irq_cnt = 2,
> .has_divslot = 1,
> .rx_fifomask = S3C2440_UFSTAT_RXMASK,
> .rx_fifoshift = S3C2440_UFSTAT_RXSHIFT,
> @@ -2471,6 +2480,7 @@ static struct s3c24xx_serial_drv_data s3c6400_serial_drv_data = {
> .name = "Samsung S3C6400 UART",
> .type = PORT_S3C6400,
> .fifosize = 64,
> + .irq_cnt = 1,
> .has_divslot = 1,
> .rx_fifomask = S3C2440_UFSTAT_RXMASK,
> .rx_fifoshift = S3C2440_UFSTAT_RXSHIFT,
> @@ -2498,6 +2508,7 @@ static struct s3c24xx_serial_drv_data s5pv210_serial_drv_data = {
> .info = &(struct s3c24xx_uart_info) {
> .name = "Samsung S5PV210 UART",
> .type = PORT_S3C6400,
> + .irq_cnt = 1,
> .has_divslot = 1,
> .rx_fifomask = S5PV210_UFSTAT_RXMASK,
> .rx_fifoshift = S5PV210_UFSTAT_RXSHIFT,
> @@ -2526,6 +2537,7 @@ static struct s3c24xx_serial_drv_data s5pv210_serial_drv_data = {
> .info = &(struct s3c24xx_uart_info) { \
> .name = "Samsung Exynos UART", \
> .type = PORT_S3C6400, \
> + .irq_cnt = 1, \
> .has_divslot = 1, \
> .rx_fifomask = S5PV210_UFSTAT_RXMASK, \
> .rx_fifoshift = S5PV210_UFSTAT_RXSHIFT, \
>

2020-06-17 16:31:31

by Tamseel Shams

[permalink] [raw]
Subject: RE: [RFC PATCH] serial: samsung: Re-factors UART IRQ resource for various Samsung SoC

Hi Greg,
I will post the patch without RFC tag.

Thanks & Regards
Tamseel

> -----Original Message-----
> From: Greg KH <[email protected]>
> Sent: Monday, June 15, 2020 6:21 PM
> To: Tamseel Shams <[email protected]>
> Cc: [email protected]; [email protected]; [email protected]; linux-arm-
> [email protected]; [email protected]; linux-
> [email protected]; [email protected];
> [email protected]
> Subject: Re: [RFC PATCH] serial: samsung: Re-factors UART IRQ resource for
> various Samsung SoC
>
> On Mon, Jun 15, 2020 at 05:56:09PM +0530, Tamseel Shams wrote:
> > In few older Samsung SoCs like s3c2410, s3c2412 and s3c2440, UART IP
> > is having 2 interrupt lines.
> > However, in other SoCs like s3c6400, s5pv210, exynos5433, and
> > exynos4210 UART is having only 1 interrupt line. Due to this,
> > "platform_get_irq(platdev, 1)"
> > call in the driver gives the following warning:
> > "IRQ index 1 not found" on recent platforms.
> >
> > This patch re-factors the IRQ resources handling for each platform and
> > hence fixing the above warnings seen on some platforms.
> >
> > Signed-off-by: Tamseel Shams <[email protected]>
> > ---
> > drivers/tty/serial/samsung_tty.c | 20 ++++++++++++++++----
> > 1 file changed, 16 insertions(+), 4 deletions(-)
>
> RFC means "I do not trust this so I don't want anyone to merge it", so
I'll just
> delete it from my queue and wait for you to come up with something that
you
> feel confident with :)
>
> thanks,
>
> greg k-h

2020-06-17 17:11:40

by Tamseel Shams

[permalink] [raw]
Subject: RE: [RFC PATCH] serial: samsung: Re-factors UART IRQ resource for various Samsung SoC

Hi Robin,

> -----Original Message-----
> From: Robin Murphy <[email protected]>
> Sent: Monday, June 15, 2020 6:43 PM
> To: Tamseel Shams <[email protected]>; [email protected];
> [email protected]; [email protected]; [email protected]
> Cc: [email protected]; [email protected]; linux-
> [email protected]; [email protected]; linux-arm-
> [email protected]
> Subject: Re: [RFC PATCH] serial: samsung: Re-factors UART IRQ resource for
> various Samsung SoC
>
> On 2020-06-15 13:26, Tamseel Shams wrote:
> > else {
> > port->irq = ret;
> > ourport->rx_irq = ret;
> > - ourport->tx_irq = ret + 1;
> > + if (ourport->info->irq_cnt == 1)
> > + ourport->tx_irq = ret;
> > + else
> > + ourport->tx_irq = ret + 1;
> > }
> >
> > - ret = platform_get_irq(platdev, 1);
> > - if (ret > 0)
> > - ourport->tx_irq = ret;
> > + if (ourport->info->irq_cnt != 1) {
> > + ret = platform_get_irq(platdev, 1);
> > + if (ret > 0)
> > + ourport->tx_irq = ret;
>
> FWIW, if you're not going to do anything in the error case then you may as well
> just call platform_get_irq_optional() unconditionally.
>
> Robin.
>
My intention behind not using 'platform_get_irq_optional' was that it does not prints the error when the 2nd interrupt resource is missing for the older UART's. I am just using it to give information to the user in error case. I can use 'platform_get_irq_optional' too.

Thanks & Regards
Tamseel

> > + }
> > /*
> > * DMA is currently supported only on DT platforms, if DMA properties
> > * are specified.
> > @@ -2387,6 +2393,7 @@ static struct s3c24xx_serial_drv_data
> s3c2410_serial_drv_data = {
> > .name = "Samsung S3C2410 UART",
> > .type = PORT_S3C2410,
> > .fifosize = 16,
> > + .irq_cnt = 2,
> > .rx_fifomask = S3C2410_UFSTAT_RXMASK,
> > .rx_fifoshift = S3C2410_UFSTAT_RXSHIFT,
> > .rx_fifofull = S3C2410_UFSTAT_RXFULL,