linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Johan Borkhuis <j.borkhuis@dutchspace.nl>
To: Linuxppc-dev@ozlabs.org
Subject: [PATCH]ppc: fix unalligned PCI BAR-mapping
Date: Fri, 17 Aug 2007 11:43:39 +0200	[thread overview]
Message-ID: <46C56DCB.2000809@dutchspace.nl> (raw)

Hello,

The following patch makes sure that all areas referred to through a BAR 
register in a PCI device are aligned on a PAGE_SIZE boundary.
When looking at the result of the PCI initialization, the BAR registers 
are filled with values that make sure the areas are directly adjacent. 
This is a problem when trying to map these memory areas into user space 
(using mmap). Mmap will only map pages, so to access the mapped area the 
user must know the offset of the BAR register within the page.
When comparing this to the i386 architecture, the areas are aligned on 
boundaries.

The following patch makes sure that all BAR areas are aligned on page 
boundaries, by rounding down the address to the next page boundary. BAR 
areas are mapped from the top down, so by just masking with 
~(PAGE_SIZE-1) the address is aligned with the page.

This is the first time I propose a patch for the Linux kernel, so please 
help me if I do something wrong here, or (in case this patch is 
acceptable) how to get this into the kernel tree.

Kind regards,
    Johan Borkhuis

=======================
diff -u linux-org/arch/ppc/syslib/pci_auto.c 
linux/arch/ppc/syslib/pci_auto.c
--- linux-org/arch/ppc/syslib/pci_auto.c    2007-01-14 
02:26:54.000000000 +0100
+++ linux/arch/ppc/syslib/pci_auto.c    2007-08-17 11:19:25.000000000 +0200
@@ -87,7 +87,7 @@
         bar_size = ~(bar_response & addr_mask) + 1;
 
         /* Allocate a base address */
-        bar_value = (*upper_limit - bar_size) & ~(bar_size - 1);
+        bar_value = ((*upper_limit - bar_size) & ~(bar_size - 1)) & 
~(PAGE_SIZE-1);
 
         /* Write it out and update our limit */
         early_write_config_dword(hose,

                 reply	other threads:[~2007-08-17  9:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=46C56DCB.2000809@dutchspace.nl \
    --to=j.borkhuis@dutchspace.nl \
    --cc=Linuxppc-dev@ozlabs.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).