[SLOF] [PATCH slof] pci-properties: Enforce all MMIO BARs to be 64K page aligned

Segher Boessenkool segher at kernel.crashing.org
Mon Feb 27 21:05:37 AEDT 2017


On Mon, Feb 27, 2017 at 12:21:45PM +0530, Nikunj A Dadhania wrote:
> Seems fine, assign-var-min-align can be optimized (untested)
> 
> : assign-var-min-align ( size var min-align -- al-mem )
>    dup 3 pick < IF                 \ ( size var min-align min-align size)
>        drop 1 pick                 \ ( size var sz-al)
>    THEN
>    swap                            \ ( size align var )              
>    dup @                           \ ( size align var cur-mem)
>    rot                             \ ( size var cur-mem align )
>    #aligned                        \ ( size var al-mem )        align the mem to the size
>    dup 2swap -rot +                \ ( al-mem var new-mem )     add size to aligned mem
>    swap !                          \ ( al-mem )                 set variable to new mem
> ;

With less stack juggling, totally untested as well of course:

: assign-var-min-align ( size var min-align -- al-mem )
  swap >r over umax r@ @ swap #aligned tuck + r> ! ;

(Why have var in the middle of the params btw?  It is more natural to
have it at the end).


Segher


More information about the SLOF mailing list