polarfire-soc / platform

Other
6 stars 11 forks source link

MSS_SYS_spi_copy() runs with wrong frequency due to issue with mailbox_reg variable definition in mss_sys_services.c #20

Open ChrRudel opened 2 months ago

ChrRudel commented 2 months ago

https://github.com/polarfire-soc/platform/blob/8b4b440f7138809d7c68f66529387e58eb0ba816/drivers/mss/mss_sys_services/mss_sys_services.c#L1978

There seems to be a bug in the HSS / bare-metal-library: mailbox_reg needs to be declared as “volatile uint32_t * mailbox_reg;”, otherwise the read/modify/write cycle starting at line 2021 will lead to unpredictable values In our case, this lead to the 17th byte of the MSS_SYS_SPI_COPY_CMD operation being corrupted. This byte contains the options / clock frequency, which explains why we were seeing wrong frequencies and data corruption.

This is likely also the root cause for why this workaround is necessary: https://github.com/polarfire-soc/hart-software-services/commit/c0583945ba11372dcb9789f3cb6496d06fe3c612

nitindeshpande commented 2 months ago

Thanks for reporting @ChrRudel. Will have this fixed soon.