Re: [PATCH] rts5208: add a missing check for the status of command sending

From: kbuild test robot
Date: Thu Dec 20 2018 - 12:32:12 EST


Hi Kangjie,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on staging/staging-testing]
[also build test WARNING on v4.20-rc7 next-20181220]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Kangjie-Lu/rts5208-add-a-missing-check-for-the-status-of-command-sending/20181221-004836
config: i386-randconfig-x005-201850 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386

All warnings (new ones prefixed by >>):

drivers/staging//rts5208/ms.c: In function 'mspro_rw_multi_sector':
>> drivers/staging//rts5208/ms.c:2722:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if (val & MS_INT_BREQ)
^~
drivers/staging//rts5208/ms.c:2724:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
if (retval != STATUS_SUCCESS)
^~

vim +/if +2722 drivers/staging//rts5208/ms.c

fa590c222f Micky Ching 2013-11-12 2605
fa590c222f Micky Ching 2013-11-12 2606 static int mspro_rw_multi_sector(struct scsi_cmnd *srb,
fa590c222f Micky Ching 2013-11-12 2607 struct rtsx_chip *chip, u32 start_sector,
fa590c222f Micky Ching 2013-11-12 2608 u16 sector_cnt)
fa590c222f Micky Ching 2013-11-12 2609 {
d1af6476e6 Dilek Uzulmez 2016-02-23 2610 struct ms_info *ms_card = &chip->ms_card;
11201769d1 Quentin Lambert 2015-03-04 2611 bool mode_2k = false;
11201769d1 Quentin Lambert 2015-03-04 2612 int retval;
fa590c222f Micky Ching 2013-11-12 2613 u16 count;
fa590c222f Micky Ching 2013-11-12 2614 u8 val, trans_mode, rw_tpc, rw_cmd;
fa590c222f Micky Ching 2013-11-12 2615
fa590c222f Micky Ching 2013-11-12 2616 ms_set_err_code(chip, MS_NO_ERROR);
fa590c222f Micky Ching 2013-11-12 2617
fa590c222f Micky Ching 2013-11-12 2618 ms_card->cleanup_counter = 0;
fa590c222f Micky Ching 2013-11-12 2619
fa590c222f Micky Ching 2013-11-12 2620 if (CHK_MSHG(ms_card)) {
fa590c222f Micky Ching 2013-11-12 2621 if ((start_sector % 4) || (sector_cnt % 4)) {
fa590c222f Micky Ching 2013-11-12 2622 if (srb->sc_data_direction == DMA_FROM_DEVICE) {
fa590c222f Micky Ching 2013-11-12 2623 rw_tpc = PRO_READ_LONG_DATA;
fa590c222f Micky Ching 2013-11-12 2624 rw_cmd = PRO_READ_DATA;
fa590c222f Micky Ching 2013-11-12 2625 } else {
fa590c222f Micky Ching 2013-11-12 2626 rw_tpc = PRO_WRITE_LONG_DATA;
fa590c222f Micky Ching 2013-11-12 2627 rw_cmd = PRO_WRITE_DATA;
fa590c222f Micky Ching 2013-11-12 2628 }
fa590c222f Micky Ching 2013-11-12 2629 } else {
fa590c222f Micky Ching 2013-11-12 2630 if (srb->sc_data_direction == DMA_FROM_DEVICE) {
fa590c222f Micky Ching 2013-11-12 2631 rw_tpc = PRO_READ_QUAD_DATA;
fa590c222f Micky Ching 2013-11-12 2632 rw_cmd = PRO_READ_2K_DATA;
fa590c222f Micky Ching 2013-11-12 2633 } else {
fa590c222f Micky Ching 2013-11-12 2634 rw_tpc = PRO_WRITE_QUAD_DATA;
fa590c222f Micky Ching 2013-11-12 2635 rw_cmd = PRO_WRITE_2K_DATA;
fa590c222f Micky Ching 2013-11-12 2636 }
11201769d1 Quentin Lambert 2015-03-04 2637 mode_2k = true;
fa590c222f Micky Ching 2013-11-12 2638 }
fa590c222f Micky Ching 2013-11-12 2639 } else {
fa590c222f Micky Ching 2013-11-12 2640 if (srb->sc_data_direction == DMA_FROM_DEVICE) {
fa590c222f Micky Ching 2013-11-12 2641 rw_tpc = PRO_READ_LONG_DATA;
fa590c222f Micky Ching 2013-11-12 2642 rw_cmd = PRO_READ_DATA;
fa590c222f Micky Ching 2013-11-12 2643 } else {
fa590c222f Micky Ching 2013-11-12 2644 rw_tpc = PRO_WRITE_LONG_DATA;
fa590c222f Micky Ching 2013-11-12 2645 rw_cmd = PRO_WRITE_DATA;
fa590c222f Micky Ching 2013-11-12 2646 }
fa590c222f Micky Ching 2013-11-12 2647 }
fa590c222f Micky Ching 2013-11-12 2648
fa590c222f Micky Ching 2013-11-12 2649 retval = ms_switch_clock(chip);
9f902b495b Aymen Qader 2018-09-20 2650 if (retval != STATUS_SUCCESS)
031366ea65 Joe Perches 2015-03-25 2651 return STATUS_FAIL;
fa590c222f Micky Ching 2013-11-12 2652
fa590c222f Micky Ching 2013-11-12 2653 if (srb->sc_data_direction == DMA_FROM_DEVICE)
fa590c222f Micky Ching 2013-11-12 2654 trans_mode = MS_TM_AUTO_READ;
fa590c222f Micky Ching 2013-11-12 2655 else
fa590c222f Micky Ching 2013-11-12 2656 trans_mode = MS_TM_AUTO_WRITE;
fa590c222f Micky Ching 2013-11-12 2657
8ee775f92c Joe Perches 2015-03-25 2658 retval = rtsx_read_register(chip, MS_TRANS_CFG, &val);
9f902b495b Aymen Qader 2018-09-20 2659 if (retval)
8ee775f92c Joe Perches 2015-03-25 2660 return retval;
fa590c222f Micky Ching 2013-11-12 2661
fa590c222f Micky Ching 2013-11-12 2662 if (ms_card->seq_mode) {
25ccf0b0a7 Wayne Porter 2016-10-11 2663 if ((ms_card->pre_dir != srb->sc_data_direction) ||
25ccf0b0a7 Wayne Porter 2016-10-11 2664 ((ms_card->pre_sec_addr + ms_card->pre_sec_cnt) !=
25ccf0b0a7 Wayne Porter 2016-10-11 2665 start_sector) ||
25ccf0b0a7 Wayne Porter 2016-10-11 2666 (mode_2k && (ms_card->seq_mode & MODE_512_SEQ)) ||
25ccf0b0a7 Wayne Porter 2016-10-11 2667 (!mode_2k && (ms_card->seq_mode & MODE_2K_SEQ)) ||
25ccf0b0a7 Wayne Porter 2016-10-11 2668 !(val & MS_INT_BREQ) ||
25ccf0b0a7 Wayne Porter 2016-10-11 2669 ((ms_card->total_sec_cnt + sector_cnt) > 0xFE00)) {
fa590c222f Micky Ching 2013-11-12 2670 ms_card->seq_mode = 0;
fa590c222f Micky Ching 2013-11-12 2671 ms_card->total_sec_cnt = 0;
fa590c222f Micky Ching 2013-11-12 2672 if (val & MS_INT_BREQ) {
fa590c222f Micky Ching 2013-11-12 2673 retval = ms_send_cmd(chip, PRO_STOP, WAIT_INT);
9f902b495b Aymen Qader 2018-09-20 2674 if (retval != STATUS_SUCCESS)
031366ea65 Joe Perches 2015-03-25 2675 return STATUS_FAIL;
fa590c222f Micky Ching 2013-11-12 2676
25ccf0b0a7 Wayne Porter 2016-10-11 2677 rtsx_write_register(chip, RBCTL, RB_FLUSH,
25ccf0b0a7 Wayne Porter 2016-10-11 2678 RB_FLUSH);
fa590c222f Micky Ching 2013-11-12 2679 }
fa590c222f Micky Ching 2013-11-12 2680 }
fa590c222f Micky Ching 2013-11-12 2681 }
fa590c222f Micky Ching 2013-11-12 2682
fa590c222f Micky Ching 2013-11-12 2683 if (!ms_card->seq_mode) {
fa590c222f Micky Ching 2013-11-12 2684 ms_card->total_sec_cnt = 0;
fa590c222f Micky Ching 2013-11-12 2685 if (sector_cnt >= SEQ_START_CRITERIA) {
fa590c222f Micky Ching 2013-11-12 2686 if ((ms_card->capacity - start_sector) > 0xFE00)
fa590c222f Micky Ching 2013-11-12 2687 count = 0xFE00;
fa590c222f Micky Ching 2013-11-12 2688 else
fa590c222f Micky Ching 2013-11-12 2689 count = (u16)(ms_card->capacity - start_sector);
fa590c222f Micky Ching 2013-11-12 2690
fa590c222f Micky Ching 2013-11-12 2691 if (count > sector_cnt) {
fa590c222f Micky Ching 2013-11-12 2692 if (mode_2k)
b0ef3ed48e Jiayi Ye 2014-10-20 2693 ms_card->seq_mode = MODE_2K_SEQ;
fa590c222f Micky Ching 2013-11-12 2694 else
b0ef3ed48e Jiayi Ye 2014-10-20 2695 ms_card->seq_mode = MODE_512_SEQ;
fa590c222f Micky Ching 2013-11-12 2696 }
fa590c222f Micky Ching 2013-11-12 2697 } else {
fa590c222f Micky Ching 2013-11-12 2698 count = sector_cnt;
fa590c222f Micky Ching 2013-11-12 2699 }
fa590c222f Micky Ching 2013-11-12 2700 retval = mspro_set_rw_cmd(chip, start_sector, count, rw_cmd);
fa590c222f Micky Ching 2013-11-12 2701 if (retval != STATUS_SUCCESS) {
fa590c222f Micky Ching 2013-11-12 2702 ms_card->seq_mode = 0;
031366ea65 Joe Perches 2015-03-25 2703 return STATUS_FAIL;
fa590c222f Micky Ching 2013-11-12 2704 }
fa590c222f Micky Ching 2013-11-12 2705 }
fa590c222f Micky Ching 2013-11-12 2706
fa590c222f Micky Ching 2013-11-12 2707 retval = ms_transfer_data(chip, trans_mode, rw_tpc, sector_cnt,
fa590c222f Micky Ching 2013-11-12 2708 WAIT_INT, mode_2k, scsi_sg_count(srb),
fa590c222f Micky Ching 2013-11-12 2709 scsi_sglist(srb), scsi_bufflen(srb));
fa590c222f Micky Ching 2013-11-12 2710 if (retval != STATUS_SUCCESS) {
fa590c222f Micky Ching 2013-11-12 2711 ms_card->seq_mode = 0;
fa590c222f Micky Ching 2013-11-12 2712 rtsx_read_register(chip, MS_TRANS_CFG, &val);
fa590c222f Micky Ching 2013-11-12 2713 rtsx_clear_ms_error(chip);
fa590c222f Micky Ching 2013-11-12 2714
fa590c222f Micky Ching 2013-11-12 2715 if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) {
fa590c222f Micky Ching 2013-11-12 2716 chip->rw_need_retry = 0;
2d77259135 Gaurav Pathak 2017-07-20 2717 dev_dbg(rtsx_dev(chip), "No card exist, exit %s\n",
2d77259135 Gaurav Pathak 2017-07-20 2718 __func__);
031366ea65 Joe Perches 2015-03-25 2719 return STATUS_FAIL;
fa590c222f Micky Ching 2013-11-12 2720 }
fa590c222f Micky Ching 2013-11-12 2721
fa590c222f Micky Ching 2013-11-12 @2722 if (val & MS_INT_BREQ)
e7cf02e967 Kangjie Lu 2018-12-20 2723 retval = ms_send_cmd(chip, PRO_STOP, WAIT_INT);
e7cf02e967 Kangjie Lu 2018-12-20 2724 if (retval != STATUS_SUCCESS)
e7cf02e967 Kangjie Lu 2018-12-20 2725 return STATUS_FAIL;
fa590c222f Micky Ching 2013-11-12 2726
fa590c222f Micky Ching 2013-11-12 2727 if (val & (MS_CRC16_ERR | MS_RDY_TIMEOUT)) {
bf6c0d110e Fabio Falzoi 2014-07-30 2728 dev_dbg(rtsx_dev(chip), "MSPro CRC error, tune clock!\n");
fa590c222f Micky Ching 2013-11-12 2729 chip->rw_need_retry = 1;
fa590c222f Micky Ching 2013-11-12 2730 ms_auto_tune_clock(chip);
fa590c222f Micky Ching 2013-11-12 2731 }
fa590c222f Micky Ching 2013-11-12 2732
031366ea65 Joe Perches 2015-03-25 2733 return retval;
fa590c222f Micky Ching 2013-11-12 2734 }
fa590c222f Micky Ching 2013-11-12 2735
fa590c222f Micky Ching 2013-11-12 2736 if (ms_card->seq_mode) {
fa590c222f Micky Ching 2013-11-12 2737 ms_card->pre_sec_addr = start_sector;
fa590c222f Micky Ching 2013-11-12 2738 ms_card->pre_sec_cnt = sector_cnt;
fa590c222f Micky Ching 2013-11-12 2739 ms_card->pre_dir = srb->sc_data_direction;
fa590c222f Micky Ching 2013-11-12 2740 ms_card->total_sec_cnt += sector_cnt;
fa590c222f Micky Ching 2013-11-12 2741 }
fa590c222f Micky Ching 2013-11-12 2742
fa590c222f Micky Ching 2013-11-12 2743 return STATUS_SUCCESS;
fa590c222f Micky Ching 2013-11-12 2744 }
fa590c222f Micky Ching 2013-11-12 2745

:::::: The code at line 2722 was first introduced by commit
:::::: fa590c222fbaa428edb2ce2194638906cea1400a staging: rts5208: add support for rts5208 and rts5288

:::::: TO: Micky Ching <micky_ching@xxxxxxxxxxxxxx>
:::::: CC: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

Attachment: .config.gz
Description: application/gzip