All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Cc: linux-arm-kernel@lists.infradead.org,
	Will Deacon <will.deacon@arm.com>,
	"bhelgaas@google.com" <bhelgaas@google.com>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	Liviu Dudau <Liviu.Dudau@arm.com>,
	"mohit.kumar@st.com" <mohit.kumar@st.com>
Subject: Re: [PATCH 2/3] PCI: ARM: add support for virtual PCI host controller
Date: Thu, 6 Feb 2014 09:28:52 +0100	[thread overview]
Message-ID: <201402060928.53310.arnd@arndb.de> (raw)
In-Reply-To: <20140205205319.GH25695@obsidianresearch.com>

On Wednesday 05 February 2014, Jason Gunthorpe wrote:
> On Wed, Feb 05, 2014 at 09:26:17PM +0100, Arnd Bergmann wrote:
> > > > What you get out of "of_pci_range_to_resource(&range, np, &pci->io)"
> > > > is not the resource you want to pass into pci_add_resource()
> > > > later.
> 
> Right, of_pci_range_to_resource returns the CPU MMIO address. A big
> problem here is that struct resource is being re-used for bus
> physical, CPU MMIO, and Linux Driver addressing domains without any
> helpful tagging.
> 
> typedef struct resource resource_bus;
> typedef struct resource resource_cpu;
> 
> ?

I fear the resource management needs a bigger overhaul than than.
Most importantly, 'struct resource' is not connected to 'struct device'
at the moment, and it only deals with resource types that were around
15 years ago.

> > > Do I need to open-code the resource translation from phys -> logical?
> > 
> > I think we should have some common infrastructure that lets you
> > get this right more easily.
> 
> The offset stuff seems to be very confusing to people, removing it
> from the APIs and forcing drivers to talk about bus addresess, CPU
> addresses and internal Linux addresses seems a bit more plain?

Interesting idea. I'm not sure how Bjorn will like that
after he just did an overhaul of all users of the offset
API some time ago, but let's see what he thinks.

> What do you think about something like this:
> 
> int of_pci_alloc_io(.. resources,
>                     struct of_pci_range *range,
>                     struct device_node *np)
> {
>   struct resource bus_address, mmio_window, res;
> 
>   bus_address.start = range->pci_addr;
>   bus_address.end = range->pci_addr + range->size - 1;
> 
>   mmio_window.start = range->cpu_addr;
>   mmio_window.end = range->cpu_addr + range->size - 1;
> 
>   /* Input bus_address - addresses seen on the bus
>            mmio_window - physical CPU address to create the bus
> 	   	         addreses
>      Output res - Address suitable for use in drivers
>      This does the pci_ioremap_io too */
>   pci_alloc_virtual_io_window(&bus_address, &mmio_window, &res);
> 
>   /* bus_address - addresses seen on the bus
>      res - matching driver view for the bus addresses */
>   pci_add_resource_bus(&resources, &bus_address, &res);
> }
> 
> And a similar function for MMIO that just omits
> pci_alloc_virtual_io_window.

It certainly seems workable. OTOH if we just manage to do a
helper that scans the OF ranges, allocates the I/O window,
remaps it and calls the existing pci_add_resource_offset()
helper, PCI host drivers don't need to worry about the
io_offsets computation either and just need to pull out the
correct window locations if they need to set up the hardware
translation windows (which I'd hope we can often let the boot
loader take care of).

	Arnd

WARNING: multiple messages have this Message-ID (diff)
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/3] PCI: ARM: add support for virtual PCI host controller
Date: Thu, 6 Feb 2014 09:28:52 +0100	[thread overview]
Message-ID: <201402060928.53310.arnd@arndb.de> (raw)
In-Reply-To: <20140205205319.GH25695@obsidianresearch.com>

On Wednesday 05 February 2014, Jason Gunthorpe wrote:
> On Wed, Feb 05, 2014 at 09:26:17PM +0100, Arnd Bergmann wrote:
> > > > What you get out of "of_pci_range_to_resource(&range, np, &pci->io)"
> > > > is not the resource you want to pass into pci_add_resource()
> > > > later.
> 
> Right, of_pci_range_to_resource returns the CPU MMIO address. A big
> problem here is that struct resource is being re-used for bus
> physical, CPU MMIO, and Linux Driver addressing domains without any
> helpful tagging.
> 
> typedef struct resource resource_bus;
> typedef struct resource resource_cpu;
> 
> ?

I fear the resource management needs a bigger overhaul than than.
Most importantly, 'struct resource' is not connected to 'struct device'
at the moment, and it only deals with resource types that were around
15 years ago.

> > > Do I need to open-code the resource translation from phys -> logical?
> > 
> > I think we should have some common infrastructure that lets you
> > get this right more easily.
> 
> The offset stuff seems to be very confusing to people, removing it
> from the APIs and forcing drivers to talk about bus addresess, CPU
> addresses and internal Linux addresses seems a bit more plain?

Interesting idea. I'm not sure how Bjorn will like that
after he just did an overhaul of all users of the offset
API some time ago, but let's see what he thinks.

> What do you think about something like this:
> 
> int of_pci_alloc_io(.. resources,
>                     struct of_pci_range *range,
>                     struct device_node *np)
> {
>   struct resource bus_address, mmio_window, res;
> 
>   bus_address.start = range->pci_addr;
>   bus_address.end = range->pci_addr + range->size - 1;
> 
>   mmio_window.start = range->cpu_addr;
>   mmio_window.end = range->cpu_addr + range->size - 1;
> 
>   /* Input bus_address - addresses seen on the bus
>            mmio_window - physical CPU address to create the bus
> 	   	         addreses
>      Output res - Address suitable for use in drivers
>      This does the pci_ioremap_io too */
>   pci_alloc_virtual_io_window(&bus_address, &mmio_window, &res);
> 
>   /* bus_address - addresses seen on the bus
>      res - matching driver view for the bus addresses */
>   pci_add_resource_bus(&resources, &bus_address, &res);
> }
> 
> And a similar function for MMIO that just omits
> pci_alloc_virtual_io_window.

