2008-07-09 00:19:14

by Ihar Hrachyshka

[permalink] [raw]
Subject: [PATCH] libertas: fix memory alignment problems on the blackfin

Fixing unaligned memory access on the blackfin architecture (maybe on the ARM also).

Signed-off-by: Ihar Hrachyshka <[email protected]>

---

diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c
index 343ed38..9dbfad3 100644
--- a/drivers/net/wireless/libertas/scan.c
+++ b/drivers/net/wireless/libertas/scan.c
@@ -567,11 +567,11 @@ static int lbs_process_bss(struct bss_descriptor *bss,
pos += 8;

/* beacon interval is 2 bytes long */
- bss->beaconperiod = le16_to_cpup((void *) pos);
+ bss->beaconperiod = le16_to_cpu(get_unaligned((__le16 *)pos));
pos += 2;

/* capability information is 2 bytes long */
- bss->capability = le16_to_cpup((void *) pos);
+ bss->capability = le16_to_cpu(get_unaligned((__le16 *)pos));
lbs_deb_scan("process_bss: capabilities 0x%04x\n", bss->capability);
pos += 2;



2008-07-10 11:31:16

by Dan Williams

[permalink] [raw]
Subject: Re: [PATCH] libertas: fix memory alignment problems on the blackfin

On Wed, 2008-07-09 at 09:29 +0300, Ihar Hrachyshka wrote:
> > There's helpers for this now: get_unaligned_le16
> Ok, third pass - the first was in January... :)
>
> Fixing unaligned memory access on the blackfin architecture (maybe on
> the ARM also).
>
> Signed-off-by: Ihar Hrachyshka <[email protected]>

Acked-by: Dan Williams <[email protected]>

> ---
>
> diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c
> index 343ed38..4b27456 100644
> --- a/drivers/net/wireless/libertas/scan.c
> +++ b/drivers/net/wireless/libertas/scan.c
> @@ -567,11 +567,11 @@ static int lbs_process_bss(struct bss_descriptor *bss,
> pos += 8;
>
> /* beacon interval is 2 bytes long */
> - bss->beaconperiod = le16_to_cpup((void *) pos);
> + bss->beaconperiod = get_unaligned_le16(pos);
> pos += 2;
>
> /* capability information is 2 bytes long */
> - bss->capability = le16_to_cpup((void *) pos);
> + bss->capability = get_unaligned_le16(pos);
> lbs_deb_scan("process_bss: capabilities 0x%04x\n", bss->capability);
> pos += 2;
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html


2008-07-09 20:55:41

by Ihar Hrachyshka

[permalink] [raw]
Subject: Re: [PATCH] libertas: fix memory alignment problems on the blackfin

On Wed, Jul 9, 2008 at 11:07 PM, Johannes Berg
<[email protected]> wrote:
> On Wed, 2008-07-09 at 23:03 +0300, Ihar Hrachyshka wrote:
>> On Wed, Jul 9, 2008 at 4:21 PM, Holger Schurig
>> <[email protected]> wrote:
>> >> Fixing unaligned memory access on the blackfin architecture
>> >> (maybe on the ARM also).
>> >
>> > You can delete the "maybe", on ARM (more specificially, on a
>> > PXA255, which is ARMv5TE) I didn't had a problem.
>>
>> Ok, just blackfin. Is it a joke or should I resend the patch with
>> another description?..
>
> I'm sure arm has that problem too and sparc and others, but it may not
> always show up because the frame might actually be aligned sometimes.
>
> OTOH, why are you getting unaligned frames in the first place? This is
> the beacon interval, so it's at a fixed modulo-two position from the
> start of the frame.

Do you mean that we should add __attribute__ ((aligned (2))) for our
'bss_descriptor' structure definition rather align particular fields
at runtime?

>
> johannes
>