LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Cc: tsbogend@alpha.franken.de, bhelgaas@google.com,
	matthias.bgg@gmail.com, gregkh@linuxfoundation.org,
	linux-mips@vger.kernel.org, linux-pci@vger.kernel.org,
	linux-staging@lists.linux.dev, neil@brown.name,
	linux-kernel@vger.kernel.org, Liviu Dudau <Liviu.Dudau@arm.com>,
	Rob Herring <robh@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH v2 2/3] PCI: fix 'pci_remap_iospace' for architectures with PCI_IOBASE not defined
Date: Tue, 21 Sep 2021 12:49:24 -0500	[thread overview]
Message-ID: <20210921174924.GA104830@bhelgaas> (raw)
In-Reply-To: <20210822161005.22467-3-sergio.paracuellos@gmail.com>

[+cc Liviu, Rob, Catalin, Arnd, since this warning was added by
8b921acfeffd ("PCI: Add pci_remap_iospace() to map bus I/O resources"),
https://git.kernel.org/linus/8b921acfeffd]

On Sun, Aug 22, 2021 at 06:10:04PM +0200, Sergio Paracuellos wrote:
> Request for I/O resources from device tree call 'pci_remap_iospace' from
> 'devm_pci_remap_iospace' which is also called from device tree function
> 'pci_parse_request_of_pci_ranges'. if PCI_IOBASE is not defined and I/O
> resources are requested the following warning appears:
> 
> ------------[ cut here ]------------
> WARNING: CPU: 2 PID: 1 at ../drivers/pci/pci.c:4066 pci_remap_iospace+0x3c/0x54
> This architecture does not support memory mapped I/O
> Modules linked in:
> CPU: 2 PID: 1 Comm: swapper/0 Not tainted 5.10.1+ #1228
> Stack : 00000000 00000000 807fa974 00000000 827ffa80 80066b48 80710000 0000000b
>         00000000 00000000 81c59aac 7d06ddec 80850000 00000001 81c59a40 7d06ddec
>         00000000 00000000 807c909c 81c598f0 00000001 81c59904 00000000 0000000a
>         203a6d6d 80708880 0000000f 70617773 80850000 00000000 00000000 807d0000
>         807ffecc 1e160000 00000001 00000200 00000000 8054e920 00000008 815e0008
>         ...
> Call Trace:
> [<80008efc>] show_stack+0x8c/0x130
> [<806e1674>] dump_stack+0x9c/0xc8
> [<80024a3c>] __warn+0xc0/0xe8
> [<80024ad0>] warn_slowpath_fmt+0x6c/0xbc
> [<80410ca8>] pci_remap_iospace+0x3c/0x54
> [<80410d20>] devm_pci_remap_iospace+0x58/0xa4
> [<8042019c>] devm_of_pci_bridge_init+0x4dc/0x55c
> [<80408de8>] devm_pci_alloc_host_bridge+0x78/0x88
> [<80424e44>] mt7621_pci_probe+0x68/0x9a4
> [<80464804>] platform_drv_probe+0x40/0x7c
> [<804628bc>] really_probe+0x2fc/0x4e4
> [<80463214>] device_driver_attach+0x4c/0x74
> [<80463384>] __driver_attach+0x148/0x150
> [<8046047c>] bus_for_each_dev+0x6c/0xb0
> [<804614dc>] bus_add_driver+0x1b4/0x1fc
> [<80463aa0>] driver_register+0xd0/0x110
> [<80001714>] do_one_initcall+0x84/0x1c0
> [<808e7fd0>] kernel_init_freeable+0x214/0x24c
> [<806e4164>] kernel_init+0x14/0x118
> [<80003358>] ret_from_kernel_thread+0x14/0x1c
> 
> ---[ end trace 1c9d4412bd51b53c ]---
> mt7621-pci 1e140000.pcie: error -19: failed to map resource [io  0x1e160000-0x1e16ffff]
> 
> Since there are architectures (like MIPS ralink) that can request I/O
> resources from device tree but have not mapeable I/O space and also PCI_IOBASE
> not defined, avoid this warning and just return zero to make the I/O ranges
> assignment work.
> 
> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
> ---
>  drivers/pci/pci.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index aacf575c15cf..10bb2191f376 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -4102,9 +4102,9 @@ unsigned long __weak pci_address_to_pio(phys_addr_t address)
>   * @phys_addr: physical address of range to be mapped
>   *
>   * Remap the memory mapped I/O space described by the @res and the CPU
> - * physical address @phys_addr into virtual address space.  Only
> - * architectures that have memory mapped IO functions defined (and the
> - * PCI_IOBASE value defined) should call this function.
> + * physical address @phys_addr into virtual address space. There
> + * are architectures that don't define PCI_IOBASE but can have not
> + * mapeable IO space. Return zero for those cases.
>   */
>  int pci_remap_iospace(const struct resource *res, phys_addr_t phys_addr)
>  {
> @@ -4122,10 +4122,10 @@ int pci_remap_iospace(const struct resource *res, phys_addr_t phys_addr)
>  #else
>  	/*
>  	 * This architecture does not have memory mapped I/O space,
> -	 * so this function should never be called
> +	 * but can have not mapeable I/O space, so just return ok
> +	 * here.
>  	 */
> -	WARN_ONCE(1, "This architecture does not support memory mapped I/O\n");
> -	return -ENODEV;
> +	return 0;

This doesn't seem right to me.  pci_remap_iospace() remaps
memory-mapped I/O space into virtual address space.

If the architecture doesn't support that remapping, we shouldn't claim
that it succeeded.

The analogous path for ACPI is in acpi_pci_root_remap_iospace(), where
we only call pci_remap_iospace() if PCI_IOBASE is defined.  Maybe we
should use the same approach here, i.e., add the corresonding #ifdef
in pci_parse_request_of_pci_ranges()?

>  #endif
>  }
>  EXPORT_SYMBOL(pci_remap_iospace);
> -- 
> 2.25.1
> 

  parent reply	other threads:[~2021-09-21 17:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-22 16:10 [PATCH v2 0/3] MIPS: ralink: properly handle pci IO resources Sergio Paracuellos
2021-08-22 16:10 ` [PATCH v2 1/3] MIPS: ralink: don't define PC_IOBASE but increase IO_SPACE_LIMIT Sergio Paracuellos
2021-09-02 11:08   ` Thomas Bogendoerfer
2021-08-22 16:10 ` [PATCH v2 2/3] PCI: fix 'pci_remap_iospace' for architectures with PCI_IOBASE not defined Sergio Paracuellos
2021-09-15 10:52   ` Sergio Paracuellos
2021-09-21 17:49   ` Bjorn Helgaas [this message]
2021-09-21 18:36     ` Sergio Paracuellos
2021-09-21 19:38       ` Bjorn Helgaas
2021-09-22  4:28         ` Sergio Paracuellos
2021-08-22 16:10 ` [PATCH v2 3/3] staging: mt7621-pci: set end limit for 'ioport_resource' Sergio Paracuellos
2021-08-27  9:01   ` Greg KH
2021-08-29 15:14     ` Sergio Paracuellos
2021-09-02  9:15       ` Greg KH
2021-09-02 10:15         ` Sergio Paracuellos
2021-09-02 11:08           ` Thomas Bogendoerfer
2021-09-02 11:19             ` Sergio Paracuellos
2021-09-21 15:28               ` Greg KH
2021-09-21 17:02                 ` Sergio Paracuellos
2021-09-21 17:08                   ` Greg KH

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=20210921174924.GA104830@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=Liviu.Dudau@arm.com \
    --cc=arnd@arndb.de \
    --cc=bhelgaas@google.com \
    --cc=catalin.marinas@arm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=matthias.bgg@gmail.com \
    --cc=neil@brown.name \
    --cc=robh@kernel.org \
    --cc=sergio.paracuellos@gmail.com \
    --cc=tsbogend@alpha.franken.de \
    --subject='Re: [PATCH v2 2/3] PCI: fix '\''pci_remap_iospace'\'' for architectures with PCI_IOBASE not defined' \
    /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

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).