Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions drivers/soundwire/intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment thread
plbossart marked this conversation as resolved.
Resolved
{
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);
}
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions drivers/soundwire/intel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
10 changes: 8 additions & 2 deletions drivers/soundwire/intel_ace2x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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,
Comment thread
plbossart marked this conversation as resolved.
Resolved
.sync_arm = intel_sync_arm,
.sync_go_unlocked = intel_sync_go_unlocked,
.sync_go = intel_sync_go,
Expand Down
34 changes: 25 additions & 9 deletions drivers/soundwire/intel_bus_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,24 @@ 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;
}

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;
Expand Down Expand Up @@ -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) {
Expand All @@ -123,16 +135,20 @@ 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;
}

if (!clock_stop0) {
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;
Expand Down
3 changes: 3 additions & 0 deletions include/linux/soundwire/sdw_intel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
Loading