Re: [PATCH v4] i2c: qcom-geni: Add support for GPI DMA

From: kernel test robot
Date: Sun Oct 31 2021 - 10:06:50 EST


Hi Vinod,

Thanks for your patch! Perhaps something to improve:

[auto build test WARNING on wsa/i2c/for-next]
[also build test WARNING on v5.15-rc7 next-20211029]
[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/i2c-qcom-geni-Add-support-for-GPI-DMA/20211019-140347
base: https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
config: riscv-randconfig-c006-20211028 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 5db7568a6a1fcb408eb8988abdaff2a225a8eb72)
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 riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/8244d69587ec2d94d34a75f5a3865d250e6880c7
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Vinod-Koul/i2c-qcom-geni-Add-support-for-GPI-DMA/20211019-140347
git checkout 8244d69587ec2d94d34a75f5a3865d250e6880c7
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer

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


clang-analyzer warnings: (new ones prefixed by >>)

>> drivers/i2c/busses/i2c-qcom-geni.c:508:8: warning: Value stored to 'dma_buf' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
void *dma_buf = &buf;
^~~~~~~ ~~~~

vim +/dma_buf +508 drivers/i2c/busses/i2c-qcom-geni.c

8244d69587ec2d9 Vinod Koul 2021-10-19 501
8244d69587ec2d9 Vinod Koul 2021-10-19 502 static int geni_i2c_gpi(struct geni_i2c_dev *gi2c, struct i2c_msg *msg,
8244d69587ec2d9 Vinod Koul 2021-10-19 503 struct dma_slave_config *config, dma_addr_t *dma_addr_p,
8244d69587ec2d9 Vinod Koul 2021-10-19 504 void **buf, unsigned int op, struct dma_chan *dma_chan)
8244d69587ec2d9 Vinod Koul 2021-10-19 505 {
8244d69587ec2d9 Vinod Koul 2021-10-19 506 struct gpi_i2c_config *peripheral;
8244d69587ec2d9 Vinod Koul 2021-10-19 507 unsigned int flags;
8244d69587ec2d9 Vinod Koul 2021-10-19 @508 void *dma_buf = &buf;
8244d69587ec2d9 Vinod Koul 2021-10-19 509 dma_addr_t addr;
8244d69587ec2d9 Vinod Koul 2021-10-19 510 enum dma_data_direction map_dirn;
8244d69587ec2d9 Vinod Koul 2021-10-19 511 enum dma_transfer_direction dma_dirn;
8244d69587ec2d9 Vinod Koul 2021-10-19 512 struct dma_async_tx_descriptor *desc;
8244d69587ec2d9 Vinod Koul 2021-10-19 513 int ret;
8244d69587ec2d9 Vinod Koul 2021-10-19 514
8244d69587ec2d9 Vinod Koul 2021-10-19 515 peripheral = config->peripheral_config;
8244d69587ec2d9 Vinod Koul 2021-10-19 516
8244d69587ec2d9 Vinod Koul 2021-10-19 517 dma_buf = i2c_get_dma_safe_msg_buf(msg, 1);
8244d69587ec2d9 Vinod Koul 2021-10-19 518 if (!dma_buf)
8244d69587ec2d9 Vinod Koul 2021-10-19 519 return -ENOMEM;
8244d69587ec2d9 Vinod Koul 2021-10-19 520
8244d69587ec2d9 Vinod Koul 2021-10-19 521 if (op == I2C_WRITE)
8244d69587ec2d9 Vinod Koul 2021-10-19 522 map_dirn = DMA_TO_DEVICE;
8244d69587ec2d9 Vinod Koul 2021-10-19 523 else
8244d69587ec2d9 Vinod Koul 2021-10-19 524 map_dirn = DMA_FROM_DEVICE;
8244d69587ec2d9 Vinod Koul 2021-10-19 525
8244d69587ec2d9 Vinod Koul 2021-10-19 526 addr = dma_map_single(gi2c->se.dev->parent, dma_buf, msg->len, map_dirn);
8244d69587ec2d9 Vinod Koul 2021-10-19 527 if (dma_mapping_error(gi2c->se.dev->parent, addr)) {
8244d69587ec2d9 Vinod Koul 2021-10-19 528 i2c_put_dma_safe_msg_buf(dma_buf, msg, false);
8244d69587ec2d9 Vinod Koul 2021-10-19 529 return -ENOMEM;
8244d69587ec2d9 Vinod Koul 2021-10-19 530 }
8244d69587ec2d9 Vinod Koul 2021-10-19 531
8244d69587ec2d9 Vinod Koul 2021-10-19 532 peripheral->rx_len = msg->len;
8244d69587ec2d9 Vinod Koul 2021-10-19 533 peripheral->op = op;
8244d69587ec2d9 Vinod Koul 2021-10-19 534
8244d69587ec2d9 Vinod Koul 2021-10-19 535 ret = dmaengine_slave_config(dma_chan, config);
8244d69587ec2d9 Vinod Koul 2021-10-19 536 if (ret) {
8244d69587ec2d9 Vinod Koul 2021-10-19 537 dev_err(gi2c->se.dev, "dma config error: %d for op:%d\n", ret, op);
8244d69587ec2d9 Vinod Koul 2021-10-19 538 goto err_config;
8244d69587ec2d9 Vinod Koul 2021-10-19 539 }
8244d69587ec2d9 Vinod Koul 2021-10-19 540
8244d69587ec2d9 Vinod Koul 2021-10-19 541 peripheral->set_config = false;
8244d69587ec2d9 Vinod Koul 2021-10-19 542 peripheral->multi_msg = true;
8244d69587ec2d9 Vinod Koul 2021-10-19 543 flags = DMA_PREP_INTERRUPT | DMA_CTRL_ACK;
8244d69587ec2d9 Vinod Koul 2021-10-19 544
8244d69587ec2d9 Vinod Koul 2021-10-19 545 if (op == I2C_WRITE)
8244d69587ec2d9 Vinod Koul 2021-10-19 546 dma_dirn = DMA_MEM_TO_DEV;
8244d69587ec2d9 Vinod Koul 2021-10-19 547 else
8244d69587ec2d9 Vinod Koul 2021-10-19 548 dma_dirn = DMA_DEV_TO_MEM;
8244d69587ec2d9 Vinod Koul 2021-10-19 549
8244d69587ec2d9 Vinod Koul 2021-10-19 550 desc = dmaengine_prep_slave_single(dma_chan, addr, msg->len, dma_dirn, flags);
8244d69587ec2d9 Vinod Koul 2021-10-19 551 if (!desc) {
8244d69587ec2d9 Vinod Koul 2021-10-19 552 dev_err(gi2c->se.dev, "prep_slave_sg failed\n");
8244d69587ec2d9 Vinod Koul 2021-10-19 553 ret = -EIO;
8244d69587ec2d9 Vinod Koul 2021-10-19 554 goto err_config;
8244d69587ec2d9 Vinod Koul 2021-10-19 555 }
8244d69587ec2d9 Vinod Koul 2021-10-19 556
8244d69587ec2d9 Vinod Koul 2021-10-19 557 desc->callback_result = i2c_gsi_cb_result;
8244d69587ec2d9 Vinod Koul 2021-10-19 558 desc->callback_param = gi2c;
8244d69587ec2d9 Vinod Koul 2021-10-19 559
8244d69587ec2d9 Vinod Koul 2021-10-19 560 dmaengine_submit(desc);
8244d69587ec2d9 Vinod Koul 2021-10-19 561 *dma_addr_p = addr;
8244d69587ec2d9 Vinod Koul 2021-10-19 562
8244d69587ec2d9 Vinod Koul 2021-10-19 563 return 0;
8244d69587ec2d9 Vinod Koul 2021-10-19 564
8244d69587ec2d9 Vinod Koul 2021-10-19 565 err_config:
8244d69587ec2d9 Vinod Koul 2021-10-19 566 dma_unmap_single(gi2c->se.dev->parent, addr, msg->len, map_dirn);
8244d69587ec2d9 Vinod Koul 2021-10-19 567 i2c_put_dma_safe_msg_buf(dma_buf, msg, false);
8244d69587ec2d9 Vinod Koul 2021-10-19 568 return ret;
8244d69587ec2d9 Vinod Koul 2021-10-19 569 }
8244d69587ec2d9 Vinod Koul 2021-10-19 570

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

Attachment: .config.gz
Description: application/gzip