qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <dwg@au1.ibm.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] xhci: Fix some DMA host endian bugs
Date: Fri, 2 Nov 2012 19:43:03 +1100	[thread overview]
Message-ID: <20121102084303.GR27695@truffula.fritz.box> (raw)
In-Reply-To: <509376CB.8000905@redhat.com>

On Fri, Nov 02, 2012 at 08:31:23AM +0100, Gerd Hoffmann wrote:
>   Hi,
> 
> > +static inline void xhci_dma_write_u32s(XHCIState *xhci, dma_addr_t addr,
> > +                                       uint32_t *buf, size_t len)
> > +{
> > +    int i;
> > +
> > +    for (i = 0; i < (len / sizeof(uint32_t)); i++) {
> > +        buf[i] = cpu_to_le32(buf[i]);
> > +    }
> > +    pci_dma_write(&xhci->pci_dev, addr, buf, len);
> > +}
> 
> I think we should use a temporary buffer here, otherwise you leave the
> values byteswapped in buf which likely has unwanted side effects.

Yeah, I wondered about that.  I did check that the side-effect doesn't
matter in any of the existing callers, so I left it that way to avoid
the extra copies.  But you're right, it's a pretty subtle constraint
that could easily be broken by future changes.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

  reply	other threads:[~2012-11-02  8:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-02  2:32 [Qemu-devel] [PATCH] xhci: Fix some DMA host endian bugs David Gibson
2012-11-02  7:31 ` Gerd Hoffmann
2012-11-02  8:43   ` David Gibson [this message]
2012-11-05  4:20   ` David Gibson
2012-11-05 10:20     ` Gerd Hoffmann
2012-11-08 15:08       ` [Qemu-devel] xhci and ehci qemu emulation performance Stefano Panella
2012-11-08 15:20         ` Gerd Hoffmann
2012-11-08 15:32           ` Stefano Panella
2012-11-08 18:26             ` Gerd Hoffmann

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=20121102084303.GR27695@truffula.fritz.box \
    --to=dwg@au1.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.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).