how to debug... program hangs while downing for write a rwsem

2022-09-21 Thread Chan Kim
Hello kernel experts and users,

I'm trying to boot linux-5.10.0-rc5 on our arm64 board (using neoverse-v1
core).
After the shell comes up, when I press enter key at the prompt, it gives me
another prompt.
But when I press enter key again, it stops responding.
After inspecting where the program hangs, I found it hangs in function
tty_set_termios while downing the rwsem.
Please see below where I marked "<= this line "". (in file
drivers/tty/tty_ioctl.c)

int tty_set_termios(struct tty_struct *tty, struct ktermios *new_termios)
{
struct ktermios old_termios;
struct tty_ldisc *ld;

WARN_ON(tty->driver->type == TTY_DRIVER_TYPE_PTY &&
tty->driver->subtype == PTY_TYPE_MASTER);
/*
 *  Perform the actual termios internal changes under lock.
 */


/* FIXME: we need to decide on some locking/ordering semantics
   for the set_termios notification eventually */
down_write(&tty->termios_rwsem);<== this
line
old_termios = tty->termios;
tty->termios = *new_termios;
unset_locked_termios(tty, &old_termios);


I have to do some research on tty, line discpline, termios, and rw
semaphores etc. but could anyone give me any suggestion on what can be going
wrong? Or what to check first?
Any suggestion will be really appreciated. 
Thank you!

Chan Kim





___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: how to debug... program hangs while downing for write a rwsem

2022-09-21 Thread Greg KH
On Wed, Sep 21, 2022 at 08:02:50PM +0900, Chan Kim wrote:
> Hello kernel experts and users,
> 
> I'm trying to boot linux-5.10.0-rc5 on our arm64 board (using neoverse-v1
> core).

5.10-rc5 is very very very old and obsolete, and not even a real
release.  Why are you using that specific kernel version?

At the very least, use a released and supported 5.10.y tree, but even
better, use the latest 5.19.y release.

> After the shell comes up, when I press enter key at the prompt, it gives me
> another prompt.
> But when I press enter key again, it stops responding.
> After inspecting where the program hangs, I found it hangs in function
> tty_set_termios while downing the rwsem.
> Please see below where I marked "<= this line "". (in file
> drivers/tty/tty_ioctl.c)
> 
> int tty_set_termios(struct tty_struct *tty, struct ktermios *new_termios)
> {
> struct ktermios old_termios;
> struct tty_ldisc *ld;
> 
> WARN_ON(tty->driver->type == TTY_DRIVER_TYPE_PTY &&
> tty->driver->subtype == PTY_TYPE_MASTER);
> /*
>  *  Perform the actual termios internal changes under lock.
>  */
> 
> 
> /* FIXME: we need to decide on some locking/ordering semantics
>for the set_termios notification eventually */
> down_write(&tty->termios_rwsem);<== this
> line

What serial driver are you using that is causing this problem?

thanks,

greg k-h

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


difference between DECLARE_* and DEFINE_* macro namespaces ?

2022-09-21 Thread jim . cromie
difference between DECLARE_* and DEFINE_* macro namespaces ?




heres some quantitative observations

1st , raw usage counts

[jimc@frodo wk-test]$ ack DECLARE_\\w+ | wc
  12541   30583 1030008
[jimc@frodo wk-test]$ ack \\bDECLARE_\\w+ | wc
  11293   25240  897730

[jimc@frodo wk-test]$ ack \\bDEFINE_\\w+ | wc
  14746   42085 1222994
[jimc@frodo wk-test]$ ack DEFINE_\\w+ | wc
  16714   48172 1386881

used quite a lot. worth seeing the patterns...


this one seems telling it counts indent=0 lines,
ie Header lines, file-scope vars, global declarations etc.

]$ ack ^DEFINE_\\w+ | wc
   7392   19578  661324


[jimc@frodo wk-test]$ ack 'static DECLARE_\w+'  | wc
9203025   80318

so about 1/12 of the DECLAREs have static outside them.









#defines determine how many PATTERN uses there are.
lets count them.

[jimc@frodo wk-test]$ ack '#define DECLARE_\w+' | wc
3141384   27393
[jimc@frodo wk-test]$ ack '#define DEFINE_\w+' | wc
6952734   9

so, 2.3x DEFINE_/DECLARE_ definitions,
and 1.15x uses of those defns

interesting, not suggestive of anything..




lets look at one case

include/linux/spinlock_types_raw.h
71:#define DEFINE_RAW_SPINLOCK(x)  raw_spinlock_t x =
__RAW_SPIN_LOCK_UNLOCKED(x)

its a variable declaration, expecting ';' in caller to close it.

[jimc@frodo wk-test]$ ack DEFINE_RAW_SPINLOCK | wc
140 293   10455
[jimc@frodo wk-test]$ ack 'static DEFINE_RAW_SPINLOCK' | wc
116 2588705
[jimc@frodo wk-test]$ ack '^static DEFINE_RAW_SPINLOCK' | wc
107 2318009

140 uses, most with static, most of those at file-scope













so, all that said, I havent gleaned any heuristics

does anyone want to offer a more qualitative review ?
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Where do I put my new driver?

2022-09-21 Thread jim . cromie
On Mon, Aug 8, 2022 at 12:21 PM Alec Matthews  wrote:
>
> I've created a new device driver that is responsible for controlling a
> GPIO expander. This driver contains gpio_chip code, pinmux/pinconf,
> code, pwm, and irq handlers.
>
> I'm not certain what I should name this driver. `pinctrl-*`, `gpio-*`,
> or something else?
>

that suggests that you have several different drivers.
each under their own tree to get the same "place"
as the ones already there, that build cleanly,
use the subsystem support, and work.

> I'm also not sure where this driver belongs in the source tree. Should
> it exist in drivers/gpio, drivers/pinctrl, or drivers/pwm?
>
> I have developed this driver out of tree, now I am trying to move it in
> tree so I can begin the patch process. I appreciate any insight that
> this list may have on where it belongs.
>

the path of least resistance might be to just put it in staging.
Once its there and building, thats a milestone.
then when it "works" there, thats clearly another.
then maybe break it up into several ko's if feedback says.

>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies