diff mbox series

ASoC: rsnd: add interrupt support for SSI BUSIF buffer

Message ID 20200508074753.10362-1-giraffesnn123@gmail.com (mailing list archive)
State Superseded
Delegated to: Kieran Bingham
Headers show
Series ASoC: rsnd: add interrupt support for SSI BUSIF buffer | expand

Commit Message

Yongbo Zhang May 8, 2020, 7:47 a.m. UTC
SSI BUSIF buffer is possible to overflow or underflow, especially in a
hypervisor environment. If there is no interrupt support, it will eventually
lead to errors in pcm data.
This patch adds overflow and underflow interrupt support for SSI BUSIF buffer.

Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reported-by: Chen Li <licheng0822@thundersoft.com>
Signed-off-by: Yongbo Zhang <giraffesnn123@gmail.com>
Tested-by: Chen Li <licheng0822@thundersoft.com>
---
 sound/soc/sh/rcar/gen.c  |   8 +++
 sound/soc/sh/rcar/rsnd.h |   9 +++
 sound/soc/sh/rcar/ssi.c  | 142 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 159 insertions(+)

Comments

kernel test robot May 8, 2020, 11:56 p.m. UTC | #1
Hi Yongbo,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on asoc/for-next]
[also build test ERROR on v5.7-rc4 next-20200508]
[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/Yongbo-Zhang/ASoC-rsnd-add-interrupt-support-for-SSI-BUSIF-buffer/20200509-035713
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: arm-defconfig (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 6d2a66b10d458e34c852be46028092d2b46edc14)
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm 

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

All errors (new ones prefixed by >>):

>> sound/soc/sh/rcar/ssi.c:600:1: error: function definition is not allowed here
   {
   ^
   sound/soc/sh/rcar/ssi.c:618:1: error: function definition is not allowed here
   {
   ^
   sound/soc/sh/rcar/ssi.c:651:1: error: function definition is not allowed here
   {
   ^
   sound/soc/sh/rcar/ssi.c:696:1: error: function definition is not allowed here
   {
   ^
>> sound/soc/sh/rcar/ssi.c:734:1: error: function declared in block scope cannot have 'static' storage class
   static bool rsnd_ssi_pio_interrupt(struct rsnd_mod *mod,
   ^
   sound/soc/sh/rcar/ssi.c:738:1: error: function definition is not allowed here
   {
   ^
   sound/soc/sh/rcar/ssi.c:830:1: error: function definition is not allowed here
   {
   ^
   sound/soc/sh/rcar/ssi.c:841:1: error: function definition is not allowed here
   {
   ^
   sound/soc/sh/rcar/ssi.c:878:1: error: function definition is not allowed here
   {
   ^
   sound/soc/sh/rcar/ssi.c:909:1: error: function definition is not allowed here
   {
   ^
   sound/soc/sh/rcar/ssi.c:923:1: error: function definition is not allowed here
   {
   ^
   sound/soc/sh/rcar/ssi.c:966:1: error: function definition is not allowed here
   {
   ^
   sound/soc/sh/rcar/ssi.c:989:1: error: function definition is not allowed here
   {
   ^
   sound/soc/sh/rcar/ssi.c:1033:1: error: function definition is not allowed here
   {
   ^
   sound/soc/sh/rcar/ssi.c:1051:1: error: function definition is not allowed here
   {
   ^
   sound/soc/sh/rcar/ssi.c:1063:1: error: function definition is not allowed here
   {
   ^
>> sound/soc/sh/rcar/ssi.c:1069:12: error: use of undeclared identifier 'rsnd_ssi_common_probe'
           .probe          = rsnd_ssi_common_probe,
                             ^
>> sound/soc/sh/rcar/ssi.c:1070:13: error: use of undeclared identifier 'rsnd_ssi_common_remove'
           .remove         = rsnd_ssi_common_remove,
                             ^
>> sound/soc/sh/rcar/ssi.c:1071:11: error: use of undeclared identifier 'rsnd_ssi_pio_init'
           .init           = rsnd_ssi_pio_init,
                             ^
   fatal error: too many errors emitted, stopping now [-ferror-limit=]
   20 errors generated.

vim +600 sound/soc/sh/rcar/ssi.c

ae5c322303fff5 Kuninori Morimoto  2013-07-21  595  
919567d914b3c1 Kuninori Morimoto  2015-04-10  596  static int rsnd_ssi_hw_params(struct rsnd_mod *mod,
2c0fac19de2cd7 Kuninori Morimoto  2015-06-15  597  			      struct rsnd_dai_stream *io,
919567d914b3c1 Kuninori Morimoto  2015-04-10  598  			      struct snd_pcm_substream *substream,
919567d914b3c1 Kuninori Morimoto  2015-04-10  599  			      struct snd_pcm_hw_params *params)
919567d914b3c1 Kuninori Morimoto  2015-04-10 @600  {
fb2815f44a9eb3 Dragos Tarcatu     2018-09-03  601  	struct rsnd_dai *rdai = rsnd_io_to_rdai(io);
fb2815f44a9eb3 Dragos Tarcatu     2018-09-03  602  	unsigned int fmt_width = snd_pcm_format_width(params_format(params));
fb2815f44a9eb3 Dragos Tarcatu     2018-09-03  603  
fb2815f44a9eb3 Dragos Tarcatu     2018-09-03  604  	if (fmt_width > rdai->chan_width) {
fb2815f44a9eb3 Dragos Tarcatu     2018-09-03  605  		struct rsnd_priv *priv = rsnd_io_to_priv(io);
fb2815f44a9eb3 Dragos Tarcatu     2018-09-03  606  		struct device *dev = rsnd_priv_to_dev(priv);
fb2815f44a9eb3 Dragos Tarcatu     2018-09-03  607  
fb2815f44a9eb3 Dragos Tarcatu     2018-09-03  608  		dev_err(dev, "invalid combination of slot-width and format-data-width\n");
fb2815f44a9eb3 Dragos Tarcatu     2018-09-03  609  		return -EINVAL;
fb2815f44a9eb3 Dragos Tarcatu     2018-09-03  610  	}
919567d914b3c1 Kuninori Morimoto  2015-04-10  611  
919567d914b3c1 Kuninori Morimoto  2015-04-10  612  	return 0;
919567d914b3c1 Kuninori Morimoto  2015-04-10  613  }
919567d914b3c1 Kuninori Morimoto  2015-04-10  614  
6a25c8da00284f Kuninori Morimoto  2016-01-26  615  static int rsnd_ssi_start(struct rsnd_mod *mod,
2c0fac19de2cd7 Kuninori Morimoto  2015-06-15  616  			  struct rsnd_dai_stream *io,
690602fcd85385 Kuninori Morimoto  2015-01-15  617  			  struct rsnd_priv *priv)
4e7d606cd52aa8 Kuninori Morimoto  2014-11-27 @618  {
597b046f0d99b0 Kuninori Morimoto  2017-08-08  619  	struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
597b046f0d99b0 Kuninori Morimoto  2017-08-08  620  
fd9adcfdc1434f Kuninori Morimoto  2016-02-18  621  	if (!rsnd_ssi_is_run_mods(mod, io))
fd9adcfdc1434f Kuninori Morimoto  2016-02-18  622  		return 0;
fd9adcfdc1434f Kuninori Morimoto  2016-02-18  623  
b4c83b17155781 Kuninori Morimoto  2015-12-17  624  	/*
b4c83b17155781 Kuninori Morimoto  2015-12-17  625  	 * EN will be set via SSIU :: SSI_CONTROL
b4c83b17155781 Kuninori Morimoto  2015-12-17  626  	 * if Multi channel mode
b4c83b17155781 Kuninori Morimoto  2015-12-17  627  	 */
4f5c634d58e719 Kuninori Morimoto  2016-02-18  628  	if (rsnd_ssi_multi_slaves_runtime(io))
0dc6bf75023a42 Kuninori Morimoto  2016-02-18  629  		return 0;
4e7d606cd52aa8 Kuninori Morimoto  2014-11-27  630  
597b046f0d99b0 Kuninori Morimoto  2017-08-08  631  	/*
597b046f0d99b0 Kuninori Morimoto  2017-08-08  632  	 * EN is for data output.
597b046f0d99b0 Kuninori Morimoto  2017-08-08  633  	 * SSI parent EN is not needed.
597b046f0d99b0 Kuninori Morimoto  2017-08-08  634  	 */
0c258657ddfe81 Matthias Blankertz 2020-04-17  635  	if (rsnd_ssi_is_parent(mod, io))
597b046f0d99b0 Kuninori Morimoto  2017-08-08  636  		return 0;
597b046f0d99b0 Kuninori Morimoto  2017-08-08  637  
597b046f0d99b0 Kuninori Morimoto  2017-08-08  638  	ssi->cr_en = EN;
597b046f0d99b0 Kuninori Morimoto  2017-08-08  639  
597b046f0d99b0 Kuninori Morimoto  2017-08-08  640  	rsnd_mod_write(mod, SSICR,	ssi->cr_own	|
597b046f0d99b0 Kuninori Morimoto  2017-08-08  641  					ssi->cr_clk	|
597b046f0d99b0 Kuninori Morimoto  2017-08-08  642  					ssi->cr_mode	|
597b046f0d99b0 Kuninori Morimoto  2017-08-08  643  					ssi->cr_en);
4e7d606cd52aa8 Kuninori Morimoto  2014-11-27  644  
4e7d606cd52aa8 Kuninori Morimoto  2014-11-27  645  	return 0;
4e7d606cd52aa8 Kuninori Morimoto  2014-11-27  646  }
4e7d606cd52aa8 Kuninori Morimoto  2014-11-27  647  
6a25c8da00284f Kuninori Morimoto  2016-01-26  648  static int rsnd_ssi_stop(struct rsnd_mod *mod,
e7d850dd10f4e6 Kuninori Morimoto  2015-10-26  649  			 struct rsnd_dai_stream *io,
e7d850dd10f4e6 Kuninori Morimoto  2015-10-26  650  			 struct rsnd_priv *priv)
e7d850dd10f4e6 Kuninori Morimoto  2015-10-26  651  {
6a25c8da00284f Kuninori Morimoto  2016-01-26  652  	struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
6a25c8da00284f Kuninori Morimoto  2016-01-26  653  	u32 cr;
6a25c8da00284f Kuninori Morimoto  2016-01-26  654  
fd9adcfdc1434f Kuninori Morimoto  2016-02-18  655  	if (!rsnd_ssi_is_run_mods(mod, io))
fd9adcfdc1434f Kuninori Morimoto  2016-02-18  656  		return 0;
fd9adcfdc1434f Kuninori Morimoto  2016-02-18  657  
0c258657ddfe81 Matthias Blankertz 2020-04-17  658  	if (rsnd_ssi_is_parent(mod, io))
6a25c8da00284f Kuninori Morimoto  2016-01-26  659  		return 0;
4e7d606cd52aa8 Kuninori Morimoto  2014-11-27  660  
e7d850dd10f4e6 Kuninori Morimoto  2015-10-26  661  	cr  =	ssi->cr_own	|
e7d850dd10f4e6 Kuninori Morimoto  2015-10-26  662  		ssi->cr_clk;
e7d850dd10f4e6 Kuninori Morimoto  2015-10-26  663  
ce548931207c0d Kuninori Morimoto  2017-10-31  664  	/*
ce548931207c0d Kuninori Morimoto  2017-10-31  665  	 * disable all IRQ,
ce548931207c0d Kuninori Morimoto  2017-10-31  666  	 * Playback: Wait all data was sent
ce548931207c0d Kuninori Morimoto  2017-10-31  667  	 * Capture:  It might not receave data. Do nothing
ce548931207c0d Kuninori Morimoto  2017-10-31  668  	 */
ce548931207c0d Kuninori Morimoto  2017-10-31  669  	if (rsnd_io_is_play(io)) {
54cb6221688660 Matthias Blankertz 2020-04-17  670  		rsnd_mod_write(mod, SSICR, cr | ssi->cr_en);
e7d850dd10f4e6 Kuninori Morimoto  2015-10-26  671  		rsnd_ssi_status_check(mod, DIRQ);
ce548931207c0d Kuninori Morimoto  2017-10-31  672  	}
e7d850dd10f4e6 Kuninori Morimoto  2015-10-26  673  
54cb6221688660 Matthias Blankertz 2020-04-17  674  	/* In multi-SSI mode, stop is performed by setting ssi0129 in
54cb6221688660 Matthias Blankertz 2020-04-17  675  	 * SSI_CONTROL to 0 (in rsnd_ssio_stop_gen2). Do nothing here.
54cb6221688660 Matthias Blankertz 2020-04-17  676  	 */
54cb6221688660 Matthias Blankertz 2020-04-17  677  	if (rsnd_ssi_multi_slaves_runtime(io))
54cb6221688660 Matthias Blankertz 2020-04-17  678  		return 0;
54cb6221688660 Matthias Blankertz 2020-04-17  679  
e7d850dd10f4e6 Kuninori Morimoto  2015-10-26  680  	/*
e7d850dd10f4e6 Kuninori Morimoto  2015-10-26  681  	 * disable SSI,
e7d850dd10f4e6 Kuninori Morimoto  2015-10-26  682  	 * and, wait idle state
e7d850dd10f4e6 Kuninori Morimoto  2015-10-26  683  	 */
e7d850dd10f4e6 Kuninori Morimoto  2015-10-26  684  	rsnd_mod_write(mod, SSICR, cr);	/* disabled all */
e7d850dd10f4e6 Kuninori Morimoto  2015-10-26  685  	rsnd_ssi_status_check(mod, IIRQ);
4e7d606cd52aa8 Kuninori Morimoto  2014-11-27  686  
597b046f0d99b0 Kuninori Morimoto  2017-08-08  687  	ssi->cr_en = 0;
597b046f0d99b0 Kuninori Morimoto  2017-08-08  688  
e7d850dd10f4e6 Kuninori Morimoto  2015-10-26  689  	return 0;
e7d850dd10f4e6 Kuninori Morimoto  2015-10-26  690  }
4e7d606cd52aa8 Kuninori Morimoto  2014-11-27  691  
615fb6c7b13b7f Kuninori Morimoto  2016-02-18  692  static int rsnd_ssi_irq(struct rsnd_mod *mod,
615fb6c7b13b7f Kuninori Morimoto  2016-02-18  693  			struct rsnd_dai_stream *io,
615fb6c7b13b7f Kuninori Morimoto  2016-02-18  694  			struct rsnd_priv *priv,
615fb6c7b13b7f Kuninori Morimoto  2016-02-18  695  			int enable)
615fb6c7b13b7f Kuninori Morimoto  2016-02-18  696  {
615fb6c7b13b7f Kuninori Morimoto  2016-02-18  697  	u32 val = 0;
391d452251464b Yongbo Zhang       2020-05-08  698  	int is_tdm, is_tdm_split;
391d452251464b Yongbo Zhang       2020-05-08  699  	int id = rsnd_mod_id(mod);
391d452251464b Yongbo Zhang       2020-05-08  700  
391d452251464b Yongbo Zhang       2020-05-08  701  	is_tdm		= rsnd_runtime_is_tdm(io);
391d452251464b Yongbo Zhang       2020-05-08  702  	is_tdm_split	= rsnd_runtime_is_tdm_split(io);
615fb6c7b13b7f Kuninori Morimoto  2016-02-18  703  
615fb6c7b13b7f Kuninori Morimoto  2016-02-18  704  	if (rsnd_is_gen1(priv))
615fb6c7b13b7f Kuninori Morimoto  2016-02-18  705  		return 0;
615fb6c7b13b7f Kuninori Morimoto  2016-02-18  706  
0c258657ddfe81 Matthias Blankertz 2020-04-17  707  	if (rsnd_ssi_is_parent(mod, io))
615fb6c7b13b7f Kuninori Morimoto  2016-02-18  708  		return 0;
615fb6c7b13b7f Kuninori Morimoto  2016-02-18  709  
fd9adcfdc1434f Kuninori Morimoto  2016-02-18  710  	if (!rsnd_ssi_is_run_mods(mod, io))
fd9adcfdc1434f Kuninori Morimoto  2016-02-18  711  		return 0;
fd9adcfdc1434f Kuninori Morimoto  2016-02-18  712  
615fb6c7b13b7f Kuninori Morimoto  2016-02-18  713  	if (enable)
615fb6c7b13b7f Kuninori Morimoto  2016-02-18  714  		val = rsnd_ssi_is_dma_mode(mod) ? 0x0e000000 : 0x0f000000;
615fb6c7b13b7f Kuninori Morimoto  2016-02-18  715  
391d452251464b Yongbo Zhang       2020-05-08  716  	if (is_tdm || is_tdm_split) {
391d452251464b Yongbo Zhang       2020-05-08  717  		switch (id) {
391d452251464b Yongbo Zhang       2020-05-08  718  		case 0:
391d452251464b Yongbo Zhang       2020-05-08  719  		case 1:
391d452251464b Yongbo Zhang       2020-05-08  720  		case 2:
391d452251464b Yongbo Zhang       2020-05-08  721  		case 3:
391d452251464b Yongbo Zhang       2020-05-08  722  		case 4:
391d452251464b Yongbo Zhang       2020-05-08  723  		case 9:
391d452251464b Yongbo Zhang       2020-05-08  724  			val |= 0xff00;
391d452251464b Yongbo Zhang       2020-05-08  725  			break;
391d452251464b Yongbo Zhang       2020-05-08  726  		}
391d452251464b Yongbo Zhang       2020-05-08  727  	}
391d452251464b Yongbo Zhang       2020-05-08  728  
615fb6c7b13b7f Kuninori Morimoto  2016-02-18  729  	rsnd_mod_write(mod, SSI_INT_ENABLE, val);
615fb6c7b13b7f Kuninori Morimoto  2016-02-18  730  
615fb6c7b13b7f Kuninori Morimoto  2016-02-18  731  	return 0;
615fb6c7b13b7f Kuninori Morimoto  2016-02-18  732  }
615fb6c7b13b7f Kuninori Morimoto  2016-02-18  733  
d8d9b9730cd62c Kuninori Morimoto  2017-12-11 @734  static bool rsnd_ssi_pio_interrupt(struct rsnd_mod *mod,
d8d9b9730cd62c Kuninori Morimoto  2017-12-11  735  				   struct rsnd_dai_stream *io);
bfc0cfe6b7acb1 Kuninori Morimoto  2015-06-15  736  static void __rsnd_ssi_interrupt(struct rsnd_mod *mod,
bfc0cfe6b7acb1 Kuninori Morimoto  2015-06-15  737  				 struct rsnd_dai_stream *io)
ae5c322303fff5 Kuninori Morimoto  2013-07-21  738  {
690602fcd85385 Kuninori Morimoto  2015-01-15  739  	struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
2b62786951ca38 Kuninori Morimoto  2018-02-13  740  	struct device *dev = rsnd_priv_to_dev(priv);
765ae7c8dda7d0 Kuninori Morimoto  2015-01-15  741  	int is_dma = rsnd_ssi_is_dma_mode(mod);
02299d9875bab5 Kuninori Morimoto  2015-05-21  742  	u32 status;
75defee0f1b3fc Kuninori Morimoto  2015-06-15  743  	bool elapsed = false;
6a25c8da00284f Kuninori Morimoto  2016-01-26  744  	bool stop = false;
391d452251464b Yongbo Zhang       2020-05-08  745  	int is_tdm, is_tdm_split;
391d452251464b Yongbo Zhang       2020-05-08  746  
391d452251464b Yongbo Zhang       2020-05-08  747  	is_tdm		= rsnd_runtime_is_tdm(io);
391d452251464b Yongbo Zhang       2020-05-08  748  	is_tdm_split	= rsnd_runtime_is_tdm_split(io);
02299d9875bab5 Kuninori Morimoto  2015-05-21  749  
02299d9875bab5 Kuninori Morimoto  2015-05-21  750  	spin_lock(&priv->lock);
ae5c322303fff5 Kuninori Morimoto  2013-07-21  751  
02299d9875bab5 Kuninori Morimoto  2015-05-21  752  	/* ignore all cases if not working */
d5bbe7de563ccc Kuninori Morimoto  2015-06-15  753  	if (!rsnd_io_is_working(io))
02299d9875bab5 Kuninori Morimoto  2015-05-21  754  		goto rsnd_ssi_interrupt_out;
02299d9875bab5 Kuninori Morimoto  2015-05-21  755  
6a25c8da00284f Kuninori Morimoto  2016-01-26  756  	status = rsnd_ssi_status_get(mod);
4e7d606cd52aa8 Kuninori Morimoto  2014-11-27  757  
4e7d606cd52aa8 Kuninori Morimoto  2014-11-27  758  	/* PIO only */
d8d9b9730cd62c Kuninori Morimoto  2017-12-11  759  	if (!is_dma && (status & DIRQ))
d8d9b9730cd62c Kuninori Morimoto  2017-12-11  760  		elapsed = rsnd_ssi_pio_interrupt(mod, io);
ae5c322303fff5 Kuninori Morimoto  2013-07-21  761  
12927a8f802642 Kuninori Morimoto  2015-06-15  762  	/* DMA only */
2b62786951ca38 Kuninori Morimoto  2018-02-13  763  	if (is_dma && (status & (UIRQ | OIRQ))) {
c0ea089dbad47a Kuninori Morimoto  2018-10-30  764  		rsnd_dbg_irq_status(dev, "%s err status : 0x%08x\n",
c0ea089dbad47a Kuninori Morimoto  2018-10-30  765  			rsnd_mod_name(mod), status);
2b62786951ca38 Kuninori Morimoto  2018-02-13  766  
6a25c8da00284f Kuninori Morimoto  2016-01-26  767  		stop = true;
2b62786951ca38 Kuninori Morimoto  2018-02-13  768  	}
69e32a58bde674 Kuninori Morimoto  2015-10-26  769  
391d452251464b Yongbo Zhang       2020-05-08  770  	status = 0;
391d452251464b Yongbo Zhang       2020-05-08  771  
391d452251464b Yongbo Zhang       2020-05-08  772  	if (is_tdm || is_tdm_split) {
391d452251464b Yongbo Zhang       2020-05-08  773  		switch (id) {
391d452251464b Yongbo Zhang       2020-05-08  774  		case 0:
391d452251464b Yongbo Zhang       2020-05-08  775  		case 1:
391d452251464b Yongbo Zhang       2020-05-08  776  		case 2:
391d452251464b Yongbo Zhang       2020-05-08  777  		case 3:
391d452251464b Yongbo Zhang       2020-05-08  778  		case 4:
391d452251464b Yongbo Zhang       2020-05-08  779  			for (i = 0; i < 4; i++) {
391d452251464b Yongbo Zhang       2020-05-08  780  				status = rsnd_mod_read(mod,
391d452251464b Yongbo Zhang       2020-05-08  781  						       SSI_SYS_STATUS(i * 2));
391d452251464b Yongbo Zhang       2020-05-08  782  				status &= 0xf << (id * 4);
391d452251464b Yongbo Zhang       2020-05-08  783  
391d452251464b Yongbo Zhang       2020-05-08  784  				if (status) {
391d452251464b Yongbo Zhang       2020-05-08  785  					rsnd_dbg_irq_status(dev,
391d452251464b Yongbo Zhang       2020-05-08  786  						"%s err status : 0x%08x\n",
391d452251464b Yongbo Zhang       2020-05-08  787  						rsnd_mod_name(mod), status);
391d452251464b Yongbo Zhang       2020-05-08  788  					rsnd_mod_write(mod,
391d452251464b Yongbo Zhang       2020-05-08  789  						       SSI_SYS_STATUS(i * 2),
391d452251464b Yongbo Zhang       2020-05-08  790  						       0xf << (id * 4));
391d452251464b Yongbo Zhang       2020-05-08  791  					stop = true;
391d452251464b Yongbo Zhang       2020-05-08  792  					break;
391d452251464b Yongbo Zhang       2020-05-08  793  				}
391d452251464b Yongbo Zhang       2020-05-08  794  			}
391d452251464b Yongbo Zhang       2020-05-08  795  			break;
391d452251464b Yongbo Zhang       2020-05-08  796  		case 9:
391d452251464b Yongbo Zhang       2020-05-08  797  			for (i = 0; i < 4; i++) {
391d452251464b Yongbo Zhang       2020-05-08  798  				status = rsnd_mod_write(mod,
391d452251464b Yongbo Zhang       2020-05-08  799  						SSI_SYS_STATUS((i * 2) + 1));
391d452251464b Yongbo Zhang       2020-05-08  800  				status &= 0xf << 4;
391d452251464b Yongbo Zhang       2020-05-08  801  
391d452251464b Yongbo Zhang       2020-05-08  802  				if (status) {
391d452251464b Yongbo Zhang       2020-05-08  803  					rsnd_dbg_irq_status(dev,
391d452251464b Yongbo Zhang       2020-05-08  804  						"%s err status : 0x%08x\n",
391d452251464b Yongbo Zhang       2020-05-08  805  						rsnd_mod_name(mod), status);
391d452251464b Yongbo Zhang       2020-05-08  806  					rsnd_mod_write(mod,
391d452251464b Yongbo Zhang       2020-05-08  807  						SSI_SYS_STATUS((i * 2) + 1),
391d452251464b Yongbo Zhang       2020-05-08  808  						0xf << 4);
391d452251464b Yongbo Zhang       2020-05-08  809  					stop = true;
391d452251464b Yongbo Zhang       2020-05-08  810  					break;
391d452251464b Yongbo Zhang       2020-05-08  811  				}
391d452251464b Yongbo Zhang       2020-05-08  812  			}
391d452251464b Yongbo Zhang       2020-05-08  813  			break;
391d452251464b Yongbo Zhang       2020-05-08  814  		}
391d452251464b Yongbo Zhang       2020-05-08  815  	}
391d452251464b Yongbo Zhang       2020-05-08  816  
5342dff2326393 Kuninori Morimoto  2015-11-26  817  	rsnd_ssi_status_clear(mod);
02299d9875bab5 Kuninori Morimoto  2015-05-21  818  rsnd_ssi_interrupt_out:
02299d9875bab5 Kuninori Morimoto  2015-05-21  819  	spin_unlock(&priv->lock);
02299d9875bab5 Kuninori Morimoto  2015-05-21  820  
75defee0f1b3fc Kuninori Morimoto  2015-06-15  821  	if (elapsed)
75defee0f1b3fc Kuninori Morimoto  2015-06-15  822  		rsnd_dai_period_elapsed(io);
6a25c8da00284f Kuninori Morimoto  2016-01-26  823  
6a25c8da00284f Kuninori Morimoto  2016-01-26  824  	if (stop)
6a25c8da00284f Kuninori Morimoto  2016-01-26  825  		snd_pcm_stop_xrun(io->substream);
6a25c8da00284f Kuninori Morimoto  2016-01-26  826  

:::::: The code at line 600 was first introduced by commit
:::::: 919567d914b3c134e60c01db72a03a0adc5f41b9 ASoC: rsnd: make sure SSI parent/child uses same number of sound channel.

:::::: TO: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
:::::: CC: Mark Brown <broonie@kernel.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Kuninori Morimoto May 11, 2020, 1:30 a.m. UTC | #2
Hi Yongbo

Thank you for the patch

> SSI BUSIF buffer is possible to overflow or underflow, especially in a
> hypervisor environment. If there is no interrupt support, it will eventually
> lead to errors in pcm data.
> This patch adds overflow and underflow interrupt support for SSI BUSIF buffer.
> 
> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> Reported-by: Chen Li <licheng0822@thundersoft.com>
> Signed-off-by: Yongbo Zhang <giraffesnn123@gmail.com>
> Tested-by: Chen Li <licheng0822@thundersoft.com>
> ---
(snip)
> @@ -635,6 +713,19 @@ static int rsnd_ssi_irq(struct rsnd_mod *mod,
>  	if (enable)
>  		val = rsnd_ssi_is_dma_mode(mod) ? 0x0e000000 : 0x0f000000;
>  
> +	if (is_tdm || is_tdm_split) {
> +		switch (id) {
> +		case 0:
> +		case 1:
> +		case 2:
> +		case 3:
> +		case 4:
> +		case 9:
> +			val |= 0xff00;
> +			break;
> +		}
> +	}

This is small things, but we like to have
	- val |= 0xff00;
	+ val |= 0x0000ff00;

Except above

	Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Thank you for your help !!

Best regards
---
Kuninori Morimoto
kernel test robot May 12, 2020, 6:39 a.m. UTC | #3
Hi Yongbo,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on asoc/for-next]
[also build test WARNING on v5.7-rc4 next-20200508]
[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/Yongbo-Zhang/ASoC-rsnd-add-interrupt-support-for-SSI-BUSIF-buffer/20200509-035713
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
:::::: branch date: 6 hours ago
:::::: commit date: 6 hours ago

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


cppcheck warnings: (new ones prefixed by >>)

>> sound/soc/sh/rcar/ssi.c:531:1: warning: Unmatched '{'. Configuration: ''. [syntaxError]
   {
   ^
>> sound/soc/sh/rcar/ssi.c:531:1: warning: Unmatched '{'. Configuration: 'DEBUG'. [syntaxError]
   {
   ^

# https://github.com/0day-ci/linux/commit/391d452251464b78f72ba3a1fd9b6091b3d4a942
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 391d452251464b78f72ba3a1fd9b6091b3d4a942
vim +531 sound/soc/sh/rcar/ssi.c

ae5c322303fff5 Kuninori Morimoto 2013-07-21  527  
ae5c322303fff5 Kuninori Morimoto 2013-07-21  528  static int rsnd_ssi_quit(struct rsnd_mod *mod,
2c0fac19de2cd7 Kuninori Morimoto 2015-06-15  529  			 struct rsnd_dai_stream *io,
690602fcd85385 Kuninori Morimoto 2015-01-15  530  			 struct rsnd_priv *priv)
ae5c322303fff5 Kuninori Morimoto 2013-07-21 @531  {
ae5c322303fff5 Kuninori Morimoto 2013-07-21  532  	struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
ae5c322303fff5 Kuninori Morimoto 2013-07-21  533  	struct device *dev = rsnd_priv_to_dev(priv);
391d452251464b Yongbo Zhang      2020-05-08  534  	int is_tdm, is_tdm_split;
391d452251464b Yongbo Zhang      2020-05-08  535  	int id = rsnd_mod_id(mod);
391d452251464b Yongbo Zhang      2020-05-08  536  	int i;
391d452251464b Yongbo Zhang      2020-05-08  537  	u32 sys_int_enable = 0;
391d452251464b Yongbo Zhang      2020-05-08  538  
391d452251464b Yongbo Zhang      2020-05-08  539  	is_tdm		= rsnd_runtime_is_tdm(io);
391d452251464b Yongbo Zhang      2020-05-08  540  	is_tdm_split	= rsnd_runtime_is_tdm_split(io);
ae5c322303fff5 Kuninori Morimoto 2013-07-21  541  
fd9adcfdc1434f Kuninori Morimoto 2016-02-18  542  	if (!rsnd_ssi_is_run_mods(mod, io))
fd9adcfdc1434f Kuninori Morimoto 2016-02-18  543  		return 0;
fd9adcfdc1434f Kuninori Morimoto 2016-02-18  544  
e5d9cfc6f5fe56 Andrzej Hajda     2015-12-24  545  	if (!ssi->usrcnt) {
c0ea089dbad47a Kuninori Morimoto 2018-10-30  546  		dev_err(dev, "%s usrcnt error\n", rsnd_mod_name(mod));
e5d9cfc6f5fe56 Andrzej Hajda     2015-12-24  547  		return -EIO;
e5d9cfc6f5fe56 Andrzej Hajda     2015-12-24  548  	}
e7d850dd10f4e6 Kuninori Morimoto 2015-10-26  549  
26d34b11af6a34 Kuninori Morimoto 2016-02-18  550  	rsnd_ssi_master_clk_stop(mod, io);
e7d850dd10f4e6 Kuninori Morimoto 2015-10-26  551  
e7d850dd10f4e6 Kuninori Morimoto 2015-10-26  552  	rsnd_mod_power_off(mod);
e7d850dd10f4e6 Kuninori Morimoto 2015-10-26  553  
e7d850dd10f4e6 Kuninori Morimoto 2015-10-26  554  	ssi->usrcnt--;
e7d850dd10f4e6 Kuninori Morimoto 2015-10-26  555  
203cdf51f28820 Kuninori Morimoto 2018-06-12  556  	if (!ssi->usrcnt) {
203cdf51f28820 Kuninori Morimoto 2018-06-12  557  		ssi->cr_own	= 0;
203cdf51f28820 Kuninori Morimoto 2018-06-12  558  		ssi->cr_mode	= 0;
203cdf51f28820 Kuninori Morimoto 2018-06-12  559  		ssi->wsr	= 0;
203cdf51f28820 Kuninori Morimoto 2018-06-12  560  	}
203cdf51f28820 Kuninori Morimoto 2018-06-12  561  
391d452251464b Yongbo Zhang      2020-05-08  562  	/* disable busif buffer over/under run interrupt. */
391d452251464b Yongbo Zhang      2020-05-08  563  	if (is_tdm || is_tdm_split) {
391d452251464b Yongbo Zhang      2020-05-08  564  		switch (id) {
391d452251464b Yongbo Zhang      2020-05-08  565  		case 0:
391d452251464b Yongbo Zhang      2020-05-08  566  		case 1:
391d452251464b Yongbo Zhang      2020-05-08  567  		case 2:
391d452251464b Yongbo Zhang      2020-05-08  568  		case 3:
391d452251464b Yongbo Zhang      2020-05-08  569  		case 4:
391d452251464b Yongbo Zhang      2020-05-08  570  			for (i = 0; i < 4; i++) {
391d452251464b Yongbo Zhang      2020-05-08  571  				sys_int_enable = rsnd_mod_read(mod,
391d452251464b Yongbo Zhang      2020-05-08  572  						SSI_SYS_INT_ENABLE(i * 2));
391d452251464b Yongbo Zhang      2020-05-08  573  				sys_int_enable &= ~(0xf << (id * 4));
391d452251464b Yongbo Zhang      2020-05-08  574  				rsnd_mod_write(mod,
391d452251464b Yongbo Zhang      2020-05-08  575  					       SSI_SYS_INT_ENABLE(i * 2),
391d452251464b Yongbo Zhang      2020-05-08  576  					       sys_int_enable);
391d452251464b Yongbo Zhang      2020-05-08  577  			}
391d452251464b Yongbo Zhang      2020-05-08  578  
391d452251464b Yongbo Zhang      2020-05-08  579  			break;
391d452251464b Yongbo Zhang      2020-05-08  580  		case 9:
391d452251464b Yongbo Zhang      2020-05-08  581  			for (i = 0; i < 4; i++) {
391d452251464b Yongbo Zhang      2020-05-08  582  				sys_int_enable = rsnd_mod_read(mod,
391d452251464b Yongbo Zhang      2020-05-08  583  					SSI_SYS_INT_ENABLE((i * 2) + 1));
391d452251464b Yongbo Zhang      2020-05-08  584  				sys_int_enable &= ~(0xf << 4);
391d452251464b Yongbo Zhang      2020-05-08  585  				rsnd_mod_write(mod,
391d452251464b Yongbo Zhang      2020-05-08  586  					       SSI_SYS_INT_ENABLE((i * 2) + 1),
391d452251464b Yongbo Zhang      2020-05-08  587  					       sys_int_enable);
391d452251464b Yongbo Zhang      2020-05-08  588  			}
391d452251464b Yongbo Zhang      2020-05-08  589  
391d452251464b Yongbo Zhang      2020-05-08  590  			break;
391d452251464b Yongbo Zhang      2020-05-08  591  		}
391d452251464b Yongbo Zhang      2020-05-08  592  
ae5c322303fff5 Kuninori Morimoto 2013-07-21  593  	return 0;
ae5c322303fff5 Kuninori Morimoto 2013-07-21  594  }
ae5c322303fff5 Kuninori Morimoto 2013-07-21  595  

:::::: The code at line 531 was first introduced by commit
:::::: ae5c322303fff50b93d60e34c6563f1264a5941b ASoC: add Renesas R-Car SSI feature

:::::: TO: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
:::::: CC: Mark Brown <broonie@linaro.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c
index af19010b9d88..8bd49c8a9517 100644
--- a/sound/soc/sh/rcar/gen.c
+++ b/sound/soc/sh/rcar/gen.c
@@ -224,6 +224,14 @@  static int rsnd_gen2_probe(struct rsnd_priv *priv)
 		RSND_GEN_S_REG(SSI_SYS_STATUS5,	0x884),
 		RSND_GEN_S_REG(SSI_SYS_STATUS6,	0x888),
 		RSND_GEN_S_REG(SSI_SYS_STATUS7,	0x88c),
+		RSND_GEN_S_REG(SSI_SYS_INT_ENABLE0, 0x850),
+		RSND_GEN_S_REG(SSI_SYS_INT_ENABLE1, 0x854),
+		RSND_GEN_S_REG(SSI_SYS_INT_ENABLE2, 0x858),
+		RSND_GEN_S_REG(SSI_SYS_INT_ENABLE3, 0x85c),
+		RSND_GEN_S_REG(SSI_SYS_INT_ENABLE4, 0x890),
+		RSND_GEN_S_REG(SSI_SYS_INT_ENABLE5, 0x894),
+		RSND_GEN_S_REG(SSI_SYS_INT_ENABLE6, 0x898),
+		RSND_GEN_S_REG(SSI_SYS_INT_ENABLE7, 0x89c),
 		RSND_GEN_S_REG(HDMI0_SEL,	0x9e0),
 		RSND_GEN_S_REG(HDMI1_SEL,	0x9e4),
 
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h
index ea6cbaa9743e..d47608ff5fac 100644
--- a/sound/soc/sh/rcar/rsnd.h
+++ b/sound/soc/sh/rcar/rsnd.h
@@ -189,6 +189,14 @@  enum rsnd_reg {
 	SSI_SYS_STATUS5,
 	SSI_SYS_STATUS6,
 	SSI_SYS_STATUS7,
+	SSI_SYS_INT_ENABLE0,
+	SSI_SYS_INT_ENABLE1,
+	SSI_SYS_INT_ENABLE2,
+	SSI_SYS_INT_ENABLE3,
+	SSI_SYS_INT_ENABLE4,
+	SSI_SYS_INT_ENABLE5,
+	SSI_SYS_INT_ENABLE6,
+	SSI_SYS_INT_ENABLE7,
 	HDMI0_SEL,
 	HDMI1_SEL,
 	SSI9_BUSIF0_MODE,
@@ -237,6 +245,7 @@  enum rsnd_reg {
 #define SSI9_BUSIF_ADINR(i)	(SSI9_BUSIF0_ADINR + (i))
 #define SSI9_BUSIF_DALIGN(i)	(SSI9_BUSIF0_DALIGN + (i))
 #define SSI_SYS_STATUS(i)	(SSI_SYS_STATUS0 + (i))
+#define SSI_SYS_INT_ENABLE(i) (SSI_SYS_INT_ENABLE0 + (i))
 
 
 struct rsnd_priv;
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c
index 4a7d3413917f..178f50a91b3e 100644
--- a/sound/soc/sh/rcar/ssi.c
+++ b/sound/soc/sh/rcar/ssi.c
@@ -372,6 +372,9 @@  static void rsnd_ssi_config_init(struct rsnd_mod *mod,
 	u32 wsr		= ssi->wsr;
 	int width;
 	int is_tdm, is_tdm_split;
+	int id = rsnd_mod_id(mod);
+	int i;
+	u32 sys_int_enable = 0;
 
 	is_tdm		= rsnd_runtime_is_tdm(io);
 	is_tdm_split	= rsnd_runtime_is_tdm_split(io);
@@ -447,6 +450,38 @@  static void rsnd_ssi_config_init(struct rsnd_mod *mod,
 		cr_mode = DIEN;		/* PIO : enable Data interrupt */
 	}
 
+	/* enable busif buffer over/under run interrupt. */
+	if (is_tdm || is_tdm_split) {
+		switch (id) {
+		case 0:
+		case 1:
+		case 2:
+		case 3:
+		case 4:
+			for (i = 0; i < 4; i++) {
+				sys_int_enable = rsnd_mod_read(mod,
+					SSI_SYS_INT_ENABLE(i * 2));
+				sys_int_enable |= 0xf << (id * 4);
+				rsnd_mod_write(mod,
+					       SSI_SYS_INT_ENABLE(i * 2),
+					       sys_int_enable);
+			}
+
+			break;
+		case 9:
+			for (i = 0; i < 4; i++) {
+				sys_int_enable = rsnd_mod_read(mod,
+					SSI_SYS_INT_ENABLE((i * 2) + 1));
+				sys_int_enable |= 0xf << 4;
+				rsnd_mod_write(mod,
+					       SSI_SYS_INT_ENABLE((i * 2) + 1),
+					       sys_int_enable);
+			}
+
+			break;
+		}
+	}
+
 init_end:
 	ssi->cr_own	= cr_own;
 	ssi->cr_mode	= cr_mode;
@@ -496,6 +531,13 @@  static int rsnd_ssi_quit(struct rsnd_mod *mod,
 {
 	struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
 	struct device *dev = rsnd_priv_to_dev(priv);
+	int is_tdm, is_tdm_split;
+	int id = rsnd_mod_id(mod);
+	int i;
+	u32 sys_int_enable = 0;
+
+	is_tdm		= rsnd_runtime_is_tdm(io);
+	is_tdm_split	= rsnd_runtime_is_tdm_split(io);
 
 	if (!rsnd_ssi_is_run_mods(mod, io))
 		return 0;
@@ -517,6 +559,37 @@  static int rsnd_ssi_quit(struct rsnd_mod *mod,
 		ssi->wsr	= 0;
 	}
 
+	/* disable busif buffer over/under run interrupt. */
+	if (is_tdm || is_tdm_split) {
+		switch (id) {
+		case 0:
+		case 1:
+		case 2:
+		case 3:
+		case 4:
+			for (i = 0; i < 4; i++) {
+				sys_int_enable = rsnd_mod_read(mod,
+						SSI_SYS_INT_ENABLE(i * 2));
+				sys_int_enable &= ~(0xf << (id * 4));
+				rsnd_mod_write(mod,
+					       SSI_SYS_INT_ENABLE(i * 2),
+					       sys_int_enable);
+			}
+
+			break;
+		case 9:
+			for (i = 0; i < 4; i++) {
+				sys_int_enable = rsnd_mod_read(mod,
+					SSI_SYS_INT_ENABLE((i * 2) + 1));
+				sys_int_enable &= ~(0xf << 4);
+				rsnd_mod_write(mod,
+					       SSI_SYS_INT_ENABLE((i * 2) + 1),
+					       sys_int_enable);
+			}
+
+			break;
+		}
+
 	return 0;
 }
 
@@ -622,6 +695,11 @@  static int rsnd_ssi_irq(struct rsnd_mod *mod,
 			int enable)
 {
 	u32 val = 0;
+	int is_tdm, is_tdm_split;
+	int id = rsnd_mod_id(mod);
+
+	is_tdm		= rsnd_runtime_is_tdm(io);
+	is_tdm_split	= rsnd_runtime_is_tdm_split(io);
 
 	if (rsnd_is_gen1(priv))
 		return 0;
@@ -635,6 +713,19 @@  static int rsnd_ssi_irq(struct rsnd_mod *mod,
 	if (enable)
 		val = rsnd_ssi_is_dma_mode(mod) ? 0x0e000000 : 0x0f000000;
 
+	if (is_tdm || is_tdm_split) {
+		switch (id) {
+		case 0:
+		case 1:
+		case 2:
+		case 3:
+		case 4:
+		case 9:
+			val |= 0xff00;
+			break;
+		}
+	}
+
 	rsnd_mod_write(mod, SSI_INT_ENABLE, val);
 
 	return 0;
@@ -651,6 +742,10 @@  static void __rsnd_ssi_interrupt(struct rsnd_mod *mod,
 	u32 status;
 	bool elapsed = false;
 	bool stop = false;
+	int is_tdm, is_tdm_split;
+
+	is_tdm		= rsnd_runtime_is_tdm(io);
+	is_tdm_split	= rsnd_runtime_is_tdm_split(io);
 
 	spin_lock(&priv->lock);
 
@@ -672,6 +767,53 @@  static void __rsnd_ssi_interrupt(struct rsnd_mod *mod,
 		stop = true;
 	}
 
+	status = 0;
+
+	if (is_tdm || is_tdm_split) {
+		switch (id) {
+		case 0:
+		case 1:
+		case 2:
+		case 3:
+		case 4:
+			for (i = 0; i < 4; i++) {
+				status = rsnd_mod_read(mod,
+						       SSI_SYS_STATUS(i * 2));
+				status &= 0xf << (id * 4);
+
+				if (status) {
+					rsnd_dbg_irq_status(dev,
+						"%s err status : 0x%08x\n",
+						rsnd_mod_name(mod), status);
+					rsnd_mod_write(mod,
+						       SSI_SYS_STATUS(i * 2),
+						       0xf << (id * 4));
+					stop = true;
+					break;
+				}
+			}
+			break;
+		case 9:
+			for (i = 0; i < 4; i++) {
+				status = rsnd_mod_write(mod,
+						SSI_SYS_STATUS((i * 2) + 1));
+				status &= 0xf << 4;
+
+				if (status) {
+					rsnd_dbg_irq_status(dev,
+						"%s err status : 0x%08x\n",
+						rsnd_mod_name(mod), status);
+					rsnd_mod_write(mod,
+						SSI_SYS_STATUS((i * 2) + 1),
+						0xf << 4);
+					stop = true;
+					break;
+				}
+			}
+			break;
+		}
+	}
+
 	rsnd_ssi_status_clear(mod);
 rsnd_ssi_interrupt_out:
 	spin_unlock(&priv->lock);