Unverified Commit 49ae74ab authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Mark Brown
Browse files

ASoC: SoundWire codecs: make regmap cache-only in probe

The SoundWire bus may start after the probe where the SoundWire ASoC
components are registered. This creates a time window where the card
can be created and the registers be accessed.

As discussed on the mailing list, we can't really control when codecs
are enumerated and initialized, but we can make sure the access to the
codecs is cached until the hardware is accessible.

This patch configures regcache_cache_only() with a 'true' parameter in
the probe function, and a 'false' parameter in the io_init routine.

The rt5682 is handled through a different patch due to its specific
cache handling.

Link: https://lore.kernel.org/alsa-devel/20230503144102.242240-1-krzysztof.kozlowski@linaro.org/


Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: default avatarRander Wang <rander.wang@intel.com>
Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20230802153629.53576-3-pierre-louis.bossart@linux.intel.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 3f3d66ba
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -160,10 +160,9 @@ static int max98363_io_init(struct sdw_slave *slave)
	struct max98363_priv *max98363 = dev_get_drvdata(dev);
	int ret, reg;

	if (max98363->first_hw_init) {
	regcache_cache_only(max98363->regmap, false);
	if (max98363->first_hw_init)
		regcache_cache_bypass(max98363->regmap, true);
	}

	/*
	 * PM runtime is only enabled when a Slave reports as Attached
@@ -409,6 +408,8 @@ static int max98363_init(struct sdw_slave *slave, struct regmap *regmap)
	max98363->regmap = regmap;
	max98363->slave = slave;

	regcache_cache_only(max98363->regmap, true);

	max98363->hw_init = false;
	max98363->first_hw_init = false;

+4 −3
Original line number Diff line number Diff line
@@ -361,10 +361,9 @@ static int max98373_io_init(struct sdw_slave *slave)
	struct device *dev = &slave->dev;
	struct max98373_priv *max98373 = dev_get_drvdata(dev);

	if (max98373->first_hw_init) {
	regcache_cache_only(max98373->regmap, false);
	if (max98373->first_hw_init)
		regcache_cache_bypass(max98373->regmap, true);
	}

	/*
	 * PM runtime is only enabled when a Slave reports as Attached
@@ -753,6 +752,8 @@ static int max98373_init(struct sdw_slave *slave, struct regmap *regmap)
	max98373->regmap = regmap;
	max98373->slave = slave;

	regcache_cache_only(max98373->regmap, true);

	max98373->cache_num = ARRAY_SIZE(max98373_sdw_cache_reg);
	max98373->cache = devm_kcalloc(dev, max98373->cache_num,
				       sizeof(*max98373->cache),
+4 −3
Original line number Diff line number Diff line
@@ -218,10 +218,9 @@ static int rt1308_io_init(struct device *dev, struct sdw_slave *slave)
	if (rt1308->hw_init)
		return 0;

	if (rt1308->first_hw_init) {
	regcache_cache_only(rt1308->regmap, false);
	if (rt1308->first_hw_init)
		regcache_cache_bypass(rt1308->regmap, true);
	}

	/*
	 * PM runtime is only enabled when a Slave reports as Attached
@@ -688,6 +687,8 @@ static int rt1308_sdw_init(struct device *dev, struct regmap *regmap,
	rt1308->sdw_slave = slave;
	rt1308->regmap = regmap;

	regcache_cache_only(rt1308->regmap, true);

	/*
	 * Mark hw_init to false
	 * HW init will be performed when device reports present
+3 −1
Original line number Diff line number Diff line
@@ -272,8 +272,8 @@ static int rt1316_io_init(struct device *dev, struct sdw_slave *slave)
	if (rt1316->hw_init)
		return 0;

	if (rt1316->first_hw_init) {
	regcache_cache_only(rt1316->regmap, false);
	if (rt1316->first_hw_init) {
		regcache_cache_bypass(rt1316->regmap, true);
	} else {
		/*
@@ -674,6 +674,8 @@ static int rt1316_sdw_init(struct device *dev, struct regmap *regmap,
	rt1316->sdw_slave = slave;
	rt1316->regmap = regmap;

	regcache_cache_only(rt1316->regmap, true);

	/*
	 * Mark hw_init to false
	 * HW init will be performed when device reports present
+3 −1
Original line number Diff line number Diff line
@@ -408,8 +408,8 @@ static int rt1318_io_init(struct device *dev, struct sdw_slave *slave)
	if (rt1318->hw_init)
		return 0;

	if (rt1318->first_hw_init) {
	regcache_cache_only(rt1318->regmap, false);
	if (rt1318->first_hw_init) {
		regcache_cache_bypass(rt1318->regmap, true);
	} else {
		/*
@@ -752,6 +752,8 @@ static int rt1318_sdw_init(struct device *dev, struct regmap *regmap,
	rt1318->sdw_slave = slave;
	rt1318->regmap = regmap;

	regcache_cache_only(rt1318->regmap, true);

	/*
	 * Mark hw_init to false
	 * HW init will be performed when device reports present
Loading