From: Liviu Dudau <Liviu.Dudau@arm.com>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: linux-pci <linux-pci@vger.kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Catalin Marinas <Catalin.Marinas@arm.com>,
Will Deacon <Will.Deacon@arm.com>,
linaro-kernel <linaro-kernel@lists.linaro.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
Arnd Bergmann <arnd@arndb.de>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
LKML <linux-kernel@vger.kernel.org>,
Tanmay Inamdar <tinamdar@apm.com>,
LAKML <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v6 1/3] Fix ioport_map() for !CONFIG_GENERIC_IOMAP cases.
Date: Thu, 6 Mar 2014 10:36:20 +0000 [thread overview]
Message-ID: <20140306103620.GB6457@e106497-lin.cambridge.arm.com> (raw)
In-Reply-To: <20140305233135.GZ21483@n2100.arm.linux.org.uk>
On Wed, Mar 05, 2014 at 11:31:35PM +0000, Russell King - ARM Linux wrote:
> On Wed, Mar 05, 2014 at 11:49:08AM +0000, Liviu Dudau wrote:
> > The inline version of ioport_map() that gets used when !CONFIG_GENERIC_IOMAP
> > is wrong. It returns a mapped (i.e. virtual) address that can start from
> > zero and completely ignores the PCI_IOBASE and IO_SPACE_LIMIT that most
> > architectures that use !CONFIG_GENERIC_MAP define.
>
> What value does PCI_IOBASE and IO_SPACE_LIMIT have on other architectures
> who make use of asm-generic/io.h ?
Hi Russell,
Sorry for being a bit opaque in the commit message, I probably conflated two
issues into one. The first issue is that ioport_map() is supposed to return
a virtual address for the IO port. I struggle to believe that a virtual address
of zero for IO is valid for most architectures other than x86. My guess is that
most of the architectures that you have listed as including asm-generic/io.h
have no support for PCI whatsoever. The other issue is that *if* you specify an
PCI_IOBASE and don't come up with your own version of ioport_map() then you
get the wrong virtual addresses back.
One way to fix all this is to use PCI_IOBASE inside the generic version and to
define it to a non-zero values for architectures that have memory mapped IO.
That should reduce the number of custom versions of ioport_map() that we currently
have.
The other implied message that I'm getting is that you are suggesting that the
commit message is generalising a bit too much? With that I agree, in light of
your analysis. I can change it to something like:
The inline version of ioport_map() that gets used for !CONFIG_GENERIC_IOMAP is
wrong when PCI_IOBASE has a non-zero value. The function is supposed to return
a virtual address for IO ports and for architectures that memory map the IO
areas that is giving incorrect results as it ignores PCI_IOBASE. Fix this and
also limit the port range to the IO_SPACE_LIMIT mask.
>
> $ git grep asm-generic/io.h arch/
> arch/arc/include/asm/io.h:#include <asm-generic/io.h>
> arch/blackfin/include/asm/io.h:#include <asm-generic/io.h>
> arch/metag/include/asm/io.h:#include <asm-generic/io.h>
> arch/microblaze/include/asm/io.h:/* from asm-generic/io.h */
> arch/openrisc/include/asm/io.h:#include <asm-generic/io.h>
> arch/s390/include/asm/io.h:#include <asm-generic/io.h>
> arch/score/include/asm/io.h:#include <asm-generic/io.h>
> arch/unicore32/include/asm/io.h:#include <asm-generic/io.h>
PCI_IOBASE = PKUNITY_PCILIO_BASE = PKUNITY_PCI_BASE + 0x00030000 =
io_p2v(0x80000000) + 0x00030000
All other ones bar arm64 are either happy with PCI_IOBASE being zero (proxy for
"no PCI support") or define their own version of ioport_map().
Best regards,
Liviu
> arch/xtensa/include/asm/io.h:#include <asm-generic/io.h>
> $ arch/arc/include/asm/io.h:#define PCI_IOBASE ((void __iomem *)0)
> arch/arm64/include/asm/io.h:#define PCI_IOBASE ((void __iomem *)(MODULES_VADDR - SZ_2M))
> arch/arm64/include/asm/io.h: return readb(addr + PCI_IOBASE);
> arch/arm64/include/asm/io.h: return readw(addr + PCI_IOBASE);
> arch/arm64/include/asm/io.h: return readl(addr + PCI_IOBASE);
> arch/arm64/include/asm/io.h: writeb(b, addr + PCI_IOBASE);
> arch/arm64/include/asm/io.h: writew(b, addr + PCI_IOBASE);
> arch/arm64/include/asm/io.h: writel(b, addr + PCI_IOBASE);
> arch/arm64/include/asm/io.h: *buf++ = __raw_readb(addr + PCI_IOBASE);
> arch/arm64/include/asm/io.h: *buf++ = __raw_readw(addr + PCI_IOBASE);
> arch/arm64/include/asm/io.h: *buf++ = __raw_readl(addr + PCI_IOBASE);
> arch/arm64/include/asm/io.h: __raw_writeb(*buf++, addr + PCI_IOBASE);
> arch/arm64/include/asm/io.h: __raw_writew(*buf++, addr + PCI_IOBASE);
> arch/arm64/include/asm/io.h: __raw_writel(*buf++, addr + PCI_IOBASE);
> arch/unicore32/include/asm/io.h:#define PCI_IOBASE PKUNITY_PCILIO_BASE
> arch/unicore32/include/asm/io.h:#define PIO_OFFSET (unsigned int)(PCI_IOBASE)
>
>
> --
> FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly
> improving, and getting towards what was expected from it.
>
--
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯
next prev parent reply other threads:[~2014-03-06 10:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-05 11:49 [PATCH v6 0/3] [RFC] Add support for PCI in AArch64 Liviu Dudau
2014-03-05 11:49 ` [PATCH v6 1/3] Fix ioport_map() for !CONFIG_GENERIC_IOMAP cases Liviu Dudau
2014-03-05 23:31 ` Russell King - ARM Linux
2014-03-06 10:36 ` Liviu Dudau [this message]
2014-03-07 0:37 ` Arnd Bergmann
2014-03-07 1:09 ` Russell King - ARM Linux
2014-03-07 1:44 ` Liviu Dudau
2014-03-14 11:54 ` Arnd Bergmann
2014-03-05 11:49 ` [PATCH v6 2/3] arm64: Extend the PCI I/O space to 16MB Liviu Dudau
2014-03-05 11:49 ` [PATCH v6 3/3] arm64: Add architecture support for PCI Liviu Dudau
2014-03-12 8:41 ` Jingoo Han
[not found] ` <000101cf3dce$df2c1840$9d8448c0$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2014-03-13 0:11 ` Liviu Dudau
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=20140306103620.GB6457@e106497-lin.cambridge.arm.com \
--to=liviu.dudau@arm.com \
--cc=Catalin.Marinas@arm.com \
--cc=Will.Deacon@arm.com \
--cc=arnd@arndb.de \
--cc=benh@kernel.crashing.org \
--cc=bhelgaas@google.com \
--cc=devicetree@vger.kernel.org \
--cc=linaro-kernel@lists.linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=tinamdar@apm.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).