Message ID | 118900ffaf094a279f7799ac9d2c73265c889121.1657149962.git.Thinh.Nguyen@synopsys.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | usb: gadget: f_tcm: Enhance UASP driver | expand |
On 07.07.22 01:34, Thinh Nguyen wrote: > Microsoft Windows checks for MI_REPORT_SUPPORTED_OPERATION_CODES. Let's > handle this MAINTENANCE_IN command and report supported commands. > +sense_reason_t > +target_emulate_report_supported_opcodes(struct se_cmd *cmd) > +{ > + unsigned char *cdb = cmd->t_task_cdb; > + unsigned char *buf; > + u8 supported = 0; > + [..] > + case ATA_12: > + case ATA_16: > + case VERIFY: > + case ZBC_IN: > + case ZBC_OUT: > + default: > + break; Why the NOP here? If you want to document something, a comment would be nice. Regards Oliver
Hi Thinh, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on 90557fa89d3e99286506593fd5180f699c41b152] url: https://github.com/intel-lab-lkp/linux/commits/Thinh-Nguyen/usb-gadget-f_tcm-Enhance-UASP-driver/20220707-074014 base: 90557fa89d3e99286506593fd5180f699c41b152 config: i386-randconfig-a002 compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 66ae1d60bb278793fd651cece264699d522bab84) 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://github.com/intel-lab-lkp/linux/commit/9a7c7d74b2c2d3c8524342cb0278ab8b77714bad git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Thinh-Nguyen/usb-gadget-f_tcm-Enhance-UASP-driver/20220707-074014 git checkout 9a7c7d74b2c2d3c8524342cb0278ab8b77714bad # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/target/ If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> drivers/target/target_core_alua.c:274:6: warning: variable 'buf' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (cdb[2] != 1) { ^~~~~~~~~~~ drivers/target/target_core_alua.c:323:2: note: uninitialized use occurs here buf[1] = supported; ^~~ drivers/target/target_core_alua.c:274:2: note: remove the 'if' if its condition is always false if (cdb[2] != 1) { ^~~~~~~~~~~~~~~~~~ drivers/target/target_core_alua.c:271:20: note: initialize the variable 'buf' to silence this warning unsigned char *buf; ^ = NULL 1 warning generated. vim +274 drivers/target/target_core_alua.c 261 262 /* 263 * REPORT_SUPPORTED_OPERATION_CODES 264 * 265 * See spc4r17 section 6.27 266 */ 267 sense_reason_t 268 target_emulate_report_supported_opcodes(struct se_cmd *cmd) 269 { 270 unsigned char *cdb = cmd->t_task_cdb; 271 unsigned char *buf; 272 u8 supported = 0; 273 > 274 if (cdb[2] != 1) { 275 pr_warn("Invalid command format %d\n", cdb[2]); 276 goto out; 277 } 278 279 buf = transport_kmap_data_sg(cmd); 280 if (!buf) 281 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 282 283 switch (cdb[3]) { 284 case INQUIRY: 285 case MODE_SENSE: 286 case MODE_SENSE_10: 287 case READ_CAPACITY: 288 case SERVICE_ACTION_IN_16: 289 case REPORT_LUNS: 290 case REQUEST_SENSE: 291 case SYNCHRONIZE_CACHE: 292 case REZERO_UNIT: 293 case SEEK_6: 294 case SEEK_10: 295 case TEST_UNIT_READY: 296 case SEND_DIAGNOSTIC: 297 case MAINTENANCE_IN: 298 case READ_6: 299 case READ_10: 300 case READ_16: 301 case WRITE_6: 302 case WRITE_10: 303 case WRITE_16: 304 case VERIFY_16: 305 case MODE_SELECT: 306 case MODE_SELECT_10: 307 case START_STOP: 308 case SECURITY_PROTOCOL_IN: 309 case SECURITY_PROTOCOL_OUT: 310 supported = 3; 311 break; 312 case ATA_12: 313 case ATA_16: 314 case VERIFY: 315 case ZBC_IN: 316 case ZBC_OUT: 317 default: 318 break; 319 } 320 321 transport_kunmap_data_sg(cmd); 322 out: 323 buf[1] = supported; 324 target_complete_cmd(cmd, SAM_STAT_GOOD); 325 return 0; 326 } 327
diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c index b56ef8af66e7..20cfcb70805d 100644 --- a/drivers/target/target_core_alua.c +++ b/drivers/target/target_core_alua.c @@ -259,6 +259,72 @@ target_emulate_report_target_port_groups(struct se_cmd *cmd) return 0; } +/* + * REPORT_SUPPORTED_OPERATION_CODES + * + * See spc4r17 section 6.27 + */ +sense_reason_t +target_emulate_report_supported_opcodes(struct se_cmd *cmd) +{ + unsigned char *cdb = cmd->t_task_cdb; + unsigned char *buf; + u8 supported = 0; + + if (cdb[2] != 1) { + pr_warn("Invalid command format %d\n", cdb[2]); + goto out; + } + + buf = transport_kmap_data_sg(cmd); + if (!buf) + return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; + + switch (cdb[3]) { + case INQUIRY: + case MODE_SENSE: + case MODE_SENSE_10: + case READ_CAPACITY: + case SERVICE_ACTION_IN_16: + case REPORT_LUNS: + case REQUEST_SENSE: + case SYNCHRONIZE_CACHE: + case REZERO_UNIT: + case SEEK_6: + case SEEK_10: + case TEST_UNIT_READY: + case SEND_DIAGNOSTIC: + case MAINTENANCE_IN: + case READ_6: + case READ_10: + case READ_16: + case WRITE_6: + case WRITE_10: + case WRITE_16: + case VERIFY_16: + case MODE_SELECT: + case MODE_SELECT_10: + case START_STOP: + case SECURITY_PROTOCOL_IN: + case SECURITY_PROTOCOL_OUT: + supported = 3; + break; + case ATA_12: + case ATA_16: + case VERIFY: + case ZBC_IN: + case ZBC_OUT: + default: + break; + } + + transport_kunmap_data_sg(cmd); +out: + buf[1] = supported; + target_complete_cmd(cmd, SAM_STAT_GOOD); + return 0; +} + /* * SET_TARGET_PORT_GROUPS for explicit ALUA operation. * diff --git a/drivers/target/target_core_alua.h b/drivers/target/target_core_alua.h index fc9637cce825..7941e4dd4f97 100644 --- a/drivers/target/target_core_alua.h +++ b/drivers/target/target_core_alua.h @@ -82,6 +82,8 @@ extern struct kmem_cache *t10_alua_tg_pt_gp_cache; extern struct kmem_cache *t10_alua_lba_map_cache; extern struct kmem_cache *t10_alua_lba_map_mem_cache; +extern sense_reason_t +target_emulate_report_supported_opcodes(struct se_cmd *cmd); extern sense_reason_t target_emulate_report_target_port_groups(struct se_cmd *); extern sense_reason_t target_emulate_set_target_port_groups(struct se_cmd *); extern sense_reason_t target_emulate_report_referrals(struct se_cmd *); diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c index c14441c89bed..dd799158609d 100644 --- a/drivers/target/target_core_spc.c +++ b/drivers/target/target_core_spc.c @@ -1425,15 +1425,25 @@ spc_parse_cdb(struct se_cmd *cmd, unsigned int *size) break; case MAINTENANCE_IN: if (dev->transport->get_device_type(dev) != TYPE_ROM) { + u8 action = cdb[1] & 0x1f; + /* * MAINTENANCE_IN from SCC-2 * Check for emulated MI_REPORT_TARGET_PGS */ - if ((cdb[1] & 0x1f) == MI_REPORT_TARGET_PGS) { + if (action == MI_REPORT_TARGET_PGS) { cmd->execute_cmd = target_emulate_report_target_port_groups; + + *size = get_unaligned_be32(&cdb[6]); + } + + if (action == MI_REPORT_SUPPORTED_OPERATION_CODES) { + cmd->execute_cmd = + target_emulate_report_supported_opcodes; + + *size = get_unaligned_be16(&cdb[2]); } - *size = get_unaligned_be32(&cdb[6]); } else { /* * GPCMD_SEND_KEY from multi media commands
Microsoft Windows checks for MI_REPORT_SUPPORTED_OPERATION_CODES. Let's handle this MAINTENANCE_IN command and report supported commands. Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> --- drivers/target/target_core_alua.c | 66 +++++++++++++++++++++++++++++++ drivers/target/target_core_alua.h | 2 + drivers/target/target_core_spc.c | 14 ++++++- 3 files changed, 80 insertions(+), 2 deletions(-)