linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guo Chao <yan@linux.vnet.ibm.com>
To: Yinghai Lu <yinghai@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 4/5] PCI: Try best to allocate pref mmio 64bit above 4g
Date: Wed, 18 Dec 2013 17:51:16 +0800	[thread overview]
Message-ID: <20131218095116.GA961@yanx> (raw)
In-Reply-To: <CAE9FiQV8kJZz0oaiZOvfWce_bu+8nZB2Qtw7KjLeASTkwUrjug@mail.gmail.com>

Hi:
On Mon, Dec 16, 2013 at 04:36:32PM -0800, Yinghai Lu wrote:
> On Mon, Dec 16, 2013 at 1:36 PM, Yinghai Lu <yinghai@kernel.org> wrote:
> > On Mon, Dec 16, 2013 at 10:13 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> >>>
> >>> 64-bit non-prefetchable BARs are missed from caculation in the scheme,
> >>> causing assign failed eventually.
> 
> >>>
> >>> Will you figure out a better way to cover them or just add a 'type3' parameter?
> >
> > Looks like we have add type3 for that case.
> 
> please check attached delta patch.
> 

It works, thank you.

Guo Chao

> Thanks
> 
> Yinghai

> ---
>  drivers/pci/setup-bus.c |   17 +++++++++++------
>  drivers/pci/setup-res.c |    8 ++++++--
>  2 files changed, 17 insertions(+), 8 deletions(-)
> 
> Index: linux-2.6/drivers/pci/setup-bus.c
> ===================================================================
> --- linux-2.6.orig/drivers/pci/setup-bus.c
> +++ linux-2.6/drivers/pci/setup-bus.c
> @@ -916,6 +916,7 @@ static inline resource_size_t calculate_
>   */
>  static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
>  			 unsigned long type, unsigned long type2,
> +			 unsigned long type3,
>  			 resource_size_t min_size, resource_size_t add_size,
>  			 struct list_head *realloc_head)
>  {
> @@ -946,7 +947,8 @@ static int pbus_size_mem(struct pci_bus
>  			resource_size_t r_size;
>  
>  			if (r->parent || ((r->flags & mask) != type &&
> -					  (r->flags & mask) != type2))
> +					  (r->flags & mask) != type2 &&
> +					  (r->flags & mask) != type3))
>  				continue;
>  			r_size = resource_size(r);
>  #ifdef CONFIG_PCI_IOV
> @@ -1119,7 +1121,7 @@ void __ref __pci_bus_size_bridges(struct
>  			struct list_head *realloc_head)
>  {
>  	struct pci_dev *dev;
> -	unsigned long mask, prefmask, type2 = 0;
> +	unsigned long mask, prefmask, type2 = 0, type3 = 0;
>  	resource_size_t additional_mem_size = 0, additional_io_size = 0;
>  	struct resource *b_res;
>  
> @@ -1171,26 +1173,29 @@ void __ref __pci_bus_size_bridges(struct
>  		prefmask = IORESOURCE_MEM | IORESOURCE_PREFETCH;
>  		if (b_res[2].flags & IORESOURCE_MEM_64) {
>  			prefmask |= IORESOURCE_MEM_64;
> -			if (pbus_size_mem(bus, prefmask, prefmask, prefmask,
> +			if (pbus_size_mem(bus, prefmask, prefmask,
> +				  prefmask, prefmask,
>  				  realloc_head ? 0 : additional_mem_size,
>  				  additional_mem_size, realloc_head)) {
>  					/* Success, size non-pref64 only. */
>  					mask = prefmask;
>  					type2 = prefmask & ~IORESOURCE_MEM_64;
> +					type3 = prefmask & ~IORESOURCE_PREFETCH;
>  			}
>  		}
>  		if (!type2) {
>  			prefmask &= ~IORESOURCE_MEM_64;
> -			if (pbus_size_mem(bus, prefmask, prefmask, prefmask,
> +			if (pbus_size_mem(bus, prefmask, prefmask,
> +					 prefmask, prefmask,
>  					 realloc_head ? 0 : additional_mem_size,
>  					 additional_mem_size, realloc_head)) {
>  				/* Success, size non-prefetch only. */
>  				mask = prefmask;
>  			} else
>  				additional_mem_size += additional_mem_size;
> -			type2 = IORESOURCE_MEM;
> +			type2 = type3 = IORESOURCE_MEM;
>  		}
> -		pbus_size_mem(bus, mask, IORESOURCE_MEM, type2,
> +		pbus_size_mem(bus, mask, IORESOURCE_MEM, type2, type3,
>  				realloc_head ? 0 : additional_mem_size,
>  				additional_mem_size, realloc_head);
>  		break;
> Index: linux-2.6/drivers/pci/setup-res.c
> ===================================================================
> --- linux-2.6.orig/drivers/pci/setup-res.c
> +++ linux-2.6/drivers/pci/setup-res.c
> @@ -212,7 +212,8 @@ static int __pci_assign_resource(struct
>  				     pcibios_align_resource, dev);
>  
>  	if (ret < 0 &&
> -	    (res->flags & (IORESOURCE_PREFETCH | IORESOURCE_MEM_64))) {
> +	    (res->flags & (IORESOURCE_PREFETCH | IORESOURCE_MEM_64)) ==
> +	     (IORESOURCE_PREFETCH | IORESOURCE_MEM_64)) {
>  		/*
>  		 * That failed.
>  		 *
> @@ -223,12 +224,15 @@ static int __pci_assign_resource(struct
>  					     pcibios_align_resource, dev);
>  	}
>  
> -	if (ret < 0 && (res->flags & IORESOURCE_PREFETCH)) {
> +	if (ret < 0 &&
> +	    (res->flags & (IORESOURCE_PREFETCH | IORESOURCE_MEM_64))) {
>  		/*
>  		 * That failed.
>  		 *
>  		 * But a prefetching area can handle a non-prefetching
>  		 * window (it will just not perform as well).
> +		 *
> +		 * Also can put 64bit under 32bit range. (below 4g).
>  		 */
>  		ret = pci_bus_alloc_resource(bus, res, size, align, min, 0,
>  					     pcibios_align_resource, dev);


  reply	other threads:[~2013-12-18  9:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-10  6:54 [PATCH v4 0/5] PCI: allocate 64bit mmio pref Yinghai Lu
2013-12-10  6:54 ` [PATCH v4 1/5] PCI: pcibus address to resource converting take bus instead of dev Yinghai Lu
2013-12-10  6:54 ` [PATCH v4 2/5] PCI: Don't use 4G bus address directly in resource allocation Yinghai Lu
2013-12-10  6:54 ` [PATCH v4 3/5] PCI: Try to allocate mem64 above 4G at first Yinghai Lu
2013-12-10  6:54 ` [PATCH v4 4/5] PCI: Try best to allocate pref mmio 64bit above 4g Yinghai Lu
2013-12-16  8:23   ` Guo Chao
2013-12-16 18:13     ` Yinghai Lu
2013-12-16 21:36       ` Yinghai Lu
2013-12-17  0:36         ` Yinghai Lu
2013-12-18  9:51           ` Guo Chao [this message]
2013-12-10  6:54 ` [PATCH v4 5/5] PCI: Sort pci root bus resources list Yinghai Lu

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=20131218095116.GA961@yanx \
    --to=yan@linux.vnet.ibm.com \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --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).