Averatec 6240 pcmcia_socket0: unable to apply power
Daniel Ritz
daniel.ritz at gmx.ch
Thu Sep 8 18:57:14 EDT 2005
On Thursday 08 September 2005 22.33, Linus Torvalds wrote:
>
> On Thu, 8 Sep 2005, Daniel Ritz wrote:
> >
> > something like the attached patch...
> >
> > cc:ing linus as he is the one that added the "find the largest gap" code
> > that comes handy here...
>
> You've got typos there ("rounded up to a multiple of 6 MB" - it should be
whoops! you just convinced me to hide that old keyboard somewhere and
use a sane one :)
> 64). Also, I really think you'd be much better off keeping the old gap
> code, and rounding _later_.
>
> The "round later" approach allows you to look at the size of the gap, and
> use that to decide whether to round or not. That's what the question in
> the comment is talking about, how we "now have the technology" for it.
>
> Also, while it's wonderful to round up in general, there really would be
> an advantage to have a gap _offset_ too: it's safer than rounding up to a
> big area, if only because it might help against people doing prefetches
> etc offset off the last few pages of RAM and into a PCI mapping..
>
> So I'd really prefer to see the gap-finding remain the same, and
> then have just the pci_mem_start calculations be something like
>
> /*
> * See how much we want to round up: start off with
> * rounding to the next 1MB area.
> */
> round = 0x100000;
> while ((gapsize >> 4) > round)
> round += round;
> /* Fun with two's complement */
> pci_mem_start = (gapstart + round) & -round;
>
> which will not really "round up" but actually "gap up" (ie it's guaranteed
> to leave a gap) to the next power-of-two, where we select the rounding
> size depending on how much space we have in the gap.
>
> The above should result in a "rounding gap" of 64MB if the real gap is
> 1GB..
>
i did the math for this months pcmcia breakages because of that...and yes,
works just fine. so attached your thinggy in diff -u format.
> The other alternative is to make PCI allocations generally start at the
> high range of the allowable - judging by the lspci listings I've seem from
> people under Windows, that seems to be what Windows does, which might be a
looking at my other box, yes. all pci devices are above 3GB at least.
> good idea (ie the closer we match windows allocation patterns, the more
> likely we're to not hit some unmarked region - because windows testing
> would have hit it too).
yeah.
> Hmm?
>
> Linus
rgds
-daniel
----
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -1299,7 +1299,7 @@ legacy_init_iomem_resources(struct resou
*/
static void __init register_memory(void)
{
- unsigned long gapstart, gapsize;
+ unsigned long gapstart, gapsize, round;
unsigned long long last;
int i;
@@ -1344,14 +1344,14 @@ static void __init register_memory(void)
}
/*
- * Start allocating dynamic PCI memory a bit into the gap,
- * aligned up to the nearest megabyte.
- *
- * Question: should we try to pad it up a bit (do something
- * like " + (gapsize >> 3)" in there too?). We now have the
- * technology.
+ * See how much we want to round up: start off with
+ * rounding to the next 1MB area.
*/
- pci_mem_start = (gapstart + 0xfffff) & ~0xfffff;
+ round = 0x100000;
+ while ((gapsize >> 4) > round)
+ round += round;
+ /* Fun with two's complement */
+ pci_mem_start = (gapstart + round) & -round;
printk("Allocating PCI resources starting at %08lx (gap: %08lx:%08lx)\n",
pci_mem_start, gapstart, gapsize);
diff --git a/arch/x86_64/kernel/e820.c b/arch/x86_64/kernel/e820.c
--- a/arch/x86_64/kernel/e820.c
+++ b/arch/x86_64/kernel/e820.c
@@ -567,7 +567,7 @@ unsigned long pci_mem_start = 0xaeedbabe
*/
__init void e820_setup_gap(void)
{
- unsigned long gapstart, gapsize;
+ unsigned long gapstart, gapsize, round;
unsigned long last;
int i;
int found = 0;
@@ -604,14 +604,14 @@ __init void e820_setup_gap(void)
}
/*
- * Start allocating dynamic PCI memory a bit into the gap,
- * aligned up to the nearest megabyte.
- *
- * Question: should we try to pad it up a bit (do something
- * like " + (gapsize >> 3)" in there too?). We now have the
- * technology.
+ * See how much we want to round up: start off with
+ * rounding to the next 1MB area.
*/
- pci_mem_start = (gapstart + 0xfffff) & ~0xfffff;
+ round = 0x100000;
+ while ((gapsize >> 4) > round)
+ round += round;
+ /* Fun with two's complement */
+ pci_mem_start = (gapstart + round) & -round;
printk(KERN_INFO "Allocating PCI resources starting at %lx (gap: %lx:%lx)\n",
pci_mem_start, gapstart, gapsize);
More information about the linux-pcmcia
mailing list