Skip to content

Commit 493f3f3

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: "A number of fairly small fixes, mostly in drivers but two in the core to change a retry for depopulation (a trendy new hdd thing that reorganizes blocks away from failing elements) and one to fix a GFP_ annotation to avoid a lock dependency (the third core patch is all in testing)" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: qla1280: Fix kernel oops when debug level > 2 scsi: ufs: core: Fix error return with query response scsi: storvsc: Set correct data length for sending SCSI command without payload scsi: ufs: core: Fix use-after free in init error and remove paths scsi: core: Do not retry I/Os during depopulation scsi: core: Use GFP_NOIO to avoid circular locking dependency scsi: ufs: Fix toggling of clk_gating.state when clock gating is not allowed scsi: ufs: core: Ensure clk_gating.lock is used only after initialization scsi: ufs: core: Simplify temperature exception event handling scsi: target: core: Add line break to status show scsi: ufs: core: Fix the HIGH/LOW_TEMP Bit Definitions scsi: core: Add passthrough tests for success and no failure definitions
2 parents 74b5161 + 5233e32 commit 493f3f3

File tree

11 files changed

+65
-63
lines changed

11 files changed

+65
-63
lines changed

drivers/scsi/qla1280.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2867,7 +2867,7 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
28672867
dprintk(3, "S/G Segment phys_addr=%x %x, len=0x%x\n",
28682868
cpu_to_le32(upper_32_bits(dma_handle)),
28692869
cpu_to_le32(lower_32_bits(dma_handle)),
2870-
cpu_to_le32(sg_dma_len(sg_next(s))));
2870+
cpu_to_le32(sg_dma_len(s)));
28712871
remseg--;
28722872
}
28732873
dprintk(5, "qla1280_64bit_start_scsi: Scatter/gather "

drivers/scsi/scsi_lib.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,13 +872,18 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)
872872
case 0x1a: /* start stop unit in progress */
873873
case 0x1b: /* sanitize in progress */
874874
case 0x1d: /* configuration in progress */
875-
case 0x24: /* depopulation in progress */
876-
case 0x25: /* depopulation restore in progress */
877875
action = ACTION_DELAYED_RETRY;
878876
break;
879877
case 0x0a: /* ALUA state transition */
880878
action = ACTION_DELAYED_REPREP;
881879
break;
880+
/*
881+
* Depopulation might take many hours,
882+
* thus it is not worthwhile to retry.
883+
*/
884+
case 0x24: /* depopulation in progress */
885+
case 0x25: /* depopulation restore in progress */
886+
fallthrough;
882887
default:
883888
action = ACTION_FAIL;
884889
break;

drivers/scsi/scsi_lib_test.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ static void scsi_lib_test_multiple_sense(struct kunit *test)
6767
};
6868
int i;
6969

70+
/* Success */
71+
sc.result = 0;
72+
KUNIT_EXPECT_EQ(test, 0, scsi_check_passthrough(&sc, &failures));
73+
KUNIT_EXPECT_EQ(test, 0, scsi_check_passthrough(&sc, NULL));
74+
/* Command failed but caller did not pass in a failures array */
75+
scsi_build_sense(&sc, 0, ILLEGAL_REQUEST, 0x91, 0x36);
76+
KUNIT_EXPECT_EQ(test, 0, scsi_check_passthrough(&sc, NULL));
7077
/* Match end of array */
7178
scsi_build_sense(&sc, 0, ILLEGAL_REQUEST, 0x91, 0x36);
7279
KUNIT_EXPECT_EQ(test, -EAGAIN, scsi_check_passthrough(&sc, &failures));

drivers/scsi/scsi_scan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ static int scsi_realloc_sdev_budget_map(struct scsi_device *sdev,
246246
}
247247
ret = sbitmap_init_node(&sdev->budget_map,
248248
scsi_device_max_queue_depth(sdev),
249-
new_shift, GFP_KERNEL,
249+
new_shift, GFP_NOIO,
250250
sdev->request_queue->node, false, true);
251251
if (!ret)
252252
sbitmap_resize(&sdev->budget_map, depth);

drivers/scsi/storvsc_drv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,7 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
18001800

