Skip to content
Merged
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
38 changes: 17 additions & 21 deletions sound/soc/sof/hw-spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,6 @@ static irqreturn_t spi_irq_handler(int irq __maybe_unused, void *context)
return IRQ_NONE;
}

static irqreturn_t spi_irq_thread(int irq __maybe_unused, void *context __maybe_unused)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am probably getting on your nerves but even this needs to be split in 3. My topic/sof-def-rebase have haswell, SKL and SPI added in 3 separate steps.

{
// read SPI data into local buffer and determine IPC cmd or reply

/*
* if reply. Handle Immediate reply from DSP Core and set DSP
* state to ready
*/

/* if cmd, Handle messages from DSP Core */

return IRQ_HANDLED;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lyakh can you do me a favor and not bundle things aren't ready for upstream with things that are. Specifically Haswell/SKL/KBL/Compressed/SPI are not shared upstream just yet, so it helps if your patches follow this split.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, what branch should I be making patches against? I was using topic/sof-dev, should I use integration/... instead?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lyakh we should use topic/sof-dev but if you look at the patches posted upstream HSW/KBL/SKL/Compressed/SPI are not included in them. So it will be easier to maintain the squash/rebase cycles if you split for ex. your commit: "ASoC: SOF: eliminate redundant mailbox reads" into 2. One intended for the files in the upstream patches and another one for those not in it (hsw.c etc).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, but how should I know which ones are and which ones aren't included? I think we need a separate branch, really.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lyakh check topic/sof-dev-rebase, everything after 'add build support' is not upstream yet. Ideally your patches should apply cleanly on the initial batch. Thanks!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plbossart let me take a semi-qualified guess: is this the commit, that I should be branching from?

commit af23c43
Author: Pierre-Louis Bossart pierre-louis.bossart@linux.intel.com
Date: Mon May 21 18:19:44 2018 -0500

ASoC: Intel: boards: initial support for Hifiberry Digiplus w/ WM8804

static int spi_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
{
/* send the message */
Expand Down Expand Up @@ -221,6 +207,23 @@ static int spi_get_reply(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
return ret;
}

static irqreturn_t spi_irq_thread(int irq __maybe_unused, void *context __maybe_unused)
{
struct snd_sof_dev *sdev = context;

// read SPI data into local buffer and determine IPC cmd or reply

/*
* if reply. Handle Immediate reply from DSP Core and set DSP
* state to ready
*/

/* if cmd, Handle messages from DSP Core */
spi_get_reply(sdev, sdev->msg);

return IRQ_HANDLED;
}

/*
* Probe and remove.
*/
Expand Down Expand Up @@ -265,11 +268,6 @@ static int spi_sof_remove(struct snd_sof_dev *sdev)
return 0;
}

static int spi_cmd_done(struct snd_sof_dev *sof_dev __maybe_unused, int dir __maybe_unused)
{
return 0;
}

/* SPI SOF ops */
const struct snd_sof_dsp_ops snd_sof_spi_ops = {
/* device init */
Expand All @@ -290,9 +288,7 @@ const struct snd_sof_dsp_ops snd_sof_spi_ops = {

/* ipc */
.send_msg = spi_send_msg,
.get_reply = spi_get_reply,
.fw_ready = spi_fw_ready,
.cmd_done = spi_cmd_done,

/* debug */
.debug_map = NULL/*spi_debugfs*/,
Expand Down
2 changes: 0 additions & 2 deletions sound/soc/sof/intel/apl.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ const struct snd_sof_dsp_ops sof_apl_ops = {

/* ipc */
.send_msg = hda_dsp_ipc_send_msg,
.get_reply = hda_dsp_ipc_get_reply,
.fw_ready = hda_dsp_ipc_fw_ready,
.cmd_done = hda_dsp_ipc_cmd_done,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ASoC: SOF: ipc prefix


/* debug */
.debug_map = apl_dsp_debugfs,
Expand Down
78 changes: 42 additions & 36 deletions sound/soc/sof/intel/bdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ static const struct snd_sof_debugfs_map bdw_debugfs[] = {
SOF_DEBUGFS_ACCESS_ALWAYS},
};

static int bdw_cmd_done(struct snd_sof_dev *sdev, int dir);
static void bdw_host_done(struct snd_sof_dev *sdev);
static void bdw_dsp_done(struct snd_sof_dev *sdev);
static void bdw_get_reply(struct snd_sof_dev *sdev);

/*
* DSP Control.
Expand Down Expand Up @@ -288,8 +290,10 @@ static irqreturn_t bdw_irq_thread(int irq, void *context)
* because the done bit can't be set in cmd_done function
* which is triggered by msg
*/
if (snd_sof_ipc_reply(sdev, ipcx))
bdw_cmd_done(sdev, SOF_IPC_DSP_REPLY);
bdw_get_reply(sdev);
snd_sof_ipc_reply(sdev, ipcx);

bdw_dsp_done(sdev);
}

ipcd = snd_sof_dsp_read(sdev, BDW_DSP_BAR, SHIM_IPCD);
Expand All @@ -309,6 +313,8 @@ static irqreturn_t bdw_irq_thread(int irq, void *context)
} else {
snd_sof_ipc_msgs_rx(sdev);
}

bdw_host_done(sdev);
}

return IRQ_HANDLED;
Expand Down Expand Up @@ -475,59 +481,61 @@ static int bdw_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
return 0;
}

static int bdw_get_reply(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
static void bdw_get_reply(struct snd_sof_dev *sdev)
{
struct snd_sof_ipc_msg *msg = sdev->msg;
struct sof_ipc_reply reply;
unsigned long flags;
int ret = 0;
u32 size;

/* get reply */
sof_mailbox_read(sdev, sdev->host_box.offset, &reply, sizeof(reply));

spin_lock_irqsave(&sdev->ipc_lock, flags);

if (reply.error < 0) {
size = sizeof(reply);
memcpy(msg->reply_data, &reply, sizeof(reply));
ret = reply.error;
} else {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lyakh please add a more complete prefix in your patches, e.g. for this one this should be ASoC: SOF: Intel since you are only touching intel-specific patches.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lyakh this comment still applies. ASoC: SOF: Intel prefix please, it makes things easier to track for reviewers (some of whom may not care about Intel specifics)

/* reply correct size ? */
if (reply.hdr.size != msg->reply_size) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, besides removing the else clause your patch also modifies the format for dev_err. I think that should be the subject of another patch.

dev_err(sdev->dev, "error: reply expected 0x%zx got 0x%x bytes\n",
dev_err(sdev->dev, "error: reply expected %zu got %u bytes\n",
msg->reply_size, reply.hdr.size);
size = msg->reply_size;
ret = -EINVAL;
} else {
size = reply.hdr.size;
}

/* read the message */
if (msg->reply_size > 0)
sof_mailbox_read(sdev, sdev->host_box.offset,
msg->reply_data, msg->reply_size);
}

/* read the message */
if (msg->msg_data && size > 0)
sof_mailbox_read(sdev, sdev->host_box.offset, msg->reply_data,
size);
msg->reply_error = ret;

return ret;
spin_unlock_irqrestore(&sdev->ipc_lock, flags);
}

static int bdw_cmd_done(struct snd_sof_dev *sdev, int dir)
static void bdw_host_done(struct snd_sof_dev *sdev)
{
if (dir == SOF_IPC_HOST_REPLY) {
/* clear BUSY bit and set DONE bit - accept new messages */
snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR, SHIM_IPCD,
SHIM_IPCD_BUSY | SHIM_IPCD_DONE,
SHIM_IPCD_DONE);

/* unmask busy interrupt */
snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR, SHIM_IMRX,
SHIM_IMRX_BUSY, 0);
} else {
/* clear DONE bit - tell DSP we have completed */
snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR, SHIM_IPCX,
SHIM_IPCX_DONE, 0);
/* clear BUSY bit and set DONE bit - accept new messages */
snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR, SHIM_IPCD,
SHIM_IPCD_BUSY | SHIM_IPCD_DONE,
SHIM_IPCD_DONE);

