Skip to content

ASoC: SOF: implement polling mode on snd_hdac_bus_get_response and force polling mode on CFL/CNL - #963

Merged
plbossart merged 5 commits into
thesofproject:topic/sof-devfrom
bardliao:fix-long-latency
May 28, 2019
Merged

plbossart merged 5 commits into
thesofproject:topic/sof-devfrom
bardliao:fix-long-latency

Conversation

@bardliao

@bardliao bardliao commented May 20, 2019 •

Copy link
Copy Markdown
Collaborator

@KailangYang found that sometimes we will get a long latency response on WHL and we can set
polling_mode as a workaround on legacy HDA driver.
#900 (comment)
The workaround is already used on CFL. if (IS_CFL(pci))

However, there is no polling_mode on snd_hdac_bus_get_response.
We can move polling_mode flag from struct azx to struct hdac_bus and implement polling_mode on snd_hdac_bus_get_response(). Then force polling mode on CFL and CNL.

Fix #953

@plbossart

Copy link
Copy Markdown
Member

@bardliao can't we add this polling to the snd_hdac_bus_get_response() and use the chip = bus_to_azx(bus) accessor?
Also that function seems to lag behind the legacy driver big time, so likely additional updates if we want to support all cases

@libinyang

libinyang commented May 21, 2019 •

Copy link
Copy Markdown

The patch is OK to me. And I have the same suggestion as Pierre that it is better to change the generic function. My suggestion is to add polling_mode flag in hdac_bus. and code like:

if (bus->polling_mode || do_poll) //we don't need to poll at the first time
xxxx

@bardliao

bardliao commented May 21, 2019 •

Copy link
Copy Markdown
Collaborator Author

@bardliao can't we add this polling to the snd_hdac_bus_get_response() and use the chip = bus_to_azx(bus) accessor?
@plbossart Yes, I also prefer to use snd_hdac_bus_get_response(). Currently struct azx is only for legacy HDA driver, and we have struct sof_intel_hda_dev in sof. So it may not be a good idea to use struct azx here. I think what we can do is

  1. create a similar struct with polling_mode and replace struct hda_bus hbus in the struct sof_intel_hda_dev {} by the new struct. So we can get polling_mode in ''snd_hdac_bus_get_response()''.
    or
  2. Add polling_mode in struct hdac_bus so we can get polling_mode directly from bus->polling_mode in snd_hdac_bus_get_response().
    Option 2 is simpler than 1. We can even move polling_mode from struct azx to struct hdac_bus.
    What do you think?

Also that function seems to lag behind the legacy driver big time, so likely additional updates if we want to support all cases

Yes, it is also my concern. Actually I am thinking if we should implement the full function of polling_mode, i.e. switch to polling mode if it is timed out, or just add a workaround for some platforms.

@bardliao

Copy link
Copy Markdown
Collaborator Author

The patch is OK to me. And I have the same suggestion as Pierre that it is better to change the generic function. My suggestion is to add polling_mode flag in hdac_bus. and code like:

if (bus->polling_mode || do_poll) //we don't need to poll at the first time
xxxx

Thanks @libinyang it should be a easier way to implement polling mode in snd_hdac_bus_get_response()

@plbossart

Copy link
Copy Markdown
Member

The patch is OK to me. And I have the same suggestion as Pierre that it is better to change the generic function. My suggestion is to add polling_mode flag in hdac_bus. and code like:

if (bus->polling_mode || do_poll) //we don't need to poll at the first time
xxxx

Thanks @libinyang it should be a easier way to implement polling mode in snd_hdac_bus_get_response()

Except that it's not conceptually clean. The polling is a controller capability, not something related to the bus. The bus has no concept of polling.

@libinyang

Copy link
Copy Markdown

@plbossart Actually it is not controller capability, I think. Every hardware can do the polling. No special HW support is needed. And polling is the behavior of controller to poll codec. So it's more like bus related feature. I'm not sure why the community will put the flag in the controller. From my viewpoint, it should be put in bus.

Except that it's not conceptually clean. The polling is a controller capability, not something related to the bus. The bus has no concept of polling.

@mengdonglin

mengdonglin commented May 22, 2019 •

Copy link
Copy Markdown

@libinyang @bardliao @plbossart According to Realtek, this latency issues was observed on SKL at first many years ago, so the legacy-HDA driver introduced this fix.

And this fix also helps SOF, verified by
QA: #953 (comment)

@ranj063

ranj063 commented May 22, 2019

Copy link
Copy Markdown
Collaborator

@plbossart Actually it is not controller capability, I think. Every hardware can do the polling. No special HW support is needed. And polling is the behavior of controller to poll codec. So it's more like bus related feature. I'm not sure why the community will put the flag in the controller. From my viewpoint, it should be put in bus.

@libinyang please dont top post when you reply to comments. Always post under(like this one).

@libinyang

Copy link
Copy Markdown

@libinyang please dont top post when you reply to comments. Always post under(like this one).

@ranj063 Good tips. Thanks. I never realize it.

@keyonjie

Copy link
Copy Markdown

Hi @bardliao so are we missing RIRB interrupts here? I am wondering if the same issue existed with SST driver or SOF specific, and if there is anything wrong in our suspend/resume routines.

@bardliao

Copy link
Copy Markdown
Collaborator Author

Hi @bardliao so are we missing RIRB interrupts here?

@keyonjie Yes, I think so.

I am wondering if the same issue existed with SST driver or SOF specific, and if there is anything wrong in our suspend/resume routines.

I think it is a HW related issue. Please see #963 (comment)

@bardliao

Copy link
Copy Markdown
Collaborator Author

Except that it's not conceptually clean. The polling is a controller capability, not something related to the bus. The bus has no concept of polling.