18011801
length = scsi_bufflen(scmnd);
18021802
payload = (struct vmbus_packet_mpb_array *)&cmd_request->mpb;
1803+
payload->range.len = 0;
18031804
payload_sz = 0;
18041805

18051806
if (scsi_sg_count(scmnd)) {

drivers/target/target_core_stat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ static ssize_t target_stat_tgt_status_show(struct config_item *item,
117117
char *page)
118118
{
119119
if (to_stat_tgt_dev(item)->export_count)
120-
return snprintf(page, PAGE_SIZE, "activated");
120+
return snprintf(page, PAGE_SIZE, "activated\n");
121121
else
122-
return snprintf(page, PAGE_SIZE, "deactivated");
122+
return snprintf(page, PAGE_SIZE, "deactivated\n");
123123
}
124124

125125
static ssize_t target_stat_tgt_non_access_lus_show(struct config_item *item,

drivers/ufs/core/ufshcd.c

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,8 +2120,6 @@ static void ufshcd_init_clk_gating(struct ufs_hba *hba)
21202120
INIT_DELAYED_WORK(&hba->clk_gating.gate_work, ufshcd_gate_work);
21212121
INIT_WORK(&hba->clk_gating.ungate_work, ufshcd_ungate_work);
21222122

2123-
spin_lock_init(&hba->clk_gating.lock);
2124-
21252123
hba->clk_gating.clk_gating_workq = alloc_ordered_workqueue(
21262124
"ufs_clk_gating_%d", WQ_MEM_RECLAIM | WQ_HIGHPRI,
21272125
hba->host->host_no);
@@ -3106,8 +3104,13 @@ ufshcd_dev_cmd_completion(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
31063104
case UPIU_TRANSACTION_QUERY_RSP: {
31073105
u8 response = lrbp->ucd_rsp_ptr->header.response;
31083106

3109-
if (response == 0)
3107+
if (response == 0) {
31103108
err = ufshcd_copy_query_response(hba, lrbp);
3109+
} else {
3110+
err = -EINVAL;
3111+
dev_err(hba->dev, "%s: unexpected response in Query RSP: %x\n",
3112+
__func__, response);
3113+
}
31113114
break;
31123115
}
31133116
case UPIU_TRANSACTION_REJECT_UPIU:
@@ -5976,24 +5979,6 @@ static void ufshcd_bkops_exception_event_handler(struct ufs_hba *hba)
59765979
__func__, err);
59775980
}
59785981

5979-
static void ufshcd_temp_exception_event_handler(struct ufs_hba *hba, u16 status)
5980-
{
5981-
u32 value;
5982-
5983-
if (ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_READ_ATTR,
5984-
QUERY_ATTR_IDN_CASE_ROUGH_TEMP, 0, 0, &value))
5985-
return;
5986-
5987-
dev_info(hba->dev, "exception Tcase %d\n", value - 80);
5988-
5989-
ufs_hwmon_notify_event(hba, status & MASK_EE_URGENT_TEMP);
5990-
5991-
/*
5992-
* A placeholder for the platform vendors to add whatever additional
5993-
* steps required
5994-
*/
5995-
}
5996-
59975982
static int __ufshcd_wb_toggle(struct ufs_hba *hba, bool set, enum flag_idn idn)
59985983
{
59995984
u8 index;
@@ -6214,7 +6199,7 @@ static void ufshcd_exception_event_handler(struct work_struct *work)
62146199
ufshcd_bkops_exception_event_handler(hba);
62156200

62166201
if (status & hba->ee_drv_mask & MASK_EE_URGENT_TEMP)
6217-
ufshcd_temp_exception_event_handler(hba, status);
6202+
ufs_hwmon_notify_event(hba, status & MASK_EE_URGENT_TEMP);
62186203

62196204
ufs_debugfs_exception_event(hba, status);
62206205
}
@@ -9160,7 +9145,7 @@ static int ufshcd_setup_clocks(struct ufs_hba *hba, bool on)
91609145
if (!IS_ERR_OR_NULL(clki->clk) && clki->enabled)
91619146
clk_disable_unprepare(clki->clk);
91629147
}
9163-
} else if (!ret && on) {
9148+
} else if (!ret && on && hba->clk_gating.is_initialized) {
91649149
scoped_guard(spinlock_irqsave, &hba->clk_gating.lock)
91659150
hba->clk_gating.state = CLKS_ON;
91669151
trace_ufshcd_clk_gating(dev_name(hba->dev),
@@ -10246,16 +10231,6 @@ int ufshcd_system_thaw(struct device *dev)
1024610231
EXPORT_SYMBOL_GPL(ufshcd_system_thaw);
1024710232
#endif /* CONFIG_PM_SLEEP */
1024810233

10249-
/**
10250-
* ufshcd_dealloc_host - deallocate Host Bus Adapter (HBA)
10251-
* @hba: pointer to Host Bus Adapter (HBA)
10252-
*/
10253-
void ufshcd_dealloc_host(struct ufs_hba *hba)
10254-
{
10255-
scsi_host_put(hba->host);
10256-
}
10257-
EXPORT_SYMBOL_GPL(ufshcd_dealloc_host);
10258-
1025910234
/**
1026010235
* ufshcd_set_dma_mask - Set dma mask based on the controller
1026110236
* addressing capability
@@ -10274,12 +10249,26 @@ static int ufshcd_set_dma_mask(struct ufs_hba *hba)
1027410249
return dma_set_mask_and_coherent(hba->dev, DMA_BIT_MASK(32));
1027510250
}
1027610251

10252+
/**
10253+
* ufshcd_devres_release - devres cleanup handler, invoked during release of
10254+
* hba->dev
10255+
* @host: pointer to SCSI host
10256+
*/
10257+
static void ufshcd_devres_release(void *host)
10258+
{
10259+
scsi_host_put(host);
10260+
}
10261+
1027710262
/**
1027810263
* ufshcd_alloc_host - allocate Host Bus Adapter (HBA)
1027910264
* @dev: pointer to device handle
1028010265
* @hba_handle: driver private handle
1028110266
*
1028210267
* Return: 0 on success, non-zero value on failure.
10268+
*
10269+
* NOTE: There is no corresponding ufshcd_dealloc_host() because this function
10270+
* keeps track of its allocations using devres and deallocates everything on
10271+
* device removal automatically.
1028310272
*/
1028410273
int ufshcd_alloc_host(struct device *dev, struct ufs_hba **hba_handle)
1028510274
{
@@ -10301,6 +10290,13 @@ int ufshcd_alloc_host(struct device *dev, struct ufs_hba **hba_handle)
1030110290
err = -ENOMEM;
1030210291
goto out_error;
1030310292
}
10293+
10294+
err = devm_add_action_or_reset(dev, ufshcd_devres_release,
10295+
host);
10296+
if (err)
10297+
return dev_err_probe(dev, err,
10298+
"failed to add ufshcd dealloc action\n");
10299+
1030410300
host->nr_maps = HCTX_TYPE_POLL + 1;
1030510301
hba = shost_priv(host);
1030610302
hba->host = host;
@@ -10429,6 +10425,12 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
1042910425
hba->irq = irq;
1043010426
hba->vps = &ufs_hba_vps;
1043110427

10428+
/*
10429+
* Initialize clk_gating.lock early since it is being used in
10430+
* ufshcd_setup_clocks()
10431+
*/
10432+
spin_lock_init(&hba->clk_gating.lock);
10433+
1043210434
err = ufshcd_hba_init(hba);
1043310435
if (err)
1043410436
goto out_error;

drivers/ufs/host/ufshcd-pci.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,6 @@ static void ufshcd_pci_remove(struct pci_dev *pdev)
562562
pm_runtime_forbid(&pdev->dev);
563563
pm_runtime_get_noresume(&pdev->dev);
564564
ufshcd_remove(hba);
565-
ufshcd_dealloc_host(hba);
566565
}
567566

568567
/**
@@ -605,7 +604,6 @@ ufshcd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
605604
err = ufshcd_init(hba, mmio_base, pdev->irq);
606605
if (err) {
607606
dev_err(&pdev->dev, "Initialization failed\n");
608-
ufshcd_dealloc_host(hba);
609607
return err;
610608
}
611609

drivers/ufs/host/ufshcd-pltfrm.c

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -465,21 +465,17 @@ int ufshcd_pltfrm_init(struct platform_device *pdev,
465465
struct device *dev = &pdev->dev;
466466

467467
mmio_base = devm_platform_ioremap_resource(pdev, 0);
468-
if (IS_ERR(mmio_base)) {
469-
err = PTR_ERR(mmio_base);
470-
goto out;
471-
}
468+
if (IS_ERR(mmio_base))
469+
return PTR_ERR(mmio_base);
472470

473471
irq = platform_get_irq(pdev, 0);
474-
if (irq < 0) {
475-
err = irq;
476-
goto out;
477-
}
472+
if (irq < 0)
473+
return irq;
478474

479475
err = ufshcd_alloc_host(dev, &hba);
480476
if (err) {
481477
dev_err(dev, "Allocation failed\n");
482-
goto out;
478+
return err;
483479
}
484480

485481
hba->vops = vops;
@@ -488,39 +484,34 @@ int ufshcd_pltfrm_init(struct platform_device *pdev,
488484
if (err) {
489485
dev_err(dev, "%s: clock parse failed %d\n",
490486
__func__, err);
491-
goto dealloc_host;
487+
return err;
492488
}
493489
err = ufshcd_parse_regulator_info(hba);
494490
if (err) {
495491
dev_err(dev, "%s: regulator init failed %d\n",
496492
__func__, err);
497-
goto dealloc_host;
493+
return err;
498494
}
499495

500496
ufshcd_init_lanes_per_dir(hba);
501497

502498
err = ufshcd_parse_operating_points(hba);
503499
if (err) {
504500
dev_err(dev, "%s: OPP parse failed %d\n", __func__, err);
505-
goto dealloc_host;
501+
return err;
506502
}
507503

508504
err = ufshcd_init(hba, mmio_base, irq);
509505
if (err) {
510506
dev_err_probe(dev, err, "Initialization failed with error %d\n",
511507
err);
512-
goto dealloc_host;
508+
return err;
513509
}
514510

515511
pm_runtime_set_active(dev);
516512
pm_runtime_enable(dev);
517513

518514
return 0;
519-
520-
dealloc_host:
521-
ufshcd_dealloc_host(hba);
522-
out:
523-
return err;
524515
}
525516
EXPORT_SYMBOL_GPL(ufshcd_pltfrm_init);
526517

@@ -534,7 +525,6 @@ void ufshcd_pltfrm_remove(struct platform_device *pdev)
534525

535526
pm_runtime_get_sync(&pdev->dev);
536527
ufshcd_remove(hba);
537-
ufshcd_dealloc_host(hba);
538528
pm_runtime_disable(&pdev->dev);
539529
pm_runtime_put_noidle(&pdev->dev);
540530
}

include/ufs/ufs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,8 @@ enum {
385385

386386
/* Possible values for dExtendedUFSFeaturesSupport */
387387
enum {
388-
UFS_DEV_LOW_TEMP_NOTIF = BIT(4),
389-
UFS_DEV_HIGH_TEMP_NOTIF = BIT(5),
388+
UFS_DEV_HIGH_TEMP_NOTIF = BIT(4),
389+
UFS_DEV_LOW_TEMP_NOTIF = BIT(5),
390390
UFS_DEV_EXT_TEMP_NOTIF = BIT(6),
391391
UFS_DEV_HPB_SUPPORT = BIT(7),
392392
UFS_DEV_WRITE_BOOSTER_SUP = BIT(8),

include/ufs/ufshcd.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,6 @@ static inline void ufshcd_rmwl(struct ufs_hba *hba, u32 mask, u32 val, u32 reg)
13091309
void ufshcd_enable_irq(struct ufs_hba *hba);
13101310
void ufshcd_disable_irq(struct ufs_hba *hba);
13111311
int ufshcd_alloc_host(struct device *, struct ufs_hba **);
1312-
void ufshcd_dealloc_host(struct ufs_hba *);
13131312
int ufshcd_hba_enable(struct ufs_hba *hba);
13141313
int ufshcd_init(struct ufs_hba *, void __iomem *, unsigned int);
13151314
int ufshcd_link_recovery(struct ufs_hba *hba);

0 commit comments

Comments
 (0)