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@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); if (port->list == NULL || port->fis == NULL || port->cmd == NULL) { warn_noalloc(); return NULL; @@ -386,7 +386,6 @@ static void ahci_port_release(struct ahci_port_s *port) static struct ahci_port_s* ahci_port_realloc(struct ahci_port_s *port) { struct ahci_port_s *tmp; - u32 cmd;
tmp = malloc_fseg(sizeof(*port)); if (!tmp) { @@ -396,25 +395,7 @@ static struct ahci_port_s* ahci_port_realloc(struct ahci_port_s *port) } *tmp = *port; free(port); - port = tmp; - - ahci_port_reset(port->ctrl, port->pnr); - - free(port->list); - free(port->fis); - free(port->cmd); - port->list = memalign_low(1024, 1024); - port->fis = memalign_low(256, 256); - port->cmd = memalign_low(256, 256); - - ahci_port_writel(port->ctrl, port->pnr, PORT_LST_ADDR, (u32)port->list); - ahci_port_writel(port->ctrl, port->pnr, PORT_FIS_ADDR, (u32)port->fis); - - cmd = ahci_port_readl(port->ctrl, port->pnr, PORT_CMD); - cmd |= (PORT_CMD_FIS_RX|PORT_CMD_START); - ahci_port_writel(port->ctrl, port->pnr, PORT_CMD, cmd); - - return port; + return tmp; }
#define MAXMODEL 40