[printk,v1,01/18] kdb: do not assume write() callback available

Message ID 20230302195618.156940-2-john.ogness@linutronix.de
State New
Headers
Series threaded/atomic console support |

Commit Message

John Ogness March 2, 2023, 7:56 p.m. UTC
  It is allowed for consoles to provide no write() callback. For
example ttynull does this.

Check if a write() callback is available before using it.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
 kernel/debug/kdb/kdb_io.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Petr Mladek March 7, 2023, 2:57 p.m. UTC | #1
On Thu 2023-03-02 21:02:01, John Ogness wrote:
> It is allowed for consoles to provide no write() callback. For
> example ttynull does this.
> 
> Check if a write() callback is available before using it.
> 
> Signed-off-by: John Ogness <john.ogness@linutronix.de>

Reviewed-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr
  
Doug Anderson March 7, 2023, 4:34 p.m. UTC | #2
Hi,

On Thu, Mar 2, 2023 at 11:57 AM John Ogness <john.ogness@linutronix.de> wrote:
>
> It is allowed for consoles to provide no write() callback. For
> example ttynull does this.
>
> Check if a write() callback is available before using it.
>
> Signed-off-by: John Ogness <john.ogness@linutronix.de>
> ---
>  kernel/debug/kdb/kdb_io.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
> index 5c7e9ba7cd6b..e9139dfc1f0a 100644
> --- a/kernel/debug/kdb/kdb_io.c
> +++ b/kernel/debug/kdb/kdb_io.c
> @@ -576,6 +576,8 @@ static void kdb_msg_write(const char *msg, int msg_len)
>                         continue;
>                 if (c == dbg_io_ops->cons)
>                         continue;
> +               if (!c->write)
> +                       continue;

Reviewed-by: Douglas Anderson <dianders@chromium.org>
  
Daniel Thompson March 9, 2023, 10:52 a.m. UTC | #3
On Thu, Mar 02, 2023 at 09:02:01PM +0106, John Ogness wrote:
> It is allowed for consoles to provide no write() callback. For
> example ttynull does this.
>
> Check if a write() callback is available before using it.
>
> Signed-off-by: John Ogness <john.ogness@linutronix.de>

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>

Any thoughts on best way to land the series. All via one tree or can
we pick and mix?


Daniel.
  
Petr Mladek March 9, 2023, 11:26 a.m. UTC | #4
On Thu 2023-03-09 10:52:40, Daniel Thompson wrote:
> On Thu, Mar 02, 2023 at 09:02:01PM +0106, John Ogness wrote:
> > It is allowed for consoles to provide no write() callback. For
> > example ttynull does this.
> >
> > Check if a write() callback is available before using it.
> >
> > Signed-off-by: John Ogness <john.ogness@linutronix.de>
> 
> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
> 
> Any thoughts on best way to land the series. All via one tree or can
> we pick and mix?

I would prefer to take everything via the printk tree because
most changes are there. Otherwise, we might end up with non-necessary
cross-tree merge conflicts. Also I would know when all pieces are
there.

That said, this seems to be the only change in
kernel/debug/kdb/kdb_io.c and it is relatively independent.
So, it should not be a big problem to take it separately.

Best Regards,
Petr
  
Daniel Thompson March 9, 2023, 11:30 a.m. UTC | #5
On Thu, Mar 09, 2023 at 12:26:23PM +0100, Petr Mladek wrote:
> On Thu 2023-03-09 10:52:40, Daniel Thompson wrote:
> > On Thu, Mar 02, 2023 at 09:02:01PM +0106, John Ogness wrote:
> > > It is allowed for consoles to provide no write() callback. For
> > > example ttynull does this.
> > >
> > > Check if a write() callback is available before using it.
> > >
> > > Signed-off-by: John Ogness <john.ogness@linutronix.de>
> >
> > Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
> >
> > Any thoughts on best way to land the series. All via one tree or can
> > we pick and mix?
>
> I would prefer to take everything via the printk tree because
> most changes are there. Otherwise, we might end up with non-necessary
> cross-tree merge conflicts. Also I would know when all pieces are
> there.
>
> That said, this seems to be the only change in
> kernel/debug/kdb/kdb_io.c and it is relatively independent.
> So, it should not be a big problem to take it separately.

Enthusiastically
Acked-by: Daniel Thompson <daniel.thompson@linaro.org>

That suits me fine: kgdb is pretty quiet at the moment so, whilst I
can't predict what patches will show up this cycle, this probably spares
me from having to put together a PR for a single patch!


Daniel.
  

Patch

diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index 5c7e9ba7cd6b..e9139dfc1f0a 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -576,6 +576,8 @@  static void kdb_msg_write(const char *msg, int msg_len)
 			continue;
 		if (c == dbg_io_ops->cons)
 			continue;
+		if (!c->write)
+			continue;
 		/*
 		 * Set oops_in_progress to encourage the console drivers to
 		 * disregard their internal spin locks: in the current calling