Skip to content

soundwire: cadence: recheck device0 attachment after status change - #3442

Merged
plbossart merged 1 commit into
thesofproject:topic/sof-devfrom
plbossart:fix/sdw-dev0-race-condition
Feb 24, 2022
Merged

soundwire: cadence: recheck device0 attachment after status change#3442
plbossart merged 1 commit into
thesofproject:topic/sof-devfrom
plbossart:fix/sdw-dev0-race-condition

Conversation

@plbossart

Copy link
Copy Markdown
Member

This patch adds a status check after device0 attachment to solve race
conditions observed during attachment with multiple devices per link

The sequence is the following

  1. deviceA attaches as device0

  2. the hardware detects a device0 status change and throws an
    interrupt.

  3. the interrupt handler schedules the work function

  4. the workqueue starts, we read the status
    slave0 = cdns_readl(cdns, CDNS_MCP_SLAVE_INTSTAT0);
    slave1 = cdns_readl(cdns, CDNS_MCP_SLAVE_INTSTAT1);

we deal with the status change and program deviceA device number to a
non-zero value.

  1. deviceB attaches as device0, the device0 status seen by the
    hardware does not change.

  2. we clear the CDNS_MCP_SLAVE_INTSTAT0/1 registers -> we will never detect
    deviceB!

This patch suggest re-checking in a loop the device0 status with a
PING frame, i.e. using the real device0 status instead of information
on status changes.

Signed-off-by: Pierre-Louis Bossart pierre-louis.bossart@linux.intel.com

This patch adds a status check after device0 attachment to solve race
conditions observed during attachment with multiple devices per link

The sequence is the following

1) deviceA attaches as device0

2) the hardware detects a device0 status change and throws an
 interrupt.

3) the interrupt handler schedules the work function

4) the workqueue starts, we read the status
slave0 = cdns_readl(cdns, CDNS_MCP_SLAVE_INTSTAT0);
slave1 = cdns_readl(cdns, CDNS_MCP_SLAVE_INTSTAT1);

we deal with the status change and program deviceA device number to a
non-zero value.

5) deviceB attaches as device0, the device0 status seen by the
hardware does not change.

6) we clear the CDNS_MCP_SLAVE_INTSTAT0/1 registers -> we will never detect
deviceB!

This patch suggest re-checking in a loop the device0 status with a
PING frame, i.e. using the real device0 status instead of information
on status changes.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
@plbossart
plbossart force-pushed the fix/sdw-dev0-race-condition branch from 19512ff to aedea04 Compare February 17, 2022 21:42
@marc-hb

marc-hb commented Feb 17, 2022

Copy link
Copy Markdown
Collaborator

Is this related to some existing bug(s) already filed? If yes then the links would be useful IMHO.

@plbossart

Copy link
Copy Markdown
Member Author

Is this related to some existing bug(s) already filed? If yes then the links would be useful IMHO.

yeah, forgot to add
BugLink: #3063

@bardliao bardliao left a comment

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.

LGTM, let's see will this patch fix the issue.

@RanderWang

Copy link
Copy Markdown

Why once the device is unattached , it will never be attached again ?

Comment thread drivers/soundwire/cadence_master.c
@plbossart

Copy link
Copy Markdown
Member Author

Why once the device is unattached , it will never be attached again ?

thats' the point, it may reattach but if it does so before we clear the interrupt status bits we will never detect it.
If the device re-attaches after we clear the interrupt status, we should see it come back as attached.

@RanderWang RanderWang 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

@plbossart

Copy link
Copy Markdown
Member Author

ok, let's merge this and see if this changes the behavior on Volteer+TGL RVP.

@bardliao let's wait to upstream this for now, we need at least a couple of weeks of test results.

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.

4 participants