--- zzzz-none-000/linux-3.10.107/drivers/scsi/pmcraid.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/scsi/pmcraid.c 2021-02-04 17:41:59.000000000 +0000 @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -237,7 +238,7 @@ scsi_dev->host->unique_id, scsi_dev->channel, scsi_dev->id, - scsi_dev->lun); + (u8)scsi_dev->lun); if (RES_IS_GSCSI(res->cfg_entry)) { scsi_dev->allow_restart = 1; @@ -249,15 +250,11 @@ PMCRAID_VSET_MAX_SECTORS); } - if (scsi_dev->tagged_supported && - (RES_IS_GSCSI(res->cfg_entry) || RES_IS_VSET(res->cfg_entry))) { - scsi_activate_tcq(scsi_dev, scsi_dev->queue_depth); - scsi_adjust_queue_depth(scsi_dev, MSG_SIMPLE_TAG, - scsi_dev->host->cmd_per_lun); - } else { - scsi_adjust_queue_depth(scsi_dev, 0, - scsi_dev->host->cmd_per_lun); - } + /* + * We never want to report TCQ support for these types of devices. + */ + if (!RES_IS_GSCSI(res->cfg_entry) && !RES_IS_VSET(res->cfg_entry)) + scsi_dev->tagged_supported = 0; return 0; } @@ -289,54 +286,17 @@ * pmcraid_change_queue_depth - Change the device's queue depth * @scsi_dev: scsi device struct * @depth: depth to set - * @reason: calling context * * Return value * actual depth set */ -static int pmcraid_change_queue_depth(struct scsi_device *scsi_dev, int depth, - int reason) +static int pmcraid_change_queue_depth(struct scsi_device *scsi_dev, int depth) { - if (reason != SCSI_QDEPTH_DEFAULT) - return -EOPNOTSUPP; - if (depth > PMCRAID_MAX_CMD_PER_LUN) depth = PMCRAID_MAX_CMD_PER_LUN; - - scsi_adjust_queue_depth(scsi_dev, scsi_get_tag_type(scsi_dev), depth); - - return scsi_dev->queue_depth; -} - -/** - * pmcraid_change_queue_type - Change the device's queue type - * @scsi_dev: scsi device struct - * @tag: type of tags to use - * - * Return value: - * actual queue type set - */ -static int pmcraid_change_queue_type(struct scsi_device *scsi_dev, int tag) -{ - struct pmcraid_resource_entry *res; - - res = (struct pmcraid_resource_entry *)scsi_dev->hostdata; - - if ((res) && scsi_dev->tagged_supported && - (RES_IS_GSCSI(res->cfg_entry) || RES_IS_VSET(res->cfg_entry))) { - scsi_set_tag_type(scsi_dev, tag); - - if (tag) - scsi_activate_tcq(scsi_dev, scsi_dev->queue_depth); - else - scsi_deactivate_tcq(scsi_dev, scsi_dev->queue_depth); - } else - tag = 0; - - return tag; + return scsi_change_queue_depth(scsi_dev, depth); } - /** * pmcraid_init_cmdblk - initializes a command block * @@ -1404,11 +1364,22 @@ }; #define PMCRAID_AEN_CMD_MAX (__PMCRAID_AEN_CMD_MAX - 1) +static struct genl_multicast_group pmcraid_mcgrps[] = { + { .name = "events", /* not really used - see ID discussion below */ }, +}; + static struct genl_family pmcraid_event_family = { - .id = GENL_ID_GENERATE, + /* + * Due to prior multicast group abuse (the code having assumed that + * the family ID can be used as a multicast group ID) we need to + * statically allocate a family (and thus group) ID. + */ + .id = GENL_ID_PMCRAID, .name = "pmcraid", .version = 1, - .maxattr = PMCRAID_AEN_ATTR_MAX + .maxattr = PMCRAID_AEN_ATTR_MAX, + .mcgrps = pmcraid_mcgrps, + .n_mcgrps = ARRAY_SIZE(pmcraid_mcgrps), }; /** @@ -1503,16 +1474,10 @@ } /* send genetlink multicast message to notify appplications */ - result = genlmsg_end(skb, msg_header); + genlmsg_end(skb, msg_header); - if (result < 0) { - pmcraid_err("genlmsg_end failed\n"); - nlmsg_free(skb); - return result; - } - - result = - genlmsg_multicast(skb, 0, pmcraid_event_family.id, GFP_ATOMIC); + result = genlmsg_multicast(&pmcraid_event_family, skb, + 0, 0, GFP_ATOMIC); /* If there are no listeners, genlmsg_multicast may return non-zero * value. @@ -3164,36 +3129,6 @@ } /** - * pmcraid_task_attributes - Translate SPI Q-Tags to task attributes - * @scsi_cmd: scsi command struct - * - * Return value - * number of tags or 0 if the task is not tagged - */ -static u8 pmcraid_task_attributes(struct scsi_cmnd *scsi_cmd) -{ - char tag[2]; - u8 rc = 0; - - if (scsi_populate_tag_msg(scsi_cmd, tag)) { - switch (tag[0]) { - case MSG_SIMPLE_TAG: - rc = TASK_TAG_SIMPLE; - break; - case MSG_HEAD_TAG: - rc = TASK_TAG_QUEUE_HEAD; - break; - case MSG_ORDERED_TAG: - rc = TASK_TAG_ORDERED; - break; - }; - } - - return rc; -} - - -/** * pmcraid_init_ioadls - initializes IOADL related fields in IOARCB * @cmd: pmcraid command struct * @sgcount: count of scatter-gather elements @@ -3548,7 +3483,9 @@ } ioarcb->request_flags0 |= NO_LINK_DESCS; - ioarcb->request_flags1 |= pmcraid_task_attributes(scsi_cmd); + + if (scsi_cmd->flags & SCMD_TAGGED) + ioarcb->request_flags1 |= TASK_TAG_SIMPLE; if (RES_IS_GSCSI(res->cfg_entry)) ioarcb->request_flags1 |= DELAY_AFTER_RESET; @@ -4202,9 +4139,9 @@ { struct Scsi_Host *shost; struct pmcraid_instance *pinstance; - unsigned long val; + u8 val; - if (strict_strtoul(buf, 10, &val)) + if (kstrtou8(buf, 10, &val)) return -EINVAL; /* log-level should be from 0 to 2 */ if (val > 2) @@ -4281,7 +4218,7 @@ static struct device_attribute pmcraid_adapter_id_attr = { .attr = { .name = "adapter_id", - .mode = S_IRUGO | S_IWUSR, + .mode = S_IRUGO, }, .show = pmcraid_show_adapter_id, }; @@ -4309,7 +4246,6 @@ .slave_configure = pmcraid_slave_configure, .slave_destroy = pmcraid_slave_destroy, .change_queue_depth = pmcraid_change_queue_depth, - .change_queue_type = pmcraid_change_queue_type, .can_queue = PMCRAID_MAX_IO_CMD, .this_id = -1, .sg_tablesize = PMCRAID_MAX_IOADLS, @@ -4318,7 +4254,7 @@ .cmd_per_lun = PMCRAID_MAX_CMD_PER_LUN, .use_clustering = ENABLE_CLUSTERING, .shost_attrs = pmcraid_host_attrs, - .proc_name = PMCRAID_DRIVER_NAME + .proc_name = PMCRAID_DRIVER_NAME, }; /* @@ -4687,19 +4623,10 @@ for (i = 0; i < PMCRAID_NUM_MSIX_VECTORS; i++) entries[i].entry = i; - rc = pci_enable_msix(pdev, entries, num_hrrq); - if (rc < 0) + num_hrrq = pci_enable_msix_range(pdev, entries, 1, num_hrrq); + if (num_hrrq < 0) goto pmcraid_isr_legacy; - /* Check how many MSIX vectors are allocated and register - * msi-x handlers for each of them giving appropriate buffer - */ - if (rc > 0) { - num_hrrq = rc; - if (pci_enable_msix(pdev, entries, num_hrrq)) - goto pmcraid_isr_legacy; - } - for (i = 0; i < num_hrrq; i++) { pinstance->hrrq_vector[i].hrrq_id = i; pinstance->hrrq_vector[i].drv_inst = pinstance; @@ -4735,7 +4662,6 @@ pinstance->hrrq_vector[0].drv_inst = pinstance; pinstance->hrrq_vector[0].vector = pdev->irq; pinstance->num_hrrq = 1; - rc = 0; rc = request_irq(pdev->irq, pmcraid_isr, IRQF_SHARED, PMCRAID_DRIVER_NAME, &pinstance->hrrq_vector[0]); @@ -5637,11 +5563,9 @@ __be32 time_stamp_len = cpu_to_be32(PMCRAID_TIMESTAMP_LEN); struct pmcraid_ioadl_desc *ioadl = ioarcb->add_data.u.ioadl; - struct timeval tv; __le64 timestamp; - do_gettimeofday(&tv); - timestamp = tv.tv_sec * 1000; + timestamp = ktime_get_real_seconds() * 1000; pinstance->timestamp_data->timestamp[0] = (__u8)(timestamp); pinstance->timestamp_data->timestamp[1] = (__u8)((timestamp) >> 8); @@ -6050,7 +5974,6 @@ out_disable_device: atomic_dec(&pmcraid_adapter_count); - pci_set_drvdata(pdev, NULL); pci_disable_device(pdev); return -ENODEV; } @@ -6093,7 +6016,7 @@ if (IS_ERR(pmcraid_class)) { error = PTR_ERR(pmcraid_class); - pmcraid_err("failed to register with with sysfs, error = %x\n", + pmcraid_err("failed to register with sysfs, error = %x\n", error); goto out_unreg_chrdev; }