2021-04-27 19:47:45

by Valentin Vidić

[permalink] [raw]
Subject: [PATCH v2] s390/sclp_vt220: Fix console name to match device

Console name reported in /proc/consoles:

ttyS1 -W- (EC p ) 4:65

does not match the char device name:

crw--w---- 1 root root 4, 65 May 17 12:18 /dev/ttysclp0

so debian-installer inside a QEMU s390x instance gets confused and fails
to start with the following error:

steal-ctty: No such file or directory

Signed-off-by: Valentin Vidic <[email protected]>
---
v2: also update preferred console for VT220 case

arch/s390/kernel/setup.c | 2 +-
drivers/s390/char/sclp_vt220.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index 72134f9f6ff5..3ec6ca9c26c0 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -165,7 +165,7 @@ static void __init set_preferred_console(void)
else if (CONSOLE_IS_3270)
add_preferred_console("tty3270", 0, NULL);
else if (CONSOLE_IS_VT220)
- add_preferred_console("ttyS", 1, NULL);
+ add_preferred_console("ttysclp", 0, NULL);
else if (CONSOLE_IS_HVC)
add_preferred_console("hvc", 0, NULL);
}
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
index 047f812d1a1c..71ed1bf15598 100644
--- a/drivers/s390/char/sclp_vt220.c
+++ b/drivers/s390/char/sclp_vt220.c
@@ -35,8 +35,8 @@
#define SCLP_VT220_MINOR 65
#define SCLP_VT220_DRIVER_NAME "sclp_vt220"
#define SCLP_VT220_DEVICE_NAME "ttysclp"
-#define SCLP_VT220_CONSOLE_NAME "ttyS"
-#define SCLP_VT220_CONSOLE_INDEX 1 /* console=ttyS1 */
+#define SCLP_VT220_CONSOLE_NAME "ttysclp"
+#define SCLP_VT220_CONSOLE_INDEX 0 /* console=ttysclp0 */

