From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: Grzegorz Jaszczyk <jaz@semihalf.com>
Cc: lorenzo.pieralisi@arm.com, bhelgaas@google.com,
linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
mw@semihalf.com,
Russell King - ARM Linux admin <linux@armlinux.org.uk>
Subject: Re: [PATCH] PCI: aardvark: fix big endian support
Date: Mon, 15 Jul 2019 17:08:40 +0200 [thread overview]
Message-ID: <20190715170840.326acd73@windsurf> (raw)
In-Reply-To: <1563200122-8323-1-git-send-email-jaz@semihalf.com>
Hello Grzegorz,
Thanks for this work. I indeed never tested this code on BE platforms,
and it is very possible that I overlooked endianness issues, so thanks
for having a look at this and proposing some patches. See some
questions/comments below.
On Mon, 15 Jul 2019 16:15:22 +0200
Grzegorz Jaszczyk <jaz@semihalf.com> wrote:
> Initialise every not-byte wide fields of emulated pci bridge config
> space with proper cpu_to_le* macro. This is required since the structure
> describing config space of emulated bridge assumes little-endian
> convention.
>
> Signed-off-by: Grzegorz Jaszczyk <jaz@semihalf.com>
> ---
> drivers/pci/controller/pci-aardvark.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c
> index 134e030..06a12749 100644
> --- a/drivers/pci/controller/pci-aardvark.c
> +++ b/drivers/pci/controller/pci-aardvark.c
> @@ -479,8 +479,10 @@ static void advk_sw_pci_bridge_init(struct advk_pcie *pcie)
> {
> struct pci_bridge_emul *bridge = &pcie->bridge;
>
> - bridge->conf.vendor = advk_readl(pcie, PCIE_CORE_DEV_ID_REG) & 0xffff;
> - bridge->conf.device = advk_readl(pcie, PCIE_CORE_DEV_ID_REG) >> 16;
> + bridge->conf.vendor =
> + cpu_to_le16(advk_readl(pcie, PCIE_CORE_DEV_ID_REG) & 0xffff);
> + bridge->conf.device =
> + cpu_to_le16(advk_readl(pcie, PCIE_CORE_DEV_ID_REG) >> 16);
> bridge->conf.class_revision =
> advk_readl(pcie, PCIE_CORE_DEV_REV_REG) & 0xff;
So conf.vendor and conf.device and stored as little-endian in the
emulated config address space, but conf.class_revision is stored in the
CPU endianness ?
>
> @@ -489,8 +491,8 @@ static void advk_sw_pci_bridge_init(struct advk_pcie *pcie)
> bridge->conf.iolimit = PCI_IO_RANGE_TYPE_32;
>
> /* Support 64 bits memory pref */
> - bridge->conf.pref_mem_base = PCI_PREF_RANGE_TYPE_64;
> - bridge->conf.pref_mem_limit = PCI_PREF_RANGE_TYPE_64;
> + bridge->conf.pref_mem_base = cpu_to_le16(PCI_PREF_RANGE_TYPE_64);
> + bridge->conf.pref_mem_limit = cpu_to_le16(PCI_PREF_RANGE_TYPE_64);
Same here: why are conf.pref_mem_{base,limit} converted to LE, but not
conf.iolimit ?
Also, the advk_pci_bridge_emul_pcie_conf_read() and
advk_pci_bridge_emul_pcie_conf_write() return values that are in the
CPU endianness.
Am I missing something ?
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
WARNING: multiple messages have this Message-ID (diff)
From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: Grzegorz Jaszczyk <jaz@semihalf.com>
Cc: lorenzo.pieralisi@arm.com, linux-pci@vger.kernel.org,
Russell King - ARM Linux admin <linux@armlinux.org.uk>,
bhelgaas@google.com, mw@semihalf.com,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] PCI: aardvark: fix big endian support
Date: Mon, 15 Jul 2019 17:08:40 +0200 [thread overview]
Message-ID: <20190715170840.326acd73@windsurf> (raw)
In-Reply-To: <1563200122-8323-1-git-send-email-jaz@semihalf.com>
Hello Grzegorz,
Thanks for this work. I indeed never tested this code on BE platforms,
and it is very possible that I overlooked endianness issues, so thanks
for having a look at this and proposing some patches. See some
questions/comments below.
On Mon, 15 Jul 2019 16:15:22 +0200
Grzegorz Jaszczyk <jaz@semihalf.com> wrote:
> Initialise every not-byte wide fields of emulated pci bridge config
> space with proper cpu_to_le* macro. This is required since the structure
> describing config space of emulated bridge assumes little-endian
> convention.
>
> Signed-off-by: Grzegorz Jaszczyk <jaz@semihalf.com>
> ---
> drivers/pci/controller/pci-aardvark.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c
> index 134e030..06a12749 100644
> --- a/drivers/pci/controller/pci-aardvark.c
> +++ b/drivers/pci/controller/pci-aardvark.c
> @@ -479,8 +479,10 @@ static void advk_sw_pci_bridge_init(struct advk_pcie *pcie)
> {
> struct pci_bridge_emul *bridge = &pcie->bridge;
>
> - bridge->conf.vendor = advk_readl(pcie, PCIE_CORE_DEV_ID_REG) & 0xffff;
> - bridge->conf.device = advk_readl(pcie, PCIE_CORE_DEV_ID_REG) >> 16;
> + bridge->conf.vendor =
> + cpu_to_le16(advk_readl(pcie, PCIE_CORE_DEV_ID_REG) & 0xffff);
> + bridge->conf.device =
> + cpu_to_le16(advk_readl(pcie, PCIE_CORE_DEV_ID_REG) >> 16);
> bridge->conf.class_revision =
> advk_readl(pcie, PCIE_CORE_DEV_REV_REG) & 0xff;
So conf.vendor and conf.device and stored as little-endian in the
emulated config address space, but conf.class_revision is stored in the
CPU endianness ?
>
> @@ -489,8 +491,8 @@ static void advk_sw_pci_bridge_init(struct advk_pcie *pcie)
> bridge->conf.iolimit = PCI_IO_RANGE_TYPE_32;
>
> /* Support 64 bits memory pref */
> - bridge->conf.pref_mem_base = PCI_PREF_RANGE_TYPE_64;
> - bridge->conf.pref_mem_limit = PCI_PREF_RANGE_TYPE_64;
> + bridge->conf.pref_mem_base = cpu_to_le16(PCI_PREF_RANGE_TYPE_64);
> + bridge->conf.pref_mem_limit = cpu_to_le16(PCI_PREF_RANGE_TYPE_64);
Same here: why are conf.pref_mem_{base,limit} converted to LE, but not
conf.iolimit ?
Also, the advk_pci_bridge_emul_pcie_conf_read() and
advk_pci_bridge_emul_pcie_conf_write() return values that are in the
CPU endianness.
Am I missing something ?
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-07-15 15:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-15 14:15 [PATCH] PCI: aardvark: fix big endian support Grzegorz Jaszczyk
2019-07-15 14:15 ` Grzegorz Jaszczyk
2019-07-15 15:08 ` Thomas Petazzoni [this message]
2019-07-15 15:08 ` Thomas Petazzoni
2019-07-15 15:10 ` Russell King - ARM Linux admin
2019-07-15 15:10 ` Russell King - ARM Linux admin
2019-07-16 6:32 ` Thomas Petazzoni
2019-07-16 6:32 ` Thomas Petazzoni
2019-07-16 8:56 ` Russell King - ARM Linux admin
2019-07-16 8:56 ` Russell King - ARM Linux admin
2019-07-16 8:31 ` Grzegorz Jaszczyk
2019-07-16 8:31 ` Grzegorz Jaszczyk
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=20190715170840.326acd73@windsurf \
--to=thomas.petazzoni@bootlin.com \
--cc=bhelgaas@google.com \
--cc=jaz@semihalf.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lorenzo.pieralisi@arm.com \
--cc=mw@semihalf.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 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.