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>
static struct ahci_port_s*
ahci_port_alloc(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();
if (!port) {
warn_noalloc();
-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;
+ tmp = malloc_fseg(sizeof(*port));
+ *tmp = *port;
+ free(port);
+ port = tmp;
+
ahci_port_reset(port->ctrl, port->pnr);
free(port->list);
ahci_port_reset(port->ctrl, port->pnr);
free(port->list);
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);
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);
}
static void ahci_port_release(struct ahci_port_s *port)
}
static void ahci_port_release(struct ahci_port_s *port)
if (rc < 0)
ahci_port_release(port);
else {
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.
dprintf(1, "AHCI/%d: registering: \"%s\"\n", port->pnr, port->desc);
if (!port->atapi) {
// Register with bcv system.