From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Laurent Dufour <ldufour@linux.vnet.ibm.com>,
David Laight <David.Laight@ACULAB.COM>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jslaby@suse.cz>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] powerpc/hvsi: Fix endianness issues in the HVSI driver
Date: Thu, 20 Aug 2015 07:50:13 +1000 [thread overview]
Message-ID: <1440021013.2737.14.camel@kernel.crashing.org> (raw)
In-Reply-To: <55D4F702.4020503@linux.vnet.ibm.com>
On Wed, 2015-08-19 at 23:37 +0200, Laurent Dufour wrote:
> On 03/08/2015 13:00, David Laight wrote:
From: Laurent Dufour
> > > Sent: 31 July 2015 10:30
> > > This patch fixes several endianness issues detected when running
> > > the HVSI
> > > driver in little endian mode.
> > >
> > > These issues are raised in little endian mode because the data
> > > exchanged in
> > > memory between the kernel and the hypervisor has to be in big
> > > endian
> > > format.
> > ...
> > > diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
> > > index 41901997c0d6..a75146f600cb 100644
> > > --- a/drivers/tty/hvc/hvsi.c
> > > +++ b/drivers/tty/hvc/hvsi.c
> > > @@ -240,9 +240,9 @@ static void hvsi_recv_control(struct
> > > hvsi_struct *hp, uint8_t *packet,
> > > {
> > > struct hvsi_control *header = (struct hvsi_control
> > > *)packet;
> > >
> > > - switch (header->verb) {
> > > + switch (be16_to_cpu(header->verb)) {
> > > case VSV_MODEM_CTL_UPDATE:
> > > - if ((header->word & HVSI_TSCD) == 0) {
> > > + if ((be32_to_cpu(header->word) &
> > > HVSI_TSCD) == 0) {
> >
> > It is generally best to byteswap constants.
> >
> > David
>
> Thanks David for your review.
> Regarding the byte swapping of the constants, I'm wondering if this
> the
> best way here.
> For instance, Benjamin wrote a similar patch to fix another
> endianness
> issue (99fc1d91b8fc) and he doesn't convert the constant neither.
> It think that byte swapping the constant value will impact more code,
> and may not ease code reading.
Right, I disagree with byteswapping the constants at their definition
point, however maybe he meant using cpu_to_be16(CONSTANT) ?
In any case, it's pretty moot as we have the lhbrx instruction which
will do the load and byteswap and for HVSI, even if it was a tad slower
than a normal load, it would not make a noticeable difference.
Ben.
next prev parent reply other threads:[~2015-08-19 21:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-31 9:29 [PATCH] powerpc/hvsi: Fix endianness issues in the HVSI driver Laurent Dufour
2015-08-03 11:00 ` David Laight
2015-08-03 11:00 ` David Laight
2015-08-19 21:37 ` Laurent Dufour
2015-08-19 21:50 ` Benjamin Herrenschmidt [this message]
2015-08-04 0:51 ` Michael Ellerman
2015-08-19 21:53 ` Laurent Dufour
2015-08-20 1:40 ` Michael Ellerman
2015-08-20 4:20 ` Michael Ellerman
2015-08-21 7:43 ` Michael Ellerman
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=1440021013.2737.14.camel@kernel.crashing.org \
--to=benh@kernel.crashing.org \
--cc=David.Laight@ACULAB.COM \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.cz \
--cc=ldufour@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.