[alsa-devel] [RESEND PATCH v5 6/6] ASoC: amd: Added ACP3x system resume and runtime pm

kbuild test robot lkp at intel.com
Wed Nov 13 18:13:23 CET 2019


Hi Ravulapati,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on asoc/for-next]
[also build test WARNING on next-20191113]
[cannot apply to v5.4-rc7]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Ravulapati-Vishnu-vardhan-rao/ASoC-amd-Create-multiple-I2S-platform-device-Endpoint/20191113-230604
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: x86_64-randconfig-h001-20191113 (attached as .config)
compiler: gcc-7 (Debian 7.4.0-14) 7.4.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp at intel.com>

All warnings (new ones prefixed by >>):

   sound/soc/amd/raven/pci-acp3x.c: In function 'acp3x_power_on':
   sound/soc/amd/raven/pci-acp3x.c:29:6: warning: unused variable 'ret' [-Wunused-variable]
     int ret = 0;
         ^~~
   sound/soc/amd/raven/pci-acp3x.c: In function 'acp3x_power_off':
>> sound/soc/amd/raven/pci-acp3x.c:68:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
   sound/soc/amd/raven/pci-acp3x.c: In function 'acp3x_power_on':
   sound/soc/amd/raven/pci-acp3x.c:50:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^

vim +68 sound/soc/amd/raven/pci-acp3x.c

    24	
    25	static int acp3x_power_on(void __iomem *acp3x_base)
    26	{
    27		u32 val;
    28		u32 timeout = 0;
  > 29		int ret = 0;
    30	
    31		val = rv_readl(acp3x_base + mmACP_PGFSM_STATUS);
    32	
    33		if (val == 0)
    34			return val;
    35	
    36		if (!((val & ACP_PGFSM_STATUS_MASK) ==
    37					ACP_POWER_ON_IN_PROGRESS))
    38			rv_writel(ACP_PGFSM_CNTL_POWER_ON_MASK,
    39				acp3x_base + mmACP_PGFSM_CONTROL);
    40		while (++timeout < DELAY) {
    41			val  = rv_readl(acp3x_base + mmACP_PGFSM_STATUS);
    42			if (!val)
    43				break;
    44			udelay(1);
    45			if (timeout > 500) {
    46				pr_err("ACP is Not Powered ON\n");
    47				return -ETIMEDOUT;
    48			}
    49		}
    50	}
    51	static int acp3x_power_off(void __iomem *acp3x_base)
    52	{
    53		u32 val;
    54		u32 timeout = 0;
    55	
    56		rv_writel(ACP_PGFSM_CNTL_POWER_OFF_MASK,
    57				acp3x_base + mmACP_PGFSM_CONTROL);
    58		while (++timeout < DELAY) {
    59			val  = rv_readl(acp3x_base + mmACP_PGFSM_STATUS);
    60			if ((val & ACP_PGFSM_STATUS_MASK) == ACP_POWERED_OFF)
    61				return 0;
    62			udelay(1);
    63			if (timeout > 500) {
    64				pr_err("ACP is Not Powered OFF\n");
    65				return -ETIMEDOUT;
    66			}
    67		}
  > 68	}
    69	static int acp3x_reset(void __iomem *acp3x_base)
    70	{
    71		u32 val, timeout;
    72	
    73		rv_writel(1, acp3x_base + mmACP_SOFT_RESET);
    74		timeout = 0;
    75		while (++timeout < DELAY) {
    76			val = rv_readl(acp3x_base + mmACP_SOFT_RESET);
    77			if ((val & ACP3x_SOFT_RESET__SoftResetAudDone_MASK) ||
    78								timeout > 100) {
    79				if (val & ACP3x_SOFT_RESET__SoftResetAudDone_MASK)
    80					break;
    81				return -ENODEV;
    82			}
    83			cpu_relax();
    84		}
    85		rv_writel(0, acp3x_base + mmACP_SOFT_RESET);
    86		timeout = 0;
    87		while (++timeout < DELAY) {
    88			val = rv_readl(acp3x_base + mmACP_SOFT_RESET);
    89			if (!val)
    90				break;
    91			if (timeout > 100)
    92				return -ENODEV;
    93			cpu_relax();
    94		}
    95		return 0;
    96	}
    97	static int acp3x_init(void __iomem *acp3x_base)
    98	{
    99		int ret;
   100	
   101		/* power on */
   102		ret = acp3x_power_on(acp3x_base);
   103		if (ret) {
   104			pr_err("ACP3x power on failed\n");
   105			return ret;
   106		}
   107		/* Reset */
   108		ret = acp3x_reset(acp3x_base);
   109		if (ret) {
   110			pr_err("ACP3x reset failed\n");
   111			return ret;
   112		}
   113		return 0;
   114	}
   115	static int acp3x_deinit(void __iomem *acp3x_base)
   116	{
   117		int ret;
   118	
   119		/* Reset */
   120		ret = acp3x_reset(acp3x_base);
   121		if (ret) {
   122			pr_err("ACP3x reset failed\n");
   123			return ret;
   124		}
   125		/* power off */
   126		ret = acp3x_power_off(acp3x_base);
   127		if (ret) {
   128			pr_err("ACP3x power off failed\n");
   129			return ret;
   130		}
   131		return 0;
   132	}
   133	static int snd_acp3x_probe(struct pci_dev *pci,
   134				   const struct pci_device_id *pci_id)
   135	{
   136		int ret;
   137		u32 addr, val, i;
   138		struct acp3x_dev_data *adata;
   139		struct platform_device_info pdevinfo[ACP3x_DEVS];
   140		unsigned int irqflags;
   141	
   142		if (pci_enable_device(pci)) {
   143			dev_err(&pci->dev, "pci_enable_device failed\n");
   144			return -ENODEV;
   145		}
   146	
   147		ret = pci_request_regions(pci, "AMD ACP3x audio");
   148		if (ret < 0) {
   149			dev_err(&pci->dev, "pci_request_regions failed\n");
   150			goto disable_pci;
   151		}
   152	
   153		adata = devm_kzalloc(&pci->dev, sizeof(struct acp3x_dev_data),
   154				     GFP_KERNEL);
   155		if (!adata) {
   156			ret = -ENOMEM;
   157			goto release_regions;
   158		}
   159	
   160		/* check for msi interrupt support */
   161		ret = pci_enable_msi(pci);
   162		if (ret)
   163			/* msi is not enabled */
   164			irqflags = IRQF_SHARED;
   165		else
   166			/* msi is enabled */
   167			irqflags = 0;
   168	
   169		addr = pci_resource_start(pci, 0);
   170		adata->acp3x_base = ioremap(addr, pci_resource_len(pci, 0));
   171		if (!adata->acp3x_base) {
   172			ret = -ENOMEM;
   173			goto release_regions;
   174		}
   175		pci_set_master(pci);
   176		pci_set_drvdata(pci, adata);
   177		ret = acp3x_init(adata->acp3x_base);
   178		if (ret)
   179			return -ENODEV;
   180	
   181	
   182		val = rv_readl(adata->acp3x_base + mmACP_I2S_PIN_CONFIG);
   183		switch (val) {
   184		case I2S_MODE:
   185			adata->res = devm_kzalloc(&pci->dev,
   186						  sizeof(struct resource) * 4,
   187						  GFP_KERNEL);
   188			if (!adata->res) {
   189				ret = -ENOMEM;
   190				goto unmap_mmio;
   191			}
   192	
   193			adata->res[0].name = "acp3x_i2s_iomem";
   194			adata->res[0].flags = IORESOURCE_MEM;
   195			adata->res[0].start = addr;
   196			adata->res[0].end = addr + (ACP3x_REG_END - ACP3x_REG_START);
   197	
   198			adata->res[1].name = "acp3x_i2s_sp";
   199			adata->res[1].flags = IORESOURCE_MEM;
   200			adata->res[1].start = addr + ACP3x_I2STDM_REG_START;
   201			adata->res[1].end = addr + ACP3x_I2STDM_REG_END;
   202	
   203			adata->res[2].name = "acp3x_i2s_bt";
   204			adata->res[2].flags = IORESOURCE_MEM;
   205			adata->res[2].start = addr + ACP3x_BT_TDM_REG_START;
   206			adata->res[2].end = addr + ACP3x_BT_TDM_REG_END;
   207	
   208			adata->res[3].name = "acp3x_i2s_irq";
   209			adata->res[3].flags = IORESOURCE_IRQ;
   210			adata->res[3].start = pci->irq;
   211			adata->res[3].end = adata->res[3].start;
   212	
   213			adata->acp3x_audio_mode = ACP3x_I2S_MODE;
   214	
   215			memset(&pdevinfo, 0, sizeof(pdevinfo));
   216			pdevinfo[0].name = "acp3x_rv_i2s_dma";
   217			pdevinfo[0].id = 0;
   218			pdevinfo[0].parent = &pci->dev;
   219			pdevinfo[0].num_res = 4;
   220			pdevinfo[0].res = &adata->res[0];
   221			pdevinfo[0].data = &irqflags;
   222			pdevinfo[0].size_data = sizeof(irqflags);
   223	
   224			pdevinfo[1].name = "acp3x_i2s_playcap";
   225			pdevinfo[1].id = 0;
   226			pdevinfo[1].parent = &pci->dev;
   227			pdevinfo[1].num_res = 1;
   228			pdevinfo[1].res = &adata->res[1];
   229	
   230			pdevinfo[2].name = "acp3x_i2s_playcap";
   231			pdevinfo[2].id = 1;
   232			pdevinfo[2].parent = &pci->dev;
   233			pdevinfo[2].num_res = 1;
   234			pdevinfo[2].res = &adata->res[2];
   235			for (i = 0; i < ACP3x_DEVS ; i++) {
   236				adata->pdev[i] =
   237					platform_device_register_full(&pdevinfo[i]);
   238				if (IS_ERR(adata->pdev[i])) {
   239					dev_err(&pci->dev, "cannot register %s device\n",
   240						pdevinfo[i].name);
   241					ret = PTR_ERR(adata->pdev[i]);
   242					goto unmap_mmio;
   243				}
   244			}
   245			break;
   246		default:
   247			dev_err(&pci->dev, "Invalid ACP audio mode : %d\n", val);
   248			ret = -ENODEV;
   249			goto unmap_mmio;
   250		}
   251		pm_runtime_set_autosuspend_delay(&pci->dev, 10000);
   252		pm_runtime_use_autosuspend(&pci->dev);
   253		pm_runtime_set_active(&pci->dev);
   254		pm_runtime_put_noidle(&pci->dev);
   255		pm_runtime_enable(&pci->dev);
   256		return 0;
   257	
   258	unmap_mmio:
   259		ret = acp3x_deinit(adata->acp3x_base);
   260		if (ret)
   261			dev_err(&pci->dev, "ACP de-init failed\n");
   262		else
   263			dev_info(&pci->dev, "ACP de-initialized\n");
   264		pci_disable_msi(pci);
   265		for (i = 0 ; i < ACP3x_DEVS ; i++)
   266			platform_device_unregister(adata->pdev[i]);
   267		kfree(adata->res);
   268		iounmap(adata->acp3x_base);
   269	release_regions:
   270		pci_release_regions(pci);
   271	disable_pci:
   272		pci_disable_device(pci);
   273	
   274		return ret;
   275	}
   276	static int  snd_acp3x_suspend(struct device *dev)
   277	{
   278		int status;
   279		struct acp3x_dev_data *adata = dev_get_drvdata(dev);
   280	
   281		status = acp3x_deinit(adata->acp3x_base);
   282		if (status)
   283			dev_err(dev, "ACP de-init failed\n");
   284		else
   285			dev_info(dev, "ACP de-initialized\n");
   286	
   287		return 0;
   288	}
   289	static int  snd_acp3x_resume(struct device *dev)
   290	{
   291		int status;
   292		struct acp3x_dev_data *adata = dev_get_drvdata(dev);
   293	
   294		status = acp3x_init(adata->acp3x_base);
   295		if (status) {
   296			dev_err(dev, "ACP init failed\n");
   297			return status;
   298		}
   299		return 0;
   300	}
   301	static const struct dev_pm_ops acp3x_pm = {
   302		.runtime_suspend = snd_acp3x_suspend,
   303		.runtime_resume =  snd_acp3x_resume,
   304		.resume =       snd_acp3x_resume,
   305	};
   306	static void snd_acp3x_remove(struct pci_dev *pci)
   307	{
   308		int i, ret;
   309		struct acp3x_dev_data *adata = pci_get_drvdata(pci);
   310	
   311		if (adata->acp3x_audio_mode == ACP3x_I2S_MODE) {
   312			for (i = 0 ; i <  ACP3x_DEVS ; i++)
   313				platform_device_unregister(adata->pdev[i]);
   314		}
   315		ret = acp3x_deinit(adata->acp3x_base);
   316		if (ret)
   317			dev_err(&pci->dev, "ACP de-init failed\n");
   318		else
   319			dev_info(&pci->dev, "ACP de-initialized\n");
   320		iounmap(adata->acp3x_base);
   321		pm_runtime_disable(&pci->dev);
   322		pm_runtime_get_noresume(&pci->dev);
   323		pci_disable_msi(pci);
   324		pci_release_regions(pci);
   325		pci_disable_device(pci);
   326	}
   327	static const struct pci_device_id snd_acp3x_ids[] = {
   328		{ PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x15e2),
   329		.class = PCI_CLASS_MULTIMEDIA_OTHER << 8,
   330		.class_mask = 0xffffff },
   331		{ 0, },
   332	};
   333	MODULE_DEVICE_TABLE(pci, snd_acp3x_ids);
   334	

---
0-DAY kernel test infrastructure                 Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 34755 bytes
Desc: not available
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20191114/4c21b339/attachment-0001.gz>


More information about the Alsa-devel mailing list