Re: [PATCH v3 4/5] spi: spi-geni-qcom: Add support for GPI dma

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Vinod,

I love your patch! Perhaps something to improve:

[auto build test WARNING on spi/for-next]
[also build test WARNING on wsa/i2c/for-next asoc/for-next linus/master v5.13-rc7 next-20210624]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Vinod-Koul/Add-and-enable-GPI-DMA-users/20210625-132320
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
config: x86_64-randconfig-a012-20210625 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 9ca0171a9ffdef5fdb1511d197a3fd72490362de)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://github.com/0day-ci/linux/commit/3632ac4a40c3ef7f86f081d462bf17b45e4c0085
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Vinod-Koul/Add-and-enable-GPI-DMA-users/20210625-132320
        git checkout 3632ac4a40c3ef7f86f081d462bf17b45e4c0085
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

>> drivers/spi/spi-geni-qcom.c:496:44: warning: variable 'i' is uninitialized when used here [-Wuninitialized]
                   dev_err(mas->dev, "Tx[%d] timeout%lu\n", i, timeout);
                                                            ^
   include/linux/dev_printk.h:112:32: note: expanded from macro 'dev_err'
           _dev_err(dev, dev_fmt(fmt), ##__VA_ARGS__)
                                         ^~~~~~~~~~~
   drivers/spi/spi-geni-qcom.c:407:12: note: initialize the variable 'i' to silence this warning
           int ret, i;
                     ^
                      = 0
>> drivers/spi/spi-geni-qcom.c:579:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (IS_ERR_OR_NULL(mas->gsi))
               ^~~~~~~~~~~~~~~~~~~~~~~~
   drivers/spi/spi-geni-qcom.c:590:9: note: uninitialized use occurs here
           return ret;
                  ^~~
   drivers/spi/spi-geni-qcom.c:579:2: note: remove the 'if' if its condition is always false
           if (IS_ERR_OR_NULL(mas->gsi))
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/spi/spi-geni-qcom.c:562:9: note: initialize the variable 'ret' to silence this warning
           int ret;
                  ^
                   = 0
   2 warnings generated.


vim +/i +496 drivers/spi/spi-geni-qcom.c

   398	
   399	static int setup_gsi_xfer(struct spi_transfer *xfer, struct spi_geni_master *mas,
   400				  struct spi_device *spi_slv, struct spi_master *spi)
   401	{
   402		unsigned long flags = DMA_PREP_INTERRUPT | DMA_CTRL_ACK;
   403		struct spi_geni_gsi *gsi;
   404		struct dma_slave_config config = {};
   405		struct gpi_spi_config peripheral = {};
   406		unsigned long timeout, jiffies;
   407		int ret, i;
   408	
   409		config.peripheral_config = &peripheral;
   410		config.peripheral_size = sizeof(peripheral);
   411		peripheral.set_config = true;
   412	
   413		if (xfer->bits_per_word != mas->cur_bits_per_word ||
   414		    xfer->speed_hz != mas->cur_speed_hz) {
   415			mas->cur_bits_per_word = xfer->bits_per_word;
   416			mas->cur_speed_hz = xfer->speed_hz;
   417		}
   418	
   419		if (!(mas->cur_bits_per_word % MIN_WORD_LEN)) {
   420			peripheral.rx_len = ((xfer->len << 3) / mas->cur_bits_per_word);
   421		} else {
   422			int bytes_per_word = (mas->cur_bits_per_word / BITS_PER_BYTE) + 1;
   423	
   424			peripheral.rx_len = (xfer->len / bytes_per_word);
   425		}
   426	
   427		if (xfer->tx_buf && xfer->rx_buf) {
   428			peripheral.cmd = SPI_DUPLEX;
   429		} else if (xfer->tx_buf) {
   430			peripheral.cmd = SPI_TX;
   431			peripheral.rx_len = 0;
   432		} else if (xfer->rx_buf) {
   433			peripheral.cmd = SPI_RX;
   434		}
   435	
   436		if (spi_slv->mode & SPI_LOOP)
   437			peripheral.loopback_en = true;
   438		if (spi_slv->mode & SPI_CPOL)
   439			peripheral.clock_pol_high = true;
   440		if (spi_slv->mode & SPI_CPHA)
   441			peripheral.data_pol_high = true;
   442	
   443		peripheral.cs = spi_slv->chip_select;
   444		peripheral.pack_en = true;
   445		peripheral.word_len = xfer->bits_per_word - MIN_WORD_LEN;
   446		peripheral.fragmentation = FRAGMENTATION;
   447	
   448		ret = get_spi_clk_cfg(mas->cur_speed_hz, mas,
   449				      &peripheral.clk_src, &peripheral.clk_div);
   450		if (ret) {
   451			dev_err(mas->dev, "Err in get_spi_clk_cfg() :%d\n", ret);
   452			return ret;
   453		}
   454	
   455		gsi = &mas->gsi[mas->num_xfers];
   456		gsi->rx_cb.mas = mas;
   457		gsi->rx_cb.xfer = xfer;
   458	
   459		if (peripheral.cmd & SPI_RX) {
   460			dmaengine_slave_config(mas->rx, &config);
   461			gsi->rx_desc = dmaengine_prep_slave_sg(mas->rx, xfer->rx_sg.sgl, xfer->rx_sg.nents,
   462							       DMA_DEV_TO_MEM, flags);
   463			if (!gsi->rx_desc) {
   464				dev_err(mas->dev, "Err setting up rx desc\n");
   465				return -EIO;
   466			}
   467			gsi->rx_desc->callback_result = spi_gsi_rx_callback_result;
   468			gsi->rx_desc->callback_param = &gsi->rx_cb;
   469		}
   470	
   471		dmaengine_slave_config(mas->tx, &config);
   472		gsi->tx_desc = dmaengine_prep_slave_sg(mas->tx, xfer->tx_sg.sgl, xfer->tx_sg.nents,
   473						       DMA_MEM_TO_DEV, flags);
   474		if (!gsi->tx_desc) {
   475			dev_err(mas->dev, "Err setting up tx desc\n");
   476			return -EIO;
   477		}
   478	
   479		gsi->tx_cb.mas = mas;
   480		gsi->tx_cb.xfer = xfer;
   481		gsi->tx_desc->callback_result = spi_gsi_tx_callback_result;
   482		gsi->tx_desc->callback_param = &gsi->tx_cb;
   483	
   484		if (peripheral.cmd & SPI_RX)
   485			gsi->rx_cookie = dmaengine_submit(gsi->rx_desc);
   486		gsi->tx_cookie = dmaengine_submit(gsi->tx_desc);
   487	
   488		if (peripheral.cmd & SPI_RX)
   489			dma_async_issue_pending(mas->rx);
   490		dma_async_issue_pending(mas->tx);
   491		mas->num_xfers++;
   492	
   493		jiffies = msecs_to_jiffies(SPI_XFER_TIMEOUT_MS);
   494		timeout = wait_for_completion_timeout(&mas->tx_cb, jiffies);
   495		if (timeout <= 0) {
 > 496			dev_err(mas->dev, "Tx[%d] timeout%lu\n", i, timeout);
   497			ret = -ETIMEDOUT;
   498			goto err_gsi_geni_transfer_one;
   499		}
   500	
   501		if (peripheral.cmd & SPI_RX) {
   502			jiffies = msecs_to_jiffies(SPI_XFER_TIMEOUT_MS);
   503			timeout = wait_for_completion_timeout(&mas->rx_cb, jiffies);
   504			if (timeout <= 0) {
   505				dev_err(mas->dev, "Rx[%d] timeout%lu\n", i, timeout);
   506				ret = -ETIMEDOUT;
   507				goto err_gsi_geni_transfer_one;
   508			}
   509		}
   510	
   511		spi_finalize_current_transfer(spi);
   512		return 0;
   513	
   514	err_gsi_geni_transfer_one:
   515		dmaengine_terminate_all(mas->tx);
   516		return ret;
   517	}
   518	
   519	static bool geni_can_dma(struct spi_controller *ctlr,
   520				 struct spi_device *slv, struct spi_transfer *xfer)
   521	{
   522		struct spi_geni_master *mas = spi_master_get_devdata(slv->master);
   523	
   524		/* check if dma is supported */
   525		if (mas->cur_xfer_mode == GENI_GPI_DMA)
   526			return true;
   527	
   528		return false;
   529	}
   530	
   531	static int spi_geni_prepare_message(struct spi_master *spi,
   532						struct spi_message *spi_msg)
   533	{
   534		struct spi_geni_master *mas = spi_master_get_devdata(spi);
   535		int ret;
   536	
   537		switch (mas->cur_xfer_mode) {
   538		case GENI_SE_FIFO:
   539			if (spi_geni_is_abort_still_pending(mas))
   540				return -EBUSY;
   541			ret = setup_fifo_params(spi_msg->spi, spi);
   542			if (ret)
   543				dev_err(mas->dev, "Couldn't select mode %d\n", ret);
   544			return ret;
   545	
   546		case GENI_GPI_DMA:
   547			mas->num_xfers = 0;
   548			reinit_completion(&mas->tx_cb);
   549			reinit_completion(&mas->rx_cb);
   550			memset(mas->gsi, 0, (sizeof(struct spi_geni_gsi) * NUM_SPI_XFER));
   551	
   552			return 0;
   553		}
   554	
   555		dev_err(mas->dev, "Mode not supported %d", mas->cur_xfer_mode);
   556		return -EINVAL;
   557	}
   558	
   559	static int spi_geni_grab_gpi_chan(struct spi_geni_master *mas)
   560	{
   561		size_t gsi_sz;
   562		int ret;
   563	
   564		mas->tx = dma_request_chan(mas->dev, "tx");
   565		if (IS_ERR_OR_NULL(mas->tx)) {
   566			dev_err(mas->dev, "Failed to get tx DMA ch %ld", PTR_ERR(mas->tx));
   567			ret = PTR_ERR(mas->tx);
   568			goto err_tx;
   569		}
   570		mas->rx = dma_request_chan(mas->dev, "rx");
   571		if (IS_ERR_OR_NULL(mas->rx)) {
   572			dev_err(mas->dev, "Failed to get rx DMA ch %ld", PTR_ERR(mas->rx));
   573			ret = PTR_ERR(mas->rx);
   574			goto err_rx;
   575		}
   576	
   577		gsi_sz = sizeof(struct spi_geni_gsi) * NUM_SPI_XFER;
   578		mas->gsi = devm_kzalloc(mas->dev, gsi_sz, GFP_KERNEL);
 > 579		if (IS_ERR_OR_NULL(mas->gsi))
   580			goto err_mem;
   581		return 0;
   582	
   583	err_mem:
   584		dma_release_channel(mas->rx);
   585	err_rx:
   586		dma_release_channel(mas->tx);
   587	err_tx:
   588		mas->tx = NULL;
   589		mas->rx = NULL;
   590		return ret;
   591	}
   592	

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

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux