From 6ab59459b01efb1166ad0b9b0300c3ab4e5745ff Mon Sep 17 00:00:00 2001 From: fangbaoshun Date: Sun, 10 Jan 2021 16:16:23 +0800 Subject: [PATCH] anolis: crypto: ccp: Fix PSP interrupt register's write race ANBZ: #6744 The wait_event() function is used to detect command completion. The interrupt handler will set the wait condition variable when the interrupt is triggered. However, the interrupt regester is cleared after the wake_up() function, which can create a race condition on multi-core processor, the 2nd command and its completion set the interrupt register before the 1st IRQ cleared the interrupt register.Because the IRQ and the PSP thread may run on different cores, this will result in the 2nd command's wait_event() never returning. make interrupt register's clear before wake_up() function. Signed-off-by: fangbaoshun --- drivers/crypto/ccp/psp-dev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index c63309ff5f0d..a6f0207a6b5b 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -105,6 +105,9 @@ static irqreturn_t psp_irq_handler(int irq, void *data) /* Read the interrupt status: */ status = ioread32(psp->io_regs + psp->vdata->intsts_reg); + /* Clear the interrupt status by writing the same value we read. */ + iowrite32(status, psp->io_regs + psp->vdata->intsts_reg); + /* invoke subdevice interrupt handlers */ if (status) { if (psp->sev_irq_handler) @@ -114,9 +117,6 @@ static irqreturn_t psp_irq_handler(int irq, void *data) psp->tee_irq_handler(irq, psp->tee_irq_data, status); } - /* Clear the interrupt status by writing the same value we read. */ - iowrite32(status, psp->io_regs + psp->vdata->intsts_reg); - return IRQ_HANDLED; } -- Gitee