ASoC: amd: Replacing MSI with Legacy IRQ model
authorRavulapati Vishnu vardhan rao <Vishnuvardhanrao.Ravulapati@amd.com>
Tue, 22 Dec 2020 11:59:18 +0000 (17:29 +0530)
committerMark Brown <broonie@kernel.org>
Mon, 28 Dec 2020 14:22:27 +0000 (14:22 +0000)
When we try to play and capture simultaneously we see that
interrupts are genrated but our handler is not being acknowledged,
After investigating further more in detail on this issue we found
that IRQ delivery via MSI from the ACP IP is unreliable and so sometimes
interrupt generated will not be acknowledged so MSI model shouldn't be used
and using legacy IRQs will resolve interrupt handling issue.

This patch replaces MSI interrupt handling with legacy IRQ model.

Issue can be reproduced easily by running below python script:

import subprocess
import time
import threading

def do2():
  cmd = 'aplay -f dat -D hw:2,1 /dev/zero -d 1'
    subprocess.call(cmd, stdin=subprocess.PIPE,
stderr=subprocess.PIPE, shell=True)
    print('Play Done')

def run():
for i in range(1000):
do2()

def do(i):
    cmd = 'arecord -f dat -D hw:2,2 /dev/null -d 1'
    subprocess.call(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, shell=True)
    print(datetime.datetime.now(), i)

t = threading.Thread(target=run)
t.start()
for i in range(1000):
do(i)

t.join()

After applying this patch issue is resolved.

Signed-off-by: Ravulapati Vishnu vardhan rao <Vishnuvardhanrao.Ravulapati@amd.com>
Link: https://lore.kernel.org/r/20201222115929.11222-1-Vishnuvardhanrao.Ravulapati@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/amd/raven/pci-acp3x.c

index 8c138e490f0c54fb20bb6800447eae53640c2802..d3536fd6a12400644a4cfa5b26795956fd2cedb3 100644 (file)
@@ -140,21 +140,14 @@ static int snd_acp3x_probe(struct pci_dev *pci,
                goto release_regions;
        }
 
-       /* check for msi interrupt support */
-       ret = pci_enable_msi(pci);
-       if (ret)
-               /* msi is not enabled */
-               irqflags = IRQF_SHARED;
-       else
-               /* msi is enabled */
-               irqflags = 0;
+       irqflags = IRQF_SHARED;
 
        addr = pci_resource_start(pci, 0);
        adata->acp3x_base = devm_ioremap(&pci->dev, addr,
                                        pci_resource_len(pci, 0));
        if (!adata->acp3x_base) {
                ret = -ENOMEM;
-               goto disable_msi;
+               goto release_regions;
        }
        pci_set_master(pci);
        pci_set_drvdata(pci, adata);
@@ -162,7 +155,7 @@ static int snd_acp3x_probe(struct pci_dev *pci,
        adata->pme_en = rv_readl(adata->acp3x_base + mmACP_PME_EN);
        ret = acp3x_init(adata);
        if (ret)
-               goto disable_msi;
+               goto release_regions;
 
        val = rv_readl(adata->acp3x_base + mmACP_I2S_PIN_CONFIG);
        switch (val) {
@@ -251,8 +244,6 @@ unregister_devs:
 de_init:
        if (acp3x_deinit(adata->acp3x_base))
                dev_err(&pci->dev, "ACP de-init failed\n");
-disable_msi:
-       pci_disable_msi(pci);
 release_regions:
        pci_release_regions(pci);
 disable_pci:
@@ -311,7 +302,6 @@ static void snd_acp3x_remove(struct pci_dev *pci)
                dev_err(&pci->dev, "ACP de-init failed\n");
        pm_runtime_forbid(&pci->dev);
        pm_runtime_get_noresume(&pci->dev);
-       pci_disable_msi(pci);
        pci_release_regions(pci);
        pci_disable_device(pci);
 }