mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Lucas Stach <dev@lynxeye.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/3] pci: correct BAR size calculation
Date: Mon, 17 Nov 2014 08:36:16 +0100	[thread overview]
Message-ID: <20141117073616.GZ30369@pengutronix.de> (raw)
In-Reply-To: <1415823877-7379-1-git-send-email-dev@lynxeye.de>

On Wed, Nov 12, 2014 at 09:24:35PM +0100, Lucas Stach wrote:
> The previous math would return negative sizes
> for some BARs.
> 
> Signed-off-by: Lucas Stach <dev@lynxeye.de>

Applied all, thanks

Sascha

> ---
>  drivers/pci/pci.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index ba9d097..87c2fca 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -154,7 +154,7 @@ static void setup_device(struct pci_dev *dev, int max_bar)
>  		}
>  
>  		if (mask & 0x01) { /* IO */
> -			size = -(mask & 0xfffffffe);
> +			size = ((~(mask & 0xfffffffe)) & 0xffff) + 1;
>  			DBG("  PCI: pbar%d: mask=%08x io %d bytes\n", bar, mask, size);
>  			if (last_io + size >
>  			    dev->bus->resource[PCI_BUS_RESOURCE_IO]->end) {
> @@ -167,7 +167,7 @@ static void setup_device(struct pci_dev *dev, int max_bar)
>  			last_io += size;
>  		} else if ((mask & PCI_BASE_ADDRESS_MEM_PREFETCH) &&
>  		           last_mem_pref) /* prefetchable MEM */ {
> -			size = -(mask & 0xfffffff0);
> +			size = (~(mask & 0xfffffff0)) + 1;
>  			DBG("  PCI: pbar%d: mask=%08x P memory %d bytes\n",
>  			    bar, mask, size);
>  			if (last_mem_pref + size >
> @@ -181,7 +181,7 @@ static void setup_device(struct pci_dev *dev, int max_bar)
>  			last_addr = last_mem_pref;
>  			last_mem_pref += size;
>  		} else { /* non-prefetch MEM */
> -			size = -(mask & 0xfffffff0);
> +			size = (~(mask & 0xfffffff0)) + 1;
>  			DBG("  PCI: pbar%d: mask=%08x NP memory %d bytes\n",
>  			    bar, mask, size);
>  			if (last_mem + size >
> -- 
> 1.9.3
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2014-11-17  7:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-12 20:24 Lucas Stach
2014-11-12 20:24 ` [PATCH 2/3] pci: align bridge windows Lucas Stach
2014-11-12 20:24 ` [PATCH 3/3] pci: tegra: relax link-up timeout Lucas Stach
2014-11-17  7:36 ` Sascha Hauer [this message]

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=20141117073616.GZ30369@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=dev@lynxeye.de \
    /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