@plbossart I think the polling_mode here is polling the rirb status by SW. So it's not about HW capability. However, the intent of this PR is to add a workaround for some specific platforms. In the point of view, it seems make more sense to add the polling_mode in a chip struct. That's the concept of option 1.

@plbossart Actually it is not controller capability, I think. Every hardware can do the polling. No special HW support is needed. And polling is the behavior of controller to poll codec. So it's more like bus related feature. I'm not sure why the community will put the flag in the controller. From my viewpoint, it should be put in bus.

@libinyang As you said, the polling mode is not a capability of bus either. Can we say it is a behavior of bus? I doubt it very much.

@plbossart

Copy link
Copy Markdown
Member

The definition of polling is an active loop to access a register/mmio.
This doesn't exist at the bus level, you don't poll a bus. It's only defined for entities that expose a register map, and for HDaudio this means a controller only. The codecs are accessed with commands/verbs.

@libinyang

Copy link
Copy Markdown

@plbossart @bardliao

Bus is not a HW device here in the driver. The bus means the connection of controller and chip. If you look into the struct hdac_bus, you will find it defines void __iomem *ppcap, *spbcap, *mlcap and other registers. And what's more, you will find in struct hdac_bus, it defines: struct hdac_rb corb, struct hdac_rb rirb. So if we are polling the corb and rirb, it is reasonable to put the flag in struct hdac_bus.

However, it will not impact on the feature implementation to put the flag in bus or chip. @bardliao when you submit the patch to community, please kindly cc me.

@bardliao
bardliao force-pushed the fix-long-latency branch from ae273c5 to 0c6bada Compare May 24, 2019 08:20
@bardliao bardliao changed the title [RFC] ASoC: SOF: create a specific get_response for sof ASoC: SOF: implement polling mode on snd_hdac_bus_get_response and force polling mode on CFL/CNL May 24, 2019
@bardliao

bardliao commented May 24, 2019 •

Copy link
Copy Markdown
Collaborator Author

Since the change will not only inside SOF, so ask for comment from alsa-dev first
https://www.spinics.net/lists/alsa-devel/msg91235.html.
Now the PR has updated and I will send it to upstream. But before that, can someone give me some comments?
@plbossart @libinyang @keyonjie @ranj063

@libinyang libinyang left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

patch seems OK to me. Only 2 comments:

  1. chip->poll_count++ seems to be good as bus->poll_count++
  2. not sure if we can merge the 2 get_response functions into 1?

@bardliao

Copy link
Copy Markdown
Collaborator Author

@libinyang

  1. chip->poll_count++ seems to be good as bus->poll_count++

Sounds good

  1. not sure if we can merge the 2 get_response functions into 1?

I don't know if it's worth doing that. And we still use struct azx in the function. eg.
if (chip->msi) {

@bardliao
bardliao force-pushed the fix-long-latency branch 2 times, most recently from ac749b3 to 90686cb Compare May 24, 2019 10:32
@bardliao
bardliao requested a review from libinyang May 24, 2019 10:33

@plbossart plbossart left a comment

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.

Sounds good @bardliao. I only have minor comments on typos, comments and patch splits. Please update and send upstream directly when you have the changes ready (long week-end in the USA, no need to wait for the reviews).

Comment thread sound/pci/hda/hda_intel.c
@@ -375,6 +375,7 @@ enum {

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.

fix typos/grammar in commit message.

We observed the same issue as reported by commit....

Comment thread sound/pci/hda/hda_intel.c Outdated

/* Workaround for a communication error on CFL (bko#199007) */
if (IS_CFL(pci))
/* Workaround for a communication error on CFL and CNL (bko#199007) */

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.

Workaround for a communication error on CFL (bko#199007) and CNL

Comment thread sound/pci/hda/hda_intel.c
/* Workaround for a communication error on CFL and CNL (bko#199007) */
if (IS_CFL(pci) || IS_CNL(pci))
chip->polling_mode = 1;

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.

you should move this first in a separate patch to allow for bisects.

for (loopcounter = 0;; loopcounter++) {
spin_lock_irq(&bus->reg_lock);
if (bus->polling_mode)
snd_hdac_bus_update_rirb(bus);

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.

should be separate patch to mirror the functionality in the legacy code.

Comment thread sound/soc/sof/intel/hda.c Outdated
#endif
sof_hda_bus_init(bus, &pci->dev, ext_ops);

/* Workaround for a communication error on CFL and CNL (bko#199007) */

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.

Workaround for a communication error on CFL (bko#199007) and CNL

@libinyang

Copy link
Copy Markdown

Use separate get_response is OK to me. So the PR is OK to me now.

libinyang
libinyang previously approved these changes May 27, 2019

@libinyang libinyang left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM.

bardliao added 5 commits May 27, 2019 12:46
We observed the same issue as reported by commit a8d7bde
("ALSA: hda - Force polling mode on CFL for fixing codec communication")
We don't have a better solution. So apply the same workaround to CNL.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
We will move the polling_mode flag from struct azx to struct hdac_bus,
and the flag should be assigned after bus init.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
polling mode is a useful function in the get_response function. Move
polling_mode flag from struct azx to struct hdac_bus so people can
implement polling mode in their own get_response function without
adding a polling_mode flag in their local chip structure.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Polling mode is useful if a machine somehow missed an expected IRQ.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
There is a workaround in legacy HDA codec for too long time respone
with CFL machine. We need the same workaround on SOF driver. The same
issue is also seen on CNL machine.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>

@plbossart plbossart left a comment

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.

will merge blindly since it's already upstream

@plbossart
plbossart merged commit d1008d1 into thesofproject:topic/sof-dev May 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][CML]Audio output via internal speaker will have 1-2s latency

6 participants