/* unmask busy interrupt */
snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR, SHIM_IMRX,
SHIM_IMRX_BUSY, 0);
}

/* unmask Done interrupt */
snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR, SHIM_IMRX,
SHIM_IMRX_DONE, 0);
}
static void bdw_dsp_done(struct snd_sof_dev *sdev)
{
/* clear DONE bit - tell DSP we have completed */
snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR, SHIM_IPCX,
SHIM_IPCX_DONE, 0);

return 0;
/* unmask Done interrupt */
snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR, SHIM_IMRX,
SHIM_IMRX_DONE, 0);
}

/*
Expand Down Expand Up @@ -664,9 +672,7 @@ const struct snd_sof_dsp_ops sof_bdw_ops = {

/* ipc */
.send_msg = bdw_send_msg,
.get_reply = bdw_get_reply,
.fw_ready = bdw_fw_ready,
.cmd_done = bdw_cmd_done,

/* debug */
.debug_map = bdw_debugfs,
Expand Down
86 changes: 44 additions & 42 deletions sound/soc/sof/intel/byt.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ static const struct snd_sof_debugfs_map cht_debugfs[] = {
SOF_DEBUGFS_ACCESS_ALWAYS},
};

static int byt_cmd_done(struct snd_sof_dev *sdev, int dir);
static void byt_host_done(struct snd_sof_dev *sdev);
static void byt_dsp_done(struct snd_sof_dev *sdev);
static void byt_get_reply(struct snd_sof_dev *sdev);

/*
* IPC Firmware ready.
Expand Down Expand Up @@ -312,7 +314,7 @@ static irqreturn_t byt_irq_handler(int irq, void *context)

static irqreturn_t byt_irq_thread(int irq, void *context)
{
struct snd_sof_dev *sdev = (struct snd_sof_dev *)context;
struct snd_sof_dev *sdev = context;
u64 ipcx, ipcd;
u64 imrx;

Expand All @@ -334,8 +336,10 @@ static irqreturn_t byt_irq_thread(int irq, void *context)
* because the done bit can't be set in cmd_done function
* which is triggered by msg
*/
if (snd_sof_ipc_reply(sdev, ipcx))
byt_cmd_done(sdev, SOF_IPC_DSP_REPLY);
byt_get_reply(sdev);
snd_sof_ipc_reply(sdev, ipcx);

byt_dsp_done(sdev);
}

/* new message from DSP */
Expand All @@ -355,6 +359,8 @@ static irqreturn_t byt_irq_thread(int irq, void *context)
} else {
snd_sof_ipc_msgs_rx(sdev);
}

byt_host_done(sdev);
}

return IRQ_HANDLED;
Expand All @@ -373,60 +379,62 @@ static int byt_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
return 0;
}

