All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c:590:37: warning: shift by negative count ('-1')
Date: Thu, 23 Jun 2022 17:01:27 +0800	[thread overview]
Message-ID: <202206231632.NknwME76-lkp@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 12508 bytes --]

:::::: 
:::::: Manual check reason: "low confidence bisect report"
:::::: Manual check reason: "low confidence static check warning: drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c:590:37: warning: shift by negative count ('-1') [-Wanalyzer-shift-count-negative]"
:::::: 

CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
CC: linux-kernel(a)vger.kernel.org
TO: Jonathan Kim <jonathan.kim@amd.com>
CC: Alex Deucher <alexander.deucher@amd.com>
CC: Felix Kuehling <felix.kuehling@amd.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   de5c208d533a46a074eb46ea17f672cc005a7269
commit: 933048103837710b6996d5487e5fcbc320b81503 drm/amdkfd: report pcie bandwidth to the kfd
date:   11 months ago
:::::: branch date: 14 hours ago
:::::: commit date: 11 months ago
config: arm-randconfig-c002-20220622 (https://download.01.org/0day-ci/archive/20220623/202206231632.NknwME76-lkp(a)intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 11.3.0
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
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=933048103837710b6996d5487e5fcbc320b81503
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 933048103837710b6996d5487e5fcbc320b81503
        # save the config file
         ARCH=arm KBUILD_USERCFLAGS='-fanalyzer -Wno-error' 

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>


gcc-analyzer warnings: (new ones prefixed by >>)
   drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c: In function 'amdgpu_amdkfd_get_pcie_bandwidth_mbytes':
>> drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c:590:37: warning: shift by negative count ('-1') [-Wanalyzer-shift-count-negative]
     590 |         uint32_t num_lanes_mask = 1 << num_lanes_shift;
         |                                   ~~^~~~~~~~~~~~~~~~~~
     'amdgpu_amdkfd_get_pcie_bandwidth_mbytes': events 1-4
       |
       |  581 | int amdgpu_amdkfd_get_pcie_bandwidth_mbytes(struct kgd_dev *dev, bool is_min)
       |      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       |      |     |
       |      |     (1) entry to 'amdgpu_amdkfd_get_pcie_bandwidth_mbytes'
       |......
       |  584 |         int num_lanes_shift = (is_min ? ffs(adev->pm.pcie_mlw_mask) :
       |      |                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       |      |                                         |           |
       |      |                                         |           (3) ...to here
       |      |                                         (4) calling 'ffs' from 'amdgpu_amdkfd_get_pcie_bandwidth_mbytes'
       |  585 |                                                         fls(adev->pm.pcie_mlw_mask)) - 1;
       |      |                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       |      |                                                                                      |
       |      |                                                                                      (2) following 'true' branch (when 'is_min != 0')...
       |
       +--> 'ffs': events 5-6
              |
              |include/asm-generic/bitops/ffs.h:13:19:
              |   13 | static inline int ffs(int x)
              |      |                   ^~~
              |      |                   |
              |      |                   (5) entry to 'ffs'
              |......
              |   17 |         if (!x)
              |      |            ~       
              |      |            |
              |      |            (6) following 'true' branch (when 'x == 0')...
              |
            'ffs': event 7
              |
              |cc1:
              | (7): ...to here
              |
       <------+
       |
     'amdgpu_amdkfd_get_pcie_bandwidth_mbytes': events 8-11
       |
       |drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c:584:41:
       |  584 |         int num_lanes_shift = (is_min ? ffs(adev->pm.pcie_mlw_mask) :
       |      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
       |      |                                         |
       |      |                                         (8) returning to 'amdgpu_amdkfd_get_pcie_bandwidth_mbytes' from 'ffs'
       |  585 |                                                         fls(adev->pm.pcie_mlw_mask)) - 1;
       |  586 |         int gen_speed_shift = (is_min ? ffs(adev->pm.pcie_gen_mask &
       |      |                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       |      |                                         |           |
       |      |                                         |           (10) ...to here
       |      |                                         (11) calling 'ffs' from 'amdgpu_amdkfd_get_pcie_bandwidth_mbytes'
       |  587 |                                                 CAIL_PCIE_LINK_SPEED_SUPPORT_MASK) :
       |      |                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       |  588 |                                         fls(adev->pm.pcie_gen_mask &
       |      |                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       |  589 |                                                 CAIL_PCIE_LINK_SPEED_SUPPORT_MASK)) - 1;
       |      |                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       |      |                                                                                     |
       |      |                                                                                     (9) following 'true' branch (when 'is_min != 0')...
       |
       +--> 'ffs': events 12-13
              |
              |include/asm-generic/bitops/ffs.h:13:19:
              |   13 | static inline int ffs(int x)
              |      |                   ^~~
              |      |                   |
              |      |                   (12) entry to 'ffs'
              |......
              |   17 |         if (!x)
              |      |            ~       
              |      |            |
              |      |            (13) following 'true' branch (when 'x == 0')...
              |
            'ffs': event 14
              |
              |cc1:
              | (14): ...to here
              |
       <------+
       |
     'amdgpu_amdkfd_get_pcie_bandwidth_mbytes': events 15-16
       |
       |drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c:586:41:
       |  586 |         int gen_speed_shift = (is_min ? ffs(adev->pm.pcie_gen_mask &
       |      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
       |      |                                         |
       |      |                                         (15) returning to 'amdgpu_amdkfd_get_pcie_bandwidth_mbytes' from 'ffs'
       |  587 |                                                 CAIL_PCIE_LINK_SPEED_SUPPORT_MASK) :
       |      |                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       |......
       |  590 |         uint32_t num_lanes_mask = 1 << num_lanes_shift;
       |      |                                   ~~~~~~~~~~~~~~~~~~~~
       |      |                                     |
       |      |                                     (16) shift by negative amount here ('-1')
       |
   drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c:591:37: warning: shift by negative count ('-1') [-Wanalyzer-shift-count-negative]
     591 |         uint32_t gen_speed_mask = 1 << gen_speed_shift;
         |                                   ~~^~~~~~~~~~~~~~~~~~
     'amdgpu_amdkfd_get_pcie_bandwidth_mbytes': events 1-4

vim +590 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c

93304810383771 Jonathan Kim 2021-06-02  580  
93304810383771 Jonathan Kim 2021-06-02  581  int amdgpu_amdkfd_get_pcie_bandwidth_mbytes(struct kgd_dev *dev, bool is_min)
93304810383771 Jonathan Kim 2021-06-02  582  {
93304810383771 Jonathan Kim 2021-06-02  583  	struct amdgpu_device *adev = (struct amdgpu_device *)dev;
93304810383771 Jonathan Kim 2021-06-02  584  	int num_lanes_shift = (is_min ? ffs(adev->pm.pcie_mlw_mask) :
93304810383771 Jonathan Kim 2021-06-02  585  							fls(adev->pm.pcie_mlw_mask)) - 1;
93304810383771 Jonathan Kim 2021-06-02  586  	int gen_speed_shift = (is_min ? ffs(adev->pm.pcie_gen_mask &
93304810383771 Jonathan Kim 2021-06-02  587  						CAIL_PCIE_LINK_SPEED_SUPPORT_MASK) :
93304810383771 Jonathan Kim 2021-06-02  588  					fls(adev->pm.pcie_gen_mask &
93304810383771 Jonathan Kim 2021-06-02  589  						CAIL_PCIE_LINK_SPEED_SUPPORT_MASK)) - 1;
93304810383771 Jonathan Kim 2021-06-02 @590  	uint32_t num_lanes_mask = 1 << num_lanes_shift;
93304810383771 Jonathan Kim 2021-06-02  591  	uint32_t gen_speed_mask = 1 << gen_speed_shift;
93304810383771 Jonathan Kim 2021-06-02  592  	int num_lanes_factor = 0, gen_speed_mbits_factor = 0;
93304810383771 Jonathan Kim 2021-06-02  593  
93304810383771 Jonathan Kim 2021-06-02  594  	switch (num_lanes_mask) {
93304810383771 Jonathan Kim 2021-06-02  595  	case CAIL_PCIE_LINK_WIDTH_SUPPORT_X1:
93304810383771 Jonathan Kim 2021-06-02  596  		num_lanes_factor = 1;
93304810383771 Jonathan Kim 2021-06-02  597  		break;
93304810383771 Jonathan Kim 2021-06-02  598  	case CAIL_PCIE_LINK_WIDTH_SUPPORT_X2:
93304810383771 Jonathan Kim 2021-06-02  599  		num_lanes_factor = 2;
93304810383771 Jonathan Kim 2021-06-02  600  		break;
93304810383771 Jonathan Kim 2021-06-02  601  	case CAIL_PCIE_LINK_WIDTH_SUPPORT_X4:
93304810383771 Jonathan Kim 2021-06-02  602  		num_lanes_factor = 4;
93304810383771 Jonathan Kim 2021-06-02  603  		break;
93304810383771 Jonathan Kim 2021-06-02  604  	case CAIL_PCIE_LINK_WIDTH_SUPPORT_X8:
93304810383771 Jonathan Kim 2021-06-02  605  		num_lanes_factor = 8;
93304810383771 Jonathan Kim 2021-06-02  606  		break;
93304810383771 Jonathan Kim 2021-06-02  607  	case CAIL_PCIE_LINK_WIDTH_SUPPORT_X12:
93304810383771 Jonathan Kim 2021-06-02  608  		num_lanes_factor = 12;
93304810383771 Jonathan Kim 2021-06-02  609  		break;
93304810383771 Jonathan Kim 2021-06-02  610  	case CAIL_PCIE_LINK_WIDTH_SUPPORT_X16:
93304810383771 Jonathan Kim 2021-06-02  611  		num_lanes_factor = 16;
93304810383771 Jonathan Kim 2021-06-02  612  		break;
93304810383771 Jonathan Kim 2021-06-02  613  	case CAIL_PCIE_LINK_WIDTH_SUPPORT_X32:
93304810383771 Jonathan Kim 2021-06-02  614  		num_lanes_factor = 32;
93304810383771 Jonathan Kim 2021-06-02  615  		break;
93304810383771 Jonathan Kim 2021-06-02  616  	}
93304810383771 Jonathan Kim 2021-06-02  617  
93304810383771 Jonathan Kim 2021-06-02  618  	switch (gen_speed_mask) {
93304810383771 Jonathan Kim 2021-06-02  619  	case CAIL_PCIE_LINK_SPEED_SUPPORT_GEN1:
93304810383771 Jonathan Kim 2021-06-02  620  		gen_speed_mbits_factor = 2500;
93304810383771 Jonathan Kim 2021-06-02  621  		break;
93304810383771 Jonathan Kim 2021-06-02  622  	case CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2:
93304810383771 Jonathan Kim 2021-06-02  623  		gen_speed_mbits_factor = 5000;
93304810383771 Jonathan Kim 2021-06-02  624  		break;
93304810383771 Jonathan Kim 2021-06-02  625  	case CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3:
93304810383771 Jonathan Kim 2021-06-02  626  		gen_speed_mbits_factor = 8000;
93304810383771 Jonathan Kim 2021-06-02  627  		break;
93304810383771 Jonathan Kim 2021-06-02  628  	case CAIL_PCIE_LINK_SPEED_SUPPORT_GEN4:
93304810383771 Jonathan Kim 2021-06-02  629  		gen_speed_mbits_factor = 16000;
93304810383771 Jonathan Kim 2021-06-02  630  		break;
93304810383771 Jonathan Kim 2021-06-02  631  	case CAIL_PCIE_LINK_SPEED_SUPPORT_GEN5:
93304810383771 Jonathan Kim 2021-06-02  632  		gen_speed_mbits_factor = 32000;
93304810383771 Jonathan Kim 2021-06-02  633  		break;
93304810383771 Jonathan Kim 2021-06-02  634  	}
93304810383771 Jonathan Kim 2021-06-02  635  
93304810383771 Jonathan Kim 2021-06-02  636  	return (num_lanes_factor * gen_speed_mbits_factor)/BITS_PER_BYTE;
3f46c4e9ce25bb Jonathan Kim 2021-05-12  637  }
3f46c4e9ce25bb Jonathan Kim 2021-05-12  638  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

             reply	other threads:[~2022-06-23  9:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-23  9:01 kernel test robot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-06-22 13:42 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c:590:37: warning: shift by negative count ('-1') kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202206231632.NknwME76-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=kbuild@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.