Skip to content

Commit

Permalink
core/flash: Only lock around flashes update in flash_register()
Browse files Browse the repository at this point in the history
[ Upstream commit 3aa5394 ]

Previously in flash_register() held flash_lock across ffs_init(), which
calls through the blocklevel layer to read the flash. This is unhelpful
with the IPMI HIOMAP protocol transport as LPC interrupts have not yet
been enabled and we are relying on polling to progress. The held lock
stalls the boot as we take the nopoll path in time_wait() while
completing ipmi_queue_msg_sync() in libflash/ipmi-flash.c

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
  • Loading branch information
amboar authored and stewartsmith committed Oct 31, 2018
1 parent c8edac1 commit f976e77
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions core/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,9 @@ int flash_register(struct blocklevel_device *bl)
prlog(PR_INFO, "FLASH: registering flash device %s "
"(size 0x%llx, blocksize 0x%x)\n",
name ?: "(unnamed)", size, block_size);

lock(&flash_lock);

flash = malloc(sizeof(struct flash));
if (!flash) {
prlog(PR_ERR, "FLASH: Error allocating flash structure\n");
unlock(&flash_lock);
return OPAL_RESOURCE;
}

Expand All @@ -417,8 +413,6 @@ int flash_register(struct blocklevel_device *bl)
flash->block_size = block_size;
flash->id = num_flashes();

list_add(&flashes, &flash->list);

rc = ffs_init(0, flash->size, bl, &ffs, 1);
if (rc) {
/**
Expand All @@ -439,6 +433,8 @@ int flash_register(struct blocklevel_device *bl)
if (ffs)
ffs_close(ffs);

lock(&flash_lock);
list_add(&flashes, &flash->list);
unlock(&flash_lock);

return OPAL_SUCCESS;
Expand Down

0 comments on commit f976e77

Please sign in to comment.