2015-04-14 10:03:26

by Michal Simek

[permalink] [raw]
Subject: [PATCH v2] serial: of-serial: Remove device_type = "serial" registration

Do not probe all serial drivers by of_serial.c which are using
device_type = "serial"; property. Only drivers which have valid
compatible strings listed in the driver should be probed.

When PORT_UNKNOWN is setup probe will fail anyway.

Arnd quotation about driver historical background:
"when I wrote that driver initially, the idea was that it would
get used as a stub to hook up all other serial drivers but after
that, the common code learned to create platform devices from DT"

This patch fix the problem with on the system with xilinx_uartps and
16550a where of_serial failed to register for xilinx_uartps and because
of irq_dispose_mapping() removed irq_desc. Then when xilinx_uartps was asking
for irq with request_irq() EINVAL is returned.

Signed-off-by: Michal Simek <[email protected]>
CC: <[email protected]>
---

Changes in v2:
- Extend patch description

drivers/tty/serial/of_serial.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
index 33fb94f78967..0a52c8b55a5f 100644
--- a/drivers/tty/serial/of_serial.c
+++ b/drivers/tty/serial/of_serial.c
@@ -344,7 +344,6 @@ static struct of_device_id of_platform_serial_table[] = {
{ .compatible = "ibm,qpace-nwp-serial",
.data = (void *)PORT_NWPSERIAL, },
#endif
- { .type = "serial", .data = (void *)PORT_UNKNOWN, },
{ /* end of list */ },
};

--
2.3.5


2015-04-15 11:08:35

by Peter Hurley

[permalink] [raw]
Subject: Re: [PATCH v2] serial: of-serial: Remove device_type = "serial" registration

On 04/14/2015 06:03 AM, Michal Simek wrote:
> Do not probe all serial drivers by of_serial.c which are using
> device_type = "serial"; property. Only drivers which have valid
> compatible strings listed in the driver should be probed.
>
> When PORT_UNKNOWN is setup probe will fail anyway.
>
> Arnd quotation about driver historical background:
> "when I wrote that driver initially, the idea was that it would
> get used as a stub to hook up all other serial drivers but after
> that, the common code learned to create platform devices from DT"
>
> This patch fix the problem with on the system with xilinx_uartps and
> 16550a where of_serial failed to register for xilinx_uartps and because
> of irq_dispose_mapping() removed irq_desc. Then when xilinx_uartps was asking
> for irq with request_irq() EINVAL is returned.

The problem is that irq_create_mapping()/irq_dispose_mapping()
is not symmetrical, which breaks the device probe model. With that
fixed, no change would be required here.

Regards,
Peter Hurley


> Signed-off-by: Michal Simek <[email protected]>
> CC: <[email protected]>
> ---
>
> Changes in v2:
> - Extend patch description
>
> drivers/tty/serial/of_serial.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
> index 33fb94f78967..0a52c8b55a5f 100644
> --- a/drivers/tty/serial/of_serial.c
> +++ b/drivers/tty/serial/of_serial.c
> @@ -344,7 +344,6 @@ static struct of_device_id of_platform_serial_table[] = {
> { .compatible = "ibm,qpace-nwp-serial",
> .data = (void *)PORT_NWPSERIAL, },
> #endif
> - { .type = "serial", .data = (void *)PORT_UNKNOWN, },
> { /* end of list */ },
> };
>
>

2015-04-16 07:28:52

by Michal Simek

[permalink] [raw]
Subject: Re: [PATCH v2] serial: of-serial: Remove device_type = "serial" registration

On 04/15/2015 01:08 PM, Peter Hurley wrote:
> On 04/14/2015 06:03 AM, Michal Simek wrote:
>> Do not probe all serial drivers by of_serial.c which are using
>> device_type = "serial"; property. Only drivers which have valid
>> compatible strings listed in the driver should be probed.
>>
>> When PORT_UNKNOWN is setup probe will fail anyway.
>>
>> Arnd quotation about driver historical background:
>> "when I wrote that driver initially, the idea was that it would
>> get used as a stub to hook up all other serial drivers but after
>> that, the common code learned to create platform devices from DT"
>>
>> This patch fix the problem with on the system with xilinx_uartps and
>> 16550a where of_serial failed to register for xilinx_uartps and because
>> of irq_dispose_mapping() removed irq_desc. Then when xilinx_uartps was asking
>> for irq with request_irq() EINVAL is returned.
>
> The problem is that irq_create_mapping()/irq_dispose_mapping()
> is not symmetrical, which breaks the device probe model. With that
> fixed, no change would be required here.

But even when this is fixed this device_type = "serial"; registration is
not needed at all and just slow down boot process.

I am not an expert but maybe you will know. A lot of drivers are calling
platform_get_irq which create mapping but in error path this mapping is
not removed. Not sure if this is done by core but based on my chat with
Arnd probably not.

Arnd: Can you please ACK this patch?

Thanks,
Michal


2015-04-16 09:31:29

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH v2] serial: of-serial: Remove device_type = "serial" registration

On Tuesday 14 April 2015 12:03:09 Michal Simek wrote:
> Do not probe all serial drivers by of_serial.c which are using
> device_type = "serial"; property. Only drivers which have valid
> compatible strings listed in the driver should be probed.
>
> When PORT_UNKNOWN is setup probe will fail anyway.
>
> Arnd quotation about driver historical background:
> "when I wrote that driver initially, the idea was that it would
> get used as a stub to hook up all other serial drivers but after
> that, the common code learned to create platform devices from DT"
>
> This patch fix the problem with on the system with xilinx_uartps and
> 16550a where of_serial failed to register for xilinx_uartps and because
> of irq_dispose_mapping() removed irq_desc. Then when xilinx_uartps was asking
> for irq with request_irq() EINVAL is returned.
>
> Signed-off-by: Michal Simek <[email protected]>
> CC: <[email protected]>
> ---
>

Acked-by: Arnd Bergmann <[email protected]>