Re: [PATCH] scsi: clear UAC before sending SG_IO

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Randall,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on mkp-scsi/for-next]
[also build test ERROR on scsi/for-next v5.9-rc4 next-20200910]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Randall-Huang/scsi-clear-UAC-before-sending-SG_IO/20200910-181617
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.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
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

   drivers/scsi/sg.c: In function 'sg_ioctl_common':
>> drivers/scsi/sg.c:938:10: error: 'SCSI_UFS_REQUEST_SENSE' undeclared (first use in this function)
     938 |   _cmd = SCSI_UFS_REQUEST_SENSE;
         |          ^~~~~~~~~~~~~~~~~~~~~~
   drivers/scsi/sg.c:938:10: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/scsi/sg.c:939:24: error: 'struct Scsi_Host' has no member named 'wlun_clr_uac'
     939 |   if (sdp->device->host->wlun_clr_uac) {
         |                        ^~
   drivers/scsi/sg.c:941:21: error: 'struct Scsi_Host' has no member named 'wlun_clr_uac'
     941 |    sdp->device->host->wlun_clr_uac = false;
         |                     ^~

# https://github.com/0day-ci/linux/commit/ff032a89412d0cf4592575b5e8f5385b223d2261
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Randall-Huang/scsi-clear-UAC-before-sending-SG_IO/20200910-181617
git checkout ff032a89412d0cf4592575b5e8f5385b223d2261
vim +/SCSI_UFS_REQUEST_SENSE +938 drivers/scsi/sg.c

   916	
   917	static long
   918	sg_ioctl_common(struct file *filp, Sg_device *sdp, Sg_fd *sfp,
   919			unsigned int cmd_in, void __user *p)
   920	{
   921		int __user *ip = p;
   922		int result, val, read_only;
   923		Sg_request *srp;
   924		unsigned long iflags;
   925		int _cmd;
   926	
   927		SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sdp,
   928					   "sg_ioctl: cmd=0x%x\n", (int) cmd_in));
   929		read_only = (O_RDWR != (filp->f_flags & O_ACCMODE));
   930	
   931		switch (cmd_in) {
   932		case SG_IO:
   933			if (atomic_read(&sdp->detaching))
   934				return -ENODEV;
   935			if (!scsi_block_when_processing_errors(sdp->device))
   936				return -ENXIO;
   937	
 > 938			_cmd = SCSI_UFS_REQUEST_SENSE;
 > 939			if (sdp->device->host->wlun_clr_uac) {
   940				sdp->device->host->hostt->ioctl(sdp->device, _cmd, NULL);
   941				sdp->device->host->wlun_clr_uac = false;
   942			}
   943	
   944			result = sg_new_write(sfp, filp, p, SZ_SG_IO_HDR,
   945					 1, read_only, 1, &srp);
   946			if (result < 0)
   947				return result;
   948			result = wait_event_interruptible(sfp->read_wait,
   949				(srp_done(sfp, srp) || atomic_read(&sdp->detaching)));
   950			if (atomic_read(&sdp->detaching))
   951				return -ENODEV;
   952			write_lock_irq(&sfp->rq_list_lock);
   953			if (srp->done) {
   954				srp->done = 2;
   955				write_unlock_irq(&sfp->rq_list_lock);
   956				result = sg_new_read(sfp, p, SZ_SG_IO_HDR, srp);
   957				return (result < 0) ? result : 0;
   958			}
   959			srp->orphan = 1;
   960			write_unlock_irq(&sfp->rq_list_lock);
   961			return result;	/* -ERESTARTSYS because signal hit process */
   962		case SG_SET_TIMEOUT:
   963			result = get_user(val, ip);
   964			if (result)
   965				return result;
   966			if (val < 0)
   967				return -EIO;
   968			if (val >= mult_frac((s64)INT_MAX, USER_HZ, HZ))
   969				val = min_t(s64, mult_frac((s64)INT_MAX, USER_HZ, HZ),
   970					    INT_MAX);
   971			sfp->timeout_user = val;
   972			sfp->timeout = mult_frac(val, HZ, USER_HZ);
   973	
   974			return 0;
   975		case SG_GET_TIMEOUT:	/* N.B. User receives timeout as return value */
   976					/* strange ..., for backward compatibility */
   977			return sfp->timeout_user;
   978		case SG_SET_FORCE_LOW_DMA:
   979			/*
   980			 * N.B. This ioctl never worked properly, but failed to
   981			 * return an error value. So returning '0' to keep compability
   982			 * with legacy applications.
   983			 */
   984			return 0;
   985		case SG_GET_LOW_DMA:
   986			return put_user((int) sdp->device->host->unchecked_isa_dma, ip);
   987		case SG_GET_SCSI_ID:
   988			{
   989				sg_scsi_id_t v;
   990	
   991				if (atomic_read(&sdp->detaching))
   992					return -ENODEV;
   993				memset(&v, 0, sizeof(v));
   994				v.host_no = sdp->device->host->host_no;
   995				v.channel = sdp->device->channel;
   996				v.scsi_id = sdp->device->id;
   997				v.lun = sdp->device->lun;
   998				v.scsi_type = sdp->device->type;
   999				v.h_cmd_per_lun = sdp->device->host->cmd_per_lun;
  1000				v.d_queue_depth = sdp->device->queue_depth;
  1001				if (copy_to_user(p, &v, sizeof(sg_scsi_id_t)))
  1002					return -EFAULT;
  1003				return 0;
  1004			}
  1005		case SG_SET_FORCE_PACK_ID:
  1006			result = get_user(val, ip);
  1007			if (result)
  1008				return result;
  1009			sfp->force_packid = val ? 1 : 0;
  1010			return 0;
  1011		case SG_GET_PACK_ID:
  1012			read_lock_irqsave(&sfp->rq_list_lock, iflags);
  1013			list_for_each_entry(srp, &sfp->rq_list, entry) {
  1014				if ((1 == srp->done) && (!srp->sg_io_owned)) {
  1015					read_unlock_irqrestore(&sfp->rq_list_lock,
  1016							       iflags);
  1017					return put_user(srp->header.pack_id, ip);
  1018				}
  1019			}
  1020			read_unlock_irqrestore(&sfp->rq_list_lock, iflags);
  1021			return put_user(-1, ip);
  1022		case SG_GET_NUM_WAITING:
  1023			read_lock_irqsave(&sfp->rq_list_lock, iflags);
  1024			val = 0;
  1025			list_for_each_entry(srp, &sfp->rq_list, entry) {
  1026				if ((1 == srp->done) && (!srp->sg_io_owned))
  1027					++val;
  1028			}
  1029			read_unlock_irqrestore(&sfp->rq_list_lock, iflags);
  1030			return put_user(val, ip);
  1031		case SG_GET_SG_TABLESIZE:
  1032			return put_user(sdp->sg_tablesize, ip);
  1033		case SG_SET_RESERVED_SIZE:
  1034			result = get_user(val, ip);
  1035			if (result)
  1036				return result;
  1037	                if (val < 0)
  1038	                        return -EINVAL;
  1039			val = min_t(int, val,
  1040				    max_sectors_bytes(sdp->device->request_queue));
  1041			mutex_lock(&sfp->f_mutex);
  1042			if (val != sfp->reserve.bufflen) {
  1043				if (sfp->mmap_called ||
  1044				    sfp->res_in_use) {
  1045					mutex_unlock(&sfp->f_mutex);
  1046					return -EBUSY;
  1047				}
  1048	
  1049				sg_remove_scat(sfp, &sfp->reserve);
  1050				sg_build_reserve(sfp, val);
  1051			}
  1052			mutex_unlock(&sfp->f_mutex);
  1053			return 0;
  1054		case SG_GET_RESERVED_SIZE:
  1055			val = min_t(int, sfp->reserve.bufflen,
  1056				    max_sectors_bytes(sdp->device->request_queue));
  1057			return put_user(val, ip);
  1058		case SG_SET_COMMAND_Q:
  1059			result = get_user(val, ip);
  1060			if (result)
  1061				return result;
  1062			sfp->cmd_q = val ? 1 : 0;
  1063			return 0;
  1064		case SG_GET_COMMAND_Q:
  1065			return put_user((int) sfp->cmd_q, ip);
  1066		case SG_SET_KEEP_ORPHAN:
  1067			result = get_user(val, ip);
  1068			if (result)
  1069				return result;
  1070			sfp->keep_orphan = val;
  1071			return 0;
  1072		case SG_GET_KEEP_ORPHAN:
  1073			return put_user((int) sfp->keep_orphan, ip);
  1074		case SG_NEXT_CMD_LEN:
  1075			result = get_user(val, ip);
  1076			if (result)
  1077				return result;
  1078			if (val > SG_MAX_CDB_SIZE)
  1079				return -ENOMEM;
  1080			sfp->next_cmd_len = (val > 0) ? val : 0;
  1081			return 0;
  1082		case SG_GET_VERSION_NUM:
  1083			return put_user(sg_version_num, ip);
  1084		case SG_GET_ACCESS_COUNT:
  1085			/* faked - we don't have a real access count anymore */
  1086			val = (sdp->device ? 1 : 0);
  1087			return put_user(val, ip);
  1088		case SG_GET_REQUEST_TABLE:
  1089			{
  1090				sg_req_info_t *rinfo;
  1091	
  1092				rinfo = kcalloc(SG_MAX_QUEUE, SZ_SG_REQ_INFO,
  1093						GFP_KERNEL);
  1094				if (!rinfo)
  1095					return -ENOMEM;
  1096				read_lock_irqsave(&sfp->rq_list_lock, iflags);
  1097				sg_fill_request_table(sfp, rinfo);
  1098				read_unlock_irqrestore(&sfp->rq_list_lock, iflags);
  1099		#ifdef CONFIG_COMPAT
  1100				if (in_compat_syscall())
  1101					result = put_compat_request_table(p, rinfo);
  1102				else
  1103		#endif
  1104					result = copy_to_user(p, rinfo,
  1105							      SZ_SG_REQ_INFO * SG_MAX_QUEUE);
  1106				result = result ? -EFAULT : 0;
  1107				kfree(rinfo);
  1108				return result;
  1109			}
  1110		case SG_EMULATED_HOST:
  1111			if (atomic_read(&sdp->detaching))
  1112				return -ENODEV;
  1113			return put_user(sdp->device->host->hostt->emulated, ip);
  1114		case SCSI_IOCTL_SEND_COMMAND:
  1115			if (atomic_read(&sdp->detaching))
  1116				return -ENODEV;
  1117			return sg_scsi_ioctl(sdp->device->request_queue, NULL, filp->f_mode, p);
  1118		case SG_SET_DEBUG:
  1119			result = get_user(val, ip);
  1120			if (result)
  1121				return result;
  1122			sdp->sgdebug = (char) val;
  1123			return 0;
  1124		case BLKSECTGET:
  1125			return put_user(max_sectors_bytes(sdp->device->request_queue),
  1126					ip);
  1127		case BLKTRACESETUP:
  1128			return blk_trace_setup(sdp->device->request_queue,
  1129					       sdp->disk->disk_name,
  1130					       MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
  1131					       NULL, p);
  1132		case BLKTRACESTART:
  1133			return blk_trace_startstop(sdp->device->request_queue, 1);
  1134		case BLKTRACESTOP:
  1135			return blk_trace_startstop(sdp->device->request_queue, 0);
  1136		case BLKTRACETEARDOWN:
  1137			return blk_trace_remove(sdp->device->request_queue);
  1138		case SCSI_IOCTL_GET_IDLUN:
  1139		case SCSI_IOCTL_GET_BUS_NUMBER:
  1140		case SCSI_IOCTL_PROBE_HOST:
  1141		case SG_GET_TRANSFORM:
  1142		case SG_SCSI_RESET:
  1143			if (atomic_read(&sdp->detaching))
  1144				return -ENODEV;
  1145			break;
  1146		default:
  1147			if (read_only)
  1148				return -EPERM;	/* don't know so take safe approach */
  1149			break;
  1150		}
  1151	
  1152		result = scsi_ioctl_block_when_processing_errors(sdp->device,
  1153				cmd_in, filp->f_flags & O_NDELAY);
  1154		if (result)
  1155			return result;
  1156	
  1157		return -ENOIOCTLCMD;
  1158	}
  1159	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux