Content-Type: multipart/mixed; boundary="===============1419584830199915655==" MIME-Version: 1.0 From: kbuild test robot To: kbuild-all@lists.01.org Subject: Re: [PATCH] cifs: smbd: Update receive credits before sending and deal with credits roll back on failure before sending Date: Thu, 02 Apr 2020 09:06:55 +0800 Message-ID: <20200402010655.GA8179@shao2-debian> In-Reply-To: <1585639101-117035-1-git-send-email-longli@linuxonhyperv.com> List-Id: --===============1419584830199915655== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hi, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on cifs/for-next] [also build test WARNING on v5.6 next-20200331] [if your patch is applied to the wrong git tree, please drop us a note to h= elp improve the system. BTW, we also suggest to use '--base' option to specify = the base tree in git format-patch, please see https://stackoverflow.com/a/37406= 982] url: https://github.com/0day-ci/linux/commits/longli-linuxonhyperv-com/c= ifs-smbd-Update-receive-credits-before-sending-and-deal-with-credits-roll-b= ack-on-failure-before-sending/20200331-152104 base: git://git.samba.org/sfrench/cifs-2.6.git for-next reproduce: # apt-get install sparse # sparse version: v0.6.1-187-gbff9b106-dirty make ARCH=3Dx86_64 allmodconfig make C=3D1 CF=3D'-fdiagnostic-prefix -D__CHECK_ENDIAN__' :::::: branch date: 10 hours ago :::::: commit date: 10 hours ago If you fix the issue, kindly add following tag Reported-by: kbuild test robot >> fs/cifs/smbdirect.c:856:26: sparse: sparse: incorrect type in argument 1= (different base types) @@ expected int i @@ got restricted __le16 [u= sertyint i @@ >> fs/cifs/smbdirect.c:856:26: sparse: expected int i >> fs/cifs/smbdirect.c:856:26: sparse: got restricted __le16 [usertype] = credits_granted >> fs/cifs/smbdirect.c:905:35: sparse: sparse: invalid assignment: +=3D >> fs/cifs/smbdirect.c:905:35: sparse: left side has type int >> fs/cifs/smbdirect.c:905:35: sparse: right side has type restricted __= le16 fs/cifs/smbdirect.c:907:26: sparse: sparse: incorrect type in argument 1= (different base types) @@ expected int i @@ got restricted __le16 [u= sertyint i @@ fs/cifs/smbdirect.c:907:26: sparse: expected int i fs/cifs/smbdirect.c:907:26: sparse: got restricted __le16 [usertype] = credits_granted # https://github.com/0day-ci/linux/commit/e5b2c129dd7cb9db51cd025f988ff5bc2= b0990a9 git remote add linux-review https://github.com/0day-ci/linux git remote update linux-review git checkout e5b2c129dd7cb9db51cd025f988ff5bc2b0990a9 vim +856 fs/cifs/smbdirect.c f198186aa9bbd6 Long Li 2017-11-04 806 = f198186aa9bbd6 Long Li 2017-11-04 807 /* f198186aa9bbd6 Long Li 2017-11-04 808 * Build and prepare the SMBD packe= t header f198186aa9bbd6 Long Li 2017-11-04 809 * This function waits for avaialbe= send credits and build a SMBD packet f198186aa9bbd6 Long Li 2017-11-04 810 * header. The caller then optional= append payload to the packet after f198186aa9bbd6 Long Li 2017-11-04 811 * the header f198186aa9bbd6 Long Li 2017-11-04 812 * intput values f198186aa9bbd6 Long Li 2017-11-04 813 * size: the size of the payload f198186aa9bbd6 Long Li 2017-11-04 814 * remaining_data_length: remaining= data to send if this is part of a f198186aa9bbd6 Long Li 2017-11-04 815 * fragmented packet f198186aa9bbd6 Long Li 2017-11-04 816 * output values f198186aa9bbd6 Long Li 2017-11-04 817 * request_out: the request allocat= ed from this function f198186aa9bbd6 Long Li 2017-11-04 818 * return values: 0 on success, oth= erwise actual error code returned f198186aa9bbd6 Long Li 2017-11-04 819 */ f198186aa9bbd6 Long Li 2017-11-04 820 static int smbd_create_header(struc= t smbd_connection *info, f198186aa9bbd6 Long Li 2017-11-04 821 int size, int remaining_data_leng= th, f198186aa9bbd6 Long Li 2017-11-04 822 struct smbd_request **request_out) f198186aa9bbd6 Long Li 2017-11-04 823 { f198186aa9bbd6 Long Li 2017-11-04 824 struct smbd_request *request; f198186aa9bbd6 Long Li 2017-11-04 825 struct smbd_data_transfer *packet; f198186aa9bbd6 Long Li 2017-11-04 826 int header_length; f198186aa9bbd6 Long Li 2017-11-04 827 int rc; f198186aa9bbd6 Long Li 2017-11-04 828 = f198186aa9bbd6 Long Li 2017-11-04 829 /* Wait for send credits. A SMBD p= acket needs one credit */ f198186aa9bbd6 Long Li 2017-11-04 830 rc =3D wait_event_interruptible(in= fo->wait_send_queue, f198186aa9bbd6 Long Li 2017-11-04 831 atomic_read(&info->send_credits) = > 0 || f198186aa9bbd6 Long Li 2017-11-04 832 info->transport_status !=3D SMBD_= CONNECTED); f198186aa9bbd6 Long Li 2017-11-04 833 if (rc) f198186aa9bbd6 Long Li 2017-11-04 834 return rc; f198186aa9bbd6 Long Li 2017-11-04 835 = f198186aa9bbd6 Long Li 2017-11-04 836 if (info->transport_status !=3D SM= BD_CONNECTED) { f198186aa9bbd6 Long Li 2017-11-04 837 log_outgoing(ERR, "disconnected n= ot sending\n"); 62fdf6707ebd46 Long Li 2019-04-05 838 return -EAGAIN; f198186aa9bbd6 Long Li 2017-11-04 839 } f198186aa9bbd6 Long Li 2017-11-04 840 atomic_dec(&info->send_credits); f198186aa9bbd6 Long Li 2017-11-04 841 = f198186aa9bbd6 Long Li 2017-11-04 842 request =3D mempool_alloc(info->re= quest_mempool, GFP_KERNEL); f198186aa9bbd6 Long Li 2017-11-04 843 if (!request) { f198186aa9bbd6 Long Li 2017-11-04 844 rc =3D -ENOMEM; e5b2c129dd7cb9 Long Li 2020-03-31 845 goto err_alloc; f198186aa9bbd6 Long Li 2017-11-04 846 } f198186aa9bbd6 Long Li 2017-11-04 847 = f198186aa9bbd6 Long Li 2017-11-04 848 request->info =3D info; f198186aa9bbd6 Long Li 2017-11-04 849 = f198186aa9bbd6 Long Li 2017-11-04 850 /* Fill in the packet header */ f198186aa9bbd6 Long Li 2017-11-04 851 packet =3D smbd_request_payload(re= quest); f198186aa9bbd6 Long Li 2017-11-04 852 packet->credits_requested =3D cpu_= to_le16(info->send_credit_target); f198186aa9bbd6 Long Li 2017-11-04 853 packet->credits_granted =3D f198186aa9bbd6 Long Li 2017-11-04 854 cpu_to_le16(manage_credits_prior_= sending(info)); f198186aa9bbd6 Long Li 2017-11-04 855 info->send_immediate =3D false; e5b2c129dd7cb9 Long Li 2020-03-31 @856 atomic_add(packet->credits_granted= , &info->receive_credits); f198186aa9bbd6 Long Li 2017-11-04 857 = f198186aa9bbd6 Long Li 2017-11-04 858 packet->flags =3D 0; f198186aa9bbd6 Long Li 2017-11-04 859 if (manage_keep_alive_before_sendi= ng(info)) f198186aa9bbd6 Long Li 2017-11-04 860 packet->flags |=3D cpu_to_le16(SM= B_DIRECT_RESPONSE_REQUESTED); f198186aa9bbd6 Long Li 2017-11-04 861 = f198186aa9bbd6 Long Li 2017-11-04 862 packet->reserved =3D 0; f198186aa9bbd6 Long Li 2017-11-04 863 if (!size) f198186aa9bbd6 Long Li 2017-11-04 864 packet->data_offset =3D 0; f198186aa9bbd6 Long Li 2017-11-04 865 else f198186aa9bbd6 Long Li 2017-11-04 866 packet->data_offset =3D cpu_to_le= 32(24); f198186aa9bbd6 Long Li 2017-11-04 867 packet->data_length =3D cpu_to_le3= 2(size); f198186aa9bbd6 Long Li 2017-11-04 868 packet->remaining_data_length =3D = cpu_to_le32(remaining_data_length); f198186aa9bbd6 Long Li 2017-11-04 869 packet->padding =3D 0; f198186aa9bbd6 Long Li 2017-11-04 870 = f198186aa9bbd6 Long Li 2017-11-04 871 log_outgoing(INFO, "credits_reques= ted=3D%d credits_granted=3D%d " f198186aa9bbd6 Long Li 2017-11-04 872 "data_offset=3D%d data_length=3D%= d remaining_data_length=3D%d\n", f198186aa9bbd6 Long Li 2017-11-04 873 le16_to_cpu(packet->credits_reque= sted), f198186aa9bbd6 Long Li 2017-11-04 874 le16_to_cpu(packet->credits_grant= ed), f198186aa9bbd6 Long Li 2017-11-04 875 le32_to_cpu(packet->data_offset), f198186aa9bbd6 Long Li 2017-11-04 876 le32_to_cpu(packet->data_length), f198186aa9bbd6 Long Li 2017-11-04 877 le32_to_cpu(packet->remaining_dat= a_length)); f198186aa9bbd6 Long Li 2017-11-04 878 = f198186aa9bbd6 Long Li 2017-11-04 879 /* Map the packet to DMA */ f198186aa9bbd6 Long Li 2017-11-04 880 header_length =3D sizeof(struct sm= bd_data_transfer); f198186aa9bbd6 Long Li 2017-11-04 881 /* If this is a packet without pay= load, don't send padding */ f198186aa9bbd6 Long Li 2017-11-04 882 if (!size) f198186aa9bbd6 Long Li 2017-11-04 883 header_length =3D offsetof(struct= smbd_data_transfer, padding); f198186aa9bbd6 Long Li 2017-11-04 884 = f198186aa9bbd6 Long Li 2017-11-04 885 request->num_sge =3D 1; f198186aa9bbd6 Long Li 2017-11-04 886 request->sge[0].addr =3D ib_dma_ma= p_single(info->id->device, f198186aa9bbd6 Long Li 2017-11-04 887 (void *)packet, f198186aa9bbd6 Long Li 2017-11-04 888 header_length, 7f46d23e1b14f0 Long Li 2019-05-13 889 DMA_TO_DEVICE); f198186aa9bbd6 Long Li 2017-11-04 890 if (ib_dma_mapping_error(info->id-= >device, request->sge[0].addr)) { f198186aa9bbd6 Long Li 2017-11-04 891 mempool_free(request, info->reque= st_mempool); f198186aa9bbd6 Long Li 2017-11-04 892 rc =3D -EIO; e5b2c129dd7cb9 Long Li 2020-03-31 893 goto err_dma; f198186aa9bbd6 Long Li 2017-11-04 894 } f198186aa9bbd6 Long Li 2017-11-04 895 = f198186aa9bbd6 Long Li 2017-11-04 896 request->sge[0].length =3D header_= length; f198186aa9bbd6 Long Li 2017-11-04 897 request->sge[0].lkey =3D info->pd-= >local_dma_lkey; f198186aa9bbd6 Long Li 2017-11-04 898 = f198186aa9bbd6 Long Li 2017-11-04 899 *request_out =3D request; f198186aa9bbd6 Long Li 2017-11-04 900 return 0; f198186aa9bbd6 Long Li 2017-11-04 901 = e5b2c129dd7cb9 Long Li 2020-03-31 902 err_dma: e5b2c129dd7cb9 Long Li 2020-03-31 903 /* roll back receive credits */ e5b2c129dd7cb9 Long Li 2020-03-31 904 spin_lock(&info->lock_new_credits_= offered); e5b2c129dd7cb9 Long Li 2020-03-31 @905 info->new_credits_offered +=3D pac= ket->credits_granted; e5b2c129dd7cb9 Long Li 2020-03-31 906 spin_unlock(&info->lock_new_credit= s_offered); e5b2c129dd7cb9 Long Li 2020-03-31 907 atomic_sub(packet->credits_granted= , &info->receive_credits); e5b2c129dd7cb9 Long Li 2020-03-31 908 = e5b2c129dd7cb9 Long Li 2020-03-31 909 err_alloc: e5b2c129dd7cb9 Long Li 2020-03-31 910 /* roll back send credits */ f198186aa9bbd6 Long Li 2017-11-04 911 atomic_inc(&info->send_credits); e5b2c129dd7cb9 Long Li 2020-03-31 912 = f198186aa9bbd6 Long Li 2017-11-04 913 return rc; f198186aa9bbd6 Long Li 2017-11-04 914 } f198186aa9bbd6 Long Li 2017-11-04 915 = --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org --===============1419584830199915655==--