/* Representation of a single write request */
struct sclp_vt220_request {
--
2.20.1


2021-04-28 17:18:19

by Christian Borntraeger

[permalink] [raw]
Subject: Re: [PATCH v2] s390/sclp_vt220: Fix console name to match device



On 27.04.21 21:40, Valentin Vidic wrote:
> Console name reported in /proc/consoles:
>
> ttyS1 -W- (EC p ) 4:65
>
> does not match the char device name:
>
> crw--w---- 1 root root 4, 65 May 17 12:18 /dev/ttysclp0
>
> so debian-installer inside a QEMU s390x instance gets confused and fails
> to start with the following error:
>
> steal-ctty: No such file or directory
>
> Signed-off-by: Valentin Vidic <[email protected]>

Ok, I will apply this internally for a while to give it some test coverage.
I also think that I found a potential statement for the documentation issue.

The tty will simply continue to work (as tty and console are not connected),
but for the console on LPAR you usually do things like
"console=ttyS0 console=ttyS1" to get console output on both (sclp line mode and
sclp full screen AKA ascii console).

When we now change the documentation to
"console=ttyS0 console=ttyS1 console=ttysclp0" the kernel will ignore the missing
console.


> ---
> v2: also update preferred console for VT220 case
>
> arch/s390/kernel/setup.c | 2 +-
> drivers/s390/char/sclp_vt220.c | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
> index 72134f9f6ff5..3ec6ca9c26c0 100644
> --- a/arch/s390/kernel/setup.c
> +++ b/arch/s390/kernel/setup.c
> @@ -165,7 +165,7 @@ static void __init set_preferred_console(void)
> else if (CONSOLE_IS_3270)
> add_preferred_console("tty3270", 0, NULL);
> else if (CONSOLE_IS_VT220)
> - add_preferred_console("ttyS", 1, NULL);
> + add_preferred_console("ttysclp", 0, NULL);
> else if (CONSOLE_IS_HVC)
> add_preferred_console("hvc", 0, NULL);
> }
> diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
> index 047f812d1a1c..71ed1bf15598 100644
> --- a/drivers/s390/char/sclp_vt220.c
> +++ b/drivers/s390/char/sclp_vt220.c
> @@ -35,8 +35,8 @@
> #define SCLP_VT220_MINOR 65
> #define SCLP_VT220_DRIVER_NAME "sclp_vt220"
> #define SCLP_VT220_DEVICE_NAME "ttysclp"
> -#define SCLP_VT220_CONSOLE_NAME "ttyS"
> -#define SCLP_VT220_CONSOLE_INDEX 1 /* console=ttyS1 */
> +#define SCLP_VT220_CONSOLE_NAME "ttysclp"
> +#define SCLP_VT220_CONSOLE_INDEX 0 /* console=ttysclp0 */
>
> /* Representation of a single write request */
> struct sclp_vt220_request {
>

2021-04-28 17:29:18

by Hendrik Brueckner

[permalink] [raw]
Subject: Re: [PATCH v2] s390/sclp_vt220: Fix console name to match device

Hi Valentin,

I just had the chance to look into this console topic yesterday.

On Tue, Apr 27, 2021 at 09:40:10PM +0200, Valentin Vidic wrote:
> Console name reported in /proc/consoles:
>
> ttyS1 -W- (EC p ) 4:65

It is been a while ago when working on consoles. However, consoles are
typically devices without having a device node associated. There is special
handling for /dev/console wrt. to the preferred console in the tty layer.

A console device might be associated with a tty device but this is not a
requirement. For example, consider the net console that streams console
messages thru UDP and is not associated with a tty.

Because console and tty are different devices, names can also be different
which is, unfortunately, the case on s390.

Therefore my suggestion here is not derive the tty device from the name
of the console, but rather looking at the associated tty being reported
as major minor number in /proc/console.

>
> does not match the char device name:
>
> crw--w---- 1 root root 4, 65 May 17 12:18 /dev/ttysclp0

In the example above, 4:65 excactly ends up in /dev/ttysclp0.

I am also in contact with Christian and thanks to him to try this out
internally. At least, there are options to bring this forward and let's
figure out what the best solution will be.

Thanks and kind regards,
Hendrik

--
Hendrik Brueckner
[email protected] | IBM Deutschland Research & Development GmbH
| Schoenaicher Str. 220, 71032 Boeblingen

2021-04-28 17:41:02

by Valentin Vidić

[permalink] [raw]
Subject: Re: [PATCH v2] s390/sclp_vt220: Fix console name to match device

On Wed, Apr 28, 2021 at 03:38:36PM +0200, Hendrik Brueckner wrote:
> It is been a while ago when working on consoles. However, consoles are
> typically devices without having a device node associated. There is special
> handling for /dev/console wrt. to the preferred console in the tty layer.
>
> A console device might be associated with a tty device but this is not a
> requirement. For example, consider the net console that streams console
> messages thru UDP and is not associated with a tty.
>
> Because console and tty are different devices, names can also be different
> which is, unfortunately, the case on s390.
>
> Therefore my suggestion here is not derive the tty device from the name
> of the console, but rather looking at the associated tty being reported
> as major minor number in /proc/console.

Yes, I see what you mean. Loading netconsole produces a line in
/proc/consoles without the major:minor numbers:

tty0 -WU (EC p ) 4:7
netcon0 -W- (E p )

On the other hand /proc/consoles documentation seems to suggest these
are character device names:
https://www.kernel.org/doc/html/latest/filesystems/proc.html#proc-consoles

Since sclp_vt220 seems to be the only know exception we are trying
to solve in that direction now.

If this does not work out, the alternative is as you suggested to take
the major:minor numbers and read the char device name from the symlink:

lrwxrwxrwx 1 root root 0 Apr 28 17:00 /sys/dev/char/4:7 -> ../../devices/virtual/tty/tty7

--
Valentin

2021-04-28 18:34:48

by Christian Borntraeger

[permalink] [raw]
Subject: Re: [PATCH v2] s390/sclp_vt220: Fix console name to match device



On 28.04.21 15:38, Hendrik Brueckner wrote:
> Hi Valentin,
>
> I just had the chance to look into this console topic yesterday.
>
> On Tue, Apr 27, 2021 at 09:40:10PM +0200, Valentin Vidic wrote:
>> Console name reported in /proc/consoles:
>>
>> ttyS1 -W- (EC p ) 4:65
>
> It is been a while ago when working on consoles. However, consoles are
> typically devices without having a device node associated. There is special
> handling for /dev/console wrt. to the preferred console in the tty layer.
>
> A console device might be associated with a tty device but this is not a
> requirement. For example, consider the net console that streams console
> messages thru UDP and is not associated with a tty.
>
> Because console and tty are different devices, names can also be different
> which is, unfortunately, the case on s390.

another example is the ttyS0 console which is called sclp_line0 as a tty.
Doesnt the debian installer thus also fails when running in an LPAR?

It might still be a good idea to actually change the console name for the
ascii console as you patch does.

> Therefore my suggestion here is not derive the tty device from the name
> of the console, but rather looking at the associated tty being reported
> as major minor number in /proc/console.

So yes we should definitely try to fix the installer program as well. All other
distros seem to handle this case fine.

>
>>
>> does not match the char device name:
>>
>> crw--w---- 1 root root 4, 65 May 17 12:18 /dev/ttysclp0
>
> In the example above, 4:65 excactly ends up in /dev/ttysclp0.
>
> I am also in contact with Christian and thanks to him to try this out
> internally. At least, there are options to bring this forward and let's
> figure out what the best solution will be.
>
> Thanks and kind regards,
> Hendrik
>
h