* [PATCH 0/5] soundwire: better error handling in deferred transfers
@ 2023-01-13 9:35 Bard Liao
2023-01-13 9:35 ` [PATCH 1/5] soundwire: stream: uniquify dev_err() logs Bard Liao
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Bard Liao @ 2023-01-13 9:35 UTC (permalink / raw)
To: alsa-devel, vkoul
Cc: vinod.koul, linux-kernel, pierre-louis.bossart, bard.liao
This is a generic cleanup series.
Pierre-Louis Bossart (5):
soundwire: stream: uniquify dev_err() logs
soundwire: stream: use consistent pattern for freeing buffers
soundwire: bus: remove sdw_defer argument in sdw_transfer_defer()
soundwire: cadence: use directly bus sdw_defer structure
soundwire: cadence: further simplify low-level xfer_msg_defer()
callback
drivers/soundwire/bus.c | 12 +++++-------
drivers/soundwire/bus.h | 3 +--
drivers/soundwire/cadence_master.c | 20 ++++++++++----------
drivers/soundwire/cadence_master.h | 5 +----
drivers/soundwire/stream.c | 22 ++++++++++++----------
include/linux/soundwire/sdw.h | 6 +++---
6 files changed, 32 insertions(+), 36 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/5] soundwire: stream: uniquify dev_err() logs
2023-01-13 9:35 [PATCH 0/5] soundwire: better error handling in deferred transfers Bard Liao
@ 2023-01-13 9:35 ` Bard Liao
2023-01-13 10:22 ` Amadeusz Sławiński
2023-01-13 9:35 ` [PATCH 2/5] soundwire: stream: use consistent pattern for freeing buffers Bard Liao
` (3 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Bard Liao @ 2023-01-13 9:35 UTC (permalink / raw)
To: alsa-devel, vkoul
Cc: vinod.koul, linux-kernel, pierre-louis.bossart, bard.liao
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
There are a couple of duplicate logs which makes harder than needed to
follow the error flows. Add __func__ or make the log unique.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
drivers/soundwire/stream.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
index df3b36670df4..e0eae0b98267 100644
--- a/drivers/soundwire/stream.c
+++ b/drivers/soundwire/stream.c
@@ -1389,7 +1389,7 @@ static int _sdw_prepare_stream(struct sdw_stream_runtime *stream,
ret = do_bank_switch(stream);
if (ret < 0) {
- dev_err(bus->dev, "Bank switch failed: %d\n", ret);
+ dev_err(bus->dev, "do_bank_switch failed: %d\n", ret);
goto restore_params;
}
@@ -1477,7 +1477,7 @@ static int _sdw_enable_stream(struct sdw_stream_runtime *stream)
/* Program params */
ret = sdw_program_params(bus, false);
if (ret < 0) {
- dev_err(bus->dev, "Program params failed: %d\n", ret);
+ dev_err(bus->dev, "%s: Program params failed: %d\n", __func__, ret);
return ret;
}
@@ -1567,7 +1567,7 @@ static int _sdw_disable_stream(struct sdw_stream_runtime *stream)
/* Program params */
ret = sdw_program_params(bus, false);
if (ret < 0) {
- dev_err(bus->dev, "Program params failed: %d\n", ret);
+ dev_err(bus->dev, "%s: Program params failed: %d\n", __func__, ret);
return ret;
}
}
@@ -1664,7 +1664,7 @@ static int _sdw_deprepare_stream(struct sdw_stream_runtime *stream)
/* Program params */
ret = sdw_program_params(bus, false);
if (ret < 0) {
- dev_err(bus->dev, "Program params failed: %d\n", ret);
+ dev_err(bus->dev, "%s: Program params failed: %d\n", __func__, ret);
return ret;
}
}
@@ -1893,7 +1893,8 @@ int sdw_stream_add_master(struct sdw_bus *bus,
m_rt = sdw_master_rt_alloc(bus, stream);
if (!m_rt) {
- dev_err(bus->dev, "Master runtime alloc failed for stream:%s\n", stream->name);
+ dev_err(bus->dev, "%s: Master runtime alloc failed for stream:%s\n",
+ __func__, stream->name);
ret = -ENOMEM;
goto unlock;
}
@@ -2012,7 +2013,8 @@ int sdw_stream_add_slave(struct sdw_slave *slave,
*/
m_rt = sdw_master_rt_alloc(slave->bus, stream);
if (!m_rt) {
- dev_err(&slave->dev, "Master runtime alloc failed for stream:%s\n", stream->name);
+ dev_err(&slave->dev, "%s: Master runtime alloc failed for stream:%s\n",
+ __func__, stream->name);
ret = -ENOMEM;
goto unlock;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/5] soundwire: stream: use consistent pattern for freeing buffers
2023-01-13 9:35 [PATCH 0/5] soundwire: better error handling in deferred transfers Bard Liao
2023-01-13 9:35 ` [PATCH 1/5] soundwire: stream: uniquify dev_err() logs Bard Liao
@ 2023-01-13 9:35 ` Bard Liao
2023-01-13 9:35 ` [PATCH 3/5] soundwire: bus: remove sdw_defer argument in sdw_transfer_defer() Bard Liao
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Bard Liao @ 2023-01-13 9:35 UTC (permalink / raw)
To: alsa-devel, vkoul
Cc: vinod.koul, linux-kernel, pierre-louis.bossart, bard.liao
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
The code should free the message buffer used for data, the message
structure used for control and assign the latter to NULL. The last
part is missing for multi-link cases, and the order is inconsistent
for single-link cases.
Link: https://github.com/thesofproject/linux/issues/4056
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
drivers/soundwire/stream.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
index e0eae0b98267..f27bd37b154d 100644
--- a/drivers/soundwire/stream.c
+++ b/drivers/soundwire/stream.c
@@ -723,8 +723,8 @@ static int sdw_bank_switch(struct sdw_bus *bus, int m_rt_count)
}
if (!multi_link) {
- kfree(wr_msg);
kfree(wbuf);
+ kfree(wr_msg);
bus->defer_msg.msg = NULL;
bus->params.curr_bank = !bus->params.curr_bank;
bus->params.next_bank = !bus->params.next_bank;
@@ -769,6 +769,7 @@ static int sdw_ml_sync_bank_switch(struct sdw_bus *bus)
if (bus->defer_msg.msg) {
kfree(bus->defer_msg.msg->buf);
kfree(bus->defer_msg.msg);
+ bus->defer_msg.msg = NULL;
}
return 0;
@@ -867,6 +868,7 @@ static int do_bank_switch(struct sdw_stream_runtime *stream)
if (bus->defer_msg.msg) {
kfree(bus->defer_msg.msg->buf);
kfree(bus->defer_msg.msg);
+ bus->defer_msg.msg = NULL;
}
}
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/5] soundwire: bus: remove sdw_defer argument in sdw_transfer_defer()
2023-01-13 9:35 [PATCH 0/5] soundwire: better error handling in deferred transfers Bard Liao
2023-01-13 9:35 ` [PATCH 1/5] soundwire: stream: uniquify dev_err() logs Bard Liao
2023-01-13 9:35 ` [PATCH 2/5] soundwire: stream: use consistent pattern for freeing buffers Bard Liao
@ 2023-01-13 9:35 ` Bard Liao
2023-01-13 9:35 ` [PATCH 4/5] soundwire: cadence: use directly bus sdw_defer structure Bard Liao
2023-01-13 9:35 ` [PATCH 5/5] soundwire: cadence: further simplify low-level xfer_msg_defer() callback Bard Liao
4 siblings, 0 replies; 8+ messages in thread
From: Bard Liao @ 2023-01-13 9:35 UTC (permalink / raw)
To: alsa-devel, vkoul
Cc: vinod.koul, linux-kernel, pierre-louis.bossart, bard.liao
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
There's no point in passing an argument that is a pointer to a bus
member. We can directly get the member and do an indirection when
needed.
This is a first step before simplifying the hardware-specific
callbacks further.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
drivers/soundwire/bus.c | 10 ++++------
drivers/soundwire/bus.h | 3 +--
drivers/soundwire/stream.c | 4 +---
3 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
index 633d411b64f3..572cc9a9af41 100644
--- a/drivers/soundwire/bus.c
+++ b/drivers/soundwire/bus.c
@@ -225,9 +225,9 @@ static inline int do_transfer(struct sdw_bus *bus, struct sdw_msg *msg)
}
static inline int do_transfer_defer(struct sdw_bus *bus,
- struct sdw_msg *msg,
- struct sdw_defer *defer)
+ struct sdw_msg *msg)
{
+ struct sdw_defer *defer = &bus->defer_msg;
int retry = bus->prop.err_threshold;
enum sdw_command_response resp;
int ret = 0, i;
@@ -335,19 +335,17 @@ EXPORT_SYMBOL(sdw_show_ping_status);
* sdw_transfer_defer() - Asynchronously transfer message to a SDW Slave device
* @bus: SDW bus
* @msg: SDW message to be xfered
- * @defer: Defer block for signal completion
*
* Caller needs to hold the msg_lock lock while calling this
*/
-int sdw_transfer_defer(struct sdw_bus *bus, struct sdw_msg *msg,
- struct sdw_defer *defer)
+int sdw_transfer_defer(struct sdw_bus *bus, struct sdw_msg *msg)
{
int ret;
if (!bus->ops->xfer_msg_defer)
return -ENOTSUPP;
- ret = do_transfer_defer(bus, msg, defer);
+ ret = do_transfer_defer(bus, msg);
if (ret != 0 && ret != -ENODATA)
dev_err(bus->dev, "Defer trf on Slave %d failed:%d\n",
msg->dev_num, ret);
diff --git a/drivers/soundwire/bus.h b/drivers/soundwire/bus.h
index 7631ef5e71fb..96927a143796 100644
--- a/drivers/soundwire/bus.h
+++ b/drivers/soundwire/bus.h
@@ -151,8 +151,7 @@ int sdw_configure_dpn_intr(struct sdw_slave *slave, int port,
bool enable, int mask);
int sdw_transfer(struct sdw_bus *bus, struct sdw_msg *msg);
-int sdw_transfer_defer(struct sdw_bus *bus, struct sdw_msg *msg,
- struct sdw_defer *defer);
+int sdw_transfer_defer(struct sdw_bus *bus, struct sdw_msg *msg);
#define SDW_READ_INTR_CLEAR_RETRY 10
diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
index f27bd37b154d..e0b0c63fc55c 100644
--- a/drivers/soundwire/stream.c
+++ b/drivers/soundwire/stream.c
@@ -684,8 +684,6 @@ static int sdw_bank_switch(struct sdw_bus *bus, int m_rt_count)
if (!wr_msg)
return -ENOMEM;
- bus->defer_msg.msg = wr_msg;
-
wbuf = kzalloc(sizeof(*wbuf), GFP_KERNEL);
if (!wbuf) {
ret = -ENOMEM;
@@ -713,7 +711,7 @@ static int sdw_bank_switch(struct sdw_bus *bus, int m_rt_count)
multi_link = bus->multi_link && (m_rt_count >= bus->hw_sync_min_links);
if (multi_link)
- ret = sdw_transfer_defer(bus, wr_msg, &bus->defer_msg);
+ ret = sdw_transfer_defer(bus, wr_msg);
else
ret = sdw_transfer(bus, wr_msg);
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/5] soundwire: cadence: use directly bus sdw_defer structure
2023-01-13 9:35 [PATCH 0/5] soundwire: better error handling in deferred transfers Bard Liao
` (2 preceding siblings ...)
2023-01-13 9:35 ` [PATCH 3/5] soundwire: bus: remove sdw_defer argument in sdw_transfer_defer() Bard Liao
@ 2023-01-13 9:35 ` Bard Liao
2023-01-13 9:35 ` [PATCH 5/5] soundwire: cadence: further simplify low-level xfer_msg_defer() callback Bard Liao
4 siblings, 0 replies; 8+ messages in thread
From: Bard Liao @ 2023-01-13 9:35 UTC (permalink / raw)
To: alsa-devel, vkoul
Cc: vinod.koul, linux-kernel, pierre-louis.bossart, bard.liao
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Copying the bus sdw_defer structure into the Cadence internals leads
to using stale pointers and kernel oopses on errors. It's just simpler
and safer to use the bus sdw_defer structure directly.
Link: https://github.com/thesofproject/linux/issues/4056
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
drivers/soundwire/bus.c | 2 +-
drivers/soundwire/cadence_master.c | 17 ++++++++---------
drivers/soundwire/cadence_master.h | 5 +----
include/linux/soundwire/sdw.h | 3 +--
4 files changed, 11 insertions(+), 16 deletions(-)
diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
index 572cc9a9af41..fc192d0c61e7 100644
--- a/drivers/soundwire/bus.c
+++ b/drivers/soundwire/bus.c
@@ -237,7 +237,7 @@ static inline int do_transfer_defer(struct sdw_bus *bus,
init_completion(&defer->complete);
for (i = 0; i <= retry; i++) {
- resp = bus->ops->xfer_msg_defer(bus, msg, defer);
+ resp = bus->ops->xfer_msg_defer(bus, msg);
ret = find_response_code(resp);
/* if cmd is ok or ignored return */
if (ret == 0 || ret == -ENODATA)
diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c
index 521387322145..2365395cb181 100644
--- a/drivers/soundwire/cadence_master.c
+++ b/drivers/soundwire/cadence_master.c
@@ -750,7 +750,7 @@ EXPORT_SYMBOL(cdns_xfer_msg);
enum sdw_command_response
cdns_xfer_msg_defer(struct sdw_bus *bus,
- struct sdw_msg *msg, struct sdw_defer *defer)
+ struct sdw_msg *msg)
{
struct sdw_cdns *cdns = bus_to_cdns(bus);
int cmd = 0, ret;
@@ -763,9 +763,6 @@ cdns_xfer_msg_defer(struct sdw_bus *bus,
if (ret)
return SDW_CMD_FAIL_OTHER;
- cdns->defer = defer;
- cdns->defer->length = msg->len;
-
return _cdns_xfer_msg(cdns, msg, cmd, 0, msg->len, true);
}
EXPORT_SYMBOL(cdns_xfer_msg_defer);
@@ -893,13 +890,15 @@ irqreturn_t sdw_cdns_irq(int irq, void *dev_id)
return IRQ_NONE;
if (int_status & CDNS_MCP_INT_RX_WL) {
+ struct sdw_bus *bus = &cdns->bus;
+ struct sdw_defer *defer = &bus->defer_msg;
+
cdns_read_response(cdns);
- if (cdns->defer) {
- cdns_fill_msg_resp(cdns, cdns->defer->msg,
- cdns->defer->length, 0);
- complete(&cdns->defer->complete);
- cdns->defer = NULL;
+ if (defer && defer->msg) {
+ cdns_fill_msg_resp(cdns, defer->msg,
+ defer->length, 0);
+ complete(&defer->complete);
} else {
complete(&cdns->tx_complete);
}
diff --git a/drivers/soundwire/cadence_master.h b/drivers/soundwire/cadence_master.h
index fa9dc38264a4..53029d22822d 100644
--- a/drivers/soundwire/cadence_master.h
+++ b/drivers/soundwire/cadence_master.h
@@ -109,7 +109,6 @@ struct sdw_cdns_dai_runtime {
* @instance: instance number
* @response_buf: SoundWire response buffer
* @tx_complete: Tx completion
- * @defer: Defer pointer
* @ports: Data ports
* @num_ports: Total number of data ports
* @pcm: PCM streams
@@ -130,7 +129,6 @@ struct sdw_cdns {
u32 response_buf[CDNS_MCP_IP_MAX_CMD_LEN + 2];
struct completion tx_complete;
- struct sdw_defer *defer;
struct sdw_cdns_port *ports;
int num_ports;
@@ -189,8 +187,7 @@ enum sdw_command_response
cdns_xfer_msg(struct sdw_bus *bus, struct sdw_msg *msg);
enum sdw_command_response
-cdns_xfer_msg_defer(struct sdw_bus *bus,
- struct sdw_msg *msg, struct sdw_defer *defer);
+cdns_xfer_msg_defer(struct sdw_bus *bus, struct sdw_msg *msg);
u32 cdns_read_ping_status(struct sdw_bus *bus);
diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h
index 3cd2a761911f..fb2bd1524a26 100644
--- a/include/linux/soundwire/sdw.h
+++ b/include/linux/soundwire/sdw.h
@@ -852,8 +852,7 @@ struct sdw_master_ops {
enum sdw_command_response (*xfer_msg)
(struct sdw_bus *bus, struct sdw_msg *msg);
enum sdw_command_response (*xfer_msg_defer)
- (struct sdw_bus *bus, struct sdw_msg *msg,
- struct sdw_defer *defer);
+ (struct sdw_bus *bus, struct sdw_msg *msg);
enum sdw_command_response (*reset_page_addr)
(struct sdw_bus *bus, unsigned int dev_num);
int (*set_bus_conf)(struct sdw_bus *bus,
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/5] soundwire: cadence: further simplify low-level xfer_msg_defer() callback
2023-01-13 9:35 [PATCH 0/5] soundwire: better error handling in deferred transfers Bard Liao
` (3 preceding siblings ...)
2023-01-13 9:35 ` [PATCH 4/5] soundwire: cadence: use directly bus sdw_defer structure Bard Liao
@ 2023-01-13 9:35 ` Bard Liao
4 siblings, 0 replies; 8+ messages in thread
From: Bard Liao @ 2023-01-13 9:35 UTC (permalink / raw)
To: alsa-devel, vkoul
Cc: vinod.koul, linux-kernel, pierre-louis.bossart, bard.liao
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
The message pointer is already stored in the bus->defer structure, not
need to pass it as an argument.
Suggested-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
drivers/soundwire/bus.c | 2 +-
drivers/soundwire/cadence_master.c | 5 +++--
drivers/soundwire/cadence_master.h | 2 +-
include/linux/soundwire/sdw.h | 5 +++--
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
index fc192d0c61e7..ed94c92bc575 100644
--- a/drivers/soundwire/bus.c
+++ b/drivers/soundwire/bus.c
@@ -237,7 +237,7 @@ static inline int do_transfer_defer(struct sdw_bus *bus,
init_completion(&defer->complete);
for (i = 0; i <= retry; i++) {
- resp = bus->ops->xfer_msg_defer(bus, msg);
+ resp = bus->ops->xfer_msg_defer(bus);
ret = find_response_code(resp);
/* if cmd is ok or ignored return */
if (ret == 0 || ret == -ENODATA)
diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c
index 2365395cb181..ece0ad89746f 100644
--- a/drivers/soundwire/cadence_master.c
+++ b/drivers/soundwire/cadence_master.c
@@ -749,10 +749,11 @@ cdns_xfer_msg(struct sdw_bus *bus, struct sdw_msg *msg)
EXPORT_SYMBOL(cdns_xfer_msg);
enum sdw_command_response
-cdns_xfer_msg_defer(struct sdw_bus *bus,
- struct sdw_msg *msg)
+cdns_xfer_msg_defer(struct sdw_bus *bus)
{
struct sdw_cdns *cdns = bus_to_cdns(bus);
+ struct sdw_defer *defer = &bus->defer_msg;
+ struct sdw_msg *msg = defer->msg;
int cmd = 0, ret;
/* for defer only 1 message is supported */
diff --git a/drivers/soundwire/cadence_master.h b/drivers/soundwire/cadence_master.h
index 53029d22822d..63c58b9b1f59 100644
--- a/drivers/soundwire/cadence_master.h
+++ b/drivers/soundwire/cadence_master.h
@@ -187,7 +187,7 @@ enum sdw_command_response
cdns_xfer_msg(struct sdw_bus *bus, struct sdw_msg *msg);
enum sdw_command_response
-cdns_xfer_msg_defer(struct sdw_bus *bus, struct sdw_msg *msg);
+cdns_xfer_msg_defer(struct sdw_bus *bus);
u32 cdns_read_ping_status(struct sdw_bus *bus);
diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h
index fb2bd1524a26..86e320cf27b1 100644
--- a/include/linux/soundwire/sdw.h
+++ b/include/linux/soundwire/sdw.h
@@ -837,7 +837,8 @@ struct sdw_defer {
* @read_prop: Read Master properties
* @override_adr: Override value read from firmware (quirk for buggy firmware)
* @xfer_msg: Transfer message callback
- * @xfer_msg_defer: Defer version of transfer message callback
+ * @xfer_msg_defer: Defer version of transfer message callback. The message is handled with the
+ * bus struct @sdw_defer
* @reset_page_addr: Reset the SCP page address registers
* @set_bus_conf: Set the bus configuration
* @pre_bank_switch: Callback for pre bank switch
@@ -852,7 +853,7 @@ struct sdw_master_ops {
enum sdw_command_response (*xfer_msg)
(struct sdw_bus *bus, struct sdw_msg *msg);
enum sdw_command_response (*xfer_msg_defer)
- (struct sdw_bus *bus, struct sdw_msg *msg);
+ (struct sdw_bus *bus);
enum sdw_command_response (*reset_page_addr)
(struct sdw_bus *bus, unsigned int dev_num);
int (*set_bus_conf)(struct sdw_bus *bus,
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/5] soundwire: stream: uniquify dev_err() logs
2023-01-13 9:35 ` [PATCH 1/5] soundwire: stream: uniquify dev_err() logs Bard Liao
@ 2023-01-13 10:22 ` Amadeusz Sławiński
2023-01-13 17:48 ` Pierre-Louis Bossart
0 siblings, 1 reply; 8+ messages in thread
From: Amadeusz Sławiński @ 2023-01-13 10:22 UTC (permalink / raw)
To: Bard Liao, alsa-devel, vkoul
Cc: pierre-louis.bossart, vinod.koul, bard.liao, linux-kernel
On 1/13/2023 10:35 AM, Bard Liao wrote:
> From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
>
> There are a couple of duplicate logs which makes harder than needed to
> follow the error flows. Add __func__ or make the log unique.
>
> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
> ---
> drivers/soundwire/stream.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
> index df3b36670df4..e0eae0b98267 100644
> --- a/drivers/soundwire/stream.c
> +++ b/drivers/soundwire/stream.c
> @@ -1389,7 +1389,7 @@ static int _sdw_prepare_stream(struct sdw_stream_runtime *stream,
>
> ret = do_bank_switch(stream);
> if (ret < 0) {
> - dev_err(bus->dev, "Bank switch failed: %d\n", ret);
> + dev_err(bus->dev, "do_bank_switch failed: %d\n", ret);
> goto restore_params;
> }
This one seems bit unrelated to the change and makes error message
inconsistent with:
https://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire.git/tree/drivers/soundwire/stream.c?h=next&id=545c365185a47672b1d5cc13c84057a1e874993c#n1498
and
https://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire.git/tree/drivers/soundwire/stream.c?h=next&id=545c365185a47672b1d5cc13c84057a1e874993c#n1575
which actually brings me to another suggestion, can this error message
perhaps be just moved into do_bank_switch() function itself, instead of
being duplicated multiple times or alternatively just also prefix all of
them with function name?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/5] soundwire: stream: uniquify dev_err() logs
2023-01-13 10:22 ` Amadeusz Sławiński
@ 2023-01-13 17:48 ` Pierre-Louis Bossart
0 siblings, 0 replies; 8+ messages in thread
From: Pierre-Louis Bossart @ 2023-01-13 17:48 UTC (permalink / raw)
To: Amadeusz Sławiński, Bard Liao, alsa-devel, vkoul
Cc: vinod.koul, bard.liao, linux-kernel
On 1/13/23 04:22, Amadeusz Sławiński wrote:
> On 1/13/2023 10:35 AM, Bard Liao wrote:
>> From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
>>
>> There are a couple of duplicate logs which makes harder than needed to
>> follow the error flows. Add __func__ or make the log unique.
>>
>> Signed-off-by: Pierre-Louis Bossart
>> <pierre-louis.bossart@linux.intel.com>
>> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
>> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
>> ---
>> drivers/soundwire/stream.c | 14 ++++++++------
>> 1 file changed, 8 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
>> index df3b36670df4..e0eae0b98267 100644
>> --- a/drivers/soundwire/stream.c
>> +++ b/drivers/soundwire/stream.c
>> @@ -1389,7 +1389,7 @@ static int _sdw_prepare_stream(struct
>> sdw_stream_runtime *stream,
>> ret = do_bank_switch(stream);
>> if (ret < 0) {
>> - dev_err(bus->dev, "Bank switch failed: %d\n", ret);
>> + dev_err(bus->dev, "do_bank_switch failed: %d\n", ret);
>> goto restore_params;
>> }
>
> This one seems bit unrelated to the change and makes error message
> inconsistent with:
> https://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire.git/tree/drivers/soundwire/stream.c?h=next&id=545c365185a47672b1d5cc13c84057a1e874993c#n1498
> and
> https://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire.git/tree/drivers/soundwire/stream.c?h=next&id=545c365185a47672b1d5cc13c84057a1e874993c#n1575
> which actually brings me to another suggestion, can this error message
> perhaps be just moved into do_bank_switch() function itself, instead of
> being duplicated multiple times or alternatively just also prefix all of
> them with function name?
well, as you correctly pointed out, there are multiple users of
'do_bank_switch' so we don't want to put the message in the function itself.
We could indeed use __func__ instead, that'd be fine.
Looking at the code, there are also inconsistencies with the use of
pr_err and dev_err. dev_err(bus->dev is wrong actually, this would use
the bus variable assigned in the previous loop, this makes no sense for
multi-segment topologies.
Let's drop this patch and revisit all this, hope Vinod can deal with
patch 1..4 otherwise we'll resend the set.
Thanks Amadeusz for the feedback.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-01-13 17:56 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-13 9:35 [PATCH 0/5] soundwire: better error handling in deferred transfers Bard Liao
2023-01-13 9:35 ` [PATCH 1/5] soundwire: stream: uniquify dev_err() logs Bard Liao
2023-01-13 10:22 ` Amadeusz Sławiński
2023-01-13 17:48 ` Pierre-Louis Bossart
2023-01-13 9:35 ` [PATCH 2/5] soundwire: stream: use consistent pattern for freeing buffers Bard Liao
2023-01-13 9:35 ` [PATCH 3/5] soundwire: bus: remove sdw_defer argument in sdw_transfer_defer() Bard Liao
2023-01-13 9:35 ` [PATCH 4/5] soundwire: cadence: use directly bus sdw_defer structure Bard Liao
2023-01-13 9:35 ` [PATCH 5/5] soundwire: cadence: further simplify low-level xfer_msg_defer() callback Bard Liao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).