Commit dd0b9619 authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Vinod Koul

soundwire: cadence: use directly bus sdw_defer structure

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/4056Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20230119073211.85979-4-yung-chuan.liao@linux.intel.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 45cb70f9
...@@ -237,7 +237,7 @@ static inline int do_transfer_defer(struct sdw_bus *bus, ...@@ -237,7 +237,7 @@ static inline int do_transfer_defer(struct sdw_bus *bus,
init_completion(&defer->complete); init_completion(&defer->complete);
for (i = 0; i <= retry; i++) { 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); ret = find_response_code(resp);
/* if cmd is ok or ignored return */ /* if cmd is ok or ignored return */
if (ret == 0 || ret == -ENODATA) if (ret == 0 || ret == -ENODATA)
......
...@@ -750,7 +750,7 @@ EXPORT_SYMBOL(cdns_xfer_msg); ...@@ -750,7 +750,7 @@ EXPORT_SYMBOL(cdns_xfer_msg);
enum sdw_command_response enum sdw_command_response
cdns_xfer_msg_defer(struct sdw_bus *bus, 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); struct sdw_cdns *cdns = bus_to_cdns(bus);
int cmd = 0, ret; int cmd = 0, ret;
...@@ -763,9 +763,6 @@ cdns_xfer_msg_defer(struct sdw_bus *bus, ...@@ -763,9 +763,6 @@ cdns_xfer_msg_defer(struct sdw_bus *bus,
if (ret) if (ret)
return SDW_CMD_FAIL_OTHER; return SDW_CMD_FAIL_OTHER;
cdns->defer = defer;
cdns->defer->length = msg->len;
return _cdns_xfer_msg(cdns, msg, cmd, 0, msg->len, true); return _cdns_xfer_msg(cdns, msg, cmd, 0, msg->len, true);
} }
EXPORT_SYMBOL(cdns_xfer_msg_defer); EXPORT_SYMBOL(cdns_xfer_msg_defer);
...@@ -879,13 +876,15 @@ irqreturn_t sdw_cdns_irq(int irq, void *dev_id) ...@@ -879,13 +876,15 @@ irqreturn_t sdw_cdns_irq(int irq, void *dev_id)
return IRQ_NONE; return IRQ_NONE;
if (int_status & CDNS_MCP_INT_RX_WL) { 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); cdns_read_response(cdns);
if (cdns->defer) { if (defer && defer->msg) {
cdns_fill_msg_resp(cdns, cdns->defer->msg, cdns_fill_msg_resp(cdns, defer->msg,
cdns->defer->length, 0); defer->length, 0);
complete(&cdns->defer->complete); complete(&defer->complete);
cdns->defer = NULL;
} else { } else {
complete(&cdns->tx_complete); complete(&cdns->tx_complete);
} }
......
...@@ -109,7 +109,6 @@ struct sdw_cdns_dai_runtime { ...@@ -109,7 +109,6 @@ struct sdw_cdns_dai_runtime {
* @instance: instance number * @instance: instance number
* @response_buf: SoundWire response buffer * @response_buf: SoundWire response buffer
* @tx_complete: Tx completion * @tx_complete: Tx completion
* @defer: Defer pointer
* @ports: Data ports * @ports: Data ports
* @num_ports: Total number of data ports * @num_ports: Total number of data ports
* @pcm: PCM streams * @pcm: PCM streams
...@@ -130,7 +129,6 @@ struct sdw_cdns { ...@@ -130,7 +129,6 @@ struct sdw_cdns {
u32 response_buf[CDNS_MCP_IP_MAX_CMD_LEN + 2]; u32 response_buf[CDNS_MCP_IP_MAX_CMD_LEN + 2];
struct completion tx_complete; struct completion tx_complete;
struct sdw_defer *defer;
struct sdw_cdns_port *ports; struct sdw_cdns_port *ports;
int num_ports; int num_ports;
...@@ -186,8 +184,7 @@ enum sdw_command_response ...@@ -186,8 +184,7 @@ enum sdw_command_response
cdns_xfer_msg(struct sdw_bus *bus, struct sdw_msg *msg); cdns_xfer_msg(struct sdw_bus *bus, struct sdw_msg *msg);
enum sdw_command_response enum sdw_command_response
cdns_xfer_msg_defer(struct sdw_bus *bus, cdns_xfer_msg_defer(struct sdw_bus *bus, struct sdw_msg *msg);
struct sdw_msg *msg, struct sdw_defer *defer);
u32 cdns_read_ping_status(struct sdw_bus *bus); u32 cdns_read_ping_status(struct sdw_bus *bus);
......
...@@ -851,8 +851,7 @@ struct sdw_master_ops { ...@@ -851,8 +851,7 @@ struct sdw_master_ops {
enum sdw_command_response (*xfer_msg) enum sdw_command_response (*xfer_msg)
(struct sdw_bus *bus, struct sdw_msg *msg); (struct sdw_bus *bus, struct sdw_msg *msg);
enum sdw_command_response (*xfer_msg_defer) enum sdw_command_response (*xfer_msg_defer)
(struct sdw_bus *bus, struct sdw_msg *msg, (struct sdw_bus *bus, struct sdw_msg *msg);
struct sdw_defer *defer);
int (*set_bus_conf)(struct sdw_bus *bus, int (*set_bus_conf)(struct sdw_bus *bus,
struct sdw_bus_params *params); struct sdw_bus_params *params);
int (*pre_bank_switch)(struct sdw_bus *bus); int (*pre_bank_switch)(struct sdw_bus *bus);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment