Commit 32709d8a authored by Keith Owens's avatar Keith Owens Committed by Tony Luck

[IA64] SAL to OS callbacks cannot call sleeping

When SAL calls back into the OS, the OS code is running with preempt
disabled so it cannot call sleeping functions.
Signed-off-by: default avatarKeith Owens <kaos@sgi.com>
Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
parent b1b901c2
...@@ -37,6 +37,11 @@ static u64 *sn_oemdata_size, sn_oemdata_bufsize; ...@@ -37,6 +37,11 @@ static u64 *sn_oemdata_size, sn_oemdata_bufsize;
* This function is the callback routine that SAL calls to log error * This function is the callback routine that SAL calls to log error
* info for platform errors. buf is appended to sn_oemdata, resizing as * info for platform errors. buf is appended to sn_oemdata, resizing as
* required. * required.
* Note: this is a SAL to OS callback, running under the same rules as the SAL
* code. SAL calls are run with preempt disabled so this routine must not
* sleep. vmalloc can sleep so print_hook cannot resize the output buffer
* itself, instead it must set the required size and return to let the caller
* resize the buffer then redrive the SAL call.
*/ */
static int print_hook(const char *fmt, ...) static int print_hook(const char *fmt, ...)
{ {
...@@ -47,18 +52,8 @@ static int print_hook(const char *fmt, ...) ...@@ -47,18 +52,8 @@ static int print_hook(const char *fmt, ...)
vsnprintf(buf, sizeof(buf), fmt, args); vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args); va_end(args);
len = strlen(buf); len = strlen(buf);
while (*sn_oemdata_size + len + 1 > sn_oemdata_bufsize) { if (*sn_oemdata_size + len <= sn_oemdata_bufsize)
u8 *newbuf = vmalloc(sn_oemdata_bufsize += 1000); memcpy(*sn_oemdata + *sn_oemdata_size, buf, len);
if (!newbuf) {
printk(KERN_ERR "%s: unable to extend sn_oemdata\n",
__FUNCTION__);
return 0;
}
memcpy(newbuf, *sn_oemdata, *sn_oemdata_size);
vfree(*sn_oemdata);
*sn_oemdata = newbuf;
}
memcpy(*sn_oemdata + *sn_oemdata_size, buf, len + 1);
*sn_oemdata_size += len; *sn_oemdata_size += len;
return 0; return 0;
} }
...@@ -98,7 +93,20 @@ sn_platform_plat_specific_err_print(const u8 * sect_header, u8 ** oemdata, ...@@ -98,7 +93,20 @@ sn_platform_plat_specific_err_print(const u8 * sect_header, u8 ** oemdata,
sn_oemdata = oemdata; sn_oemdata = oemdata;
sn_oemdata_size = oemdata_size; sn_oemdata_size = oemdata_size;
sn_oemdata_bufsize = 0; sn_oemdata_bufsize = 0;
*sn_oemdata_size = PAGE_SIZE; /* first guess at how much data will be generated */
while (*sn_oemdata_size > sn_oemdata_bufsize) {
u8 *newbuf = vmalloc(*sn_oemdata_size);
if (!newbuf) {
printk(KERN_ERR "%s: unable to extend sn_oemdata\n",
__FUNCTION__);
return 1;
}
vfree(*sn_oemdata);
*sn_oemdata = newbuf;
sn_oemdata_bufsize = *sn_oemdata_size;
*sn_oemdata_size = 0;
ia64_sn_plat_specific_err_print(print_hook, (char *)sect_header); ia64_sn_plat_specific_err_print(print_hook, (char *)sect_header);
}
up(&sn_oemdata_mutex); up(&sn_oemdata_mutex);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment