Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi

Pull SCSI fixes from James Bottomley:
"This is a set of eight fixes.

Two are trivial gcc-6 updates (brace additions and unused variable
removal). There's a couple of cxlflash regressions, a correction for
sd being overly chatty on revalidation (causing excess log increases).
A VPD issue which could crash USB devices because they seem very
intolerant to VPD inquiries, an ALUA deadlock fix and a mpt3sas buffer
overrun fix"

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
scsi: Do not attach VPD to devices that don't support it
sd: Fix excessive capacity printing on devices with blocks bigger than 512 bytes
scsi_dh_alua: Fix a recently introduced deadlock
scsi: Declare local symbols static
cxlflash: Move to exponential back-off when cmd_room is not available
cxlflash: Fix regression issue with re-ordering patch
mpt3sas: Don't overreach ioc->reply_post[] during initialization
aacraid: add missing curly braces

+164 -109
+2 -1
drivers/scsi/aacraid/linit.c
··· 452 452 else if (depth < 2) 453 453 depth = 2; 454 454 scsi_change_queue_depth(sdev, depth); 455 - } else 455 + } else { 456 456 scsi_change_queue_depth(sdev, 1); 457 457 458 458 sdev->tagged_supported = 1; 459 + } 459 460 460 461 return 0; 461 462 }
+95 -43
drivers/scsi/cxlflash/main.c
··· 289 289 atomic64_set(&afu->room, room); 290 290 if (room) 291 291 goto write_rrin; 292 - udelay(nretry); 292 + udelay(1 << nretry); 293 293 } while (nretry++ < MC_ROOM_RETRY_CNT); 294 294 295 295 pr_err("%s: no cmd_room to send reset\n", __func__); ··· 303 303 if (rrin != 0x1) 304 304 break; 305 305 /* Double delay each time */ 306 - udelay(2 << nretry); 306 + udelay(1 << nretry); 307 307 } while (nretry++ < MC_ROOM_RETRY_CNT); 308 308 } 309 309 ··· 338 338 atomic64_set(&afu->room, room); 339 339 if (room) 340 340 goto write_ioarrin; 341 - udelay(nretry); 341 + udelay(1 << nretry); 342 342 } while (nretry++ < MC_ROOM_RETRY_CNT); 343 343 344 344 dev_err(dev, "%s: no cmd_room to send 0x%X\n", ··· 352 352 * afu->room. 353 353 */ 354 354 if (nretry++ < MC_ROOM_RETRY_CNT) { 355 - udelay(nretry); 355 + udelay(1 << nretry); 356 356 goto retry; 357 357 } 358 358 ··· 683 683 } 684 684 685 685 /** 686 - * term_mc() - terminates the master context 686 + * term_intr() - disables all AFU interrupts 687 687 * @cfg: Internal structure associated with the host. 688 688 * @level: Depth of allocation, where to begin waterfall tear down. 689 689 * 690 690 * Safe to call with AFU/MC in partially allocated/initialized state. 691 691 */ 692 - static void term_mc(struct cxlflash_cfg *cfg, enum undo_level level) 692 + static void term_intr(struct cxlflash_cfg *cfg, enum undo_level level) 693 693 { 694 - int rc = 0; 695 694 struct afu *afu = cfg->afu; 696 695 struct device *dev = &cfg->dev->dev; 697 696 698 697 if (!afu || !cfg->mcctx) { 699 - dev_err(dev, "%s: returning from term_mc with NULL afu or MC\n", 700 - __func__); 698 + dev_err(dev, "%s: returning with NULL afu or MC\n", __func__); 701 699 return; 702 700 } 703 701 704 702 switch (level) { 705 - case UNDO_START: 706 - rc = cxl_stop_context(cfg->mcctx); 707 - BUG_ON(rc); 708 703 case UNMAP_THREE: 709 704 cxl_unmap_afu_irq(cfg->mcctx, 3, afu); 710 705 case UNMAP_TWO: ··· 708 713 cxl_unmap_afu_irq(cfg->mcctx, 1, afu); 709 714 case FREE_IRQ: 710 715 cxl_free_afu_irqs(cfg->mcctx); 711 - case RELEASE_CONTEXT: 712 - cfg->mcctx = NULL; 716 + /* fall through */ 717 + case UNDO_NOOP: 718 + /* No action required */ 719 + break; 713 720 } 721 + } 722 + 723 + /** 724 + * term_mc() - terminates the master context 725 + * @cfg: Internal structure associated with the host. 726 + * @level: Depth of allocation, where to begin waterfall tear down. 727 + * 728 + * Safe to call with AFU/MC in partially allocated/initialized state. 729 + */ 730 + static void term_mc(struct cxlflash_cfg *cfg) 731 + { 732 + int rc = 0; 733 + struct afu *afu = cfg->afu; 734 + struct device *dev = &cfg->dev->dev; 735 + 736 + if (!afu || !cfg->mcctx) { 737 + dev_err(dev, "%s: returning with NULL afu or MC\n", __func__); 738 + return; 739 + } 740 + 741 + rc = cxl_stop_context(cfg->mcctx); 742 + WARN_ON(rc); 743 + cfg->mcctx = NULL; 714 744 } 715 745 716 746 /** ··· 746 726 */ 747 727 static void term_afu(struct cxlflash_cfg *cfg) 748 728 { 729 + /* 730 + * Tear down is carefully orchestrated to ensure 731 + * no interrupts can come in when the problem state 732 + * area is unmapped. 733 + * 734 + * 1) Disable all AFU interrupts 735 + * 2) Unmap the problem state area 736 + * 3) Stop the master context 737 + */ 738 + term_intr(cfg, UNMAP_THREE); 749 739 if (cfg->afu) 750 740 stop_afu(cfg); 751 741 752 - term_mc(cfg, UNDO_START); 742 + term_mc(cfg); 753 743 754 744 pr_debug("%s: returning\n", __func__); 755 745 } ··· 1627 1597 } 1628 1598 1629 1599 /** 1630 - * init_mc() - create and register as the master context 1600 + * init_intr() - setup interrupt handlers for the master context 1631 1601 * @cfg: Internal structure associated with the host. 1632 1602 * 1633 1603 * Return: 0 on success, -errno on failure 1634 1604 */ 1635 - static int init_mc(struct cxlflash_cfg *cfg) 1605 + static enum undo_level init_intr(struct cxlflash_cfg *cfg, 1606 + struct cxl_context *ctx) 1636 1607 { 1637 - struct cxl_context *ctx; 1638 - struct device *dev = &cfg->dev->dev; 1639 1608 struct afu *afu = cfg->afu; 1609 + struct device *dev = &cfg->dev->dev; 1640 1610 int rc = 0; 1641 - enum undo_level level; 1642 - 1643 - ctx = cxl_get_context(cfg->dev); 1644 - if (unlikely(!ctx)) 1645 - return -ENOMEM; 1646 - cfg->mcctx = ctx; 1647 - 1648 - /* Set it up as a master with the CXL */ 1649 - cxl_set_master(ctx); 1650 - 1651 - /* During initialization reset the AFU to start from a clean slate */ 1652 - rc = cxl_afu_reset(cfg->mcctx); 1653 - if (unlikely(rc)) { 1654 - dev_err(dev, "%s: initial AFU reset failed rc=%d\n", 1655 - __func__, rc); 1656 - level = RELEASE_CONTEXT; 1657 - goto out; 1658 - } 1611 + enum undo_level level = UNDO_NOOP; 1659 1612 1660 1613 rc = cxl_allocate_afu_irqs(ctx, 3); 1661 1614 if (unlikely(rc)) { 1662 1615 dev_err(dev, "%s: call to allocate_afu_irqs failed rc=%d!\n", 1663 1616 __func__, rc); 1664 - level = RELEASE_CONTEXT; 1617 + level = UNDO_NOOP; 1665 1618 goto out; 1666 1619 } 1667 1620 ··· 1674 1661 level = UNMAP_TWO; 1675 1662 goto out; 1676 1663 } 1664 + out: 1665 + return level; 1666 + } 1677 1667 1678 - rc = 0; 1668 + /** 1669 + * init_mc() - create and register as the master context 1670 + * @cfg: Internal structure associated with the host. 1671 + * 1672 + * Return: 0 on success, -errno on failure 1673 + */ 1674 + static int init_mc(struct cxlflash_cfg *cfg) 1675 + { 1676 + struct cxl_context *ctx; 1677 + struct device *dev = &cfg->dev->dev; 1678 + int rc = 0; 1679 + enum undo_level level; 1680 + 1681 + ctx = cxl_get_context(cfg->dev); 1682 + if (unlikely(!ctx)) { 1683 + rc = -ENOMEM; 1684 + goto ret; 1685 + } 1686 + cfg->mcctx = ctx; 1687 + 1688 + /* Set it up as a master with the CXL */ 1689 + cxl_set_master(ctx); 1690 + 1691 + /* During initialization reset the AFU to start from a clean slate */ 1692 + rc = cxl_afu_reset(cfg->mcctx); 1693 + if (unlikely(rc)) { 1694 + dev_err(dev, "%s: initial AFU reset failed rc=%d\n", 1695 + __func__, rc); 1696 + goto ret; 1697 + } 1698 + 1699 + level = init_intr(cfg, ctx); 1700 + if (unlikely(level)) { 1701 + dev_err(dev, "%s: setting up interrupts failed rc=%d\n", 1702 + __func__, rc); 1703 + goto out; 1704 + } 1679 1705 1680 1706 /* This performs the equivalent of the CXL_IOCTL_START_WORK. 1681 1707 * The CXL_IOCTL_GET_PROCESS_ELEMENT is implicit in the process ··· 1730 1678 pr_debug("%s: returning rc=%d\n", __func__, rc); 1731 1679 return rc; 1732 1680 out: 1733 - term_mc(cfg, level); 1681 + term_intr(cfg, level); 1734 1682 goto ret; 1735 1683 } 1736 1684 ··· 1803 1751 err2: 1804 1752 kref_put(&afu->mapcount, afu_unmap); 1805 1753 err1: 1806 - term_mc(cfg, UNDO_START); 1754 + term_intr(cfg, UNMAP_THREE); 1755 + term_mc(cfg); 1807 1756 goto out; 1808 1757 } 1809 1758 ··· 2541 2488 if (unlikely(rc)) 2542 2489 dev_err(dev, "%s: Failed to mark user contexts!(%d)\n", 2543 2490 __func__, rc); 2544 - stop_afu(cfg); 2545 - term_mc(cfg, UNDO_START); 2491 + term_afu(cfg); 2546 2492 return PCI_ERS_RESULT_NEED_RESET; 2547 2493 case pci_channel_io_perm_failure: 2548 2494 cfg->state = STATE_FAILTERM;
+2 -3
drivers/scsi/cxlflash/main.h
··· 79 79 #define WWPN_BUF_LEN (WWPN_LEN + 1) 80 80 81 81 enum undo_level { 82 - RELEASE_CONTEXT = 0, 82 + UNDO_NOOP = 0, 83 83 FREE_IRQ, 84 84 UNMAP_ONE, 85 85 UNMAP_TWO, 86 - UNMAP_THREE, 87 - UNDO_START 86 + UNMAP_THREE 88 87 }; 89 88 90 89 struct dev_dependent_vals {
+2 -2
drivers/scsi/device_handler/scsi_dh_alua.c
··· 1112 1112 h->sdev = NULL; 1113 1113 spin_unlock(&h->pg_lock); 1114 1114 if (pg) { 1115 - spin_lock(&pg->lock); 1115 + spin_lock_irq(&pg->lock); 1116 1116 list_del_rcu(&h->node); 1117 - spin_unlock(&pg->lock); 1117 + spin_unlock_irq(&pg->lock); 1118 1118 kref_put(&pg->kref, release_port_group); 1119 1119 } 1120 1120 sdev->handler_data = NULL;
+16 -17
drivers/scsi/mpt3sas/mpt3sas_base.c
··· 5030 5030 static int 5031 5031 _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) 5032 5032 { 5033 - int r, i; 5033 + int r, i, index; 5034 5034 unsigned long flags; 5035 5035 u32 reply_address; 5036 5036 u16 smid; ··· 5039 5039 struct _event_ack_list *delayed_event_ack, *delayed_event_ack_next; 5040 5040 u8 hide_flag; 5041 5041 struct adapter_reply_queue *reply_q; 5042 - long reply_post_free; 5043 - u32 reply_post_free_sz, index = 0; 5042 + Mpi2ReplyDescriptorsUnion_t *reply_post_free_contig; 5044 5043 5045 5044 dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, 5046 5045 __func__)); ··· 5123 5124 _base_assign_reply_queues(ioc); 5124 5125 5125 5126 /* initialize Reply Post Free Queue */ 5126 - reply_post_free_sz = ioc->reply_post_queue_depth * 5127 - sizeof(Mpi2DefaultReplyDescriptor_t); 5128 - reply_post_free = (long)ioc->reply_post[index].reply_post_free; 5127 + index = 0; 5128 + reply_post_free_contig = ioc->reply_post[0].reply_post_free; 5129 5129 list_for_each_entry(reply_q, &ioc->reply_queue_list, list) { 5130 + /* 5131 + * If RDPQ is enabled, switch to the next allocation. 5132 + * Otherwise advance within the contiguous region. 5133 + */ 5134 + if (ioc->rdpq_array_enable) { 5135 + reply_q->reply_post_free = 5136 + ioc->reply_post[index++].reply_post_free; 5137 + } else { 5138 + reply_q->reply_post_free = reply_post_free_contig; 5139 + reply_post_free_contig += ioc->reply_post_queue_depth; 5140 + } 5141 + 5130 5142 reply_q->reply_post_host_index = 0; 5131 - reply_q->reply_post_free = (Mpi2ReplyDescriptorsUnion_t *) 5132 - reply_post_free; 5133 5143 for (i = 0; i < ioc->reply_post_queue_depth; i++) 5134 5144 reply_q->reply_post_free[i].Words = 5135 5145 cpu_to_le64(ULLONG_MAX); 5136 5146 if (!_base_is_controller_msix_enabled(ioc)) 5137 5147 goto skip_init_reply_post_free_queue; 5138 - /* 5139 - * If RDPQ is enabled, switch to the next allocation. 5140 - * Otherwise advance within the contiguous region. 5141 - */ 5142 - if (ioc->rdpq_array_enable) 5143 - reply_post_free = (long) 5144 - ioc->reply_post[++index].reply_post_free; 5145 - else 5146 - reply_post_free += reply_post_free_sz; 5147 5148 } 5148 5149 skip_init_reply_post_free_queue: 5149 5150
+2 -1
drivers/scsi/scsi.c
··· 784 784 int pg83_supported = 0; 785 785 unsigned char __rcu *vpd_buf, *orig_vpd_buf = NULL; 786 786 787 - if (sdev->skip_vpd_pages) 787 + if (!scsi_device_supports_vpd(sdev)) 788 788 return; 789 + 789 790 retry_pg0: 790 791 vpd_buf = kmalloc(vpd_len, GFP_KERNEL); 791 792 if (!vpd_buf)
+5 -3
drivers/scsi/scsi_sysfs.c
··· 81 81 return name; 82 82 } 83 83 84 + #ifdef CONFIG_SCSI_DH 84 85 static const struct { 85 86 unsigned char value; 86 87 char *name; ··· 95 94 { SCSI_ACCESS_STATE_TRANSITIONING, "transitioning" }, 96 95 }; 97 96 98 - const char *scsi_access_state_name(unsigned char state) 97 + static const char *scsi_access_state_name(unsigned char state) 99 98 { 100 99 int i; 101 100 char *name = NULL; ··· 108 107 } 109 108 return name; 110 109 } 110 + #endif 111 111 112 112 static int check_set(unsigned long long *val, char *src) 113 113 { ··· 228 226 } 229 227 230 228 /* DEVICE_ATTR(state) clashes with dev_attr_state for sdev */ 231 - struct device_attribute dev_attr_hstate = 229 + static struct device_attribute dev_attr_hstate = 232 230 __ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state); 233 231 234 232 static ssize_t ··· 403 401 NULL 404 402 }; 405 403 406 - struct attribute_group scsi_shost_attr_group = { 404 + static struct attribute_group scsi_shost_attr_group = { 407 405 .attrs = scsi_sysfs_shost_attrs, 408 406 }; 409 407
+9 -38
drivers/scsi/sd.c
··· 1275 1275 struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk); 1276 1276 struct scsi_device *sdp = sdkp->device; 1277 1277 struct Scsi_Host *host = sdp->host; 1278 + sector_t capacity = logical_to_sectors(sdp, sdkp->capacity); 1278 1279 int diskinfo[4]; 1279 1280 1280 1281 /* default to most commonly used values */ 1281 - diskinfo[0] = 0x40; /* 1 << 6 */ 1282 - diskinfo[1] = 0x20; /* 1 << 5 */ 1283 - diskinfo[2] = sdkp->capacity >> 11; 1284 - 1282 + diskinfo[0] = 0x40; /* 1 << 6 */ 1283 + diskinfo[1] = 0x20; /* 1 << 5 */ 1284 + diskinfo[2] = capacity >> 11; 1285 + 1285 1286 /* override with calculated, extended default, or driver values */ 1286 1287 if (host->hostt->bios_param) 1287 - host->hostt->bios_param(sdp, bdev, sdkp->capacity, diskinfo); 1288 + host->hostt->bios_param(sdp, bdev, capacity, diskinfo); 1288 1289 else 1289 - scsicam_bios_param(bdev, sdkp->capacity, diskinfo); 1290 + scsicam_bios_param(bdev, capacity, diskinfo); 1290 1291 1291 1292 geo->heads = diskinfo[0]; 1292 1293 geo->sectors = diskinfo[1]; ··· 2338 2337 if (sdkp->capacity > 0xffffffff) 2339 2338 sdp->use_16_for_rw = 1; 2340 2339 2341 - /* Rescale capacity to 512-byte units */ 2342 - if (sector_size == 4096) 2343 - sdkp->capacity <<= 3; 2344 - else if (sector_size == 2048) 2345 - sdkp->capacity <<= 2; 2346 - else if (sector_size == 1024) 2347 - sdkp->capacity <<= 1; 2348 - 2349 2340 blk_queue_physical_block_size(sdp->request_queue, 2350 2341 sdkp->physical_block_size); 2351 2342 sdkp->device->sector_size = sector_size; ··· 2788 2795 sdkp->ws10 = 1; 2789 2796 } 2790 2797 2791 - static int sd_try_extended_inquiry(struct scsi_device *sdp) 2792 - { 2793 - /* Attempt VPD inquiry if the device blacklist explicitly calls 2794 - * for it. 2795 - */ 2796 - if (sdp->try_vpd_pages) 2797 - return 1; 2798 - /* 2799 - * Although VPD inquiries can go to SCSI-2 type devices, 2800 - * some USB ones crash on receiving them, and the pages 2801 - * we currently ask for are for SPC-3 and beyond 2802 - */ 2803 - if (sdp->scsi_level > SCSI_SPC_2 && !sdp->skip_vpd_pages) 2804 - return 1; 2805 - return 0; 2806 - } 2807 - 2808 - static inline u32 logical_to_sectors(struct scsi_device *sdev, u32 blocks) 2809 - { 2810 - return blocks << (ilog2(sdev->sector_size) - 9); 2811 - } 2812 - 2813 2798 /** 2814 2799 * sd_revalidate_disk - called the first time a new disk is seen, 2815 2800 * performs disk spin up, read_capacity, etc. ··· 2827 2856 if (sdkp->media_present) { 2828 2857 sd_read_capacity(sdkp, buffer); 2829 2858 2830 - if (sd_try_extended_inquiry(sdp)) { 2859 + if (scsi_device_supports_vpd(sdp)) { 2831 2860 sd_read_block_provisioning(sdkp); 2832 2861 sd_read_block_limits(sdkp); 2833 2862 sd_read_block_characteristics(sdkp); ··· 2871 2900 /* Combine with controller limits */ 2872 2901 q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q)); 2873 2902 2874 - set_capacity(disk, sdkp->capacity); 2903 + set_capacity(disk, logical_to_sectors(sdp, sdkp->capacity)); 2875 2904 sd_config_write_same(sdkp); 2876 2905 kfree(buffer); 2877 2906
+6 -1
drivers/scsi/sd.h
··· 65 65 struct device dev; 66 66 struct gendisk *disk; 67 67 atomic_t openers; 68 - sector_t capacity; /* size in 512-byte sectors */ 68 + sector_t capacity; /* size in logical blocks */ 69 69 u32 max_xfer_blocks; 70 70 u32 opt_xfer_blocks; 71 71 u32 max_ws_blocks; ··· 144 144 } 145 145 146 146 return 0; 147 + } 148 + 149 + static inline sector_t logical_to_sectors(struct scsi_device *sdev, sector_t blocks) 150 + { 151 + return blocks << (ilog2(sdev->sector_size) - 9); 147 152 } 148 153 149 154 /*
+25
include/scsi/scsi_device.h
··· 516 516 return sdev->inquiry ? (sdev->inquiry[5] >> 4) & 0x3 : 0; 517 517 } 518 518 519 + /** 520 + * scsi_device_supports_vpd - test if a device supports VPD pages 521 + * @sdev: the &struct scsi_device to test 522 + * 523 + * If the 'try_vpd_pages' flag is set it takes precedence. 524 + * Otherwise we will assume VPD pages are supported if the 525 + * SCSI level is at least SPC-3 and 'skip_vpd_pages' is not set. 526 + */ 527 + static inline int scsi_device_supports_vpd(struct scsi_device *sdev) 528 + { 529 + /* Attempt VPD inquiry if the device blacklist explicitly calls 530 + * for it. 531 + */ 532 + if (sdev->try_vpd_pages) 533 + return 1; 534 + /* 535 + * Although VPD inquiries can go to SCSI-2 type devices, 536 + * some USB ones crash on receiving them, and the pages 537 + * we currently ask for are for SPC-3 and beyond 538 + */ 539 + if (sdev->scsi_level > SCSI_SPC_2 && !sdev->skip_vpd_pages) 540 + return 1; 541 + return 0; 542 + } 543 + 519 544 #define MODULE_ALIAS_SCSI_DEVICE(type) \ 520 545 MODULE_ALIAS("scsi:t-" __stringify(type) "*") 521 546 #define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x"