linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Lamparter <chunkeey@googlemail.com>
To: David Miller <davem@davemloft.net>
Cc: linville@tuxdriver.com, linux-wireless@vger.kernel.org
Subject: Re: pull request: wireless-next-2.6 2010-09-21
Date: Wed, 22 Sep 2010 20:54:05 +0200	[thread overview]
Message-ID: <201009222054.05469.chunkeey@googlemail.com> (raw)
In-Reply-To: <20100922.092252.116390431.davem@davemloft.net>

On Wednesday 22 September 2010 18:22:52 David Miller wrote:
> From: Christian Lamparter <chunkeey@googlemail.com>
> Date: Wed, 22 Sep 2010 11:58:13 +0200
> 
> > On Wednesday 22 September 2010 03:36:14 David Miller wrote:
> >> From: "John W. Linville" <linville@tuxdriver.com>
> >> Date: Tue, 21 Sep 2010 16:17:05 -0400
> >> 
> >> Pulled, but I suspect the 'packed' attribute usage is wrong in
> >> ath/carl9170 and can just be deleted.
> > 
> > which __packed do you think can be removed?
> > 
> > Note:
> > The overzealous use of __packed is a result of a report from Al Viro
> > for ar9170usb: "arm will pad even between u8's".
> >
> > as decribed in http://tinyurl.com/2ww8c53 [git.kernel.org]
> 
> Then only the structure that has the "u8's" needs the __packed attribute
> not every single other structure it is included in.

Which exactly is the "every single other structure"?
All structs which are internal to the driver are not packed
(e.g.: device context, tid & sta info, tx info, etc... - carl9170.h).

Only the structs which deal with hardware (hw.h, eeprom.h, wlan.h)
or firmware (fwcmd.h, fwdesc.h & wlan.h) interface have the
__packed attribute. And there are several good reasons.

e.g.:
 * prevent gcc from aligning the elements to the architecture boundary,
   which would be fatal because it can cause the device to malfunction.

 * prevent possibly fatal unaligned memory access bugs on
   architectures that don't allow/support unaligned memory access.
   (as described in Documentation/unaligned-memory-access.txt )

 * __packed does not only affect a structs element position, but
   also prevent gcc from adding additional padding at the end.
   This is bad because it breaks BUILD_BUG_ON asserts (as reported by Al Viro)

 * consistency and future-proofing changes.
   The firmware is open source, and other people which are not familiar with
   the point above are working/adding new stuff to the code.
   Therefore the firmware descriptor (fwdesc.h), firmware command  interface
   (fwcmd.h) and the super tx/rx descriptors (wlan.h) can change _alot_. 
   So even it looks like some structs that currently don't necessarily need
   to be __packed they need it in the future.
   (no stable API nonsense!)

In my opinion __packed is necessary for these *interface definitions/API*
as long as it can't be 100% proven that the questionable structure would
not cause problems with any compiler on any platform or architecture at
any time.

But If anyone thinks: "That's all just utter rubbish, you have no idea
what you are talking about!" Then he/she is entitled to take action and
draft a new guild-line which lists valid technical(not religious!) reasons
why the use of __packed is discouraged for interface protocol definitions.

This worked before, take a look at the rants in:
volatile-considered-harmful.txt. Now check-patch.pl warns as soon
as a volatile is buried deep between the lines.

Best Regards,
	Chr 

  reply	other threads:[~2010-09-22 18:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-21 20:17 pull request: wireless-next-2.6 2010-09-21 John W. Linville
2010-09-22  1:36 ` David Miller
2010-09-22  9:58   ` Christian Lamparter
2010-09-22 10:01     ` Johannes Berg
2010-09-22 10:27       ` Christian Lamparter
2010-09-22 10:34         ` Johannes Berg
2010-09-22 11:09           ` Christian Lamparter
2010-09-22 16:22     ` David Miller
2010-09-22 18:54       ` Christian Lamparter [this message]
2010-09-22 19:19         ` David Miller
2010-09-22 20:46           ` Christian Lamparter
2010-09-22 20:57             ` David Miller

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=201009222054.05469.chunkeey@googlemail.com \
    --to=chunkeey@googlemail.com \
    --cc=davem@davemloft.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /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).