lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202305180153.lEnd7dUA-lkp@intel.com>
Date:   Thu, 18 May 2023 02:13:22 +0800
From:   kernel test robot <lkp@...el.com>
To:     Huacai Chen <chenhuacai@...ngson.cn>
Cc:     oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
        WANG Xuerui <git@...0n.name>,
        Jianmin Lv <lvjianmin@...ngson.cn>
Subject: drivers/message/fusion/mptlan.c:1177:21: sparse: sparse: cast to
 restricted __le16

Hi Huacai,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   f1fcbaa18b28dec10281551dfe6ed3a3ed80e3d6
commit: 57fc7323a8e7c2e7c1d5795ab63cb3ffea3cfdfb LoongArch: Add PCI controller support
date:   9 months ago
config: loongarch-randconfig-s041-20230517
compiler: loongarch64-linux-gcc (GCC) 12.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-39-gce1a6720-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=57fc7323a8e7c2e7c1d5795ab63cb3ffea3cfdfb
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 57fc7323a8e7c2e7c1d5795ab63cb3ffea3cfdfb
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=loongarch olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=loongarch SHELL=/bin/bash drivers/message/fusion/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202305180153.lEnd7dUA-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> drivers/message/fusion/mptlan.c:1177:21: sparse: sparse: cast to restricted __le16
>> drivers/message/fusion/mptlan.c:1240:52: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [usertype] TransactionContext @@     got restricted __le32 [usertype] @@
   drivers/message/fusion/mptlan.c:1240:52: sparse:     expected unsigned int [usertype] TransactionContext
   drivers/message/fusion/mptlan.c:1240:52: sparse:     got restricted __le32 [usertype]
>> drivers/message/fusion/mptlan.c:1244:46: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [usertype] FlagsLength @@     got restricted __le32 [usertype] @@
   drivers/message/fusion/mptlan.c:1244:46: sparse:     expected unsigned int [usertype] FlagsLength
   drivers/message/fusion/mptlan.c:1244:46: sparse:     got restricted __le32 [usertype]
>> drivers/message/fusion/mptlan.c:1248:46: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [usertype] Low @@     got restricted __le32 [usertype] @@
   drivers/message/fusion/mptlan.c:1248:46: sparse:     expected unsigned int [usertype] Low
   drivers/message/fusion/mptlan.c:1248:46: sparse:     got restricted __le32 [usertype]
>> drivers/message/fusion/mptlan.c:1250:55: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [usertype] High @@     got restricted __le32 [usertype] @@
   drivers/message/fusion/mptlan.c:1250:55: sparse:     expected unsigned int [usertype] High
   drivers/message/fusion/mptlan.c:1250:55: sparse:     got restricted __le32 [usertype]
>> drivers/message/fusion/mptlan.c:1264:38: sparse: sparse: invalid assignment: |=
>> drivers/message/fusion/mptlan.c:1264:38: sparse:    left side has type unsigned int
>> drivers/message/fusion/mptlan.c:1264:38: sparse:    right side has type restricted __le32
>> drivers/message/fusion/mptlan.c:1266:39: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [usertype] BucketCount @@     got restricted __le32 [usertype] @@
   drivers/message/fusion/mptlan.c:1266:39: sparse:     expected unsigned int [usertype] BucketCount
   drivers/message/fusion/mptlan.c:1266:39: sparse:     got restricted __le32 [usertype]
>> drivers/message/fusion/mptlan.c:969:25: sparse: sparse: cast to restricted __le32
   drivers/message/fusion/mptlan.c:974:9: sparse: sparse: cast to restricted __le16
   drivers/message/fusion/mptlan.c:977:14: sparse: sparse: cast to restricted __le16
   drivers/message/fusion/mptlan.c:981:15: sparse: sparse: cast to restricted __le32
   drivers/message/fusion/mptlan.c:986:17: sparse: sparse: cast to restricted __le16
   drivers/message/fusion/mptlan.c:991:18: sparse: sparse: cast to restricted __le32
   drivers/message/fusion/mptlan.c:995:18: sparse: sparse: cast to restricted __le32
   drivers/message/fusion/mptlan.c:1025:31: sparse: sparse: cast to restricted __le32
   drivers/message/fusion/mptlan.c:612:9: sparse: sparse: cast to restricted __le16
   drivers/message/fusion/mptlan.c:617:17: sparse: sparse: cast to restricted __le16
   drivers/message/fusion/mptlan.c:641:23: sparse: sparse: cast to restricted __le32
   drivers/message/fusion/mptlan.c:346:17: sparse: sparse: cast to restricted __le32
