From 5c6df9e5cb5e54efb4301f8c261fb81fa45ce15f Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Wed, 16 Feb 2022 17:06:52 -0600 Subject: [PATCH] soundwire: intel: don't mask all status changes, only the detected ones On a status change, we mask all possible sources of interrupts (ATTACH, ALERT and UNATTACHED). This may not be so clever, for example when a device becomes UNATTACHED we will mask the ATTACH interrupt. If a device re-attaches immediately while we are processing the interrupt and workqueue, we may never detect attachment. FIXME: we've got to get rid of the set of 'if' tests. BugLink: https://github.com/thesofproject/linux/issues/3063 Signed-off-by: Pierre-Louis Bossart --- drivers/soundwire/cadence_master.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c index c2ed4d77393350..b9cfbee067feb2 100644 --- a/drivers/soundwire/cadence_master.c +++ b/drivers/soundwire/cadence_master.c @@ -925,9 +925,23 @@ irqreturn_t sdw_cdns_irq(int irq, void *dev_id) } if (int_status & CDNS_MCP_INT_SLAVE_MASK) { + + u32 slv_mask; + + slv_mask = cdns_readl(cdns, CDNS_MCP_INTMASK); + + /* FIXME: there must be a clever way to do this in one shot */ + if (int_status & CDNS_MCP_INT_SLAVE_RSVD) + slv_mask &= ~CDNS_MCP_INT_SLAVE_RSVD; + if (int_status & CDNS_MCP_INT_SLAVE_ALERT) + slv_mask &= ~CDNS_MCP_INT_SLAVE_ALERT; + if (int_status & CDNS_MCP_INT_SLAVE_ATTACH) + slv_mask &= ~CDNS_MCP_INT_SLAVE_ATTACH; + if (int_status & CDNS_MCP_INT_SLAVE_NATTACH) + slv_mask &= ~CDNS_MCP_INT_SLAVE_NATTACH; + /* Mask the Slave interrupt and wake thread */ - cdns_updatel(cdns, CDNS_MCP_INTMASK, - CDNS_MCP_INT_SLAVE_MASK, 0); + cdns_writel(cdns, CDNS_MCP_INTMASK, slv_mask); int_status &= ~CDNS_MCP_INT_SLAVE_MASK;