* [PATCH v2 0/7] ASoC/soundwire: filter out invalid PARITY errors
@ 2020-09-08 13:45 Bard Liao
2020-09-08 13:45 ` [PATCH v2 2/7] soundwire: bus: filter-out unwanted interrupt reports Bard Liao
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Bard Liao @ 2020-09-08 13:45 UTC (permalink / raw)
To: alsa-devel, vkoul
Cc: vinod.koul, linux-kernel, tiwai, broonie, gregkh, jank,
srinivas.kandagatla, rander.wang, ranjani.sridharan, hui.wang,
pierre-louis.bossart, sanyog.r.kale, mengdong.lin, bard.liao
Some codecs may report fake PARITY errors in the initial state. This
series will filter them out.
Pierre-Louis Bossart (7):
ASoC/soundwire: bus: use property to set interrupt masks
soundwire: bus: filter-out unwanted interrupt reports
soundwire: slave: add first_interrupt_done status
soundwire: bus: use quirk to filter out invalid parity errors
ASoC: codecs: realtek-soundwire: ignore initial PARITY errors
soundwire: bus: export broadcast read/write capability for tests
soundwire: cadence: add parity error injection through debugfs
drivers/soundwire/bus.c | 93 ++++++++++++++++++++++++------
drivers/soundwire/bus.h | 4 ++
drivers/soundwire/cadence_master.c | 86 +++++++++++++++++++++++++++
drivers/soundwire/slave.c | 1 +
include/linux/soundwire/sdw.h | 9 +++
sound/soc/codecs/max98373-sdw.c | 3 +
sound/soc/codecs/rt1308-sdw.c | 3 +
sound/soc/codecs/rt5682-sdw.c | 5 ++
sound/soc/codecs/rt700-sdw.c | 5 ++
sound/soc/codecs/rt711-sdw.c | 5 ++
sound/soc/codecs/rt715-sdw.c | 5 ++
sound/soc/codecs/wsa881x.c | 1 +
12 files changed, 202 insertions(+), 18 deletions(-)
Acked-by: Jaroslav Kysela <perex@perex.cz>
--
2.17.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 2/7] soundwire: bus: filter-out unwanted interrupt reports
2020-09-08 13:45 [PATCH v2 0/7] ASoC/soundwire: filter out invalid PARITY errors Bard Liao
@ 2020-09-08 13:45 ` Bard Liao
2020-09-08 13:45 ` [PATCH v2 4/7] soundwire: bus: use quirk to filter out invalid parity errors Bard Liao
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Bard Liao @ 2020-09-08 13:45 UTC (permalink / raw)
To: alsa-devel, vkoul
Cc: vinod.koul, linux-kernel, tiwai, broonie, gregkh, jank,
srinivas.kandagatla, rander.wang, ranjani.sridharan, hui.wang,
pierre-louis.bossart, sanyog.r.kale, mengdong.lin, bard.liao
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Unlike the traditional usage, in the SoundWire specification the
interrupt masks only gate the propagation of an interrupt condition to
the PING frame status. They do not gate the changes of the INT_STAT
registers, which will happen regardless of the mask settings. See
Figure 116 of the SoundWire 1.2 specification for an in-depth
description of the interrupt model.
When the bus driver reads the SCP_INT1_STAT register, it will retrieve
all the interrupt status, including for the mask fields that were not
explicitly set. For example, even if the PARITY mask is not set, the
PARITY error status will be reported if an implementation-defined
interrupt for jack detection is enabled and occurs.
Filtering undesired interrupt reports and handling has to be
implemented in software. This patch enables this filtering for the
INT1_IMPL_DEF, PARITY and BUS_CLASH interrupt sources.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
drivers/soundwire/bus.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
index 9f4cc24ccea3..029818b1f568 100644
--- a/drivers/soundwire/bus.c
+++ b/drivers/soundwire/bus.c
@@ -1394,12 +1394,14 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
* interrupt
*/
if (buf & SDW_SCP_INT1_PARITY) {
- dev_err(&slave->dev, "Parity error detected\n");
+ if (slave->prop.scp_int1_mask & SDW_SCP_INT1_PARITY)
+ dev_err(&slave->dev, "Parity error detected\n");
clear |= SDW_SCP_INT1_PARITY;
}
if (buf & SDW_SCP_INT1_BUS_CLASH) {
- dev_err(&slave->dev, "Bus clash error detected\n");
+ if (slave->prop.scp_int1_mask & SDW_SCP_INT1_BUS_CLASH)
+ dev_err(&slave->dev, "Bus clash detected\n");
clear |= SDW_SCP_INT1_BUS_CLASH;
}
@@ -1411,9 +1413,11 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
*/
if (buf & SDW_SCP_INT1_IMPL_DEF) {
- dev_dbg(&slave->dev, "Slave impl defined interrupt\n");
+ if (slave->prop.scp_int1_mask & SDW_SCP_INT1_IMPL_DEF) {
+ dev_dbg(&slave->dev, "Slave impl defined interrupt\n");
+ slave_notify = true;
+ }
clear |= SDW_SCP_INT1_IMPL_DEF;
- slave_notify = true;
}
/* Check port 0 - 3 interrupts */
--
2.17.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 4/7] soundwire: bus: use quirk to filter out invalid parity errors
2020-09-08 13:45 [PATCH v2 0/7] ASoC/soundwire: filter out invalid PARITY errors Bard Liao
2020-09-08 13:45 ` [PATCH v2 2/7] soundwire: bus: filter-out unwanted interrupt reports Bard Liao
@ 2020-09-08 13:45 ` Bard Liao
2020-09-08 13:45 ` [PATCH v2 7/7] soundwire: cadence: add parity error injection through debugfs Bard Liao
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Bard Liao @ 2020-09-08 13:45 UTC (permalink / raw)
To: alsa-devel, vkoul
Cc: vinod.koul, linux-kernel, tiwai, broonie, gregkh, jank,
srinivas.kandagatla, rander.wang, ranjani.sridharan, hui.wang,
pierre-louis.bossart, sanyog.r.kale, mengdong.lin, bard.liao
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
If a Slave device reports with a quirk that its initial parity check
may be incorrect, filter it but keep the parity checks active in
steady state.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
drivers/soundwire/bus.c | 8 +++++++-
include/linux/soundwire/sdw.h | 4 ++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
index 30b0bed16630..09185e5cfd70 100644
--- a/drivers/soundwire/bus.c
+++ b/drivers/soundwire/bus.c
@@ -1362,6 +1362,8 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
unsigned long port;
bool slave_notify = false;
u8 buf, buf2[2], _buf, _buf2[2];
+ bool parity_check;
+ bool parity_quirk;
sdw_modify_slave_status(slave, SDW_SLAVE_ALERT);
@@ -1394,7 +1396,11 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
* interrupt
*/
if (buf & SDW_SCP_INT1_PARITY) {
- if (slave->prop.scp_int1_mask & SDW_SCP_INT1_PARITY)
+ parity_check = slave->prop.scp_int1_mask & SDW_SCP_INT1_PARITY;
+ parity_quirk = !slave->first_interrupt_done &&
+ (slave->prop.quirks & SDW_SLAVE_QUIRKS_INVALID_INITIAL_PARITY);
+
+ if (parity_check && !parity_quirk)
dev_err(&slave->dev, "Parity error detected\n");
clear |= SDW_SCP_INT1_PARITY;
}
diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h
index 2b93a8ef7fad..790823d2d33b 100644
--- a/include/linux/soundwire/sdw.h
+++ b/include/linux/soundwire/sdw.h
@@ -358,6 +358,7 @@ struct sdw_dpn_prop {
* @src_dpn_prop: Source Data Port N properties
* @sink_dpn_prop: Sink Data Port N properties
* @scp_int1_mask: SCP_INT1_MASK desired settings
+ * @quirks: bitmask identifying deltas from the MIPI specification
*/
struct sdw_slave_prop {
u32 mipi_revision;
@@ -380,8 +381,11 @@ struct sdw_slave_prop {
struct sdw_dpn_prop *src_dpn_prop;
struct sdw_dpn_prop *sink_dpn_prop;
u8 scp_int1_mask;
+ u32 quirks;
};
+#define SDW_SLAVE_QUIRKS_INVALID_INITIAL_PARITY BIT(0)
+
/**
* struct sdw_master_prop - Master properties
* @revision: MIPI spec version of the implementation
--
2.17.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 7/7] soundwire: cadence: add parity error injection through debugfs
2020-09-08 13:45 [PATCH v2 0/7] ASoC/soundwire: filter out invalid PARITY errors Bard Liao
2020-09-08 13:45 ` [PATCH v2 2/7] soundwire: bus: filter-out unwanted interrupt reports Bard Liao
2020-09-08 13:45 ` [PATCH v2 4/7] soundwire: bus: use quirk to filter out invalid parity errors Bard Liao
@ 2020-09-08 13:45 ` Bard Liao
[not found] ` <20200908134521.6781-2-yung-chuan.liao@linux.intel.com>
2020-09-10 5:51 ` [PATCH v2 0/7] ASoC/soundwire: filter out invalid PARITY errors Vinod Koul
4 siblings, 0 replies; 6+ messages in thread
From: Bard Liao @ 2020-09-08 13:45 UTC (permalink / raw)
To: alsa-devel, vkoul
Cc: vinod.koul, linux-kernel, tiwai, broonie, gregkh, jank,
srinivas.kandagatla, rander.wang, ranjani.sridharan, hui.wang,
pierre-louis.bossart, sanyog.r.kale, mengdong.lin, bard.liao
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
The Cadence IP can inject errors, let's make use of this capability to
test Slave parity error checks.
See e.g. example log where both the master and slave detect the parity
error injected on a dummy read command.
cd /sys/kernel/debug/soundwire/master-1/intel-sdw/
echo 1 > cdns-parity-error-injection
[ 44.756249] intel-master sdw-master-1: Parity error
[ 44.756313] intel-master sdw-master-1: Msg NACK received
[ 44.756366] intel-master sdw-master-1: Msg NACKed for Slave 15
[ 44.756375] intel-master sdw-master-1: trf on Slave 15 failed:-5
[ 44.756382] intel-master sdw-master-1: parity error injection, read: -5
[ 44.756649] rt1308 sdw:1:25d:1308:0: Parity error detected
The code makes sure the Master device is resumed, hence the clock
restarted, before sending a parity error.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
drivers/soundwire/cadence_master.c | 86 ++++++++++++++++++++++++++++++
1 file changed, 86 insertions(+)
diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c
index ecf503fb23e1..13e565f93166 100644
--- a/drivers/soundwire/cadence_master.c
+++ b/drivers/soundwire/cadence_master.c
@@ -13,6 +13,7 @@
#include <linux/io.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
+#include <linux/pm_runtime.h>
#include <linux/soundwire/sdw_registers.h>
#include <linux/soundwire/sdw.h>
#include <sound/pcm_params.h>
@@ -50,6 +51,9 @@ MODULE_PARM_DESC(cdns_mcp_int_mask, "Cadence MCP IntMask");
#define CDNS_MCP_CONTROL_BLOCK_WAKEUP BIT(0)
#define CDNS_MCP_CMDCTRL 0x8
+
+#define CDNS_MCP_CMDCTRL_INSERT_PARITY_ERR BIT(2)
+
#define CDNS_MCP_SSPSTAT 0xC
#define CDNS_MCP_FRAME_SHAPE 0x10
#define CDNS_MCP_FRAME_SHAPE_INIT 0x14
@@ -366,6 +370,85 @@ static int cdns_hw_reset(void *data, u64 value)
DEFINE_DEBUGFS_ATTRIBUTE(cdns_hw_reset_fops, NULL, cdns_hw_reset, "%llu\n");
+static int cdns_parity_error_injection(void *data, u64 value)
+{
+ struct sdw_cdns *cdns = data;
+ struct sdw_bus *bus;
+ int ret;
+
+ if (value != 1)
+ return -EINVAL;
+
+ bus = &cdns->bus;
+
+ /*
+ * Resume Master device. If this results in a bus reset, the
+ * Slave devices will re-attach and be re-enumerated.
+ */
+ ret = pm_runtime_get_sync(bus->dev);
+ if (ret < 0 && ret != -EACCES) {
+ dev_err_ratelimited(cdns->dev,
+ "pm_runtime_get_sync failed in %s, ret %d\n",
+ __func__, ret);
+ pm_runtime_put_noidle(bus->dev);
+ return ret;
+ }
+
+ /*
+ * wait long enough for Slave(s) to be in steady state. This
+ * does not need to be super precise.
+ */
+ msleep(200);
+
+ /*
+ * Take the bus lock here to make sure that any bus transactions
+ * will be queued while we inject a parity error on a dummy read
+ */
+ mutex_lock(&bus->bus_lock);
+
+ /* program hardware to inject parity error */
+ cdns_updatel(cdns, CDNS_MCP_CMDCTRL,
+ CDNS_MCP_CMDCTRL_INSERT_PARITY_ERR,
+ CDNS_MCP_CMDCTRL_INSERT_PARITY_ERR);
+
+ /* commit changes */
+ cdns_updatel(cdns, CDNS_MCP_CONFIG_UPDATE,
+ CDNS_MCP_CONFIG_UPDATE_BIT,
+ CDNS_MCP_CONFIG_UPDATE_BIT);
+
+ /* do a broadcast dummy read to avoid bus clashes */
+ ret = sdw_bread_no_pm_unlocked(&cdns->bus, 0xf, SDW_SCP_DEVID_0);
+ dev_info(cdns->dev, "parity error injection, read: %d\n", ret);
+
+ /* program hardware to disable parity error */
+ cdns_updatel(cdns, CDNS_MCP_CMDCTRL,
+ CDNS_MCP_CMDCTRL_INSERT_PARITY_ERR,
+ 0);
+
+ /* commit changes */
+ cdns_updatel(cdns, CDNS_MCP_CONFIG_UPDATE,
+ CDNS_MCP_CONFIG_UPDATE_BIT,
+ CDNS_MCP_CONFIG_UPDATE_BIT);
+
+ /* Continue bus operation with parity error injection disabled */
+ mutex_unlock(&bus->bus_lock);
+
+ /* Userspace changed the hardware state behind the kernel's back */
+ add_taint(TAINT_USER, LOCKDEP_STILL_OK);
+
+ /*
+ * allow Master device to enter pm_runtime suspend. This may
+ * also result in Slave devices suspending.
+ */
+ pm_runtime_mark_last_busy(bus->dev);
+ pm_runtime_put_autosuspend(bus->dev);
+
+ return 0;
+}
+
+DEFINE_DEBUGFS_ATTRIBUTE(cdns_parity_error_fops, NULL,
+ cdns_parity_error_injection, "%llu\n");
+
/**
* sdw_cdns_debugfs_init() - Cadence debugfs init
* @cdns: Cadence instance
@@ -377,6 +460,9 @@ void sdw_cdns_debugfs_init(struct sdw_cdns *cdns, struct dentry *root)
debugfs_create_file("cdns-hw-reset", 0200, root, cdns,
&cdns_hw_reset_fops);
+
+ debugfs_create_file("cdns-parity-error-injection", 0200, root, cdns,
+ &cdns_parity_error_fops);
}
EXPORT_SYMBOL_GPL(sdw_cdns_debugfs_init);
--
2.17.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/7] ASoC/soundwire: bus: use property to set interrupt masks
[not found] ` <20200908134521.6781-2-yung-chuan.liao@linux.intel.com>
@ 2020-09-09 9:55 ` Mark Brown
0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2020-09-09 9:55 UTC (permalink / raw)
To: Bard Liao
Cc: alsa-devel, vkoul, vinod.koul, linux-kernel, tiwai, gregkh, jank,
srinivas.kandagatla, rander.wang, ranjani.sridharan, hui.wang,
pierre-louis.bossart, sanyog.r.kale, mengdong.lin, bard.liao
[-- Attachment #1: Type: text/plain, Size: 398 bytes --]
On Tue, Sep 08, 2020 at 09:45:15PM +0800, Bard Liao wrote:
> From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
>
> Add a slave-level property and program the SCP_INT1_MASK as desired by
> the codec driver. Since there is no DisCo property this has to be an
> implementation-specific firmware property or hard-coded in the driver.
Acked-by: Mark Brown <broonie@kernel.org>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/7] ASoC/soundwire: filter out invalid PARITY errors
2020-09-08 13:45 [PATCH v2 0/7] ASoC/soundwire: filter out invalid PARITY errors Bard Liao
` (3 preceding siblings ...)
[not found] ` <20200908134521.6781-2-yung-chuan.liao@linux.intel.com>
@ 2020-09-10 5:51 ` Vinod Koul
4 siblings, 0 replies; 6+ messages in thread
From: Vinod Koul @ 2020-09-10 5:51 UTC (permalink / raw)
To: Bard Liao
Cc: alsa-devel, linux-kernel, tiwai, broonie, gregkh, jank,
srinivas.kandagatla, rander.wang, ranjani.sridharan, hui.wang,
pierre-louis.bossart, sanyog.r.kale, mengdong.lin, bard.liao
On 08-09-20, 21:45, Bard Liao wrote:
> Some codecs may report fake PARITY errors in the initial state. This
> series will filter them out.
Applied, thanks
--
~Vinod
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-09-10 5:53 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-08 13:45 [PATCH v2 0/7] ASoC/soundwire: filter out invalid PARITY errors Bard Liao
2020-09-08 13:45 ` [PATCH v2 2/7] soundwire: bus: filter-out unwanted interrupt reports Bard Liao
2020-09-08 13:45 ` [PATCH v2 4/7] soundwire: bus: use quirk to filter out invalid parity errors Bard Liao
2020-09-08 13:45 ` [PATCH v2 7/7] soundwire: cadence: add parity error injection through debugfs Bard Liao
[not found] ` <20200908134521.6781-2-yung-chuan.liao@linux.intel.com>
2020-09-09 9:55 ` [PATCH v2 1/7] ASoC/soundwire: bus: use property to set interrupt masks Mark Brown
2020-09-10 5:51 ` [PATCH v2 0/7] ASoC/soundwire: filter out invalid PARITY errors Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®