2 Jun 23:35
[PATCH] usb/input/hid-core.c extract() brain damage
Grant Grundler <grundler <at> parisc-linux.org>
2005-06-02 21:35:19 GMT
2005-06-02 21:35:19 GMT
Hi folks,, extract() and implement() are bit field manipulation routines. They mangle "n" bits starting at "offset" index into the bit field. Since this is USB, the byte array is little endian. Big endian machines (e.g. parisc, mips) should only need to byte swap the value. extract() and implement() have brain damaged attempts to handle 32-bit wide "fields". The problem is the index math in the original code didn't clear all the relevant bits. (offset >> 5) only compensated for 32-bit index. We need (offset >> 6) if we want to use 64-bit loads. But it was also wrong in that it tried to use quasi-aligned loads. Ie "report" was only incremented in multiples of 4 bytes and then the offset was masked off for values greater than 4 bytes. The right way is to pretend "report" points at a byte array. And offset is then only minor adjustment for < 8 bits of offset. "n" (field width) can then be as big as 24 (assuming 32-bit loads) since "offset" will never be bigger than 7. If someone needs either function to handle more than 24-bits, please document why - point at a specification or specific USB hid device - in comments in the code. extract/implement() are also an eyesore to read. Please banish whoever wrote it to read CodingStyle 3 times in a row to a classroom full of 1st graders armed with rubberbands. Or just flame them. Whatever. Globbing all the code together on two lines does NOT make it faster and is Just Wrong.(Continue reading)
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.
RSS Feed