mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Simplification in pbus_size_mem
@ 2003-11-20 12:28 Richard Curnow
  2003-11-20 14:16 ` Ivan Kokshaysky
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Curnow @ 2003-11-20 12:28 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Greg KH, ink

The following patch is against 2.4, but the 2.6 code looks identical.

===== setup-bus.c 1.6 vs edited =====
--- 1.6/drivers/pci/setup-bus.c Thu Dec 12 22:14:01 2002
+++ edited/setup-bus.c  Thu Nov 20 11:54:28 2003
@@ -311,18 +311,8 @@
                }
        }
 
-       align = 0;
-       min_align = 0;
-       for (order = 0; order <= max_order; order++) {
-               unsigned long align1 = 1UL << (order + 20);
+       min_align = 1UL << (max_order + 20);
 
-               if (!align)
-                       min_align = align1;
-               else if (ROUND_UP(align + min_align, min_align) < align1)
-                       min_align = align1 >> 1;
-               align += aligns[order];
-       }
-       size = ROUND_UP(size, min_align);
        if (!size) {
                b_res->flags = 0;
                return;


This is fixing the allocation on a system which looks like this

* 96Mb PCI memory aperture
* Kyro graphics card, requiring 64Mb + 768kb prefetchable
* USB card requiring 4x4k non-prefetchable

Without the change, 'min_align' is computed as 32Mb (the algorithm in the
loop basically seems to make 'min_align' end up as 1/2 the largest
alignment requirement that was found?), hence in the pass where the
prefetchable block is sized, 'size' ends up as 96Mb, which means there
is no space left in which to place the non-prefetchable blocks for the
USB card.

With the patch above, the alignment requirement for the prefetchable
memory actually ends up as the alignment required for the framebuffer,
and the size isn't rounded up unnecessarily.  The USB card gets
allocated successfully as a result.

I couldn't be sure what the code in the loop is attempting to do, so I'm
sure I'm overlooking something subtle.  Any comments?

-- 
Richard \\\ SuperH Core+Debug Architect /// .. At home ..
  P.    /// richard.curnow@superh.com  ///  rc@rc0.org.uk
Curnow  \\\ http://www.superh.com/    ///  www.rc0.org.uk

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-11-24 15:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-20 12:28 Simplification in pbus_size_mem Richard Curnow
2003-11-20 14:16 ` Ivan Kokshaysky
2003-11-20 15:25   ` Richard Curnow
2003-11-20 16:36     ` Ivan Kokshaysky
2003-11-24 15:28       ` Richard Curnow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®