static int byt_get_reply(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
static void byt_get_reply(struct snd_sof_dev *sdev)
{
struct snd_sof_ipc_msg *msg = sdev->msg;
struct sof_ipc_reply reply;
unsigned long flags;
int ret = 0;
u32 size;

/* get reply */
sof_mailbox_read(sdev, sdev->host_box.offset, &reply, sizeof(reply));

spin_lock_irqsave(&sdev->ipc_lock, flags);

if (reply.error < 0) {
size = sizeof(reply);
memcpy(msg->reply_data, &reply, sizeof(reply));
ret = reply.error;
} else {
/* reply correct size ? */
if (reply.hdr.size != msg->reply_size) {
dev_err(sdev->dev, "error: reply expected 0x%zx got 0x%x bytes\n",
dev_err(sdev->dev, "error: reply expected %zu got %u bytes\n",
msg->reply_size, reply.hdr.size);
size = msg->reply_size;
ret = -EINVAL;
} else {
size = reply.hdr.size;
}

/* read the message */
if (msg->reply_size > 0)
sof_mailbox_read(sdev, sdev->host_box.offset,
msg->reply_data, msg->reply_size);
}

/* read the message */
if (msg->msg_data && size > 0)
sof_mailbox_read(sdev, sdev->host_box.offset, msg->reply_data,
size);
msg->reply_error = ret;

return ret;
spin_unlock_irqrestore(&sdev->ipc_lock, flags);
}

static int byt_cmd_done(struct snd_sof_dev *sdev, int dir)
static void byt_host_done(struct snd_sof_dev *sdev)
{
if (dir == SOF_IPC_HOST_REPLY) {
/* clear BUSY bit and set DONE bit - accept new messages */
snd_sof_dsp_update_bits64_unlocked(sdev, BYT_DSP_BAR, SHIM_IPCD,
SHIM_BYT_IPCD_BUSY |
SHIM_BYT_IPCD_DONE,
SHIM_BYT_IPCD_DONE);

/* unmask busy interrupt */
snd_sof_dsp_update_bits64_unlocked(sdev, BYT_DSP_BAR, SHIM_IMRX,
SHIM_IMRX_BUSY, 0);
} else {
/* clear DONE bit - tell DSP we have completed */
snd_sof_dsp_update_bits64_unlocked(sdev, BYT_DSP_BAR, SHIM_IPCX,
SHIM_BYT_IPCX_DONE, 0);
/* clear BUSY bit and set DONE bit - accept new messages */
snd_sof_dsp_update_bits64_unlocked(sdev, BYT_DSP_BAR, SHIM_IPCD,
SHIM_BYT_IPCD_BUSY |
SHIM_BYT_IPCD_DONE,
SHIM_BYT_IPCD_DONE);

/* unmask busy interrupt */
snd_sof_dsp_update_bits64_unlocked(sdev, BYT_DSP_BAR, SHIM_IMRX,
SHIM_IMRX_BUSY, 0);
}

/* unmask Done interrupt */
snd_sof_dsp_update_bits64_unlocked(sdev, BYT_DSP_BAR, SHIM_IMRX,
SHIM_IMRX_DONE, 0);
}
static void byt_dsp_done(struct snd_sof_dev *sdev)
{
/* clear DONE bit - tell DSP we have completed */
snd_sof_dsp_update_bits64_unlocked(sdev, BYT_DSP_BAR, SHIM_IPCX,
SHIM_BYT_IPCX_DONE, 0);

return 0;
/* unmask Done interrupt */
snd_sof_dsp_update_bits64_unlocked(sdev, BYT_DSP_BAR, SHIM_IMRX,
SHIM_IMRX_DONE, 0);
}

/*
Expand Down Expand Up @@ -603,9 +611,7 @@ const struct snd_sof_dsp_ops sof_tng_ops = {

/* ipc */
.send_msg = byt_send_msg,
.get_reply = byt_get_reply,
.fw_ready = byt_fw_ready,
.cmd_done = byt_cmd_done,

/* debug */
.debug_map = byt_debugfs,
Expand Down Expand Up @@ -764,9 +770,7 @@ const struct snd_sof_dsp_ops sof_byt_ops = {

/* ipc */
.send_msg = byt_send_msg,
.get_reply = byt_get_reply,
.fw_ready = byt_fw_ready,
.cmd_done = byt_cmd_done,

/* debug */
.debug_map = byt_debugfs,
Expand Down Expand Up @@ -820,9 +824,7 @@ const struct snd_sof_dsp_ops sof_cht_ops = {

/* ipc */
.send_msg = byt_send_msg,
.get_reply = byt_get_reply,
.fw_ready = byt_fw_ready,
.cmd_done = byt_cmd_done,

/* debug */
.debug_map = cht_debugfs,
Expand Down
Loading