It certainly seems workable. OTOH if we just manage to do a
helper that scans the OF ranges, allocates the I/O window,
remaps it and calls the existing pci_add_resource_offset()
helper, PCI host drivers don't need to worry about the
io_offsets computation either and just need to pull out the
correct window locations if they need to set up the hardware
translation windows (which I'd hope we can often let the boot
loader take care of).

	Arnd

  reply	other threads:[~2014-02-06  8:29 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-04 16:53 [PATCH 0/3] ARM: PCI: implement virtual PCI host controller Will Deacon
2014-02-04 16:53 ` Will Deacon
2014-02-04 16:53 ` [PATCH 1/3] ARM: bios32: use pci_enable_resource to enable PCI resources Will Deacon
2014-02-04 16:53   ` Will Deacon
2014-02-12  1:06   ` Bjorn Helgaas
2014-02-12  1:06     ` Bjorn Helgaas
2014-02-12 16:18     ` Will Deacon
2014-02-12 16:18       ` Will Deacon
2014-02-04 16:53 ` [PATCH 2/3] PCI: ARM: add support for virtual PCI host controller Will Deacon
2014-02-04 16:53   ` Will Deacon
2014-02-04 19:13   ` Arnd Bergmann
2014-02-04 19:13     ` Arnd Bergmann
2014-02-05 19:09     ` Will Deacon
2014-02-05 19:09       ` Will Deacon
2014-02-05 19:27       ` Jason Gunthorpe
2014-02-05 19:27         ` Jason Gunthorpe
2014-02-05 19:41         ` Peter Maydell
2014-02-05 19:41           ` Peter Maydell
2014-02-05 20:26       ` Arnd Bergmann
2014-02-05 20:26         ` Arnd Bergmann
2014-02-05 20:53         ` Jason Gunthorpe
2014-02-05 20:53           ` Jason Gunthorpe
2014-02-06  8:28           ` Arnd Bergmann [this message]
2014-02-06  8:28             ` Arnd Bergmann
2014-02-06 20:31             ` Russell King - ARM Linux
2014-02-06 20:31               ` Russell King - ARM Linux
2014-02-09 20:18               ` Arnd Bergmann
2014-02-09 20:18                 ` Arnd Bergmann
2014-02-09 20:34                 ` Russell King - ARM Linux
2014-02-09 20:34                   ` Russell King - ARM Linux
2014-02-11 19:15                   ` Arnd Bergmann
2014-02-11 19:15                     ` Arnd Bergmann
2014-02-07 11:46         ` Will Deacon
2014-02-07 11:46           ` Will Deacon
2014-02-07 17:54           ` Jason Gunthorpe
2014-02-07 17:54             ` Jason Gunthorpe
2014-02-12 18:10             ` Will Deacon
2014-02-12 18:10               ` Will Deacon
2014-02-12 18:19               ` Jason Gunthorpe
2014-02-12 18:19                 ` Jason Gunthorpe
2014-02-12 18:21                 ` Will Deacon
2014-02-12 18:21                   ` Will Deacon
2014-02-09 20:30           ` Arnd Bergmann
2014-02-09 20:30             ` Arnd Bergmann
2014-02-10 17:34             ` Jason Gunthorpe
2014-02-10 17:34               ` Jason Gunthorpe
2014-02-11 10:42               ` Arnd Bergmann
2014-02-11 10:42                 ` Arnd Bergmann
2014-02-12 19:43                 ` Jason Gunthorpe
2014-02-12 19:43                   ` Jason Gunthorpe
2014-02-12 20:07                   ` Arnd Bergmann
2014-02-12 20:07                     ` Arnd Bergmann
2014-02-12 20:33                     ` Bjorn Helgaas
2014-02-12 20:33                       ` Bjorn Helgaas
2014-02-12 21:15                   ` Thomas Petazzoni
2014-02-12 21:15                     ` Thomas Petazzoni
2014-02-12 22:24                     ` Jason Gunthorpe
2014-02-12 22:24                       ` Jason Gunthorpe
2014-02-12 19:49                 ` Will Deacon
2014-02-12 19:49                   ` Will Deacon
2014-02-06  8:54   ` Anup Patel
2014-02-06  8:54     ` Anup Patel
2014-02-06 10:26     ` Arnd Bergmann
2014-02-06 10:26       ` Arnd Bergmann
2014-02-06 10:52       ` Anup Patel
2014-02-06 10:52         ` Anup Patel
2014-02-06 10:54     ` Liviu Dudau
2014-02-06 10:54       ` Liviu Dudau
2014-02-06 11:00       ` Will Deacon
2014-02-06 11:00         ` Will Deacon
2014-02-06 11:28         ` Arnd Bergmann
2014-02-06 11:28           ` Arnd Bergmann
2014-02-04 16:53 ` [PATCH 3/3] ARM: mach-virt: allow PCI support to be selected Will Deacon
2014-02-04 16:53   ` Will Deacon
2014-04-03 22:07 ` [PATCH 0/3] ARM: PCI: implement virtual PCI host controller Bjorn Helgaas
2014-04-03 22:07   ` Bjorn Helgaas
2014-04-14 17:13   ` Will Deacon
2014-04-14 17:13     ` Will Deacon
2014-04-14 18:48     ` Arnd Bergmann
2014-04-14 18:48       ` Arnd Bergmann
2014-04-15 14:47       ` Will Deacon
2014-04-15 14:47         ` Will Deacon
2014-04-15 15:26         ` Arnd Bergmann
2014-04-15 15:26           ` Arnd Bergmann
2014-04-16 13:58           ` Will Deacon
2014-04-16 13:58             ` Will Deacon

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=201402060928.53310.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=Liviu.Dudau@arm.com \
    --cc=bhelgaas@google.com \
    --cc=jgunthorpe@obsidianresearch.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mohit.kumar@st.com \
    --cc=will.deacon@arm.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.