>> drivers/message/fusion/mptlan.c:1498:27: sparse: sparse: restricted __be16 degrades to integer
>> drivers/message/fusion/mptlan.c:1535:29: sparse: sparse: incorrect type in return expression (different base types) @@     expected unsigned short @@     got restricted __be16 [usertype] ethertype @@
   drivers/message/fusion/mptlan.c:1535:29: sparse:     expected unsigned short
   drivers/message/fusion/mptlan.c:1535:29: sparse:     got restricted __be16 [usertype] ethertype
>> drivers/message/fusion/mptlan.c:1538:16: sparse: sparse: incorrect type in return expression (different base types) @@     expected unsigned short @@     got restricted __be16 [usertype] @@
   drivers/message/fusion/mptlan.c:1538:16: sparse:     expected unsigned short
   drivers/message/fusion/mptlan.c:1538:16: sparse:     got restricted __be16 [usertype]
   drivers/message/fusion/mptlan.c:746:36: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [usertype] TransactionContext @@     got restricted __le32 [usertype] @@
   drivers/message/fusion/mptlan.c:746:36: sparse:     expected unsigned int [usertype] TransactionContext
   drivers/message/fusion/mptlan.c:746:36: sparse:     got restricted __le32 [usertype]
>> drivers/message/fusion/mptlan.c:754:39: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int @@     got restricted __le32 [usertype] @@
   drivers/message/fusion/mptlan.c:754:39: sparse:     expected unsigned int
   drivers/message/fusion/mptlan.c:754:39: sparse:     got restricted __le32 [usertype]
   drivers/message/fusion/mptlan.c:757:39: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int @@     got restricted __le32 [usertype] @@
   drivers/message/fusion/mptlan.c:757:39: sparse:     expected unsigned int
   drivers/message/fusion/mptlan.c:757:39: sparse:     got restricted __le32 [usertype]
   drivers/message/fusion/mptlan.c:767:30: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [usertype] FlagsLength @@     got restricted __le32 [usertype] @@
   drivers/message/fusion/mptlan.c:767:30: sparse:     expected unsigned int [usertype] FlagsLength
   drivers/message/fusion/mptlan.c:767:30: sparse:     got restricted __le32 [usertype]
   drivers/message/fusion/mptlan.c:776:30: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [usertype] Low @@     got restricted __le32 [usertype] @@
   drivers/message/fusion/mptlan.c:776:30: sparse:     expected unsigned int [usertype] Low
   drivers/message/fusion/mptlan.c:776:30: sparse:     got restricted __le32 [usertype]
   drivers/message/fusion/mptlan.c:778:39: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [usertype] High @@     got restricted __le32 [usertype] @@
   drivers/message/fusion/mptlan.c:778:39: sparse:     expected unsigned int [usertype] High
   drivers/message/fusion/mptlan.c:778:39: sparse:     got restricted __le32 [usertype]
   drivers/message/fusion/mptlan.c:785:9: sparse: sparse: cast to restricted __le32
>> drivers/message/fusion/mptlan.c:820:23: sparse: sparse: incorrect type in assignment (different base types) @@     expected restricted __be16 [usertype] protocol @@     got unsigned short @@
   drivers/message/fusion/mptlan.c:820:23: sparse:     expected restricted __be16 [usertype] protocol
   drivers/message/fusion/mptlan.c:820:23: sparse:     got unsigned short
   drivers/message/fusion/mptlan.c:924:23: sparse: sparse: cast to restricted __le32

vim +1177 drivers/message/fusion/mptlan.c

