aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2011-08-04 19:36:31 +0200
committerKevin O'Connor <kevin@koconnor.net>2011-08-06 13:57:53 -0400
commitef8adc0220b6072289ac4640b168acfccaf19867 (patch)
treeca403113d66e6a9d764b02f85946cdce4cf0b164
parent2dcbf7fafc15acb62adbceaae7ca3a6e3a06f0e3 (diff)
downloadseabios-ef8adc0220b6072289ac4640b168acfccaf19867.tar.gz
ahci: use malloc_tmp memory for probing ports
Also allocate the ahci port struct itself from tmp memory for probing, then copy to fseg memory in case we detected some device. This way we don't waste fseg memory for unused ports. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
-rw-r--r--src/ahci.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/ahci.c b/src/ahci.c
index ecdd3cb..9b3ce2f 100644
--- a/src/ahci.c
+++ b/src/ahci.c
@@ -383,7 +383,7 @@ ahci_port_reset(struct ahci_ctrl_s *ctrl, u32 pnr)
static struct ahci_port_s*
ahci_port_alloc(struct ahci_ctrl_s *ctrl, u32 pnr)
{
- struct ahci_port_s *port = malloc_fseg(sizeof(*port));
+ struct ahci_port_s *port = malloc_tmp(sizeof(*port));
if (!port) {
warn_noalloc();
@@ -407,10 +407,16 @@ ahci_port_alloc(struct ahci_ctrl_s *ctrl, u32 pnr)
return port;
}
-static void ahci_port_realloc(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));
+ *tmp = *port;
+ free(port);
+ port = tmp;
+
ahci_port_reset(port->ctrl, port->pnr);
free(port->list);
@@ -426,6 +432,8 @@ static void ahci_port_realloc(struct ahci_port_s *port)
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;
}
static void ahci_port_release(struct ahci_port_s *port)
@@ -570,7 +578,7 @@ ahci_port_detect(void *data)
if (rc < 0)
ahci_port_release(port);
else {
- ahci_port_realloc(port);
+ port = ahci_port_realloc(port);
dprintf(1, "AHCI/%d: registering: \"%s\"\n", port->pnr, port->desc);
if (!port->atapi) {
// Register with bcv system.