[SeaBIOS] [PATCH 3/3] ahci: alloc structs in high memory, simplify realloc

Kevin O'Connor kevin at koconnor.net
Wed Nov 27 04:08:01 CET 2013


On Tue, Nov 26, 2013 at 02:23:41PM +0100, Gerd Hoffmann wrote:
> With ahci running in 32bit mode we can also allocate the
> (ahci private) data structures in high memory.  This
> reduces the real mode memory footprint and also simplifies
> the realloc as we only need to move struct ahci_port_s
> (which contains struct drive_s) from high memory to fseg
> in case the port probe was successful.
> 
> Signed-off-by: Gerd Hoffmann <kraxel at redhat.com>
> ---
>  src/hw/ahci.c | 27 ++++-----------------------
>  1 file changed, 4 insertions(+), 23 deletions(-)
> 
> diff --git a/src/hw/ahci.c b/src/hw/ahci.c
> index 5984c1c..5add207 100644
> --- a/src/hw/ahci.c
> +++ b/src/hw/ahci.c
> @@ -358,9 +358,9 @@ ahci_port_alloc(struct ahci_ctrl_s *ctrl, u32 pnr)
>      }
>      port->pnr = pnr;
>      port->ctrl = ctrl;
> -    port->list = memalign_tmp(1024, 1024);
> -    port->fis = memalign_tmp(256, 256);
> -    port->cmd = memalign_tmp(256, 256);
> +    port->list = memalign_high(1024, 1024);
> +    port->fis = memalign_high(256, 256);
> +    port->cmd = memalign_high(256, 256);

Ideally, one wouldn't allocate in "high" ram and then go on to free
it.  (Memory fragmentation due to malloc/free could chew up some guest
ram.)  So, I'm not sure this is an improvement.

Also, if this is done then it wont work for 1Meg guests.  That's
probably not a concern though.

Otherwise, the other patches look fine to me.

-Kevin



More information about the SeaBIOS mailing list