linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kyle McMartin <kyle@mcmartin.ca>
To: Daniel Drake <dsd@gentoo.org>
Cc: linux-wireless@vger.kernel.org,
	David Miller <davem@davemloft.net>,
	Johannes Berg <johannes@sipsolutions.net>,
	jt@hpl.hp.com
Subject: Re: zd1211rw (2.6.22 sparc64): unaligned access (do_rx)
Date: Wed, 21 Nov 2007 13:05:20 -0500	[thread overview]
Message-ID: <20071121180520.GC13298@fattire.cabal.ca> (raw)
In-Reply-To: <47443F78.60701@gentoo.org>

On Wed, Nov 21, 2007 at 02:23:52PM +0000, Daniel Drake wrote:
> 	network = ieee80211softmac_get_network_by_bssid_locked(mac, 
> resp->header.addr3);
> 
> addr3 is offset 20 bytes in the struct and is 6 bytes long. Because 20 
> is not evenly divisible by 6 does that make it an unaligned access?
> 

Sort of. An "unaligned" access is one where the referenced address is
not aligned to the size of the data type being accessed. For example,
a 4-byte load must be accessed on 4-byte aligned boundaries:
	0xffff0000 0xffff0004 0xffff0008, and so forth.

Obviously a single byte load is always aligned.

Unaligned accesses are universally bad. On some architectures (x86, ppc)
they will be emulated in hardware at a performance cost. On others
(sparc, parisc, ia64) they will trap, giving you the option of software
emulation (very slow) or sending a SIGBUS. On still others (arm, I
think[1]) they'll "align" in hardware, resulting in loads or stores to
the wrong address.

The Linux networking code is a pretty good example of when to use the
support macros (get|put)_unaligned to do the right thing. For something
like a packed structure accessed in a data stream, you're invariably going
to have to use these.

> Is there any documentation I can read on this topic? In my current 
> uneducated state I'm likely to write further code with these problems...
> 

cheers,
	Kyle

1. Just a guess based on <asm-arm/unaligned.h> providing macros that
actually do something, and the lack of an obvious unaligned trap
handler.

  reply	other threads:[~2007-11-21 18:05 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-19  0:56 zd1211rw (2.6.22 sparc64): unaligned access (do_rx) Shaddy Baddah
2007-11-19  8:27 ` David Miller
2007-11-19 12:11   ` Shaddy Baddah
2007-11-19 12:19     ` David Miller
2007-11-21 13:08     ` Shaddy Baddah
2007-11-19 15:03   ` Johannes Berg
2007-11-19 18:04     ` Jean Tourrilhes
2007-11-21 13:18       ` Shaddy Baddah
2007-11-21 13:30         ` Shaddy Baddah
2007-11-21 14:23           ` Daniel Drake
2007-11-21 18:05             ` Kyle McMartin [this message]
2007-11-30  5:31             ` Shaddy Baddah
2007-11-21 14:33           ` Daniel Drake
2007-11-21 18:44         ` Jean Tourrilhes
2007-11-30  3:42           ` Shaddy Baddah
2007-11-30 20:21             ` Jean Tourrilhes
2007-12-04  0:01               ` Jean Tourrilhes
     [not found]                 ` <4756AABC.3000204@hotmail.com>
     [not found]                   ` <20071205215600.GA28349@bougret.hpl.hp.com>
2007-12-05 23:25                     ` Shaddy Baddah
2007-12-05 23:40                       ` Jean Tourrilhes
2007-12-06 21:59                       ` Jean Tourrilhes
2007-12-06  2:36                     ` David Miller
2007-12-06 21:25                       ` Jean Tourrilhes
2007-12-06 21:33                         ` Michael Buesch
2007-12-06 21:43                           ` Jean Tourrilhes
2007-12-07  3:52                             ` David Miller
2007-12-07 11:35                               ` Michael Buesch
2007-12-07 12:34                                 ` David Miller
2007-12-07 13:36                                   ` Michael Buesch
2007-12-07 14:48                                     ` Daniel Drake
2007-12-08  1:36                                       ` David Miller
2007-12-08  1:35                                     ` David Miller
2007-12-08 11:21                                       ` Michael Buesch
2007-12-08 12:54                                         ` Daniel Drake
2007-12-07  3:50                           ` David Miller
2007-12-07  3:49                         ` David Miller
2007-11-19 22:20     ` David Miller
2007-11-19 22:35       ` Jean Tourrilhes
2007-11-20  7:42         ` David Miller
2007-11-20 17:43           ` Jean Tourrilhes
2007-11-20 21:56             ` David Miller
2007-11-20 12:40       ` Johannes Berg
2007-11-20 12:46         ` David Miller
     [not found]           ` <20071120180016.GC1480@bougret.hpl.hp.com>
2007-11-20 21:58             ` David Miller
2007-11-20 22:08               ` John W. Linville
2007-11-20 22:38                 ` David Miller
2007-11-20 22:16               ` Jean Tourrilhes
2007-11-20 22:41                 ` David Miller
     [not found]             ` <20071120180601.GA2019@bougret.hpl.hp.com>
     [not found]               ` <47443430.3010504@hotmail.com>
2007-11-21 19:06                 ` Jean Tourrilhes
2007-11-20 17:38         ` Jean Tourrilhes
2007-11-20 12:34   ` David Miller
2007-11-20 13:15     ` Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071121180520.GC13298@fattire.cabal.ca \
    --to=kyle@mcmartin.ca \
    --cc=davem@davemloft.net \
    --cc=dsd@gentoo.org \
    --cc=johannes@sipsolutions.net \
    --cc=jt@hpl.hp.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).