From: Michael Buesch <mb@bu3sch.de>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: Tomas Winkler <tomasw@gmail.com>,
"John W. Linville" <linville@tuxdriver.com>,
Dan Williams <dcbw@redhat.com>,
linux-wireless <linux-wireless@vger.kernel.org>,
Zhu Yi <yi.zhu@intel.com>,
Reinette Chatre <reinette.chatre@intel.com>
Subject: Re: coding style lesson: iwlwifi vs. endianness
Date: Mon, 10 Dec 2007 16:30:47 +0100 [thread overview]
Message-ID: <200712101630.48124.mb@bu3sch.de> (raw)
In-Reply-To: <1197299937.6035.81.camel@johannes.berg>
On Monday 10 December 2007 16:18:57 Johannes Berg wrote:
>
> > > I never said you should keep native layout structures. I merely said
> > > that it leads to better code if the data is converted to CPU endianness
> > > at the system boundary. While the actual system boundary is obviously
> > > the PCI(-E) bus, the logical system boundary may well be at the point
> > > where you load a certain value from the DMA memory into the CPU to
> > > operate with it (whether it's then pushed back out to memory on the
> > > stack is uninteresting).
> >
> > I'm not buying this logical boundary definition if you don't do clean
> > cut you still have to be endian aware across the whole code so what's
> > a difference.
>
> No, you only have to be endian aware when you do a load from a structure
> you *know* was/is DMAed from/to the card. That's a world of a
> difference.
I agree that it's a lot easier to read and maintain, if you convert _all_
your data structures (also single integers) to and from device endianness
at the time when you write/read them to the device. It unifies the
workflow a lot and results in much less swappings.
my_data = read_drom_device()
swap_to_cpu(my_data)
do_whatever(my_data)
store the data somewhere else in the device structs for
later use, maybe.
do_something_else(my_data)
You see that now you have only _one_ place that you have to care about.
And if you have to write your data back at some point, simply do it
just before the write.
And, little endian intel guys, this will simplify your life a lot by
removing lots of cpu_to_xxx stuff _and_ result
in no performance loss, as the swap will be optimized away. :)
That's a deal, eh?
And we big endian people, we don't care about one or two swap instructions.
It won't hurt performance in any way.
(Johannes also showed that in most cases this approach doesn't even
add extra instructions).
--
Greetings Michael.
next prev parent reply other threads:[~2007-12-10 15:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-27 18:44 coding style lesson: iwlwifi vs. endianness Johannes Berg
2007-11-28 18:20 ` Tomas Winkler
2007-11-28 18:50 ` Johannes Berg
2007-11-28 21:43 ` Dan Williams
2007-11-29 0:58 ` John W. Linville
2007-11-29 23:02 ` Tomas Winkler
2007-12-10 11:42 ` Johannes Berg
2007-12-10 14:18 ` Tomas Winkler
2007-12-10 15:18 ` Johannes Berg
2007-12-10 15:30 ` Michael Buesch [this message]
2007-12-10 16:18 ` Johannes Berg
2007-12-10 16:48 ` Michael Buesch
2007-12-10 16:21 ` Tomas Winkler
2007-12-10 16:25 ` Johannes Berg
2007-12-10 21:18 ` Tomas Winkler
2007-12-10 16:10 ` Tomas Winkler
2007-12-10 16:17 ` Johannes Berg
2007-12-10 16:23 ` Johannes Berg
2007-11-29 9:03 ` Holger Schurig
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=200712101630.48124.mb@bu3sch.de \
--to=mb@bu3sch.de \
--cc=dcbw@redhat.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=reinette.chatre@intel.com \
--cc=tomasw@gmail.com \
--cc=yi.zhu@intel.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).