Content-Type: multipart/mixed; boundary="===============1236374563991623588==" MIME-Version: 1.0 From: kbuild test robot To: kbuild-all@lists.01.org Subject: Re: [RFC PATCH] usb: gadget: f_tcm: Added DMA32 flag while allocation of command buffer Date: Fri, 15 Nov 2019 11:43:46 +0800 Message-ID: <201911151130.6UL0YfvP%lkp@intel.com> In-Reply-To: <1573640672-10344-1-git-send-email-jpawar@cadence.com> List-Id: --===============1236374563991623588== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hi Jayshri, [FYI, it's a private test report for your RFC patch.] [auto build test WARNING on balbi-usb/next] [also build test WARNING on v5.4-rc7 next-20191114] [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/Jayshri-Pawar/usb-gadget-f= _tcm-Added-DMA32-flag-while-allocation-of-command-buffer/20191114-022602 base: https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git next reproduce: # apt-get install sparse # sparse version: v0.6.1-31-gfd3528a-dirty make ARCH=3Dx86_64 allmodconfig make C=3D1 CF=3D'-fdiagnostic-prefix -D__CHECK_ENDIAN__' If you fix the issue, kindly add following tag Reported-by: kbuild test robot sparse warnings: (new ones prefixed by >>) drivers/usb/gadget/function/f_tcm.c:81:18: sparse: sparse: incorrect typ= e in assignment (different base types) @@ expected unsigned int [usertyp= e] Tag @@ got restrunsigned int [usertype] Tag @@ drivers/usb/gadget/function/f_tcm.c:81:18: sparse: expected unsigned = int [usertype] Tag drivers/usb/gadget/function/f_tcm.c:81:18: sparse: got restricted __l= e32 [usertype] bot_tag drivers/usb/gadget/function/f_tcm.c:163:26: sparse: sparse: incorrect ty= pe in assignment (different base types) @@ expected unsigned int [userty= pe] Tag @@ got restrunsigned int [usertype] Tag @@ drivers/usb/gadget/function/f_tcm.c:163:26: sparse: expected unsigned= int [usertype] Tag drivers/usb/gadget/function/f_tcm.c:163:26: sparse: got restricted __= le32 [usertype] bot_tag >> drivers/usb/gadget/function/f_tcm.c:216:62: sparse: sparse: restricted g= fp_t degrades to integer >> drivers/usb/gadget/function/f_tcm.c:216:73: sparse: sparse: incorrect ty= pe in argument 2 (different base types) @@ expected restricted gfp_t [us= ertype] flags @@ got [usertype] flags @@ >> drivers/usb/gadget/function/f_tcm.c:216:73: sparse: expected restrict= ed gfp_t [usertype] flags >> drivers/usb/gadget/function/f_tcm.c:216:73: sparse: got unsigned int drivers/usb/gadget/function/f_tcm.c:990:62: sparse: sparse: restricted g= fp_t degrades to integer drivers/usb/gadget/function/f_tcm.c:990:73: sparse: sparse: incorrect ty= pe in argument 2 (different base types) @@ expected restricted gfp_t [us= ertype] flags @@ got [usertype] flags @@ drivers/usb/gadget/function/f_tcm.c:990:73: sparse: expected restrict= ed gfp_t [usertype] flags drivers/usb/gadget/function/f_tcm.c:990:73: sparse: got unsigned int drivers/usb/gadget/function/f_tcm.c:261:62: sparse: sparse: restricted g= fp_t degrades to integer drivers/usb/gadget/function/f_tcm.c:261:73: sparse: sparse: incorrect ty= pe in argument 2 (different base types) @@ expected restricted gfp_t [us= ertype] flags @@ got [usertype] flags @@ drivers/usb/gadget/function/f_tcm.c:261:73: sparse: expected restrict= ed gfp_t [usertype] flags drivers/usb/gadget/function/f_tcm.c:261:73: sparse: got unsigned int drivers/usb/gadget/function/f_tcm.c:1242:22: sparse: sparse: incorrect t= ype in assignment (different base types) @@ expected restricted __le32 [= usertype] bot_tag @@ got icted __le32 [usertype] bot_tag @@ drivers/usb/gadget/function/f_tcm.c:1242:22: sparse: expected restric= ted __le32 [usertype] bot_tag drivers/usb/gadget/function/f_tcm.c:1242:22: sparse: got unsigned int= [usertype] Tag drivers/usb/gadget/function/f_tcm.c:333:54: sparse: sparse: restricted g= fp_t degrades to integer drivers/usb/gadget/function/f_tcm.c:333:65: sparse: sparse: incorrect ty= pe in argument 2 (different base types) @@ expected restricted gfp_t [us= ertype] flags @@ got [usertype] flags @@ drivers/usb/gadget/function/f_tcm.c:333:65: sparse: expected restrict= ed gfp_t [usertype] flags drivers/usb/gadget/function/f_tcm.c:333:65: sparse: got unsigned int drivers/usb/gadget/function/f_tcm.c:522:62: sparse: sparse: restricted g= fp_t degrades to integer drivers/usb/gadget/function/f_tcm.c:522:73: sparse: sparse: incorrect ty= pe in argument 2 (different base types) @@ expected restricted gfp_t [us= ertype] flags @@ got [usertype] flags @@ drivers/usb/gadget/function/f_tcm.c:522:73: sparse: expected restrict= ed gfp_t [usertype] flags drivers/usb/gadget/function/f_tcm.c:522:73: sparse: got unsigned int drivers/usb/gadget/function/f_tcm.c:776:54: sparse: sparse: restricted g= fp_t degrades to integer drivers/usb/gadget/function/f_tcm.c:776:65: sparse: sparse: incorrect ty= pe in argument 2 (different base types) @@ expected restricted gfp_t [us= ertype] flags @@ got [usertype] flags @@ drivers/usb/gadget/function/f_tcm.c:776:65: sparse: expected restrict= ed gfp_t [usertype] flags drivers/usb/gadget/function/f_tcm.c:776:65: sparse: got unsigned int drivers/usb/gadget/function/f_tcm.c:1982:9: sparse: sparse: advancing pa= st deep designator vim +216 drivers/usb/gadget/function/f_tcm.c 73 = 74 static void bot_enqueue_sense_code(struct f_uas *fu, struct usbg_cmd= *cmd) 75 { 76 struct bulk_cs_wrap *csw =3D &fu->bot_status.csw; 77 int ret; 78 unsigned int csw_stat; 79 = 80 csw_stat =3D cmd->csw_code; > 81 csw->Tag =3D cmd->bot_tag; 82 csw->Status =3D csw_stat; 83 fu->bot_status.req->context =3D cmd; 84 ret =3D usb_ep_queue(fu->ep_in, fu->bot_status.req, GFP_ATOMIC); 85 if (ret) 86 pr_err("%s(%d) ERR: %d\n", __func__, __LINE__, ret); 87 } 88 = 89 static void bot_err_compl(struct usb_ep *ep, struct usb_request *req) 90 { 91 struct usbg_cmd *cmd =3D req->context; 92 struct f_uas *fu =3D cmd->fu; 93 = 94 if (req->status < 0) 95 pr_err("ERR %s(%d)\n", __func__, __LINE__); 96 = 97 if (cmd->data_len) { 98 if (cmd->data_len > ep->maxpacket) { 99 req->length =3D ep->maxpacket; 100 cmd->data_len -=3D ep->maxpacket; 101 } else { 102 req->length =3D cmd->data_len; 103 cmd->data_len =3D 0; 104 } 105 = 106 usb_ep_queue(ep, req, GFP_ATOMIC); 107 return; 108 } 109 bot_enqueue_sense_code(fu, cmd); 110 } 111 = 112 static void bot_send_bad_status(struct usbg_cmd *cmd) 113 { 114 struct f_uas *fu =3D cmd->fu; 115 struct bulk_cs_wrap *csw =3D &fu->bot_status.csw; 116 struct usb_request *req; 117 struct usb_ep *ep; 118 = 119 csw->Residue =3D cpu_to_le32(cmd->data_len); 120 = 121 if (cmd->data_len) { 122 if (cmd->is_read) { 123 ep =3D fu->ep_in; 124 req =3D fu->bot_req_in; 125 } else { 126 ep =3D fu->ep_out; 127 req =3D fu->bot_req_out; 128 } 129 = 130 if (cmd->data_len > fu->ep_in->maxpacket) { 131 req->length =3D ep->maxpacket; 132 cmd->data_len -=3D ep->maxpacket; 133 } else { 134 req->length =3D cmd->data_len; 135 cmd->data_len =3D 0; 136 } 137 req->complete =3D bot_err_compl; 138 req->context =3D cmd; 139 req->buf =3D fu->cmd.buf; 140 usb_ep_queue(ep, req, GFP_KERNEL); 141 } else { 142 bot_enqueue_sense_code(fu, cmd); 143 } 144 } 145 = 146 static int bot_send_status(struct usbg_cmd *cmd, bool moved_data) 147 { 148 struct f_uas *fu =3D cmd->fu; 149 struct bulk_cs_wrap *csw =3D &fu->bot_status.csw; 150 int ret; 151 = 152 if (cmd->se_cmd.scsi_status =3D=3D SAM_STAT_GOOD) { 153 if (!moved_data && cmd->data_len) { 154 /* 155 * the host wants to move data, we don't. Fill / empty 156 * the pipe and then send the csw with reside set. 157 */ 158 cmd->csw_code =3D US_BULK_STAT_OK; 159 bot_send_bad_status(cmd); 160 return 0; 161 } 162 = 163 csw->Tag =3D cmd->bot_tag; 164 csw->Residue =3D cpu_to_le32(0); 165 csw->Status =3D US_BULK_STAT_OK; 166 fu->bot_status.req->context =3D cmd; 167 = 168 ret =3D usb_ep_queue(fu->ep_in, fu->bot_status.req, GFP_KERNEL); 169 if (ret) 170 pr_err("%s(%d) ERR: %d\n", __func__, __LINE__, ret); 171 } else { 172 cmd->csw_code =3D US_BULK_STAT_FAIL; 173 bot_send_bad_status(cmd); 174 } 175 return 0; 176 } 177 = 178 /* 179 * Called after command (no data transfer) or after the write (to de= vice) 180 * operation is completed 181 */ 182 static int bot_send_status_response(struct usbg_cmd *cmd) 183 { 184 bool moved_data =3D false; 185 = 186 if (!cmd->is_read) 187 moved_data =3D true; 188 return bot_send_status(cmd, moved_data); 189 } 190 = 191 /* Read request completed, now we have to send the CSW */ 192 static void bot_read_compl(struct usb_ep *ep, struct usb_request *re= q) 193 { 194 struct usbg_cmd *cmd =3D req->context; 195 = 196 if (req->status < 0) 197 pr_err("ERR %s(%d)\n", __func__, __LINE__); 198 = 199 bot_send_status(cmd, true); 200 } 201 = 202 static int bot_send_read_response(struct usbg_cmd *cmd) 203 { 204 struct f_uas *fu =3D cmd->fu; 205 struct se_cmd *se_cmd =3D &cmd->se_cmd; 206 struct usb_gadget *gadget =3D fuas_to_gadget(fu); 207 int ret; 208 = 209 if (!cmd->data_len) { 210 cmd->csw_code =3D US_BULK_STAT_PHASE; 211 bot_send_bad_status(cmd); 212 return 0; 213 } 214 = 215 if (!gadget->sg_supported) { > 216 cmd->data_buf =3D kmalloc(se_cmd->data_length, GFP_ATOMIC | 217 gadget->dma_flag); 218 if (!cmd->data_buf) 219 return -ENOMEM; 220 = 221 sg_copy_to_buffer(se_cmd->t_data_sg, 222 se_cmd->t_data_nents, 223 cmd->data_buf, 224 se_cmd->data_length); 225 = 226 fu->bot_req_in->buf =3D cmd->data_buf; 227 } else { 228 fu->bot_req_in->buf =3D NULL; 229 fu->bot_req_in->num_sgs =3D se_cmd->t_data_nents; 230 fu->bot_req_in->sg =3D se_cmd->t_data_sg; 231 } 232 = 233 fu->bot_req_in->complete =3D bot_read_compl; 234 fu->bot_req_in->length =3D se_cmd->data_length; 235 fu->bot_req_in->context =3D cmd; 236 ret =3D usb_ep_queue(fu->ep_in, fu->bot_req_in, GFP_ATOMIC); 237 if (ret) 238 pr_err("%s(%d)\n", __func__, __LINE__); 239 return 0; 240 } 241 = --- 0-DAY kernel test infrastructure Open Source Technology Cen= ter https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corpor= ation --===============1236374563991623588==--