Skip to content
Merged
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
11 changes: 9 additions & 2 deletions sound/soc/sof/intel/hda-dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ static int hda_link_hw_params(struct snd_pcm_substream *substream,
link_dev = hda_link_stream_assign(bus, substream);
if (!link_dev)
return -EBUSY;

snd_soc_dai_set_dma_data(dai, substream, (void *)link_dev);

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.

@plbossart is this correct? what happens if link_dev isnt null on line 215, then we'd never set the dma_data?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

well, that's the whole point: when is this dma_data supposed to be set?

I understood the code as doing the stream assignment once, so if it's null the dma_data had to be set earlier.
Also there are multiple return cases so it's possible with errors that this dma_data is never set, so I moved it just after the stream is allocated.

But to be honest I really don't understand the code. The pattern of testing for something before allocating it assumes a state machine...

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.

@plbossart, @RanderWang added the get_dma_data() where it is now based on the bug with multi-pipeline usecase: c7f1b85

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

right, but the question is where should the set_dma_data() be done?
The way it's currently done is error prone, there are a set of return cases where this set_dma_data() would not be set, ever.

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.

@plbossart I think it should be done just outside the if (!link_dev) {} on line 223 instead

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

then we'd set the set_dma_data multiple times, no very clear why?

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.

@plbossart you are correct. Sorry I dont know what I was reading this morning. Maybe its time to have breakfast!

}

stream_tag = hdac_stream(link_dev)->stream_tag;
Expand All @@ -229,8 +231,6 @@ static int hda_link_hw_params(struct snd_pcm_substream *substream,
if (ret < 0)
return ret;

snd_soc_dai_set_dma_data(dai, substream, (void *)link_dev);

link = snd_hdac_ext_bus_get_link(bus, codec_dai->component->name);
if (!link)
return -EINVAL;
Expand Down Expand Up @@ -362,6 +362,13 @@ static int hda_link_hw_free(struct snd_pcm_substream *substream,
bus = hstream->bus;
rtd = snd_pcm_substream_chip(substream);
link_dev = snd_soc_dai_get_dma_data(dai, substream);

if (!link_dev) {
dev_dbg(dai->dev,
"%s: link_dev is not assigned\n", __func__);
return -EINVAL;
}

hda_stream = hstream_to_sof_hda_stream(link_dev);

/* free the link DMA channel in the FW */
Expand Down