• Peng Fan's avatar
    mailbox: imx: fix TXDB_V2 channel race condition · b5ef1791
    Peng Fan authored
    Two TXDB_V2 channels are used between Linux and System Manager(SM).
    Channel0 for normal TX, Channel 1 for notification completion.
    The TXDB_V2 trigger logic is using imx_mu_xcr_rmw which uses
    read/modify/update logic.
    
    Note: clear MUB GSR BITs, the MUA side GCR BITs will also got cleared per
    hardware design.
    Channel0 Linux
    read GCR->modify GCR->write GCR->M33 SM->read GSR----->clear GSR
                                                    |-(1)-|
    Channel1 Linux start in time slot(1)
    read GCR->modify GCR->write GCR->M33 SM->read GSR->clear GSR
    So Channel1 read GCR will read back the GCR that Channel0 wrote, because
    M33 has not finish clear GSR, this means Channel1 GCR writing will
    trigger Channel1 and Channel0 interrupt both which is wrong.
    
    Channel0 will be freed(SCMI channel status set to FREE) in M33 SM when
    processing the 1st Channel0 interrupt. So when 2nd interrupt trigger
    (channel 0/1 trigger together), SM will see a freed Channel0, and report
    protocol error.
    
    To address the issue, not using read/modify/update logic, just use
    write, because write 0 to GCR will be ignored. And after write MUA GCR,
    wait the SM to clear MUB GSR by looping MUA GCR value.
    
    Fixes: 5bfe4067 ("mailbox: imx: support channel type tx doorbell v2")
    Reviewed-by: default avatarRanjani Vaidyanathan <ranjani.vaidyanathan@nxp.com>
    Signed-off-by: default avatarPeng Fan <peng.fan@nxp.com>
    Signed-off-by: default avatarJassi Brar <jassisinghbrar@gmail.com>
    b5ef1791
imx-mailbox.c 28.5 KB