From: "Jiaxun Yang" <jiaxun.yang@flygoat.com>
To: "Arnd Bergmann" <arnd@arndb.de>,
"Thomas Bogendoerfer" <tsbogend@alpha.franken.de>,
"Baoquan He" <bhe@redhat.com>
Cc: "linux-mips@vger.kernel.org" <linux-mips@vger.kernel.org>,
linux-kernel@vger.kernel.org,
"stable@vger.kernel.org" <stable@vger.kernel.org>,
"Mateusz Jończyk" <mat.jonczyk@o2.pl>
Subject: Re: [PATCH] MIPS: pci-legacy: Override pci_address_to_pio
Date: Wed, 15 Jan 2025 09:26:11 +0000 [thread overview]
Message-ID: <11e402c9-ea38-4132-9ab6-0bd346a82c88@app.fastmail.com> (raw)
In-Reply-To: <23f46c23-a58e-4a85-8733-480b5ebf993b@app.fastmail.com>
在2025年1月15日一月 上午7:38,Arnd Bergmann写道:
[...]
>
> Where "range->cpu_addr" is the phys_addr_t location of the
> MMIO window that maps the host controllers port ranges, i.e.
> the fully translated address from the "ranges" property.
This is valid for MIPS's PCI_DRIVERS_GENERIC, but not for PCI_DRIVERS_LEGACY,
which have it's own implementation of various functions. See
arch/mips/pci/pci-legacy.c, pci_load_of_ranges. The address translation
is handled by io_map_base, which usually comes from mips_io_port_base.
>
> The point of the pci_address_to_pio() function is to convert
> this into the Linux-internal virtual port number that gets
> used as an argument to inb()/outb() and reported in
> /proc/ioports and that may or may not be the same as the
> address on the bus itself, depending on the how the translation
> gets set up.
>
> On loongson, we seem to have two port ranges that are set up
> like
>
> isa@18000000 {
> compatible = "isa";
> ranges = <1 0x0 0x0 0x18000000 0x4000>;
> };
>
> pci@1a000000 {
> ranges = <0x01000000 0x0 0x00020000 0x0
> 0x18020000 0x0 0x00020000>,
> <0x02000000 0x0 0x40000000 0x0
> 0x40000000 0x0 0x40000000>;
> }
>
> Here, the cpu_addr is 0x18000000 for the isa bus and
> 0x18020000 for the PCI bus, apparently the intention being that
> these are consecutive in physical space, though Linux is free
> to rearrange the logical port numbers in a different way, e.g.
> to ensure that the PCI bus can use port numbers below 0x10000.
>
> On Malta, I see a very strange
>
> isa {
> compatible = "isa";
> ranges = <1 0 0 0x1000>;
> };
>
> which maps the first 4096 port numbers into cpu_addr=0x0. The
> actual port window appears to be at a board specific location
>
> #define MALTA_GT_PORT_BASE get_gt_port_base(GT_PCI0IOLD_OFS)
> #define MALTA_BONITO_PORT_BASE ((unsigned long)ioremap (0x1fd00000, 0x10000))
> #define MALTA_MSC_PORT_BASE get_msc_port_base(MSC01_PCI_SC2PIOBASL)
>
> So e.g. on Bonito, the ranges property would have to be
>
> ranges = <1 0 0x1fd00000 0x1000>;
>
> Not sure if this is patched in by the bootloader, or where the
> corresponding window for PCI gets defined, but I suspect that
> the reason for the regression is that the caller of
> pci_address_to_pio() accidentally passed in '0' instead of
> the physical address, and it happened to work because of the
> missing PCI_IOBASE definition but broke after that got defined.
Many other pci-legacy drivers are also working this way, PCI core
is not aware of virtual port to physical MMIO address mapping.
PCI core just see it as x86 style port.
Thanks
>
> Arnd
--
- Jiaxun
next prev parent reply other threads:[~2025-01-15 9:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-14 18:11 Jiaxun Yang
2025-01-14 18:42 ` Mateusz Jończyk
2025-01-14 18:51 ` Jiaxun Yang
2025-01-19 11:42 ` Mateusz Jończyk
2025-01-14 18:46 ` Greg KH
2025-01-14 18:55 ` Jiaxun Yang
2025-01-14 19:03 ` Arnd Bergmann
2025-01-14 19:20 ` Jiaxun Yang
2025-01-15 7:38 ` Arnd Bergmann
2025-01-15 8:57 ` Maciej W. Rozycki
2025-01-15 9:26 ` Jiaxun Yang [this message]
2025-01-20 19:41 ` Thomas Bogendoerfer
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=11e402c9-ea38-4132-9ab6-0bd346a82c88@app.fastmail.com \
--to=jiaxun.yang@flygoat.com \
--cc=arnd@arndb.de \
--cc=bhe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=mat.jonczyk@o2.pl \
--cc=stable@vger.kernel.org \
--cc=tsbogend@alpha.franken.de \
/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
all inboxes | Powered by JetHome®