/* * OPAL update flash */ static int opal_flash_update(int op) { struct opal_sg_list *list; unsigned long addr; int64_t rc = OPAL_PARAMETER; if (op == FLASH_UPDATE_CANCEL) { pr_alert("FLASH: Image update cancelled\n"); addr = '\0'; goto flash; } list = opal_vmalloc_to_sg_list(image_data.data, image_data.size); if (!list) goto invalid_img; /* First entry address */ addr = __pa(list); flash: rc = opal_update_flash(addr); invalid_img: return rc; }
static int64_t dump_read_data(struct dump_obj *dump) { struct opal_sg_list *list; uint64_t addr; int64_t rc; /* Allocate memory */ dump->buffer = vzalloc(PAGE_ALIGN(dump->size)); if (!dump->buffer) { pr_err("%s : Failed to allocate memory\n", __func__); rc = -ENOMEM; goto out; } /* Generate SG list */ list = opal_vmalloc_to_sg_list(dump->buffer, dump->size); if (!list) { rc = -ENOMEM; goto out; } /* First entry address */ addr = __pa(list); /* Fetch data */ rc = OPAL_BUSY_EVENT; while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) { rc = opal_dump_read(dump->id, addr); if (rc == OPAL_BUSY_EVENT) { opal_poll_events(NULL); msleep(20); } } if (rc != OPAL_SUCCESS && rc != OPAL_PARTIAL) pr_warn("%s: Extract dump failed for ID 0x%x\n", __func__, dump->id); /* Free SG list */ opal_free_sg_list(list); out: return rc; }