From: "Oliver O'Halloran" <oohall@gmail.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: qemu-ppc@nongnu.org, "Cédric Le Goater" <clg@kaod.org>,
"Nicholas Piggin" <npiggin@gmail.com>,
qemu-devel@nongnu.org
Subject: Re: [PATCH 1/2] ppc/pnv: Add models for POWER9 PHB4 PCIe Host bridge
Date: Wed, 29 Jan 2020 14:54:19 +1100 [thread overview]
Message-ID: <CAOSf1CHvYOMd2cjQDLT44QxyQakkV6a8eBrWX+V6FhQMQh2GWA@mail.gmail.com> (raw)
In-Reply-To: <20200129030920.GX42099@umbus.fritz.box>
On Wed, Jan 29, 2020 at 2:09 PM David Gibson
<david@gibson.dropbear.id.au> wrote:
>
> On Mon, Jan 27, 2020 at 03:45:05PM +0100, Cédric Le Goater wrote:
> > From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> >
*snip*
> > +
> > +/*
> > + * The CONFIG_DATA register expects little endian accesses, but as the
> > + * region is big endian, we have to swap the value.
> > + */
> > +static void pnv_phb4_config_write(PnvPHB4 *phb, unsigned off,
> > + unsigned size, uint64_t val)
> > +{
> > + uint32_t cfg_addr, limit;
> > + PCIDevice *pdev;
> > +
> > + pdev = pnv_phb4_find_cfg_dev(phb);
> > + if (!pdev) {
> > + return;
> > + }
> > + cfg_addr = (phb->regs[PHB_CONFIG_ADDRESS >> 3] >> 32) & 0xffc;
> > + cfg_addr |= off;
> > + limit = pci_config_size(pdev);
> > + if (limit <= cfg_addr) {
> > + /*
> > + * conventional pci device can be behind pcie-to-pci bridge.
> > + * 256 <= addr < 4K has no effects.
> > + */
> > + return;
> > + }
> > + switch (size) {
> > + case 1:
> > + break;
> > + case 2:
> > + val = bswap16(val);
>
> I'm a little confused by these byteswaps. As I see below the device
> is set to big endian, so the values passed in here should already be
> in host-native endian. Why do you need the swap? Are some of the
> registers in the bank BE and some LE?
All the registers are BE except for CONFIG_DATA, which isn't actually
a register. It's really a window into the config space of the device
specified in CONFIG_ADDR so it doesn't do any byte-swapping.
> > + break;
> > + case 4:
> > + val = bswap32(val);
> > + break;
> > + default:
> > + g_assert_not_reached();
> > + }
> > + pci_host_config_write_common(pdev, cfg_addr, limit, val, size);
> > +}
next prev parent reply other threads:[~2020-01-29 4:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-27 14:45 [PATCH 0/2] ppc/pnv: Add models for PHB4 and PHB3 PCIe Host bridges Cédric Le Goater
2020-01-27 14:45 ` [PATCH 1/2] ppc/pnv: Add models for POWER9 PHB4 PCIe Host bridge Cédric Le Goater
2020-01-29 3:09 ` David Gibson
2020-01-29 3:54 ` Oliver O'Halloran [this message]
2020-01-29 6:16 ` David Gibson
2020-01-27 14:45 ` [PATCH 2/2] ppc/pnv: Add models for POWER8 PHB3 " Cédric Le Goater
2020-01-29 6:31 ` [PATCH 0/2] ppc/pnv: Add models for PHB4 and PHB3 PCIe Host bridges David Gibson
2020-01-29 13:15 ` Cédric Le Goater
2020-01-29 22:14 ` David Gibson
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=CAOSf1CHvYOMd2cjQDLT44QxyQakkV6a8eBrWX+V6FhQMQh2GWA@mail.gmail.com \
--to=oohall@gmail.com \
--cc=clg@kaod.org \
--cc=david@gibson.dropbear.id.au \
--cc=npiggin@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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).