Skip to contentSkip to conversation

usb/input/hid-core.c extract() brain damage

PATCH John David Anglin 4 participants 6 messages Jun 4, 2005 5 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 3 lines
Quoted 1 line

It seems that this problem has been around for some time.

I didn't check to see how long this code has been around.

It's in 2.6.10-pa3. Since the USB mouse and keyboard work in it, some other change must have been involved in the 2.6.12 breakage.

As an aside, 2.6.10-pa3 doesn't seem to have the stability problems that I saw 2.6.11-pa4. It pretty much seems as stable as 2.6.8.1-pa11 on my c3750. There was hang in the java testsuite (PR218) in one of two gcc builds and check. Otherwise, the test results were identical.

Quoted 3 lines
Quoted 1 line

Does it fix the usb keyboard and mouse problems in 2.6.12?

USB keyboard and mouse work with 2.6.12-rc5 on parisc.

Great!

Dave

Signature · 6 lines
J. David Anglin                                  [email protected]
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 6 lines · John David Anglin
Quoted 3 lines
Quoted 1 line

It seems that this problem has been around for some time.

I didn't check to see how long this code has been around.

It's in 2.6.10-pa3. Since the USB mouse and keyboard work in it, some other change must have been involved in the 2.6.12 breakage.

Yes, Kyle tracked it down to parisc switching from a parisc asm definition of get_unaligned() to using the generic ones. Ie we moved from avoiding kernel traps to exercising them. But 64-bit kernel worked fine with USB.
And on 32-bit kernels le64() loads degenerate into two 32-bit loads. Ie the trap handler is still only dealing with 32-bit misaligned accesses like it would with this patch. So I don't think the kernel trap support is the problem.

Regardless, the two functions are badly written and could be alot clearer.

Quoted 4 lines

As an aside, 2.6.10-pa3 doesn't seem to have the stability problems that I saw 2.6.11-pa4. It pretty much seems as stable as 2.6.8.1-pa11 on my c3750. There was hang in the java testsuite (PR218) in one of two gcc builds and check. Otherwise, the test results were identical.

Ok. Can you want to try the older version of include/asm-parisc/unaligned.h?

Quoted 3 lines
Quoted 1 line

USB keyboard and mouse work with 2.6.12-rc5 on parisc.

Great!

Well, I haven't committed it to cvs.parisc-linux.org. I'm waiting for the USB guru's to comment.

grant
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 19 lines · Grant Grundler
Quoted 6 lines · John David Anglin
Quoted 3 lines
Quoted 1 line

It seems that this problem has been around for some time.

I didn't check to see how long this code has been around.

It's in 2.6.10-pa3. Since the USB mouse and keyboard work in it, some other change must have been involved in the 2.6.12 breakage.

Yes, Kyle tracked it down to parisc switching from a parisc asm definition of get_unaligned() to using the generic ones. Ie we moved from avoiding kernel traps to exercising them. But 64-bit kernel worked fine with USB.
And on 32-bit kernels le64() loads degenerate into two 32-bit loads. Ie the trap handler is still only dealing with 32-bit misaligned accesses like it would with this patch. So I don't think the kernel trap support is the problem.

Quoted 3 lines

Regardless, the two functions are badly written and could be alot clearer.

Thanks for feedback ;-)

That said, I also noticed a big difference of behaviour when I select or not the CONFIG_PDC_STABLE option or not:
o when selected my stress test make panicing my b2k in 5 min showing a cash_grow() pb (as reported before)
o when not selected the system hang as decribe by jda.

Quoted 2 lines
Quoted 2 lines

As an aside, 2.6.10-pa3 doesn't seem to have the stability problems

Interesting, I will check. Thanks

Quoted 7 lines
Quoted 3 lines

that I saw 2.6.11-pa4. It pretty much seems as stable as 2.6.8.1-pa11 on my c3750. There was hang in the java testsuite (PR218) in one of two gcc builds and check. Otherwise, the test results were identical.

Ok. Can you want to try the older version of include/asm-parisc/unaligned.h?

Interesting, I will too

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

USB keyboard and mouse work with 2.6.12-rc5 on parisc.

Great!

Well, I haven't committed it to cvs.parisc-linux.org. I'm waiting for the USB guru's to comment.

Many thanks,
Joel
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw

[...]

Quoted 5 lines
Quoted 3 lines

Ok. Can you want to try the older version of include/asm-parisc/unaligned.h?

Interesting, I will too

