All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org, linux-arch@vger.kernel.org
Subject: Re: [RFC PATCH v1 14/18] powerpc/PCI: get rid of device resource fixups
Date: Tue, 31 Jan 2012 07:49:04 +1100	[thread overview]
Message-ID: <1327956544.28487.47.camel@pasglop> (raw)
In-Reply-To: <20120130165820.3231.9878.stgit@bhelgaas.mtv.corp.google.com>

On Mon, 2012-01-30 at 09:58 -0700, Bjorn Helgaas wrote:
> Tell the PCI core about host bridge address translation so it can take
> care of bus-to-resource conversion for us.
> 
> N.B. powerpc used a 32-bit mask when converting IO addresses.  If we
> figure out the right offset, I think simple addition should do the
> same thing, but I might not have it exactly right yet.

Wow that's going to be a big change :-) A quick look... seems like you
do a per-resource offset right ? I will need that (was about to change
powerpc) as we have hardware that provides us with two different windows
to MMIO space with different offsets unfortunately.

One thing I also want to generalize is the whole "REASSIGN_ALL_RSRC"
flag, ie, avoid reading & printing all those resources we know we are
just going to kill off.

I'll try to test your stuff asap (I'm doing 3 things at once right now
so it might take a few days unless I find somebody to look at it).

Cheers,
Ben.

> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
>  arch/powerpc/include/asm/pci.h   |    8 ----
>  arch/powerpc/kernel/pci-common.c |   79 ++------------------------------------
>  2 files changed, 6 insertions(+), 81 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h
> index f54b3d2..839178b 100644
> --- a/arch/powerpc/include/asm/pci.h
> +++ b/arch/powerpc/include/asm/pci.h
> @@ -154,13 +154,7 @@ extern int pci_mmap_legacy_page_range(struct pci_bus *bus,
>  
>  #endif /* CONFIG_PPC64 */
>  
> -extern void pcibios_resource_to_bus(struct pci_dev *dev,
> -			struct pci_bus_region *region,
> -			struct resource *res);
> -
> -extern void pcibios_bus_to_resource(struct pci_dev *dev,
> -			struct resource *res,
> -			struct pci_bus_region *region);
> +#define ARCH_HAS_GENERIC_PCI_OFFSETS
>  
>  extern void pcibios_claim_one_bus(struct pci_bus *b);
>  
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index cce98d7..f0084c9 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -849,60 +849,6 @@ int pci_proc_domain(struct pci_bus *bus)
>  	return 1;
>  }
>  
> -void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
> -			     struct resource *res)
> -{
> -	resource_size_t offset = 0, mask = (resource_size_t)-1;
> -	struct pci_controller *hose = pci_bus_to_host(dev->bus);
> -
> -	if (!hose)
> -		return;
> -	if (res->flags & IORESOURCE_IO) {
> -		offset = (unsigned long)hose->io_base_virt - _IO_BASE;
> -		mask = 0xffffffffu;
> -	} else if (res->flags & IORESOURCE_MEM)
> -		offset = hose->pci_mem_offset;
> -
> -	region->start = (res->start - offset) & mask;
> -	region->end = (res->end - offset) & mask;
> -}
> -EXPORT_SYMBOL(pcibios_resource_to_bus);
> -
> -void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
> -			     struct pci_bus_region *region)
> -{
> -	resource_size_t offset = 0, mask = (resource_size_t)-1;
> -	struct pci_controller *hose = pci_bus_to_host(dev->bus);
> -
> -	if (!hose)
> -		return;
> -	if (res->flags & IORESOURCE_IO) {
> -		offset = (unsigned long)hose->io_base_virt - _IO_BASE;
> -		mask = 0xffffffffu;
> -	} else if (res->flags & IORESOURCE_MEM)
> -		offset = hose->pci_mem_offset;
> -	res->start = (region->start + offset) & mask;
> -	res->end = (region->end + offset) & mask;
> -}
> -EXPORT_SYMBOL(pcibios_bus_to_resource);
> -
> -/* Fixup a bus resource into a linux resource */
> -static void __devinit fixup_resource(struct resource *res, struct pci_dev *dev)
> -{
> -	struct pci_controller *hose = pci_bus_to_host(dev->bus);
> -	resource_size_t offset = 0, mask = (resource_size_t)-1;
> -
> -	if (res->flags & IORESOURCE_IO) {
> -		offset = (unsigned long)hose->io_base_virt - _IO_BASE;
> -		mask = 0xffffffffu;
> -	} else if (res->flags & IORESOURCE_MEM)
> -		offset = hose->pci_mem_offset;
> -
> -	res->start = (res->start + offset) & mask;
> -	res->end = (res->end + offset) & mask;
> -}
> -
> -
>  /* This header fixup will do the resource fixup for all devices as they are
>   * probed, but not for bridge ranges
>   */
> @@ -942,18 +888,11 @@ static void __devinit pcibios_fixup_resources(struct pci_dev *dev)
>  			continue;
>  		}
>  
> -		pr_debug("PCI:%s Resource %d %016llx-%016llx [%x] fixup...\n",
> +		pr_debug("PCI:%s Resource %d %016llx-%016llx [%x]\n",
>  			 pci_name(dev), i,
>  			 (unsigned long long)res->start,\
>  			 (unsigned long long)res->end,
>  			 (unsigned int)res->flags);
> -
> -		fixup_resource(res, dev);
> -
> -		pr_debug("PCI:%s            %016llx-%016llx\n",
> -			 pci_name(dev),
> -			 (unsigned long long)res->start,
> -			 (unsigned long long)res->end);
>  	}
>  
>  	/* Call machine specific resource fixup */
> @@ -1055,27 +994,18 @@ static void __devinit pcibios_fixup_bridge(struct pci_bus *bus)
>  			continue;
>  		}
>  
> -		pr_debug("PCI:%s Bus rsrc %d %016llx-%016llx [%x] fixup...\n",
> +		pr_debug("PCI:%s Bus rsrc %d %016llx-%016llx [%x]\n",
>  			 pci_name(dev), i,
>  			 (unsigned long long)res->start,\
>  			 (unsigned long long)res->end,
>  			 (unsigned int)res->flags);
>  
> -		/* Perform fixup */
> -		fixup_resource(res, dev);
> -
>  		/* Try to detect uninitialized P2P bridge resources,
>  		 * and clear them out so they get re-assigned later
>  		 */
>  		if (pcibios_uninitialized_bridge_resource(bus, res)) {
>  			res->flags = 0;
>  			pr_debug("PCI:%s            (unassigned)\n", pci_name(dev));
> -		} else {
> -
> -			pr_debug("PCI:%s            %016llx-%016llx\n",
> -				 pci_name(dev),
> -				 (unsigned long long)res->start,
> -				 (unsigned long long)res->end);
>  		}
>  	}
>  }
> @@ -1589,7 +1519,8 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, s
>  		 (unsigned long long)res->start,
>  		 (unsigned long long)res->end,
>  		 (unsigned long)res->flags);
> -	pci_add_resource(resources, res);
> +	pci_add_resource_offset(resources, res,
> +			(resource_size_t) hose->io_base_virt - _IO_BASE);
>  
>  	/* Hookup PHB Memory resources */
>  	for (i = 0; i < 3; ++i) {
> @@ -1612,7 +1543,7 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, s
>  			 (unsigned long long)res->start,
>  			 (unsigned long long)res->end,
>  			 (unsigned long)res->flags);
> -		pci_add_resource(resources, res);
> +		pci_add_resource_offset(resources, res, hose->pci_mem_offset);
>  	}
>  
>  	pr_debug("PCI: PHB MEM offset     = %016llx\n",

  reply	other threads:[~2012-01-30 20:49 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-30 16:57 [RFC PATCH v1 00/18] add PCI bus-to-resource offset support in core Bjorn Helgaas
2012-01-30 16:57 ` [RFC PATCH v1 01/18] PCI: don't publish new root bus until it's fully initialized Bjorn Helgaas
2012-01-30 16:57 ` [RFC PATCH v1 02/18] PCI: add struct pci_host_bridge and a list of all bridges found Bjorn Helgaas
2012-01-30 20:52   ` Yinghai Lu
2012-01-30 22:00     ` Bjorn Helgaas
2012-01-30 22:29       ` Yinghai Lu
2012-01-30 16:57 ` [RFC PATCH v1 03/18] PCI: add struct pci_host_bridge_window with CPU/bus address offset Bjorn Helgaas
2012-01-30 16:57 ` [RFC PATCH v1 04/18] PCI: convert bus addresses to resource when reading BARs Bjorn Helgaas
2012-01-30 16:57 ` [RFC PATCH v1 05/18] PCI: add generic pcibios_resource_to_bus() Bjorn Helgaas
2012-01-30 16:57 ` [RFC PATCH v1 06/18] alpha/PCI: get rid of device resource fixups Bjorn Helgaas
2012-01-30 16:57 ` [RFC PATCH v1 07/18] arm/PCI: " Bjorn Helgaas
2012-02-03 16:01   ` Russell King - ARM Linux
2012-02-03 16:12     ` Bjorn Helgaas
2012-02-03 16:55       ` Russell King - ARM Linux
2012-02-03 17:51         ` Bjorn Helgaas
2012-01-30 16:57 ` [RFC PATCH v1 08/18] ia64/PCI: SN: convert to pci_scan_root_bus() for correct root bus resources Bjorn Helgaas
2012-01-30 16:57 ` [RFC PATCH v1 09/18] ia64/PCI: get rid of device resource fixups Bjorn Helgaas
2012-01-30 16:58 ` [RFC PATCH v1 10/18] microblaze/PCI: " Bjorn Helgaas
2012-02-02 10:50   ` Michal Simek
2012-02-03 11:46     ` Benjamin Herrenschmidt
2012-01-30 16:58 ` [RFC PATCH v1 11/18] mips/PCI: " Bjorn Helgaas
2012-01-31  2:42   ` Yoichi Yuasa
2012-01-31  3:54     ` Bjorn Helgaas
2012-02-08  2:56       ` Bjorn Helgaas
     [not found]         ` <20120208132234.710f19be.yuasa@linux-mips.org>
2012-02-08 21:16           ` Bjorn Helgaas
2012-01-30 16:58 ` [RFC PATCH v1 12/18] mn10300/PCI: " Bjorn Helgaas
2012-01-30 16:58 ` [RFC PATCH v1 13/18] parisc/PCI: " Bjorn Helgaas
2012-01-30 16:58 ` [RFC PATCH v1 14/18] powerpc/PCI: " Bjorn Helgaas
2012-01-30 20:49   ` Benjamin Herrenschmidt [this message]
2012-01-30 21:46     ` Bjorn Helgaas
2012-01-30 16:58 ` [RFC PATCH v1 15/18] sh/PCI: " Bjorn Helgaas
2012-01-30 16:58 ` [RFC PATCH v1 16/18] sparc/PCI: " Bjorn Helgaas
2012-01-30 16:58 ` [RFC PATCH v1 17/18] xtensa/PCI: " Bjorn Helgaas
2012-01-30 16:58 ` [RFC PATCH v1 18/18] PCI: collapse pcibios_resource_to_bus Bjorn Helgaas

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=1327956544.28487.47.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=bhelgaas@google.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    /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.