diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-04-09 15:00:42 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-04-09 15:00:42 -0400 |
commit | fb41b4be00270f5b28784a31a458a4dcf4519b9e (patch) | |
tree | 0b290e379051e4e1db71e63ed5dc1e943379fb1b | |
parent | 63b106a87dd84283e21aa2ce476732633eaab11d (diff) | |
parent | 6ea7e3873e52902af9ee8c0837450fdb69d54140 (diff) |
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
-rw-r--r-- | drivers/scsi/aacraid/linit.c | 3 | ||||
-rw-r--r-- | drivers/scsi/cxlflash/main.c | 138 | ||||
-rw-r--r-- | drivers/scsi/cxlflash/main.h | 5 | ||||
-rw-r--r-- | drivers/scsi/device_handler/scsi_dh_alua.c | 4 | ||||
-rw-r--r-- | drivers/scsi/mpt3sas/mpt3sas_base.c | 33 | ||||
-rw-r--r-- | drivers/scsi/scsi.c | 3 | ||||
-rw-r--r-- | drivers/scsi/scsi_sysfs.c | 8 | ||||
-rw-r--r-- | drivers/scsi/sd.c | 47 | ||||
-rw-r--r-- | drivers/scsi/sd.h | 7 | ||||
-rw-r--r-- | include/scsi/scsi_device.h | 25 |
10 files changed, 164 insertions, 109 deletions
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 21a67ed047e8..ff6caab8cc8b 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c | |||
@@ -452,10 +452,11 @@ static int aac_slave_configure(struct scsi_device *sdev) | |||
452 | else if (depth < 2) | 452 | else if (depth < 2) |
453 | depth = 2; | 453 | depth = 2; |
454 | scsi_change_queue_depth(sdev, depth); | 454 | scsi_change_queue_depth(sdev, depth); |
455 | } else | 455 | } else { |
456 | scsi_change_queue_depth(sdev, 1); | 456 | scsi_change_queue_depth(sdev, 1); |
457 | 457 | ||
458 | sdev->tagged_supported = 1; | 458 | sdev->tagged_supported = 1; |
459 | } | ||
459 | 460 | ||
460 | return 0; | 461 | return 0; |
461 | } | 462 | } |
diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 35968bdb4866..8fb9643fe6e3 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c | |||
@@ -289,7 +289,7 @@ static void context_reset(struct afu_cmd *cmd) | |||
289 | atomic64_set(&afu->room, room); | 289 | atomic64_set(&afu->room, room); |
290 | if (room) | 290 | if (room) |
291 | goto write_rrin; | 291 | goto write_rrin; |
292 | udelay(nretry); | 292 | udelay(1 << nretry); |
293 | } while (nretry++ < MC_ROOM_RETRY_CNT); | 293 | } while (nretry++ < MC_ROOM_RETRY_CNT); |
294 | 294 | ||
295 | pr_err("%s: no cmd_room to send reset\n", __func__); | 295 | pr_err("%s: no cmd_room to send reset\n", __func__); |
@@ -303,7 +303,7 @@ write_rrin: | |||
303 | if (rrin != 0x1) | 303 | if (rrin != 0x1) |
304 | break; | 304 | break; |
305 | /* Double delay each time */ | 305 | /* Double delay each time */ |
306 | udelay(2 << nretry); | 306 | udelay(1 << nretry); |
307 | } while (nretry++ < MC_ROOM_RETRY_CNT); | 307 | } while (nretry++ < MC_ROOM_RETRY_CNT); |
308 | } | 308 | } |
309 | 309 | ||
@@ -338,7 +338,7 @@ retry: | |||
338 | atomic64_set(&afu->room, room); | 338 | atomic64_set(&afu->room, room); |
339 | if (room) | 339 | if (room) |
340 | goto write_ioarrin; | 340 | goto write_ioarrin; |
341 | udelay(nretry); | 341 | udelay(1 << nretry); |
342 | } while (nretry++ < MC_ROOM_RETRY_CNT); | 342 | } while (nretry++ < MC_ROOM_RETRY_CNT); |
343 | 343 | ||
344 | dev_err(dev, "%s: no cmd_room to send 0x%X\n", | 344 | dev_err(dev, "%s: no cmd_room to send 0x%X\n", |
@@ -352,7 +352,7 @@ retry: | |||
352 | * afu->room. | 352 | * afu->room. |
353 | */ | 353 | */ |
354 | if (nretry++ < MC_ROOM_RETRY_CNT) { | 354 | if (nretry++ < MC_ROOM_RETRY_CNT) { |
355 | udelay(nretry); | 355 | udelay(1 << nretry); |
356 | goto retry; | 356 | goto retry; |
357 | } | 357 | } |
358 | 358 | ||
@@ -683,28 +683,23 @@ static void stop_afu(struct cxlflash_cfg *cfg) | |||
683 | } | 683 | } |
684 | 684 | ||
685 | /** | 685 | /** |
686 | * term_mc() - terminates the master context | 686 | * term_intr() - disables all AFU interrupts |
687 | * @cfg: Internal structure associated with the host. | 687 | * @cfg: Internal structure associated with the host. |
688 | * @level: Depth of allocation, where to begin waterfall tear down. | 688 | * @level: Depth of allocation, where to begin waterfall tear down. |
689 | * | 689 | * |
690 | * Safe to call with AFU/MC in partially allocated/initialized state. | 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 | struct afu *afu = cfg->afu; | 694 | struct afu *afu = cfg->afu; |
696 | struct device *dev = &cfg->dev->dev; | 695 | struct device *dev = &cfg->dev->dev; |
697 | 696 | ||
698 | if (!afu || !cfg->mcctx) { | 697 | if (!afu || !cfg->mcctx) { |
699 | dev_err(dev, "%s: returning from term_mc with NULL afu or MC\n", | 698 | dev_err(dev, "%s: returning with NULL afu or MC\n", __func__); |
700 | __func__); | ||
701 | return; | 699 | return; |
702 | } | 700 | } |
703 | 701 | ||
704 | switch (level) { | 702 | switch (level) { |
705 | case UNDO_START: | ||
706 | rc = cxl_stop_context(cfg->mcctx); | ||
707 | BUG_ON(rc); | ||
708 | case UNMAP_THREE: | 703 | case UNMAP_THREE: |
709 | cxl_unmap_afu_irq(cfg->mcctx, 3, afu); | 704 | cxl_unmap_afu_irq(cfg->mcctx, 3, afu); |
710 | case UNMAP_TWO: | 705 | case UNMAP_TWO: |
@@ -713,9 +708,34 @@ static void term_mc(struct cxlflash_cfg *cfg, enum undo_level level) | |||
713 | cxl_unmap_afu_irq(cfg->mcctx, 1, afu); | 708 | cxl_unmap_afu_irq(cfg->mcctx, 1, afu); |
714 | case FREE_IRQ: | 709 | case FREE_IRQ: |
715 | cxl_free_afu_irqs(cfg->mcctx); | 710 | cxl_free_afu_irqs(cfg->mcctx); |
716 | case RELEASE_CONTEXT: | 711 | /* fall through */ |
717 | cfg->mcctx = NULL; | 712 | case UNDO_NOOP: |
713 | /* No action required */ | ||
714 | break; | ||
715 | } | ||
716 | } | ||
717 | |||
718 | /** | ||
719 | * term_mc() - terminates the master context | ||
720 | * @cfg: Internal structure associated with the host. | ||
721 | * @level: Depth of allocation, where to begin waterfall tear down. | ||
722 | * | ||
723 | * Safe to call with AFU/MC in partially allocated/initialized state. | ||
724 | */ | ||
725 | static void term_mc(struct cxlflash_cfg *cfg) | ||
726 | { | ||
727 | int rc = 0; | ||
728 | struct afu *afu = cfg->afu; | ||
729 | struct device *dev = &cfg->dev->dev; | ||
730 | |||
731 | if (!afu || !cfg->mcctx) { | ||
732 | dev_err(dev, "%s: returning with NULL afu or MC\n", __func__); | ||
733 | return; | ||
718 | } | 734 | } |
735 | |||
736 | rc = cxl_stop_context(cfg->mcctx); | ||
737 | WARN_ON(rc); | ||
738 | cfg->mcctx = NULL; | ||
719 | } | 739 | } |
720 | 740 | ||
721 | /** | 741 | /** |
@@ -726,10 +746,20 @@ static void term_mc(struct cxlflash_cfg *cfg, enum undo_level level) | |||
726 | */ | 746 | */ |
727 | static void term_afu(struct cxlflash_cfg *cfg) | 747 | static void term_afu(struct cxlflash_cfg *cfg) |
728 | { | 748 | { |
749 | /* | ||
750 | * Tear down is carefully orchestrated to ensure | ||
751 | * no interrupts can come in when the problem state | ||
752 | * area is unmapped. | ||
753 | * | ||
754 | * 1) Disable all AFU interrupts | ||
755 | * 2) Unmap the problem state area | ||
756 | * 3) Stop the master context | ||
757 | */ | ||
758 | term_intr(cfg, UNMAP_THREE); | ||
729 | if (cfg->afu) | 759 | if (cfg->afu) |
730 | stop_afu(cfg); | 760 | stop_afu(cfg); |
731 | 761 | ||
732 | term_mc(cfg, UNDO_START); | 762 | term_mc(cfg); |
733 | 763 | ||
734 | pr_debug("%s: returning\n", __func__); | 764 | pr_debug("%s: returning\n", __func__); |
735 | } | 765 | } |
@@ -1597,41 +1627,24 @@ static int start_afu(struct cxlflash_cfg *cfg) | |||
1597 | } | 1627 | } |
1598 | 1628 | ||
1599 | /** | 1629 | /** |
1600 | * init_mc() - create and register as the master context | 1630 | * init_intr() - setup interrupt handlers for the master context |
1601 | * @cfg: Internal structure associated with the host. | 1631 | * @cfg: Internal structure associated with the host. |
1602 | * | 1632 | * |
1603 | * Return: 0 on success, -errno on failure | 1633 | * Return: 0 on success, -errno on failure |
1604 | */ | 1634 | */ |
1605 | static int init_mc(struct cxlflash_cfg *cfg) | 1635 | static enum undo_level init_intr(struct cxlflash_cfg *cfg, |
1636 | struct cxl_context *ctx) | ||
1606 | { | 1637 | { |
1607 | struct cxl_context *ctx; | ||
1608 | struct device *dev = &cfg->dev->dev; | ||
1609 | struct afu *afu = cfg->afu; | 1638 | struct afu *afu = cfg->afu; |
1639 | struct device *dev = &cfg->dev->dev; | ||
1610 | int rc = 0; | 1640 | int rc = 0; |
1611 | enum undo_level level; | 1641 | enum undo_level level = UNDO_NOOP; |
1612 | |||
1613 | ctx = cxl_get_context(cfg->dev); | ||
1614 | if (unlikely(!ctx)) | ||
1615 | return -ENOMEM; | ||
1616 | cfg->mcctx = ctx; | ||
1617 | |||
1618 | /* Set it up as a master with the CXL */ | ||
1619 | cxl_set_master(ctx); | ||
1620 | |||
1621 | /* During initialization reset the AFU to start from a clean slate */ | ||
1622 | rc = cxl_afu_reset(cfg->mcctx); | ||
1623 | if (unlikely(rc)) { | ||
1624 | dev_err(dev, "%s: initial AFU reset failed rc=%d\n", | ||
1625 | __func__, rc); | ||
1626 | level = RELEASE_CONTEXT; | ||
1627 | goto out; | ||
1628 | } | ||
1629 | 1642 | ||
1630 | rc = cxl_allocate_afu_irqs(ctx, 3); | 1643 | rc = cxl_allocate_afu_irqs(ctx, 3); |
1631 | if (unlikely(rc)) { | 1644 | if (unlikely(rc)) { |
1632 | dev_err(dev, "%s: call to allocate_afu_irqs failed rc=%d!\n", | 1645 | dev_err(dev, "%s: call to allocate_afu_irqs failed rc=%d!\n", |
1633 | __func__, rc); | 1646 | __func__, rc); |
1634 | level = RELEASE_CONTEXT; | 1647 | level = UNDO_NOOP; |
1635 | goto out; | 1648 | goto out; |
1636 | } | 1649 | } |
1637 | 1650 | ||
@@ -1661,8 +1674,47 @@ static int init_mc(struct cxlflash_cfg *cfg) | |||
1661 | level = UNMAP_TWO; | 1674 | level = UNMAP_TWO; |
1662 | goto out; | 1675 | goto out; |
1663 | } | 1676 | } |
1677 | out: | ||
1678 | return level; | ||
1679 | } | ||
1664 | 1680 | ||
1665 | rc = 0; | 1681 | /** |
1682 | * init_mc() - create and register as the master context | ||
1683 | * @cfg: Internal structure associated with the host. | ||
1684 | * | ||
1685 | * Return: 0 on success, -errno on failure | ||
1686 | */ | ||
1687 | static int init_mc(struct cxlflash_cfg *cfg) | ||
1688 | { | ||
1689 | struct cxl_context *ctx; | ||
1690 | struct device *dev = &cfg->dev->dev; | ||
1691 | int rc = 0; | ||
1692 | enum undo_level level; | ||
1693 | |||
1694 | ctx = cxl_get_context(cfg->dev); | ||
1695 | if (unlikely(!ctx)) { | ||
1696 | rc = -ENOMEM; | ||
1697 | goto ret; | ||
1698 | } | ||
1699 | cfg->mcctx = ctx; | ||
1700 | |||
1701 | /* Set it up as a master with the CXL */ | ||
1702 | cxl_set_master(ctx); | ||
1703 | |||
1704 | /* During initialization reset the AFU to start from a clean slate */ | ||
1705 | rc = cxl_afu_reset(cfg->mcctx); | ||
1706 | if (unlikely(rc)) { | ||
1707 | dev_err(dev, "%s: initial AFU reset failed rc=%d\n", | ||
1708 | __func__, rc); | ||
1709 | goto ret; | ||
1710 | } | ||
1711 | |||
1712 | level = init_intr(cfg, ctx); | ||
1713 | if (unlikely(level)) { | ||
1714 | dev_err(dev, "%s: setting up interrupts failed rc=%d\n", | ||
1715 | __func__, rc); | ||
1716 | goto out; | ||
1717 | } | ||
1666 | 1718 | ||
1667 | /* This performs the equivalent of the CXL_IOCTL_START_WORK. | 1719 | /* This performs the equivalent of the CXL_IOCTL_START_WORK. |
1668 | * The CXL_IOCTL_GET_PROCESS_ELEMENT is implicit in the process | 1720 | * The CXL_IOCTL_GET_PROCESS_ELEMENT is implicit in the process |
@@ -1678,7 +1730,7 @@ ret: | |||
1678 | pr_debug("%s: returning rc=%d\n", __func__, rc); | 1730 | pr_debug("%s: returning rc=%d\n", __func__, rc); |
1679 | return rc; | 1731 | return rc; |
1680 | out: | 1732 | out: |
1681 | term_mc(cfg, level); | 1733 | term_intr(cfg, level); |
1682 | goto ret; | 1734 | goto ret; |
1683 | } | 1735 | } |
1684 | 1736 | ||
@@ -1751,7 +1803,8 @@ out: | |||
1751 | err2: | 1803 | err2: |
1752 | kref_put(&afu->mapcount, afu_unmap); | 1804 | kref_put(&afu->mapcount, afu_unmap); |
1753 | err1: | 1805 | err1: |
1754 | term_mc(cfg, UNDO_START); | 1806 | term_intr(cfg, UNMAP_THREE); |
1807 | term_mc(cfg); | ||
1755 | goto out; | 1808 | goto out; |
1756 | } | 1809 | } |
1757 | 1810 | ||
@@ -2488,8 +2541,7 @@ static pci_ers_result_t cxlflash_pci_error_detected(struct pci_dev *pdev, | |||
2488 | if (unlikely(rc)) | 2541 | if (unlikely(rc)) |
2489 | dev_err(dev, "%s: Failed to mark user contexts!(%d)\n", | 2542 | dev_err(dev, "%s: Failed to mark user contexts!(%d)\n", |
2490 | __func__, rc); | 2543 | __func__, rc); |
2491 | stop_afu(cfg); | 2544 | term_afu(cfg); |
2492 | term_mc(cfg, UNDO_START); | ||
2493 | return PCI_ERS_RESULT_NEED_RESET; | 2545 | return PCI_ERS_RESULT_NEED_RESET; |
2494 | case pci_channel_io_perm_failure: | 2546 | case pci_channel_io_perm_failure: |
2495 | cfg->state = STATE_FAILTERM; | 2547 | cfg->state = STATE_FAILTERM; |
diff --git a/drivers/scsi/cxlflash/main.h b/drivers/scsi/cxlflash/main.h index 0faed422c7f4..eb9d8f730b38 100644 --- a/drivers/scsi/cxlflash/main.h +++ b/drivers/scsi/cxlflash/main.h | |||
@@ -79,12 +79,11 @@ | |||
79 | #define WWPN_BUF_LEN (WWPN_LEN + 1) | 79 | #define WWPN_BUF_LEN (WWPN_LEN + 1) |
80 | 80 | ||
81 | enum undo_level { | 81 | enum undo_level { |
82 | RELEASE_CONTEXT = 0, | 82 | UNDO_NOOP = 0, |
83 | FREE_IRQ, | 83 | FREE_IRQ, |
84 | UNMAP_ONE, | 84 | UNMAP_ONE, |
85 | UNMAP_TWO, | 85 | UNMAP_TWO, |
86 | UNMAP_THREE, | 86 | UNMAP_THREE |
87 | UNDO_START | ||
88 | }; | 87 | }; |
89 | 88 | ||
90 | struct dev_dependent_vals { | 89 | struct dev_dependent_vals { |
diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c index a404a41e871c..8eaed0522aa3 100644 --- a/drivers/scsi/device_handler/scsi_dh_alua.c +++ b/drivers/scsi/device_handler/scsi_dh_alua.c | |||
@@ -1112,9 +1112,9 @@ static void alua_bus_detach(struct scsi_device *sdev) | |||
1112 | h->sdev = NULL; | 1112 | h->sdev = NULL; |
1113 | spin_unlock(&h->pg_lock); | 1113 | spin_unlock(&h->pg_lock); |
1114 | if (pg) { | 1114 | if (pg) { |
1115 | spin_lock(&pg->lock); | 1115 | spin_lock_irq(&pg->lock); |
1116 | list_del_rcu(&h->node); | 1116 | list_del_rcu(&h->node); |
1117 | spin_unlock(&pg->lock); | 1117 | spin_unlock_irq(&pg->lock); |
1118 | kref_put(&pg->kref, release_port_group); | 1118 | kref_put(&pg->kref, release_port_group); |
1119 | } | 1119 | } |
1120 | sdev->handler_data = NULL; | 1120 | sdev->handler_data = NULL; |
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index e4db5fb3239a..8c44b9c424af 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c | |||
@@ -5030,7 +5030,7 @@ _base_make_ioc_ready(struct MPT3SAS_ADAPTER *ioc, int sleep_flag, | |||
5030 | static int | 5030 | static int |
5031 | _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | 5031 | _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) |
5032 | { | 5032 | { |
5033 | int r, i; | 5033 | int r, i, index; |
5034 | unsigned long flags; | 5034 | unsigned long flags; |
5035 | u32 reply_address; | 5035 | u32 reply_address; |
5036 | u16 smid; | 5036 | u16 smid; |
@@ -5039,8 +5039,7 @@ _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | |||
5039 | struct _event_ack_list *delayed_event_ack, *delayed_event_ack_next; | 5039 | struct _event_ack_list *delayed_event_ack, *delayed_event_ack_next; |
5040 | u8 hide_flag; | 5040 | u8 hide_flag; |
5041 | struct adapter_reply_queue *reply_q; | 5041 | struct adapter_reply_queue *reply_q; |
5042 | long reply_post_free; | 5042 | Mpi2ReplyDescriptorsUnion_t *reply_post_free_contig; |
5043 | u32 reply_post_free_sz, index = 0; | ||
5044 | 5043 | ||
5045 | dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, | 5044 | dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, |
5046 | __func__)); | 5045 | __func__)); |
@@ -5124,27 +5123,27 @@ _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | |||
5124 | _base_assign_reply_queues(ioc); | 5123 | _base_assign_reply_queues(ioc); |
5125 | 5124 | ||
5126 | /* initialize Reply Post Free Queue */ | 5125 | /* initialize Reply Post Free Queue */ |
5127 | reply_post_free_sz = ioc->reply_post_queue_depth * | 5126 | index = 0; |
5128 | sizeof(Mpi2DefaultReplyDescriptor_t); | 5127 | reply_post_free_contig = ioc->reply_post[0].reply_post_free; |
5129 | reply_post_free = (long)ioc->reply_post[index].reply_post_free; | ||
5130 | list_for_each_entry(reply_q, &ioc->reply_queue_list, list) { | 5128 | list_for_each_entry(reply_q, &ioc->reply_queue_list, list) { |
5129 | /* | ||
5130 | * If RDPQ is enabled, switch to the next allocation. | ||
5131 | * Otherwise advance within the contiguous region. | ||
5132 | */ | ||
5133 | if (ioc->rdpq_array_enable) { | ||
5134 | reply_q->reply_post_free = | ||
5135 | ioc->reply_post[index++].reply_post_free; | ||
5136 | } else { | ||
5137 | reply_q->reply_post_free = reply_post_free_contig; | ||
5138 | reply_post_free_contig += ioc->reply_post_queue_depth; | ||
5139 | } | ||
5140 | |||
5131 | reply_q->reply_post_host_index = 0; | 5141 | reply_q->reply_post_host_index = 0; |
5132 | reply_q->reply_post_free = (Mpi2ReplyDescriptorsUnion_t *) | ||
5133 | reply_post_free; | ||
5134 | for (i = 0; i < ioc->reply_post_queue_depth; i++) | 5142 | for (i = 0; i < ioc->reply_post_queue_depth; i++) |
5135 | reply_q->reply_post_free[i].Words = | 5143 | reply_q->reply_post_free[i].Words = |
5136 | cpu_to_le64(ULLONG_MAX); | 5144 | cpu_to_le64(ULLONG_MAX); |
5137 | if (!_base_is_controller_msix_enabled(ioc)) | 5145 | if (!_base_is_controller_msix_enabled(ioc)) |
5138 | goto skip_init_reply_post_free_queue; | 5146 | goto skip_init_reply_post_free_queue; |
5139 | /* | ||
5140 | * If RDPQ is enabled, switch to the next allocation. | ||
5141 | * Otherwise advance within the contiguous region. | ||
5142 | */ | ||
5143 | if (ioc->rdpq_array_enable) | ||
5144 | reply_post_free = (long) | ||
5145 | ioc->reply_post[++index].reply_post_free; | ||
5146 | else | ||
5147 | reply_post_free += reply_post_free_sz; | ||
5148 | } | 5147 | } |
5149 | skip_init_reply_post_free_queue: | 5148 | skip_init_reply_post_free_queue: |
5150 | 5149 | ||
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index b1bf42b93fcc..1deb6adc411f 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c | |||
@@ -784,8 +784,9 @@ void scsi_attach_vpd(struct scsi_device *sdev) | |||
784 | int pg83_supported = 0; | 784 | int pg83_supported = 0; |
785 | unsigned char __rcu *vpd_buf, *orig_vpd_buf = NULL; | 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 | return; | 788 | return; |
789 | |||
789 | retry_pg0: | 790 | retry_pg0: |
790 | vpd_buf = kmalloc(vpd_len, GFP_KERNEL); | 791 | vpd_buf = kmalloc(vpd_len, GFP_KERNEL); |
791 | if (!vpd_buf) | 792 | if (!vpd_buf) |
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 92ffd2406f97..2b642b145be1 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c | |||
@@ -81,6 +81,7 @@ const char *scsi_host_state_name(enum scsi_host_state state) | |||
81 | return name; | 81 | return name; |
82 | } | 82 | } |
83 | 83 | ||
84 | #ifdef CONFIG_SCSI_DH | ||
84 | static const struct { | 85 | static const struct { |
85 | unsigned char value; | 86 | unsigned char value; |
86 | char *name; | 87 | char *name; |
@@ -94,7 +95,7 @@ static const struct { | |||
94 | { SCSI_ACCESS_STATE_TRANSITIONING, "transitioning" }, | 95 | { SCSI_ACCESS_STATE_TRANSITIONING, "transitioning" }, |
95 | }; | 96 | }; |
96 | 97 | ||
97 | const char *scsi_access_state_name(unsigned char state) | 98 | static const char *scsi_access_state_name(unsigned char state) |
98 | { | 99 | { |
99 | int i; | 100 | int i; |
100 | char *name = NULL; | 101 | char *name = NULL; |
@@ -107,6 +108,7 @@ const char *scsi_access_state_name(unsigned char state) | |||
107 | } | 108 | } |
108 | return name; | 109 | return name; |
109 | } | 110 | } |
111 | #endif | ||
110 | 112 | ||
111 | static int check_set(unsigned long long *val, char *src) | 113 | static int check_set(unsigned long long *val, char *src) |
112 | { | 114 | { |
@@ -226,7 +228,7 @@ show_shost_state(struct device *dev, struct device_attribute *attr, char *buf) | |||
226 | } | 228 | } |
227 | 229 | ||
228 | /* DEVICE_ATTR(state) clashes with dev_attr_state for sdev */ | 230 | /* DEVICE_ATTR(state) clashes with dev_attr_state for sdev */ |
229 | struct device_attribute dev_attr_hstate = | 231 | static struct device_attribute dev_attr_hstate = |
230 | __ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state); | 232 | __ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state); |
231 | 233 | ||
232 | static ssize_t | 234 | static ssize_t |
@@ -401,7 +403,7 @@ static struct attribute *scsi_sysfs_shost_attrs[] = { | |||
401 | NULL | 403 | NULL |
402 | }; | 404 | }; |
403 | 405 | ||
404 | struct attribute_group scsi_shost_attr_group = { | 406 | static struct attribute_group scsi_shost_attr_group = { |
405 | .attrs = scsi_sysfs_shost_attrs, | 407 | .attrs = scsi_sysfs_shost_attrs, |
406 | }; | 408 | }; |
407 | 409 | ||
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 1bd0753f678a..f52b74cf8d1e 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -1275,18 +1275,19 @@ static int sd_getgeo(struct block_device *bdev, struct hd_geometry *geo) | |||
1275 | struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk); | 1275 | struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk); |
1276 | struct scsi_device *sdp = sdkp->device; | 1276 | struct scsi_device *sdp = sdkp->device; |
1277 | struct Scsi_Host *host = sdp->host; | 1277 | struct Scsi_Host *host = sdp->host; |
1278 | sector_t capacity = logical_to_sectors(sdp, sdkp->capacity); | ||
1278 | int diskinfo[4]; | 1279 | int diskinfo[4]; |
1279 | 1280 | ||
1280 | /* default to most commonly used values */ | 1281 | /* default to most commonly used values */ |
1281 | diskinfo[0] = 0x40; /* 1 << 6 */ | 1282 | diskinfo[0] = 0x40; /* 1 << 6 */ |
1282 | diskinfo[1] = 0x20; /* 1 << 5 */ | 1283 | diskinfo[1] = 0x20; /* 1 << 5 */ |
1283 | diskinfo[2] = sdkp->capacity >> 11; | 1284 | diskinfo[2] = capacity >> 11; |
1284 | 1285 | ||
1285 | /* override with calculated, extended default, or driver values */ | 1286 | /* override with calculated, extended default, or driver values */ |
1286 | if (host->hostt->bios_param) | 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 | else | 1289 | else |
1289 | scsicam_bios_param(bdev, sdkp->capacity, diskinfo); | 1290 | scsicam_bios_param(bdev, capacity, diskinfo); |
1290 | 1291 | ||
1291 | geo->heads = diskinfo[0]; | 1292 | geo->heads = diskinfo[0]; |
1292 | geo->sectors = diskinfo[1]; | 1293 | geo->sectors = diskinfo[1]; |
@@ -2337,14 +2338,6 @@ got_data: | |||
2337 | if (sdkp->capacity > 0xffffffff) | 2338 | if (sdkp->capacity > 0xffffffff) |
2338 | sdp->use_16_for_rw = 1; | 2339 | sdp->use_16_for_rw = 1; |
2339 | 2340 | ||
2340 | /* Rescale capacity to 512-byte units */ | ||
2341 | if (sector_size == 4096) | ||
2342 | sdkp->capacity <<= 3; | ||
2343 | else if (sector_size == 2048) | ||
2344 | sdkp->capacity <<= 2; | ||
2345 | else if (sector_size == 1024) | ||
2346 | sdkp->capacity <<= 1; | ||
2347 | |||
2348 | blk_queue_physical_block_size(sdp->request_queue, | 2341 | blk_queue_physical_block_size(sdp->request_queue, |
2349 | sdkp->physical_block_size); | 2342 | sdkp->physical_block_size); |
2350 | sdkp->device->sector_size = sector_size; | 2343 | sdkp->device->sector_size = sector_size; |
@@ -2795,28 +2788,6 @@ static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer) | |||
2795 | sdkp->ws10 = 1; | 2788 | sdkp->ws10 = 1; |
2796 | } | 2789 | } |
2797 | 2790 | ||
2798 | static int sd_try_extended_inquiry(struct scsi_device *sdp) | ||
2799 | { | ||
2800 | /* Attempt VPD inquiry if the device blacklist explicitly calls | ||
2801 | * for it. | ||
2802 | */ | ||
2803 | if (sdp->try_vpd_pages) | ||
2804 | return 1; | ||
2805 | /* | ||
2806 | * Although VPD inquiries can go to SCSI-2 type devices, | ||
2807 | * some USB ones crash on receiving them, and the pages | ||
2808 | * we currently ask for are for SPC-3 and beyond | ||
2809 | */ | ||
2810 | if (sdp->scsi_level > SCSI_SPC_2 && !sdp->skip_vpd_pages) | ||
2811 | return 1; | ||
2812 | return 0; | ||
2813 | } | ||
2814 | |||
2815 | static inline u32 logical_to_sectors(struct scsi_device *sdev, u32 blocks) | ||
2816 | { | ||
2817 | return blocks << (ilog2(sdev->sector_size) - 9); | ||
2818 | } | ||
2819 | |||
2820 | /** | 2791 | /** |
2821 | * sd_revalidate_disk - called the first time a new disk is seen, | 2792 | * sd_revalidate_disk - called the first time a new disk is seen, |
2822 | * performs disk spin up, read_capacity, etc. | 2793 | * performs disk spin up, read_capacity, etc. |
@@ -2856,7 +2827,7 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
2856 | if (sdkp->media_present) { | 2827 | if (sdkp->media_present) { |
2857 | sd_read_capacity(sdkp, buffer); | 2828 | sd_read_capacity(sdkp, buffer); |
2858 | 2829 | ||
2859 | if (sd_try_extended_inquiry(sdp)) { | 2830 | if (scsi_device_supports_vpd(sdp)) { |
2860 | sd_read_block_provisioning(sdkp); | 2831 | sd_read_block_provisioning(sdkp); |
2861 | sd_read_block_limits(sdkp); | 2832 | sd_read_block_limits(sdkp); |
2862 | sd_read_block_characteristics(sdkp); | 2833 | sd_read_block_characteristics(sdkp); |
@@ -2900,7 +2871,7 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
2900 | /* Combine with controller limits */ | 2871 | /* Combine with controller limits */ |
2901 | q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q)); | 2872 | q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q)); |
2902 | 2873 | ||
2903 | set_capacity(disk, sdkp->capacity); | 2874 | set_capacity(disk, logical_to_sectors(sdp, sdkp->capacity)); |
2904 | sd_config_write_same(sdkp); | 2875 | sd_config_write_same(sdkp); |
2905 | kfree(buffer); | 2876 | kfree(buffer); |
2906 | 2877 | ||
diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h index 5f2a84aff29f..654630bb7d0e 100644 --- a/drivers/scsi/sd.h +++ b/drivers/scsi/sd.h | |||
@@ -65,7 +65,7 @@ struct scsi_disk { | |||
65 | struct device dev; | 65 | struct device dev; |
66 | struct gendisk *disk; | 66 | struct gendisk *disk; |
67 | atomic_t openers; | 67 | atomic_t openers; |
68 | sector_t capacity; /* size in 512-byte sectors */ | 68 | sector_t capacity; /* size in logical blocks */ |
69 | u32 max_xfer_blocks; | 69 | u32 max_xfer_blocks; |
70 | u32 opt_xfer_blocks; | 70 | u32 opt_xfer_blocks; |
71 | u32 max_ws_blocks; | 71 | u32 max_ws_blocks; |
@@ -146,6 +146,11 @@ static inline int scsi_medium_access_command(struct scsi_cmnd *scmd) | |||
146 | return 0; | 146 | return 0; |
147 | } | 147 | } |
148 | 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); | ||
152 | } | ||
153 | |||
149 | /* | 154 | /* |
150 | * A DIF-capable target device can be formatted with different | 155 | * A DIF-capable target device can be formatted with different |
151 | * protection schemes. Currently 0 through 3 are defined: | 156 | * protection schemes. Currently 0 through 3 are defined: |
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index c067019ed12a..74d79bde7075 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h | |||
@@ -516,6 +516,31 @@ static inline int scsi_device_tpgs(struct scsi_device *sdev) | |||
516 | return sdev->inquiry ? (sdev->inquiry[5] >> 4) & 0x3 : 0; | 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 | #define MODULE_ALIAS_SCSI_DEVICE(type) \ | 544 | #define MODULE_ALIAS_SCSI_DEVICE(type) \ |
520 | MODULE_ALIAS("scsi:t-" __stringify(type) "*") | 545 | MODULE_ALIAS("scsi:t-" __stringify(type) "*") |
521 | #define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x" | 546 | #define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x" |