summaryrefslogtreecommitdiffstats
path: root/mboxd.c
diff options
context:
space:
mode:
authorCyril Bur <cyril.bur@au1.ibm.com>2017-01-25 11:02:20 +1100
committerCyril Bur <cyril.bur@au1.ibm.com>2017-01-25 11:43:38 +1100
commitf0409b99d08d1b15329c714f2b9683645f08de10 (patch)
treedc736dd109862d8b295596b9ad20f27657222465 /mboxd.c
parent465c676ffbe7518813d021f56d8faa70c6633fc2 (diff)
downloadphosphor-mboxd-f0409b99d08d1b15329c714f2b9683645f08de10.tar.gz
phosphor-mboxd-f0409b99d08d1b15329c714f2b9683645f08de10.zip
mboxd: Workaround buggy kernel flash driver
Currently when mboxd starts (and on every SIGHUP) it reads the entire flash into RAM (typically 32 or 64M). This large read causes the kernel to become unresponsive for an extended period of time (in the order of 10s of seconds). This period of unresponsiveness can cause misbehaviour by the BMC, in particular it often causes SSH sessions to drop. This patch is a temporary workaround until the kernel driver has been fixed, at that point this patch should be reverted! Patch originally from Michael Neuling <mikey@neuling.org>. Change-Id: Ibd848a4074fc7bdcab194d669806589f9d274c93 Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Diffstat (limited to 'mboxd.c')
-rw-r--r--mboxd.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/mboxd.c b/mboxd.c
index cb8eaf7..8fdcc2d 100644
--- a/mboxd.c
+++ b/mboxd.c
@@ -325,9 +325,14 @@ out:
return r;
}
+
+#define CHUNKSIZE (64 * 1024)
+
int copy_flash(struct mbox_context *context)
{
int r;
+ int readsize = CHUNKSIZE;
+ int offset = 0;
/*
* Copy flash into RAM early, same time.
@@ -342,11 +347,17 @@ int copy_flash(struct mbox_context *context)
MSG_ERR("Couldn't reset MBOX pos to zero\n");
return r;
}
- r = read(context->fds[MTD_FD].fd, context->lpc_mem, context->size);
- if (r != context->size) {
- r = -errno;
- MSG_ERR("Couldn't copy mtd into ram: %d\n", r);
- return r;
+ while (readsize) {
+ r = read(context->fds[MTD_FD].fd, context->lpc_mem + offset, readsize);
+ if (r != readsize) {
+ r = -errno;
+ MSG_ERR("Couldn't copy mtd into ram: %d\n", r);
+ return r;
+ }
+ offset += readsize;
+ readsize = context->size - offset;
+ if (readsize > CHUNKSIZE)
+ readsize = CHUNKSIZE;
}
return 0;
}
OpenPOWER on IntegriCloud