m1n1.fw.asc.{crash, ioreporting}: Do not align prealloc buffer sizes

On SMC on t602x, this is a small SRAM and we can run off the edge.

Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
Hector Martin 2023-04-10 23:24:32 +09:00
parent 55ca08d482
commit 93a6daa337
2 changed files with 5 additions and 3 deletions

View file

@ -210,12 +210,13 @@ class ASCCrashLogEndpoint(ASCBaseEndpoint):
return self.handle_getbuf(msg) return self.handle_getbuf(msg)
def handle_getbuf(self, msg): def handle_getbuf(self, msg):
size = align(0x1000 * msg.SIZE, 0x4000)
if msg.DVA: if msg.DVA:
size = 0x1000 * msg.SIZE
self.iobuffer_dva = msg.DVA self.iobuffer_dva = msg.DVA
self.log(f"buf prealloc at dva {self.iobuffer_dva:#x}") self.log(f"buf prealloc at dva {self.iobuffer_dva:#x}")
else: else:
size = align(0x1000 * msg.SIZE, 0x4000)
self.iobuffer, self.iobuffer_dva = self.asc.ioalloc(size) self.iobuffer, self.iobuffer_dva = self.asc.ioalloc(size)
self.log(f"buf {self.iobuffer:#x} / {self.iobuffer_dva:#x}") self.log(f"buf {self.iobuffer:#x} / {self.iobuffer_dva:#x}")
self.send(CrashLogMessage(TYPE=1, SIZE=size // 0x1000, DVA=self.iobuffer_dva)) self.send(CrashLogMessage(TYPE=1, SIZE=size // 0x1000, DVA=self.iobuffer_dva))

View file

@ -30,12 +30,13 @@ class ASCIOReportingEndpoint(ASCBaseEndpoint):
if self.iobuffer: if self.iobuffer:
self.log("WARNING: trying to reset iobuffer!") self.log("WARNING: trying to reset iobuffer!")
self.bufsize = align(0x1000 * msg.SIZE, 0x4000)
if msg.DVA != 0: if msg.DVA != 0:
self.bufsize = 0x1000 * msg.SIZE
self.iobuffer = self.iobuffer_dva = msg.DVA self.iobuffer = self.iobuffer_dva = msg.DVA
self.log(f"buf {self.iobuffer:#x} / {self.iobuffer_dva:#x}") self.log(f"buf prealloc {self.iobuffer:#x} / {self.iobuffer_dva:#x}")
else: else:
self.bufsize = align(0x1000 * msg.SIZE, 0x4000)
self.iobuffer, self.iobuffer_dva = self.asc.ioalloc(self.bufsize) self.iobuffer, self.iobuffer_dva = self.asc.ioalloc(self.bufsize)
self.log(f"buf {self.iobuffer:#x} / {self.iobuffer_dva:#x}") self.log(f"buf {self.iobuffer:#x} / {self.iobuffer_dva:#x}")
self.send(IOReporting_GetBuf(DVA=self.iobuffer_dva, SIZE=self.bufsize // 0x1000)) self.send(IOReporting_GetBuf(DVA=self.iobuffer_dva, SIZE=self.bufsize // 0x1000))