Skip to content

Commit fb41b4b

Browse files
committed
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
2 parents 63b106a + 6ea7e38 commit fb41b4b

File tree

10 files changed

+164
-109
lines changed

10 files changed

+164
-109
lines changed

drivers/scsi/aacraid/linit.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,11 @@ static int aac_slave_configure(struct scsi_device *sdev)
452452
else if (depth < 2)
453453
depth = 2;
454454
scsi_change_queue_depth(sdev, depth);
455-
} else
455+
} else {
456456
scsi_change_queue_depth(sdev, 1);
457457

458458
sdev->tagged_supported = 1;
459+
}
459460

460461
return 0;
461462
}

drivers/scsi/cxlflash/main.c

Lines changed: 95 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static void context_reset(struct afu_cmd *cmd)
289289
atomic64_set(&afu->room, room);
290290
if (room)
291291
goto write_rrin;
292-
udelay(nretry);
292+
udelay(1 << nretry);
293293
} while (nretry++ < MC_ROOM_RETRY_CNT);
294294

295295
pr_err("%s: no cmd_room to send reset\n", __func__);
@@ -303,7 +303,7 @@ static void context_reset(struct afu_cmd *cmd)
303303
if (rrin != 0x1)
304304
break;
305305
/* Double delay each time */
306-
udelay(2 << nretry);
306+
udelay(1 << nretry);
307307
} while (nretry++ < MC_ROOM_RETRY_CNT);
308308
}
309309

@@ -338,7 +338,7 @@ static int send_cmd(struct afu *afu, struct afu_cmd *cmd)
338338
atomic64_set(&afu->room, room);
339339
if (room)
340340
goto write_ioarrin;
341-
udelay(nretry);
341+
udelay(1 << nretry);
342342
} while (nretry++ < MC_ROOM_RETRY_CNT);
343343

344344
dev_err(dev, "%s: no cmd_room to send 0x%X\n",
@@ -352,7 +352,7 @@ static int send_cmd(struct afu *afu, struct afu_cmd *cmd)
352352
* afu->room.
353353
*/
354354
if (nretry++ < MC_ROOM_RETRY_CNT) {
355-
udelay(nretry);
355+
udelay(1 << nretry);
356356
goto retry;
357357
}
358358

@@ -683,28 +683,23 @@ static void stop_afu(struct cxlflash_cfg *cfg)
683683
}
684684

685685
/**
686-
* term_mc() - terminates the master context
686+
* term_intr() - disables all AFU interrupts
687687
* @cfg: Internal structure associated with the host.
688688
* @level: Depth of allocation, where to begin waterfall tear down.
689689
*
690690
* Safe to call with AFU/MC in partially allocated/initialized state.
691691
*/
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)
693693
{
694-
int rc = 0;
695694
struct afu *afu = cfg->afu;
696695
struct device *dev = &cfg->dev->dev;
697696

698697
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__);
701699
return;
702700
}
703701

704702
switch (level) {
705-
case UNDO_START:
706-
rc = cxl_stop_context(cfg->mcctx);
707-
BUG_ON(rc);
708703
case UNMAP_THREE:
709704
cxl_unmap_afu_irq(cfg->mcctx, 3, afu);
710705
case UNMAP_TWO:
@@ -713,9 +708,34 @@ static void term_mc(struct cxlflash_cfg *cfg, enum undo_level level)
713708
cxl_unmap_afu_irq(cfg->mcctx, 1, afu);
714709
case FREE_IRQ:
715710
cxl_free_afu_irqs(cfg->mcctx);
716-
case RELEASE_CONTEXT:
717-
cfg->mcctx = NULL;
711+
/* fall through */
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;
718734
}
735+
736+
rc = cxl_stop_context(cfg->mcctx);
737+
WARN_ON(rc);
738+
cfg->mcctx = NULL;
719739
}
720740

721741
/**
@@ -726,10 +746,20 @@ static void term_mc(struct cxlflash_cfg *cfg, enum undo_level level)
726746
*/
727747
static void term_afu(struct cxlflash_cfg *cfg)
728748
{
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);
729759
if (cfg->afu)
730760
stop_afu(cfg);
731761

732-
term_mc(cfg, UNDO_START);
762+
term_mc(cfg);
733763

734764
pr_debug("%s: returning\n", __func__);
735765
}
@@ -1597,41 +1627,24 @@ static int start_afu(struct cxlflash_cfg *cfg)
15971627
}
15981628

15991629
/**
1600-
* init_mc() - create and register as the master context
1630+
* init_intr() - setup interrupt handlers for the master context
16011631
* @cfg: Internal structure associated with the host.
16021632
*
16031633
* Return: 0 on success, -errno on failure
16041634
*/
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)
16061637
{
1607-
struct cxl_context *ctx;
1608-
struct device *dev = &cfg->dev->dev;
16091638
struct afu *afu = cfg->afu;
1639+
struct device *dev = &cfg->dev->dev;
16101640
int rc = 0;
1611-
enum undo_level level;
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-
}
1641+
enum undo_level level = UNDO_NOOP;
16291642

16301643
rc = cxl_allocate_afu_irqs(ctx, 3);
16311644
if (unlikely(rc)) {
16321645
dev_err(dev, "%s: call to allocate_afu_irqs failed rc=%d!\n",
16331646
__func__, rc);
1634-
level = RELEASE_CONTEXT;
1647+
level = UNDO_NOOP;
16351648
goto out;
16361649
}
16371650

@@ -1661,8 +1674,47 @@ static int init_mc(struct cxlflash_cfg *cfg)
16611674
level = UNMAP_TWO;
16621675
goto out;
16631676
}
1677+
out:
1678+
return level;
1679+
}
16641680

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+
}
16661718

16671719
/* This performs the equivalent of the CXL_IOCTL_START_WORK.
16681720
* The CXL_IOCTL_GET_PROCESS_ELEMENT is implicit in the process
@@ -1678,7 +1730,7 @@ static int init_mc(struct cxlflash_cfg *cfg)
16781730
pr_debug("%s: returning rc=%d\n", __func__, rc);
16791731
return rc;
16801732
out:
1681-
term_mc(cfg, level);
1733+
term_intr(cfg, level);
16821734
goto ret;
16831735
}
16841736

@@ -1751,7 +1803,8 @@ static int init_afu(struct cxlflash_cfg *cfg)
17511803
err2:
17521804
kref_put(&afu->mapcount, afu_unmap);
17531805
err1:
1754-
term_mc(cfg, UNDO_START);
1806+
term_intr(cfg, UNMAP_THREE);
1807+
term_mc(cfg);
17551808
goto out;
17561809
}
17571810

@@ -2488,8 +2541,7 @@ static pci_ers_result_t cxlflash_pci_error_detected(struct pci_dev *pdev,
24882541
if (unlikely(rc))
24892542
dev_err(dev, "%s: Failed to mark user contexts!(%d)\n",
24902543
__func__, rc);
2491-
stop_afu(cfg);
2492-
term_mc(cfg, UNDO_START);
2544+
term_afu(cfg);
24932545
return PCI_ERS_RESULT_NEED_RESET;
24942546
case pci_channel_io_perm_failure:
24952547
cfg->state = STATE_FAILTERM;

drivers/scsi/cxlflash/main.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,11 @@
7979
#define WWPN_BUF_LEN (WWPN_LEN + 1)
8080

8181
enum undo_level {
82-
RELEASE_CONTEXT = 0,
82+
UNDO_NOOP = 0,
8383
FREE_IRQ,
8484
UNMAP_ONE,
8585
UNMAP_TWO,
86-
UNMAP_THREE,
87-
UNDO_START
86+
UNMAP_THREE
8887
};
8988

9089
struct dev_dependent_vals {

drivers/scsi/device_handler/scsi_dh_alua.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,9 +1112,9 @@ static void alua_bus_detach(struct scsi_device *sdev)
11121112
h->sdev = NULL;
11131113
spin_unlock(&h->pg_lock);
11141114
if (pg) {
1115-
spin_lock(&pg->lock);
1115+
spin_lock_irq(&pg->lock);
11161116
list_del_rcu(&h->node);
1117-
spin_unlock(&pg->lock);
1117+
spin_unlock_irq(&pg->lock);
11181118
kref_put(&pg->kref, release_port_group);
11191119
}
11201120
sdev->handler_data = NULL;

drivers/scsi/mpt3sas/mpt3sas_base.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5030,7 +5030,7 @@ _base_make_ioc_ready(struct MPT3SAS_ADAPTER *ioc, int sleep_flag,
50305030
static int
50315031
_base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, int sleep_flag)
50325032
{
5033-
int r, i;
5033+
int r, i, index;
50345034
unsigned long flags;
50355035
u32 reply_address;
50365036
u16 smid;
@@ -5039,8 +5039,7 @@ _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, int sleep_flag)
50395039
struct _event_ack_list *delayed_event_ack, *delayed_event_ack_next;
50405040
u8 hide_flag;
50415041
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;
50445043

50455044
dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
50465045
__func__));
@@ -5124,27 +5123,27 @@ _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, int sleep_flag)
51245123
_base_assign_reply_queues(ioc);
51255124

51265125
/* initialize Reply Post Free Queue */
5127-
reply_post_free_sz = ioc->reply_post_queue_depth *
5128-
sizeof(Mpi2DefaultReplyDescriptor_t);
5129-
reply_post_free = (long)ioc->reply_post[index].reply_post_free;
5126+
index = 0;
5127+
reply_post_free_contig = ioc->reply_post[0].reply_post_free;
51305128
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+
51315141
reply_q->reply_post_host_index = 0;
5132-
reply_q->reply_post_free = (Mpi2ReplyDescriptorsUnion_t *)
5133-
reply_post_free;
51345142
for (i = 0; i < ioc->reply_post_queue_depth; i++)
51355143
reply_q->reply_post_free[i].Words =
51365144
cpu_to_le64(ULLONG_MAX);
51375145
if (!_base_is_controller_msix_enabled(ioc))
51385146
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;
51485147
}
51495148
skip_init_reply_post_free_queue:
51505149

drivers/scsi/scsi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,9 @@ void scsi_attach_vpd(struct scsi_device *sdev)
784784
int pg83_supported = 0;
785785
unsigned char __rcu *vpd_buf, *orig_vpd_buf = NULL;
786786

787-
if (sdev->skip_vpd_pages)
787+
if (!scsi_device_supports_vpd(sdev))
788788
return;
789+
789790
retry_pg0:
790791
vpd_buf = kmalloc(vpd_len, GFP_KERNEL);
791792
if (!vpd_buf)

0 commit comments

Comments
 (0)