diff --git a/drivers/soundwire/intel.c b/drivers/soundwire/intel.c index af65214836b4d0..bde06d0232c7e0 100644 --- a/drivers/soundwire/intel.c +++ b/drivers/soundwire/intel.c @@ -497,17 +497,22 @@ static int intel_link_power_down(struct sdw_intel *sdw) return ret; } -static void intel_shim_sync_arm(struct sdw_intel *sdw) +static void intel_shim_sync_arm_unlocked(struct sdw_intel *sdw) { void __iomem *shim = sdw->link_res->shim; u32 sync_reg; - mutex_lock(sdw->link_res->shim_lock); - /* update SYNC register */ sync_reg = intel_readl(shim, SDW_SHIM_SYNC); sync_reg |= (SDW_SHIM_SYNC_CMDSYNC << sdw->instance); intel_writel(shim, SDW_SHIM_SYNC, sync_reg); +} + +static void intel_shim_sync_arm(struct sdw_intel *sdw) +{ + mutex_lock(sdw->link_res->shim_lock); + + intel_shim_sync_arm_unlocked(sdw); mutex_unlock(sdw->link_res->shim_lock); } @@ -1088,6 +1093,7 @@ const struct sdw_intel_hw_ops sdw_intel_cnl_hw_ops = { .pre_bank_switch = intel_pre_bank_switch, .post_bank_switch = intel_post_bank_switch, + .sync_arm_unlocked = intel_shim_sync_arm_unlocked, .sync_arm = intel_shim_sync_arm, .sync_go_unlocked = intel_shim_sync_go_unlocked, .sync_go = intel_shim_sync_go, diff --git a/drivers/soundwire/intel.h b/drivers/soundwire/intel.h index 7a2e7e73ad632a..0e8c93e223c802 100644 --- a/drivers/soundwire/intel.h +++ b/drivers/soundwire/intel.h @@ -222,6 +222,12 @@ static inline void sdw_intel_shim_wake(struct sdw_intel *sdw, bool wake_enable) SDW_INTEL_OPS(sdw, shim_wake)(sdw, wake_enable); } +static inline void sdw_intel_sync_arm_unlocked(struct sdw_intel *sdw) +{ + if (SDW_INTEL_CHECK_OPS(sdw, sync_arm_unlocked)) + SDW_INTEL_OPS(sdw, sync_arm_unlocked)(sdw); +} + static inline void sdw_intel_sync_arm(struct sdw_intel *sdw) { if (SDW_INTEL_CHECK_OPS(sdw, sync_arm)) diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2x.c index 642b33ab552606..eebb4d44b6de4a 100644 --- a/drivers/soundwire/intel_ace2x.c +++ b/drivers/soundwire/intel_ace2x.c @@ -631,13 +631,18 @@ static int intel_link_power_down(struct sdw_intel *sdw) return ret; } -static void intel_sync_arm(struct sdw_intel *sdw) +static void intel_sync_arm_unlocked(struct sdw_intel *sdw) { unsigned int link_id = sdw->instance; + hdac_bus_eml_sdw_sync_arm_unlocked(sdw->link_res->hbus, link_id); +} + +static void intel_sync_arm(struct sdw_intel *sdw) +{ mutex_lock(sdw->link_res->shim_lock); - hdac_bus_eml_sdw_sync_arm_unlocked(sdw->link_res->hbus, link_id); + intel_sync_arm_unlocked(sdw); mutex_unlock(sdw->link_res->shim_lock); } @@ -1166,6 +1171,7 @@ const struct sdw_intel_hw_ops sdw_intel_lnl_hw_ops = { .pre_bank_switch = intel_pre_bank_switch, .post_bank_switch = intel_post_bank_switch, + .sync_arm_unlocked = intel_sync_arm_unlocked, .sync_arm = intel_sync_arm, .sync_go_unlocked = intel_sync_go_unlocked, .sync_go = intel_sync_go, diff --git a/drivers/soundwire/intel_bus_common.c b/drivers/soundwire/intel_bus_common.c index fa35eb2fc76328..61e0f99669ef4d 100644 --- a/drivers/soundwire/intel_bus_common.c +++ b/drivers/soundwire/intel_bus_common.c @@ -26,11 +26,15 @@ int intel_start_bus(struct sdw_intel *sdw) * follow recommended programming flows to avoid timeouts when * gsync is enabled */ - if (bus->multi_link) - sdw_intel_sync_arm(sdw); + if (bus->multi_link) { + mutex_lock(sdw->link_res->shim_lock); + sdw_intel_sync_arm_unlocked(sdw); + } ret = sdw_cdns_init(cdns); if (ret < 0) { + if (bus->multi_link) + mutex_unlock(sdw->link_res->shim_lock); dev_err(dev, "%s: unable to initialize Cadence IP: %d\n", __func__, ret); return ret; } @@ -38,7 +42,8 @@ int intel_start_bus(struct sdw_intel *sdw) sdw_cdns_config_update(cdns); if (bus->multi_link) { - ret = sdw_intel_sync_go(sdw); + ret = sdw_intel_sync_go_unlocked(sdw); + mutex_unlock(sdw->link_res->shim_lock); if (ret < 0) { dev_err(dev, "%s: sync go failed: %d\n", __func__, ret); return ret; @@ -104,14 +109,21 @@ int intel_start_bus_after_reset(struct sdw_intel *sdw) * follow recommended programming flows to avoid * timeouts when gsync is enabled */ - if (bus->multi_link) - sdw_intel_sync_arm(sdw); + if (bus->multi_link) { + mutex_lock(sdw->link_res->shim_lock); + sdw_intel_sync_arm_unlocked(sdw); + } /* * Re-initialize the IP since it was powered-off */ - sdw_cdns_init(&sdw->cdns); - + ret = sdw_cdns_init(&sdw->cdns); + if (ret < 0) { + if (bus->multi_link) + mutex_unlock(sdw->link_res->shim_lock); + dev_err(dev, "%s: unable to initialize Cadence IP: %d\n", __func__, ret); + return ret; + } } else { ret = sdw_cdns_enable_interrupt(cdns, true); if (ret < 0) { @@ -123,8 +135,11 @@ int intel_start_bus_after_reset(struct sdw_intel *sdw) ret = sdw_cdns_clock_restart(cdns, !clock_stop0); if (ret < 0) { dev_err(dev, "unable to restart clock during resume\n"); - if (!clock_stop0) + if (!clock_stop0) { sdw_cdns_enable_interrupt(cdns, false); + if (bus->multi_link) + mutex_unlock(sdw->link_res->shim_lock); + } return ret; } @@ -132,7 +147,8 @@ int intel_start_bus_after_reset(struct sdw_intel *sdw) sdw_cdns_config_update(cdns); if (bus->multi_link) { - ret = sdw_intel_sync_go(sdw); + ret = sdw_intel_sync_go_unlocked(sdw); + mutex_unlock(sdw->link_res->shim_lock); if (ret < 0) { dev_err(sdw->cdns.dev, "sync go failed during resume\n"); return ret; diff --git a/include/linux/soundwire/sdw_intel.h b/include/linux/soundwire/sdw_intel.h index 9710f2dc04e298..1d10183566aa23 100644 --- a/include/linux/soundwire/sdw_intel.h +++ b/include/linux/soundwire/sdw_intel.h @@ -404,6 +404,8 @@ struct sdw_intel; * @shim_wake: enable/disable in-band wake management * @pre_bank_switch: helper for bus management * @post_bank_switch: helper for bus management + * @sync_arm_unlocked: helper for multi-link synchronization - + * shim_lock is assumed to be locked at higher level * @sync_arm: helper for multi-link synchronization * @sync_go_unlocked: helper for multi-link synchronization - * shim_lock is assumed to be locked at higher level @@ -435,6 +437,7 @@ struct sdw_intel_hw_ops { int (*pre_bank_switch)(struct sdw_intel *sdw); int (*post_bank_switch)(struct sdw_intel *sdw); + void (*sync_arm_unlocked)(struct sdw_intel *sdw); void (*sync_arm)(struct sdw_intel *sdw); int (*sync_go_unlocked)(struct sdw_intel *sdw); int (*sync_go)(struct sdw_intel *sdw);