Re: [PATCH 1/1] [net/irda]: Fix a misalign access issue.

Previous thread: [PATCH] I2C: SiByte: Convert the driver to make use of interrupts by Maciej W. Rozycki on Monday, May 12, 2008 - 8:28 pm. (3 messages)

Next thread: [PATCH 0/2] Add irq extra flags to 8250 serial driver by Bryan Wu on Monday, May 12, 2008 - 9:14 pm. (5 messages)
From: Yang, Graf
Date: Monday, May 12, 2008 - 9:07 pm

Hi Marcel,

The root cause is __u8 hints[2] are unaligned because of __u8 charset defined in file include/linux/irda.h:132
struct irda_device_info {
        __u32       saddr;    /* Address of local interface */
        __u32       daddr;    /* Address of remote device */
        char        info[22]; /* Description */
        __u8        charset;  /* Charset used for description */
        __u8        hints[2]; /* Hint bits */
};
And code may access hints[2] as u16. 

As put_unaligned/get_unaligned would set/get value through several instructions which decreases the performance. So I'd like to modify the irda_device_info instead of using put_unaligned/get_unaligned in irlmp.c/discovery.c.

I have tried
struct irda_device_info {
        __u32       saddr;    /* Address of local interface */
        __u32       daddr;    /* Address of remote device */
        char        info[22]; /* Description */
        __u8        charset;  /* Charset used for description */
        __u8        reserve;  /* For align data */ 
        __u8        hints[2]; /* Hint bits */
};

It works with my irda driver. Can I modify it like this?
There are many methods to modify this structure, which method are better?


It seems u16ho is useless, I would remove them from net/irda.

I can't enable irnet, so didn't touch net/irda/irnet/irnet_irda.c.
Would you give some information about how to enable irnet?

BRs,
Graf

-----Original Message-----
From: Marcel Holtmann [mailto:marcel@holtmann.org]
Sent: Mon 5/12/2008 9:15 PM
To: Bryan Wu
Cc: samuel@sortiz.org; irda-users@lists.sourceforge.net; linux-kernel@vger.kernel.org; Graf Yang
Subject: Re: [PATCH 1/1] [net/irda]: Fix a misalign access issue.
 

what about net/irda/irnet/irnet_irda.c and why not also kill the u16ho
macro at the same time.

Regards

Marcel

--

From: David Miller
Date: Monday, May 12, 2008 - 9:14 pm

From: "Yang, Graf" <Graf.Yang@analog.com>

This header file and the irda_device_info datastructure are exported
to, and used by, userspace.

Therefore you cannot change this structure's layout without breaking
every single existing IRDA binary out there.
--

From: Bryan Wu
Date: Monday, May 12, 2008 - 11:07 pm

Exactly, so we plan to add put/get_unaligned method to fix this issue.
After Graf fix it, I will send out the patch

Thanks
-Bryan
--

Previous thread: [PATCH] I2C: SiByte: Convert the driver to make use of interrupts by Maciej W. Rozycki on Monday, May 12, 2008 - 8:28 pm. (3 messages)

Next thread: [PATCH 0/2] Add irq extra flags to 8250 serial driver by Bryan Wu on Monday, May 12, 2008 - 9:14 pm. (5 messages)