linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bhelgaas@google.com>
To: Gavin Shan <shangw@linux.vnet.ibm.com>
Cc: linux-pci@vger.kernel.org, linuxppc-dev@ozlabs.org,
	benh@kernel.crashing.org, yinghai@kernel.org,
	linuxram@us.ibm.com
Subject: Re: [PATCH 04/15] pci: weak function returns alignment
Date: Mon, 16 Jul 2012 18:07:34 -0600	[thread overview]
Message-ID: <20120717000734.GB32203@google.com> (raw)
In-Reply-To: <1342452631-21152-4-git-send-email-shangw@linux.vnet.ibm.com>

On Mon, Jul 16, 2012 at 11:30:27PM +0800, Gavin Shan wrote:
> The patch implements the weak function to return the default I/O
> or memory alignment for P2P bridge. Currently, I/O window has 4KiB
> alignment and memory window is 4MiB aligned by default. On the other
> hand, those platforms (e.g. powernv) that have special requirements
> on the alignment could override the function by themselves.
> 
> Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
> ---
>  drivers/pci/host-bridge.c |   17 +++++++++++++++++
>  include/linux/pci.h       |    2 ++
>  2 files changed, 19 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index abcf053..dcbc47d 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -105,3 +105,20 @@ void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
>  }
>  
>  EXPORT_SYMBOL(pcibios_bus_to_resource);
> +
> +/*
> + * Retrieve the default memory or I/O alignment for the
> + * specific P2P bridge. The function has been implemented
> + * as weak so that it can be overrided by platform that
> + * has special requirments for memory and I/O alignment.
> + */
> +resource_size_t __weak pcibios_window_alignment(struct pci_bus *bus,
> +						unsigned long type)

This no longer has anything to do with the host bridge, so I think it
could be moved to setup-bus.c and made static.  We shouldn't have to
repeat the default 1M and 4K code in the arch versions, so maybe we
could do something like this:

    resource_size_t __weak pcibios_window_alignment(struct pci_bus *bus, unsigned long type)
    {
	return 1;
    }

    static resource_size_t window_alignment(struct pci_bus *bus, unsigned long type)
    {
	resource_size_t align = 1, arch_align;

	if (type & IORESOURCE_MEM)
	    align = 1024*1024;
	else if (type & IORESOURCE_IO)
	    align = 4*1024;
    
	arch_align = pcibios_window_alignment(bus, type);
	return max(align, arch_align);
    }

I made the default 1, thinking of bus number apertures (though we don't use this
path for bus numbers today).

> +{
> +	/* Memory windows must be 1MiB aligned */
> +	if (type & IORESOURCE_MEM)
> +		return 1024*1024;
> +
> +	/* I/O windows have default alignment of 4KiB */
> +	return 4*1024;
> +}
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 9acea4b..283da11 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -662,6 +662,8 @@ void __pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
>  			       struct pci_bus_region *region);
>  void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
>  			     struct pci_bus_region *region);
> +resource_size_t pcibios_window_alignment(struct pci_bus *bus,
> +					 unsigned long type);
>  void pcibios_scan_specific_bus(int busn);
>  extern struct pci_bus *pci_find_bus(int domain, int busnr);
>  void pci_bus_add_devices(const struct pci_bus *bus);
> -- 
> 1.7.5.4
> 

  parent reply	other threads:[~2012-07-17  0:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-29  6:47 [PATCH V5 0/7] minimal alignment for p2p bars Gavin Shan
2012-06-29  6:47 ` [PATCH 1/7] pci: change variable name for find_pci_host_bridge Gavin Shan
2012-06-29  6:47 ` [PATCH 2/7] pci: argument pci_bus " Gavin Shan
2012-06-29  6:47 ` [PATCH 3/7] pci: make find_pci_host_bridge global Gavin Shan
2012-06-29  6:47 ` [PATCH 4/7] pci: fiddle with conversion of pci and CPU address Gavin Shan
2012-06-29  6:47 ` [PATCH 5/7] pci: minimal alignment for bars of P2P bridges Gavin Shan
2012-07-13 20:12   ` Bjorn Helgaas
     [not found]     ` <20120716035044.GC24203@shangw>
2012-07-16 14:58       ` Bjorn Helgaas
2012-06-29  6:47 ` [PATCH 6/7] pci: function to retrieve alignment of p2p bars Gavin Shan
2012-06-29  6:47 ` [PATCH 7/7] pci: resource assignment based on p2p alignment Gavin Shan
2012-07-03  7:01 ` [PATCH V5 0/7] minimal alignment for p2p bars Gavin Shan
2012-07-16 23:12 ` [PATCH v5 " Bjorn Helgaas
     [not found] ` <1342452631-21152-4-git-send-email-shangw@linux.vnet.ibm.com>
2012-07-17  0:07   ` Bjorn Helgaas [this message]
     [not found] ` <1342452631-21152-5-git-send-email-shangw@linux.vnet.ibm.com>
2012-07-17  0:47   ` [PATCH 05/15] pci: resource assignment based on p2p alignment 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=20120717000734.GB32203@google.com \
    --to=bhelgaas@google.com \
    --cc=benh@kernel.crashing.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=linuxram@us.ibm.com \
    --cc=shangw@linux.vnet.ibm.com \
    --cc=yinghai@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 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).