Sorry it didn't help for me (on a b180 with kernel 2.6.12-rc5-pa2 and 2.6.8/include/asm-parisc/unaligned.h) still panicing as usual:

 [<101511b0>] cache_grow+0xd8/0x1a8
 [<10151428>] cache_alloc_refill+0x1a8/0x264
 [<10151744>] kmem_cache_alloc+0x48/0x4c
 [<101b590c>] ext3_alloc_inode+0x18/0x40
 [<10186ae8>] alloc_inode+0x28/0x1a0
 [<1018772c>] new_inode+0x10/0x8c
 [<101aa718>] ext3_new_inode+0xc4/0x73c
 [<101b36b8>] ext3_create+0x8c/0x12c
 [<1017b484>] vfs_create+0xe0/0x140
 [<1017bd54>] open_namei+0x680/0x734
 [<101694bc>] filp_open+0x3c/0x70
 [<101699ac>] sys_open+0x70/0xb8
 [<1010d12c>] syscall_exit+0x0/0x14

Kernel Fault: Code=15 regs=15154600 (Addr=27c944cc)

YZrvWESTHLNXBCVMcbcbcbcbOGFRQPDI
PSW: 00000000000001001110011100001111 Not tainted

r00-03  00000000 10513e58 101511b0 105004f8
r04-07  17794000 100df6e0 00000010 00000050
r08-11  00000001 15f172bc 17b050dc 00000000
r12-15  15154110 000081a4 0004db4e 000e1bc8
r16-19  000e1c68 00000000 00000000 27c944f8
r20-23  27c944bc 000003dc 000001a5 00000050
r24-27  105004bc 17794000 100df6e0 10400010
r28-31  27c944bc 00000000 15154600 10153a94
sr0-3   00000000 000028a9 00000000 00002635
sr4-7   00000000 00000000 00000000 00000000

IASQ: 00000000 00000000 IAOQ: 10150f30 10150f34
IIR: 6b800020 ISR: 00000000 IOR: 27c944cc
CPU: 0 CR30: 15154000 CR31: 10460000
ORIG_R28: 00000000
IAOQ[0]: alloc_slabmgmt+0x30/0x6c IAOQ[1]: alloc_slabmgmt+0x34/0x6c RP(r2): cache_grow+0xd8/0x1a8

Kernel panic - not syncing: Kernel Fault
 <0>Rebooting in 120 seconds..

:_(

Thanks,
Joel

_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux

#8 lore raw
In reply to a message not in the archive
Quoted 11 lines · Grant Grundler

Yes, Kyle tracked it down to parisc switching from a parisc asm definition of get_unaligned() to using the generic ones. Ie we moved from avoiding kernel traps to exercising them. But 64-bit kernel worked fine with USB.
And on 32-bit kernels le64() loads degenerate into two 32-bit loads. Ie the trap handler is still only dealing with 32-bit misaligned accesses like it would with this patch. So I don't think the kernel trap support is the problem.

Regardless, the two functions are badly written and could be alot clearer.

This is a naive question from someone who doesn't know much about the various implementations of get_unaligned() and put_unaligned().

In spite of the total overall number of changes required, wouldn't it be much simpler to have a suite of routines (inlines or macros) like:

	get_16, put_16, get_le16, put_le16, get_be16, put_be16
	get_32, put_32, get_le32, put_le32, get_be32, put_be32
	get_64, put_64, get_le64, put_le64, get_be64, put_be64

	in short, {get|put}_{|le|be}{16|32|64}

for native, little-endian, and big-endian unaligned accesses? The generic definitions are extremely simple and architecture-specific headers could easily provide optimized versions.

I realize this doesn't fit in very well with the current state of the API, but IMHO it would be a big improvement.

Alan Stern

_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw
Quoted 8 lines · Alan Stern

In spite of the total overall number of changes required, wouldn't it be much simpler to have a suite of routines (inlines or macros) like:

	get_16, put_16, get_le16, put_le16, get_be16, put_be16
	get_32, put_32, get_le32, put_le32, get_be32, put_be32
	get_64, put_64, get_le64, put_le64, get_be64, put_be64

	in short, {get|put}_{|le|be}{16|32|64}

Sorry, no. The architectures that trap on misaligned accesses have to handle that in the kernel. And even though the implementations get simpler, a plethoria of interfaces just clutters up the general device driver API. For that reason alone I wouldn't want it.

The endian conversion (swap) macros are PITA already. I'll argue the swap API should be simplified to four macros:

	cpu_to_le(x), cpu_to_be(x), le_to_cpu(x), be_to_cpu(x)

and force the caller to cast to the right size. switch(sizeof(x)) would then select the right arch specific variant. I'll figure out how to pitch this to linux-arch...and then see how far it gets batted back. :^)

Quoted 6 lines

for native, little-endian, and big-endian unaligned accesses? The generic definitions are extremely simple and architecture-specific headers could easily provide optimized versions.

I realize this doesn't fit in very well with the current state of the API, but IMHO it would be a big improvement.

Not really. davem is right that it would clutter up certain parts of the code (e.g. networking stack).
Don't forget all the above is a NOP on 90% (x86) of the computers.

I'm annoyed that certain performance sensitive paths (e.g. TCP/IP) don't use macros to access unaligned data. It affects my work (ia64) and pet (parisc) architectures. But that's how it is and I don't see it changing anytime in the near future.

thanks for thinking about it,
grant
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux