linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH] powerpc/PCI: compute I/O space bus-to-resource offset consistently
Date: Tue, 28 Feb 2012 14:52:13 +1100	[thread overview]
Message-ID: <1330401133.11728.24.camel@pasglop> (raw)
In-Reply-To: <20120228025002.3990.7392.stgit@bhelgaas.mtv.corp.google.com>

On Mon, 2012-02-27 at 19:50 -0700, Bjorn Helgaas wrote:
> --- a/arch/powerpc/kernel/pci_32.c
> +++ b/arch/powerpc/kernel/pci_32.c
> @@ -219,9 +219,9 @@ void __devinit pcibios_setup_phb_io_space(struct
> pci_controller *hose)
>         struct resource *res = &hose->io_resource;
>  
>         /* Fixup IO space offset */
> -       io_offset = (unsigned long)hose->io_base_virt - isa_io_base;
> -       res->start = (res->start + io_offset) & 0xffffffffu;
> -       res->end = (res->end + io_offset) & 0xffffffffu;
> +       io_offset = pcibios_io_space_offset(hose);
> +       res->start += io_offset;
> +       res->end += io_offset;
>  } 

Well, you are losing the 0xffffffff mask... so basically, what happens
is that your offset, if negative, will be 0 extended by
pcibios_io_space_offset() instead of sign-extended, and thus the
resource will have crap stuff in the top 32-bit.

As I said on irc, it might be a non-issue because the inX/outX accessors
are going to take an unsigned int port number anyway, but anything that
tries to print out that resource (or expose it to userspace) will look
bad.

One way to fix that is to ensure that pcibios_io_space_offset() does a
full sign extension to 64-bit.

Cheers,
Ben.



  reply	other threads:[~2012-02-28  3:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-28  2:50 [PATCH] powerpc/PCI: compute I/O space bus-to-resource offset consistently Bjorn Helgaas
2012-02-28  3:52 ` Benjamin Herrenschmidt [this message]
2012-02-28  4:26   ` 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=1330401133.11728.24.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=bhelgaas@google.com \
    --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 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).