^1da177e4c3f41 Linus Torvalds           2005-04-16   958  
^1da177e4c3f41 Linus Torvalds           2005-04-16   959  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
^1da177e4c3f41 Linus Torvalds           2005-04-16   960  static int
^1da177e4c3f41 Linus Torvalds           2005-04-16   961  mpt_lan_receive_post_reply(struct net_device *dev,
^1da177e4c3f41 Linus Torvalds           2005-04-16   962  			   LANReceivePostReply_t *pRecvRep)
^1da177e4c3f41 Linus Torvalds           2005-04-16   963  {
97341249c4c30c Wang Chen                2008-12-03   964  	struct mpt_lan_priv *priv = netdev_priv(dev);
^1da177e4c3f41 Linus Torvalds           2005-04-16   965  	MPT_ADAPTER *mpt_dev = priv->mpt_dev;
^1da177e4c3f41 Linus Torvalds           2005-04-16   966  	struct sk_buff *skb, *old_skb;
^1da177e4c3f41 Linus Torvalds           2005-04-16   967  	unsigned long flags;
^1da177e4c3f41 Linus Torvalds           2005-04-16   968  	u32 len, ctx, offset;
^1da177e4c3f41 Linus Torvalds           2005-04-16   969  	u32 remaining = le32_to_cpu(pRecvRep->BucketsRemaining);
^1da177e4c3f41 Linus Torvalds           2005-04-16   970  	int count;
^1da177e4c3f41 Linus Torvalds           2005-04-16   971  	int i, l;
^1da177e4c3f41 Linus Torvalds           2005-04-16   972  
^1da177e4c3f41 Linus Torvalds           2005-04-16   973  	dioprintk((KERN_INFO MYNAM ": mpt_lan_receive_post_reply called\n"));
^1da177e4c3f41 Linus Torvalds           2005-04-16   974  	dioprintk((KERN_INFO MYNAM ": receive_post_reply: IOCStatus: %04x\n",
^1da177e4c3f41 Linus Torvalds           2005-04-16   975  		 le16_to_cpu(pRecvRep->IOCStatus)));
^1da177e4c3f41 Linus Torvalds           2005-04-16   976  
^1da177e4c3f41 Linus Torvalds           2005-04-16   977  	if ((le16_to_cpu(pRecvRep->IOCStatus) & MPI_IOCSTATUS_MASK) ==
^1da177e4c3f41 Linus Torvalds           2005-04-16   978  						MPI_IOCSTATUS_LAN_CANCELED)
^1da177e4c3f41 Linus Torvalds           2005-04-16   979  		return mpt_lan_receive_post_free(dev, pRecvRep);
^1da177e4c3f41 Linus Torvalds           2005-04-16   980  
^1da177e4c3f41 Linus Torvalds           2005-04-16  @981  	len = le32_to_cpu(pRecvRep->PacketLength);
^1da177e4c3f41 Linus Torvalds           2005-04-16   982  	if (len == 0) {
^1da177e4c3f41 Linus Torvalds           2005-04-16   983  		printk (KERN_ERR MYNAM ": %s/%s: ERROR - Got a non-TURBO "
^1da177e4c3f41 Linus Torvalds           2005-04-16   984  			"ReceivePostReply w/ PacketLength zero!\n",
^1da177e4c3f41 Linus Torvalds           2005-04-16   985  				IOC_AND_NETDEV_NAMES_s_s(dev));
^1da177e4c3f41 Linus Torvalds           2005-04-16  @986  		printk (KERN_ERR MYNAM ": MsgFlags = %02x, IOCStatus = %04x\n",
^1da177e4c3f41 Linus Torvalds           2005-04-16   987  				pRecvRep->MsgFlags, le16_to_cpu(pRecvRep->IOCStatus));
^1da177e4c3f41 Linus Torvalds           2005-04-16   988  		return -1;
^1da177e4c3f41 Linus Torvalds           2005-04-16   989  	}
^1da177e4c3f41 Linus Torvalds           2005-04-16   990  
^1da177e4c3f41 Linus Torvalds           2005-04-16   991  	ctx    = le32_to_cpu(pRecvRep->BucketContext[0]);
^1da177e4c3f41 Linus Torvalds           2005-04-16   992  	count  = pRecvRep->NumberOfContexts;
^1da177e4c3f41 Linus Torvalds           2005-04-16   993  	skb    = priv->RcvCtl[ctx].skb;
^1da177e4c3f41 Linus Torvalds           2005-04-16   994  
^1da177e4c3f41 Linus Torvalds           2005-04-16   995  	offset = le32_to_cpu(pRecvRep->PacketOffset);
^1da177e4c3f41 Linus Torvalds           2005-04-16   996  //	if (offset != 0) {
^1da177e4c3f41 Linus Torvalds           2005-04-16   997  //		printk (KERN_INFO MYNAM ": %s/%s: Got a ReceivePostReply "
^1da177e4c3f41 Linus Torvalds           2005-04-16   998  //			"w/ PacketOffset %u\n",
^1da177e4c3f41 Linus Torvalds           2005-04-16   999  //				IOC_AND_NETDEV_NAMES_s_s(dev),
^1da177e4c3f41 Linus Torvalds           2005-04-16  1000  //				offset);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1001  //	}
^1da177e4c3f41 Linus Torvalds           2005-04-16  1002  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1003  	dioprintk((KERN_INFO MYNAM ": %s/%s: @rpr, offset = %d, len = %d\n",
^1da177e4c3f41 Linus Torvalds           2005-04-16  1004  			IOC_AND_NETDEV_NAMES_s_s(dev),
^1da177e4c3f41 Linus Torvalds           2005-04-16  1005  			offset, len));
^1da177e4c3f41 Linus Torvalds           2005-04-16  1006  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1007  	if (count > 1) {
^1da177e4c3f41 Linus Torvalds           2005-04-16  1008  		int szrem = len;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1009  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1010  //		dioprintk((KERN_INFO MYNAM ": %s/%s: Multiple buckets returned "
^1da177e4c3f41 Linus Torvalds           2005-04-16  1011  //			"for single packet, concatenating...\n",
^1da177e4c3f41 Linus Torvalds           2005-04-16  1012  //				IOC_AND_NETDEV_NAMES_s_s(dev)));
^1da177e4c3f41 Linus Torvalds           2005-04-16  1013  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1014  		skb = (struct sk_buff *)dev_alloc_skb(len);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1015  		if (!skb) {
^1da177e4c3f41 Linus Torvalds           2005-04-16  1016  			printk (KERN_ERR MYNAM ": %s/%s: ERROR - Can't allocate skb! (%s@%d)\n",
^1da177e4c3f41 Linus Torvalds           2005-04-16  1017  					IOC_AND_NETDEV_NAMES_s_s(dev),
^1da177e4c3f41 Linus Torvalds           2005-04-16  1018  					__FILE__, __LINE__);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1019  			return -ENOMEM;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1020  		}
^1da177e4c3f41 Linus Torvalds           2005-04-16  1021  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1022  		spin_lock_irqsave(&priv->rxfidx_lock, flags);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1023  		for (i = 0; i < count; i++) {
^1da177e4c3f41 Linus Torvalds           2005-04-16  1024  
^1da177e4c3f41 Linus Torvalds           2005-04-16 @1025  			ctx = le32_to_cpu(pRecvRep->BucketContext[i]);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1026  			old_skb = priv->RcvCtl[ctx].skb;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1027  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1028  			l = priv->RcvCtl[ctx].len;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1029  			if (szrem < l)
^1da177e4c3f41 Linus Torvalds           2005-04-16  1030  				l = szrem;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1031  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1032  //			dioprintk((KERN_INFO MYNAM ": %s/%s: Buckets = %d, len = %u\n",
^1da177e4c3f41 Linus Torvalds           2005-04-16  1033  //					IOC_AND_NETDEV_NAMES_s_s(dev),
^1da177e4c3f41 Linus Torvalds           2005-04-16  1034  //					i, l));
^1da177e4c3f41 Linus Torvalds           2005-04-16  1035  
b114dda6f2f10c Christophe JAILLET       2022-01-06  1036  			dma_sync_single_for_cpu(&mpt_dev->pcidev->dev,
^1da177e4c3f41 Linus Torvalds           2005-04-16  1037  						priv->RcvCtl[ctx].dma,
^1da177e4c3f41 Linus Torvalds           2005-04-16  1038  						priv->RcvCtl[ctx].len,
b114dda6f2f10c Christophe JAILLET       2022-01-06  1039  						DMA_FROM_DEVICE);
d626f62b11e00c Arnaldo Carvalho de Melo 2007-03-27  1040  			skb_copy_from_linear_data(old_skb, skb_put(skb, l), l);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1041  
b114dda6f2f10c Christophe JAILLET       2022-01-06  1042  			dma_sync_single_for_device(&mpt_dev->pcidev->dev,
^1da177e4c3f41 Linus Torvalds           2005-04-16  1043  						   priv->RcvCtl[ctx].dma,
^1da177e4c3f41 Linus Torvalds           2005-04-16  1044  						   priv->RcvCtl[ctx].len,
b114dda6f2f10c Christophe JAILLET       2022-01-06  1045  						   DMA_FROM_DEVICE);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1046  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1047  			priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = ctx;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1048  			szrem -= l;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1049  		}
^1da177e4c3f41 Linus Torvalds           2005-04-16  1050  		spin_unlock_irqrestore(&priv->rxfidx_lock, flags);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1051  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1052  	} else if (len < MPT_LAN_RX_COPYBREAK) {
^1da177e4c3f41 Linus Torvalds           2005-04-16  1053  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1054  		old_skb = skb;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1055  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1056  		skb = (struct sk_buff *)dev_alloc_skb(len);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1057  		if (!skb) {
^1da177e4c3f41 Linus Torvalds           2005-04-16  1058  			printk (KERN_ERR MYNAM ": %s/%s: ERROR - Can't allocate skb! (%s@%d)\n",
^1da177e4c3f41 Linus Torvalds           2005-04-16  1059  					IOC_AND_NETDEV_NAMES_s_s(dev),
^1da177e4c3f41 Linus Torvalds           2005-04-16  1060  					__FILE__, __LINE__);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1061  			return -ENOMEM;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1062  		}
^1da177e4c3f41 Linus Torvalds           2005-04-16  1063  
b114dda6f2f10c Christophe JAILLET       2022-01-06  1064  		dma_sync_single_for_cpu(&mpt_dev->pcidev->dev,
^1da177e4c3f41 Linus Torvalds           2005-04-16  1065  					priv->RcvCtl[ctx].dma,
^1da177e4c3f41 Linus Torvalds           2005-04-16  1066  					priv->RcvCtl[ctx].len,
b114dda6f2f10c Christophe JAILLET       2022-01-06  1067  					DMA_FROM_DEVICE);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1068  
d626f62b11e00c Arnaldo Carvalho de Melo 2007-03-27  1069  		skb_copy_from_linear_data(old_skb, skb_put(skb, len), len);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1070  
b114dda6f2f10c Christophe JAILLET       2022-01-06  1071  		dma_sync_single_for_device(&mpt_dev->pcidev->dev,
^1da177e4c3f41 Linus Torvalds           2005-04-16  1072  					   priv->RcvCtl[ctx].dma,
^1da177e4c3f41 Linus Torvalds           2005-04-16  1073  					   priv->RcvCtl[ctx].len,
b114dda6f2f10c Christophe JAILLET       2022-01-06  1074  					   DMA_FROM_DEVICE);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1075  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1076  		spin_lock_irqsave(&priv->rxfidx_lock, flags);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1077  		priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = ctx;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1078  		spin_unlock_irqrestore(&priv->rxfidx_lock, flags);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1079  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1080  	} else {
^1da177e4c3f41 Linus Torvalds           2005-04-16  1081  		spin_lock_irqsave(&priv->rxfidx_lock, flags);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1082  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1083  		priv->RcvCtl[ctx].skb = NULL;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1084  
b114dda6f2f10c Christophe JAILLET       2022-01-06  1085  		dma_unmap_single(&mpt_dev->pcidev->dev, priv->RcvCtl[ctx].dma,
b114dda6f2f10c Christophe JAILLET       2022-01-06  1086  				 priv->RcvCtl[ctx].len, DMA_FROM_DEVICE);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1087  		priv->RcvCtl[ctx].dma = 0;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1088  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1089  		priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = ctx;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1090  		spin_unlock_irqrestore(&priv->rxfidx_lock, flags);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1091  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1092  		skb_put(skb,len);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1093  	}
^1da177e4c3f41 Linus Torvalds           2005-04-16  1094  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1095  	atomic_sub(count, &priv->buckets_out);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1096  	priv->total_received += count;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1097  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1098  	if (priv->mpt_rxfidx_tail >= MPT_LAN_MAX_BUCKETS_OUT) {
^1da177e4c3f41 Linus Torvalds           2005-04-16  1099  		printk (KERN_ERR MYNAM ": %s/%s: Yoohoo! mpt_rxfidx_tail = %d, "
^1da177e4c3f41 Linus Torvalds           2005-04-16  1100  			"MPT_LAN_MAX_BUCKETS_OUT = %d\n",
^1da177e4c3f41 Linus Torvalds           2005-04-16  1101  				IOC_AND_NETDEV_NAMES_s_s(dev),
^1da177e4c3f41 Linus Torvalds           2005-04-16  1102  				priv->mpt_rxfidx_tail,
^1da177e4c3f41 Linus Torvalds           2005-04-16  1103  				MPT_LAN_MAX_BUCKETS_OUT);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1104  
4f8d98abaf9576 Moore, Eric              2006-02-02  1105  		return -1;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1106  	}
^1da177e4c3f41 Linus Torvalds           2005-04-16  1107  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1108  	if (remaining == 0)
^1da177e4c3f41 Linus Torvalds           2005-04-16  1109  		printk (KERN_WARNING MYNAM ": %s/%s: WARNING - IOC out of buckets! "
^1da177e4c3f41 Linus Torvalds           2005-04-16  1110  			"(priv->buckets_out = %d)\n",
^1da177e4c3f41 Linus Torvalds           2005-04-16  1111  			IOC_AND_NETDEV_NAMES_s_s(dev),
^1da177e4c3f41 Linus Torvalds           2005-04-16  1112  			atomic_read(&priv->buckets_out));
^1da177e4c3f41 Linus Torvalds           2005-04-16  1113  	else if (remaining < 10)
^1da177e4c3f41 Linus Torvalds           2005-04-16  1114  		printk (KERN_INFO MYNAM ": %s/%s: IOC says %d buckets left. "
^1da177e4c3f41 Linus Torvalds           2005-04-16  1115  			"(priv->buckets_out = %d)\n",
^1da177e4c3f41 Linus Torvalds           2005-04-16  1116  			IOC_AND_NETDEV_NAMES_s_s(dev),
^1da177e4c3f41 Linus Torvalds           2005-04-16  1117  			remaining, atomic_read(&priv->buckets_out));
^1da177e4c3f41 Linus Torvalds           2005-04-16  1118  	
^1da177e4c3f41 Linus Torvalds           2005-04-16  1119  	if ((remaining < priv->bucketthresh) &&
^1da177e4c3f41 Linus Torvalds           2005-04-16  1120  	    ((atomic_read(&priv->buckets_out) - remaining) >
^1da177e4c3f41 Linus Torvalds           2005-04-16  1121  	     MPT_LAN_BUCKETS_REMAIN_MISMATCH_THRESH)) {
^1da177e4c3f41 Linus Torvalds           2005-04-16  1122  		
^1da177e4c3f41 Linus Torvalds           2005-04-16  1123  		printk (KERN_WARNING MYNAM " Mismatch between driver's "
^1da177e4c3f41 Linus Torvalds           2005-04-16  1124  			"buckets_out count and fw's BucketsRemaining "
^1da177e4c3f41 Linus Torvalds           2005-04-16  1125  			"count has crossed the threshold, issuing a "
^1da177e4c3f41 Linus Torvalds           2005-04-16  1126  			"LanReset to clear the fw's hashtable. You may "
^1da177e4c3f41 Linus Torvalds           2005-04-16  1127  			"want to check your /var/log/messages for \"CRC "
^1da177e4c3f41 Linus Torvalds           2005-04-16  1128  			"error\" event notifications.\n");
^1da177e4c3f41 Linus Torvalds           2005-04-16  1129  		
^1da177e4c3f41 Linus Torvalds           2005-04-16  1130  		mpt_lan_reset(dev);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1131  		mpt_lan_wake_post_buckets_task(dev, 0);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1132  	}
^1da177e4c3f41 Linus Torvalds           2005-04-16  1133  	
^1da177e4c3f41 Linus Torvalds           2005-04-16  1134  	return mpt_lan_receive_skb(dev, skb);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1135  }
^1da177e4c3f41 Linus Torvalds           2005-04-16  1136  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1137  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
^1da177e4c3f41 Linus Torvalds           2005-04-16  1138  /* Simple SGE's only at the moment */
^1da177e4c3f41 Linus Torvalds           2005-04-16  1139  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1140  static void
c4028958b6ecad David Howells            2006-11-22  1141  mpt_lan_post_receive_buckets(struct mpt_lan_priv *priv)
^1da177e4c3f41 Linus Torvalds           2005-04-16  1142  {
c4028958b6ecad David Howells            2006-11-22  1143  	struct net_device *dev = priv->dev;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1144  	MPT_ADAPTER *mpt_dev = priv->mpt_dev;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1145  	MPT_FRAME_HDR *mf;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1146  	LANReceivePostRequest_t *pRecvReq;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1147  	SGETransaction32_t *pTrans;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1148  	SGESimple64_t *pSimple;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1149  	struct sk_buff *skb;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1150  	dma_addr_t dma;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1151  	u32 curr, buckets, count, max;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1152  	u32 len = (dev->mtu + dev->hard_header_len + 4);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1153  	unsigned long flags;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1154  	int i;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1155  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1156  	curr = atomic_read(&priv->buckets_out);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1157  	buckets = (priv->max_buckets_out - curr);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1158  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1159  	dioprintk((KERN_INFO MYNAM ": %s/%s: @%s, Start_buckets = %u, buckets_out = %u\n",
^1da177e4c3f41 Linus Torvalds           2005-04-16  1160  			IOC_AND_NETDEV_NAMES_s_s(dev),
cadbd4a5e36dde Harvey Harrison          2008-07-03  1161  			__func__, buckets, curr));
^1da177e4c3f41 Linus Torvalds           2005-04-16  1162  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1163  	max = (mpt_dev->req_sz - MPT_LAN_RECEIVE_POST_REQUEST_SIZE) /
4e2e619f3c9e3c Gustavo A. R. Silva      2021-03-24  1164  			(sizeof(SGETransaction32_t) + sizeof(SGESimple64_t));
^1da177e4c3f41 Linus Torvalds           2005-04-16  1165  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1166  	while (buckets) {
^1da177e4c3f41 Linus Torvalds           2005-04-16  1167  		mf = mpt_get_msg_frame(LanCtx, mpt_dev);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1168  		if (mf == NULL) {
^1da177e4c3f41 Linus Torvalds           2005-04-16  1169  			printk (KERN_ERR "%s: Unable to alloc request frame\n",
cadbd4a5e36dde Harvey Harrison          2008-07-03  1170  				__func__);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1171  			dioprintk((KERN_ERR "%s: %u buckets remaining\n",
cadbd4a5e36dde Harvey Harrison          2008-07-03  1172  				 __func__, buckets));
^1da177e4c3f41 Linus Torvalds           2005-04-16  1173  			goto out;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1174  		}
^1da177e4c3f41 Linus Torvalds           2005-04-16  1175  		pRecvReq = (LANReceivePostRequest_t *) mf;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1176  
e1fc2b5167f9c3 Eric Moore               2007-09-29 @1177  		i = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
e1fc2b5167f9c3 Eric Moore               2007-09-29  1178  		mpt_dev->RequestNB[i] = 0;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1179  		count = buckets;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1180  		if (count > max)
^1da177e4c3f41 Linus Torvalds           2005-04-16  1181  			count = max;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1182  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1183  		pRecvReq->Function    = MPI_FUNCTION_LAN_RECEIVE;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1184  		pRecvReq->ChainOffset = 0;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1185  		pRecvReq->MsgFlags    = 0;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1186  		pRecvReq->PortNumber  = priv->pnum;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1187  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1188  		pTrans = (SGETransaction32_t *) pRecvReq->SG_List;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1189  		pSimple = NULL;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1190  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1191  		for (i = 0; i < count; i++) {
^1da177e4c3f41 Linus Torvalds           2005-04-16  1192  			int ctx;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1193  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1194  			spin_lock_irqsave(&priv->rxfidx_lock, flags);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1195  			if (priv->mpt_rxfidx_tail < 0) {
^1da177e4c3f41 Linus Torvalds           2005-04-16  1196  				printk (KERN_ERR "%s: Can't alloc context\n",
cadbd4a5e36dde Harvey Harrison          2008-07-03  1197  					__func__);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1198  				spin_unlock_irqrestore(&priv->rxfidx_lock,
^1da177e4c3f41 Linus Torvalds           2005-04-16  1199  						       flags);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1200  				break;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1201  			}
^1da177e4c3f41 Linus Torvalds           2005-04-16  1202  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1203  			ctx = priv->mpt_rxfidx[priv->mpt_rxfidx_tail--];
^1da177e4c3f41 Linus Torvalds           2005-04-16  1204  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1205  			skb = priv->RcvCtl[ctx].skb;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1206  			if (skb && (priv->RcvCtl[ctx].len != len)) {
b114dda6f2f10c Christophe JAILLET       2022-01-06  1207  				dma_unmap_single(&mpt_dev->pcidev->dev,
^1da177e4c3f41 Linus Torvalds           2005-04-16  1208  						 priv->RcvCtl[ctx].dma,
^1da177e4c3f41 Linus Torvalds           2005-04-16  1209  						 priv->RcvCtl[ctx].len,
b114dda6f2f10c Christophe JAILLET       2022-01-06  1210  						 DMA_FROM_DEVICE);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1211  				dev_kfree_skb(priv->RcvCtl[ctx].skb);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1212  				skb = priv->RcvCtl[ctx].skb = NULL;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1213  			}
^1da177e4c3f41 Linus Torvalds           2005-04-16  1214  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1215  			if (skb == NULL) {
^1da177e4c3f41 Linus Torvalds           2005-04-16  1216  				skb = dev_alloc_skb(len);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1217  				if (skb == NULL) {
^1da177e4c3f41 Linus Torvalds           2005-04-16  1218  					printk (KERN_WARNING
^1da177e4c3f41 Linus Torvalds           2005-04-16  1219  						MYNAM "/%s: Can't alloc skb\n",
cadbd4a5e36dde Harvey Harrison          2008-07-03  1220  						__func__);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1221  					priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = ctx;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1222  					spin_unlock_irqrestore(&priv->rxfidx_lock, flags);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1223  					break;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1224  				}
^1da177e4c3f41 Linus Torvalds           2005-04-16  1225  
b114dda6f2f10c Christophe JAILLET       2022-01-06  1226  				dma = dma_map_single(&mpt_dev->pcidev->dev,
b114dda6f2f10c Christophe JAILLET       2022-01-06  1227  						     skb->data, len,
b114dda6f2f10c Christophe JAILLET       2022-01-06  1228  						     DMA_FROM_DEVICE);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1229  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1230  				priv->RcvCtl[ctx].skb = skb;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1231  				priv->RcvCtl[ctx].dma = dma;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1232  				priv->RcvCtl[ctx].len = len;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1233  			}
^1da177e4c3f41 Linus Torvalds           2005-04-16  1234  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1235  			spin_unlock_irqrestore(&priv->rxfidx_lock, flags);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1236  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1237  			pTrans->ContextSize   = sizeof(u32);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1238  			pTrans->DetailsLength = 0;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1239  			pTrans->Flags         = 0;
4e2e619f3c9e3c Gustavo A. R. Silva      2021-03-24 @1240  			pTrans->TransactionContext = cpu_to_le32(ctx);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1241  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1242  			pSimple = (SGESimple64_t *) pTrans->TransactionDetails;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1243  
^1da177e4c3f41 Linus Torvalds           2005-04-16 @1244  			pSimple->FlagsLength = cpu_to_le32(
^1da177e4c3f41 Linus Torvalds           2005-04-16  1245  				((MPI_SGE_FLAGS_END_OF_BUFFER |
^1da177e4c3f41 Linus Torvalds           2005-04-16  1246  				  MPI_SGE_FLAGS_SIMPLE_ELEMENT |
^1da177e4c3f41 Linus Torvalds           2005-04-16  1247  				  MPI_SGE_FLAGS_64_BIT_ADDRESSING) << MPI_SGE_FLAGS_SHIFT) | len);
^1da177e4c3f41 Linus Torvalds           2005-04-16 @1248  			pSimple->Address.Low = cpu_to_le32((u32) priv->RcvCtl[ctx].dma);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1249  			if (sizeof(dma_addr_t) > sizeof(u32))
^1da177e4c3f41 Linus Torvalds           2005-04-16 @1250  				pSimple->Address.High = cpu_to_le32((u32) ((u64) priv->RcvCtl[ctx].dma >> 32));
^1da177e4c3f41 Linus Torvalds           2005-04-16  1251  			else
^1da177e4c3f41 Linus Torvalds           2005-04-16  1252  				pSimple->Address.High = 0;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1253  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1254  			pTrans = (SGETransaction32_t *) (pSimple + 1);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1255  		}
^1da177e4c3f41 Linus Torvalds           2005-04-16  1256  
^1da177e4c3f41 Linus Torvalds           2005-04-16  1257  		if (pSimple == NULL) {
^1da177e4c3f41 Linus Torvalds           2005-04-16  1258  /**/			printk (KERN_WARNING MYNAM "/%s: No buckets posted\n",
cadbd4a5e36dde Harvey Harrison          2008-07-03  1259  /**/				__func__);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1260  			mpt_free_msg_frame(mpt_dev, mf);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1261  			goto out;
^1da177e4c3f41 Linus Torvalds           2005-04-16  1262  		}
^1da177e4c3f41 Linus Torvalds           2005-04-16  1263  
^1da177e4c3f41 Linus Torvalds           2005-04-16 @1264  		pSimple->FlagsLength |= cpu_to_le32(MPI_SGE_FLAGS_END_OF_LIST << MPI_SGE_FLAGS_SHIFT);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1265  
^1da177e4c3f41 Linus Torvalds           2005-04-16 @1266  		pRecvReq->BucketCount = cpu_to_le32(i);
^1da177e4c3f41 Linus Torvalds           2005-04-16  1267  

:::::: The code at line 1177 was first introduced by commit
:::::: e1fc2b5167f9c3614099e55d3f49763a26a5a339 [SCSI] mptlan: bug fix, only half the message frame is dma'd resulting in corruption

:::::: TO: Eric Moore <eric.moore@....com>
:::::: CC: James Bottomley <jejb@...grave.localdomain>

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

View attachment "config" of type "text/plain" (180699 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