mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Linus Torvalds <torvalds@osdl.org>
Cc: Andi Kleen <ak@colin2.muc.de>,
	Mika Penttil? <mika.penttila@kolumbus.fi>, Andi Kleen <ak@muc.de>,
	David Hinds <dhinds@sonic.net>,
	Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: PCI memory allocation bug with CONFIG_HIGHMEM
Date: 07 Jan 2004 08:53:50 -0700	[thread overview]
Message-ID: <m1smirlppt.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <Pine.LNX.4.58.0401062116230.12602@home.osdl.org>

Linus Torvalds <torvalds@osdl.org> writes:

> On Tue, 6 Jan 2004, Eric W. Biederman wrote:
> > If I wanted to flash my ROM what I need to do is:
> >
> > [ horrorcase deleted ]
> > 
> > So to do this cleanly it looks like I need to write a pci quirk for
> > the southbridge.  Adding a BAR that enables decodes to the BIOS ROM chip.  
> > And that quirk should always be present, so that nothing even thinks
> > of using that region for something else.
> 
> Sounds correct. However, the BIOS map will still clash with this quirk, so 
> there may be some double resource allocations in the resource maps. The 
> quirks get run _after_ the memory setup has run, which is why you end up 
> with this problem:
> 
> > The very practical question.  After the BIOS has allocated:
> > 0xFFFF0000 - 0xFFFFFFFF how do I allocate
> > 0xFFF00000 - 0xFFFFFFFF in the pci quirk?
> 
> And _this_ is the only really nasty case. It's nasty exactly because the 
> BIOS is involved, and we have _no_ idea why the heck the BIOS marked 
> certain areas reserved.
> 
> The resource allocation code in kernel/resource.c _will_ help you if you 
> want to do this right. The internal "__request_resource()" function will 
> pinpoint any conflicting entry, and in fact we already have a 
> "insert_resource()" that uses exactly this to try to "fix up" these 
> issues.

Last time I was looking I got as far as __request_resource, but
it was and still is private to resource.c so it needs a wrapper around
it that does something useful.
 
> The "insert_resource()" function is able to put "new" resources below old
> ones, but it does assume that the the resources are fully overlapping in 
> _some_ way. It will correctly insert your PCI quirk (because the BIOS 
> allocation is wholly inside of the quirk you want to add), but it would 
> _not_ be able to handle two different regions conflicting.

And this looks like a useful wrapper, that comes very close to what
I need.  insert_resource is new since last time I looked so I missed
it.

> And such a conflict could happen if the BIOS uses a single "reserved" 
> region for two different PCI resources. Then your quirk might cover one of 
> the PCI resources fully, but wouldn't cover the whole BIOS "reserved" 
> area. "insert_resource()" would still be happy if your quirk is wholly 
> inside, but it would _not_ be happy if your quirk is bigger than the BIOS 
> allocation in one direction but not the other.
> 
> See?

Yes.  insert_resource does has it's limitations but it doesn't look
like I am likely to run into them.
 
> Right now, the ia64 port actually does _exactly_ this to mark all the
> strange PCI window stuff into the resource tree. For a different reason,
> but with a number of similar issues.

It comes very close, to that what this weird case needs.  And things
are at least close enough now that I can hack something up for 2.6.

However insert_resource does not quite match what I think needs to
happen.  After a pci quirk applies insert_resource I will get
something like:

fff0000-ffffffff : BIOS ROM Window
  ffff0000-ffffffff : reserved

With the reserved region still present and marked as BUSY.  Ideally
the map driver would carve up the window into sub regions for each
ROM chip.  Usually that is just one sub region but it is possible to
have multiple ROMs in it.  So I would expect to wind up with something like:

fff0000-ffffffff : BIOS ROM Window
  fffc0000-ffffffff : mtd0
  ffff0000-ffffffff : reserved

But that again runs afoul of the reserved region so it really won't
work.  I could again use insert_resource and wind up with:

fff0000-ffffffff : BIOS ROM Window
  fffc0000-ffffffff : mtd0
    ffff0000-ffffffff : reserved

But that is increasingly a hack instead of a clean solution.  Would it
be reasonable to write a variant of request_resource that just drops
BIOS resources.  I can live with the restrictions of the current
insert_resource, but especially if I do this in a quirk I just want
the BIOS resources to go away.

Eric


  reply	other threads:[~2004-01-07 16:01 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1aJdi-7TH-25@gated-at.bofh.it>
2004-01-06  3:32 ` Andi Kleen
2004-01-06  3:40   ` Linus Torvalds
2004-01-06  4:05     ` Andi Kleen
2004-01-06  5:04       ` Linus Torvalds
2004-01-06  8:12         ` Andi Kleen
2004-01-06  9:11           ` Mika Penttilä
2004-01-06  9:44             ` Andi Kleen
2004-01-06 10:16               ` Mika Penttilä
2004-01-06 10:49                 ` Andi Kleen
2004-01-06 15:27               ` Linus Torvalds
2004-01-06 15:37                 ` Andi Kleen
2004-01-06 15:48                   ` Linus Torvalds
2004-01-06 22:29                     ` Adam Belay
2004-01-07  4:06                       ` Linus Torvalds
2004-01-07  5:02                         ` Andi Kleen
2004-01-07  5:55                           ` Dave Jones
2004-01-07  6:06                             ` Linus Torvalds
2004-01-07  6:08                               ` Dave Jones
2004-01-07  6:45                                 ` Linus Torvalds
2004-01-07  6:51                             ` Andi Kleen
2004-01-07  2:43                               ` Adam Belay
2004-01-07  8:32                       ` Helge Hafting
2004-01-06 22:45                   ` Eric W. Biederman
2004-01-07  0:06                     ` Linus Torvalds
2004-01-07  4:58                       ` Eric W. Biederman
2004-01-07  5:32                         ` Linus Torvalds
2004-01-07 15:53                           ` Eric W. Biederman [this message]
2004-01-07 16:32                             ` Linus Torvalds
2004-01-07 17:32                               ` Eric W. Biederman
2004-01-08 19:34                               ` Eric W. Biederman
2004-01-07  9:31                         ` Russell King
2004-01-07 15:06                           ` Eric W. Biederman
2004-01-07 20:29                             ` Russell King
2004-01-06 22:56     ` Eric W. Biederman
2004-01-05 20:07 David Hinds
2004-01-05 23:00 ` Russell King
2004-01-05 23:45   ` David Hinds
2004-01-06  0:36 ` Linus Torvalds
2004-01-06  0:44   ` David Hinds
2004-01-06  1:11     ` Linus Torvalds
2004-01-06  1:41       ` Linus Torvalds

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=m1smirlppt.fsf@ebiederm.dsl.xmission.com \
    --to=ebiederm@xmission.com \
    --cc=ak@colin2.muc.de \
    --cc=ak@muc.de \
    --cc=dhinds@sonic.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mika.penttila@kolumbus.fi \
    --cc=torvalds@osdl.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

Powered by JetHome