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

scsi: sas: Convert timers to use timer_setup()

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly. This requires adding a pointer to
hold the timer's target task, as there isn't a link back from slow_task.

Cc: John Garry <john.garry@huawei.com>
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Jack Wang <jinpu.wang@profitbricks.com>
Cc: lindar_liu@usish.com
Cc: Jens Axboe <axboe@fb.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Benjamin Block <bblock@linux.vnet.ibm.com>
Cc: Baoyou Xie <baoyou.xie@linaro.org>
Cc: Wei Yongjun <weiyongjun1@huawei.com>
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Acked-by: John Garry <john.garry@huawei.com> # for hisi_sas part
Tested-by: John Garry <john.garry@huawei.com> # basic sanity test for hisi_sas
Reviewed-by: Jack Wang <jinpu.wang@profitbricks.com>

+42 -49
-1
drivers/scsi/hisi_sas/hisi_sas.h
··· 103 103 struct hisi_sas_port *port; 104 104 struct asd_sas_phy sas_phy; 105 105 struct sas_identify identify; 106 - struct timer_list timer; 107 106 struct work_struct phyup_ws; 108 107 u64 port_id; /* from hw */ 109 108 u64 dev_sas_addr;
+6 -8
drivers/scsi/hisi_sas/hisi_sas_main.c
··· 627 627 628 628 phy->hisi_hba = hisi_hba; 629 629 phy->port = NULL; 630 - init_timer(&phy->timer); 631 630 sas_phy->enabled = (phy_no < hisi_hba->n_phy) ? 1 : 0; 632 631 sas_phy->class = SAS; 633 632 sas_phy->iproto = SAS_PROTOCOL_ALL; ··· 791 792 complete(&task->slow_task->completion); 792 793 } 793 794 794 - static void hisi_sas_tmf_timedout(unsigned long data) 795 + static void hisi_sas_tmf_timedout(struct timer_list *t) 795 796 { 796 - struct sas_task *task = (struct sas_task *)data; 797 + struct sas_task_slow *slow = from_timer(slow, t, timer); 798 + struct sas_task *task = slow->task; 797 799 unsigned long flags; 798 800 799 801 spin_lock_irqsave(&task->task_state_lock, flags); ··· 833 833 } 834 834 task->task_done = hisi_sas_task_done; 835 835 836 - task->slow_task->timer.data = (unsigned long) task; 837 - task->slow_task->timer.function = hisi_sas_tmf_timedout; 836 + task->slow_task->timer.function = (TIMER_FUNC_TYPE)hisi_sas_tmf_timedout; 838 837 task->slow_task->timer.expires = jiffies + TASK_TIMEOUT*HZ; 839 838 add_timer(&task->slow_task->timer); 840 839 ··· 1446 1447 task->dev = device; 1447 1448 task->task_proto = device->tproto; 1448 1449 task->task_done = hisi_sas_task_done; 1449 - task->slow_task->timer.data = (unsigned long)task; 1450 - task->slow_task->timer.function = hisi_sas_tmf_timedout; 1450 + task->slow_task->timer.function = (TIMER_FUNC_TYPE)hisi_sas_tmf_timedout; 1451 1451 task->slow_task->timer.expires = jiffies + msecs_to_jiffies(110); 1452 1452 add_timer(&task->slow_task->timer); 1453 1453 ··· 1875 1877 hisi_hba->shost = shost; 1876 1878 SHOST_TO_SAS_HA(shost) = &hisi_hba->sha; 1877 1879 1878 - init_timer(&hisi_hba->timer); 1880 + timer_setup(&hisi_hba->timer, NULL, 0); 1879 1881 1880 1882 if (hisi_sas_get_fw_info(hisi_hba) < 0) 1881 1883 goto err_out;
+3 -3
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
··· 807 807 start_phy_v1_hw(hisi_hba, phy_no); 808 808 } 809 809 810 - static void start_phys_v1_hw(unsigned long data) 810 + static void start_phys_v1_hw(struct timer_list *t) 811 811 { 812 - struct hisi_hba *hisi_hba = (struct hisi_hba *)data; 812 + struct hisi_hba *hisi_hba = from_timer(hisi_hba, t, timer); 813 813 int i; 814 814 815 815 for (i = 0; i < hisi_hba->n_phy; i++) { ··· 828 828 hisi_sas_phy_read32(hisi_hba, i, CHL_INT2_MSK); 829 829 } 830 830 831 - setup_timer(timer, start_phys_v1_hw, (unsigned long)hisi_hba); 831 + timer_setup(timer, start_phys_v1_hw, 0); 832 832 mod_timer(timer, jiffies + HZ); 833 833 } 834 834
+11 -13
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
··· 728 728 #define ERR_ON_RX_PHASE(err_phase) (err_phase == 0x10 || \ 729 729 err_phase == 0x20 || err_phase == 0x40) 730 730 731 - static void link_timeout_disable_link(unsigned long data); 731 + static void link_timeout_disable_link(struct timer_list *t); 732 732 733 733 static u32 hisi_sas_read32(struct hisi_hba *hisi_hba, u32 off) 734 734 { ··· 1270 1270 upper_32_bits(hisi_hba->initial_fis_dma)); 1271 1271 } 1272 1272 1273 - static void link_timeout_enable_link(unsigned long data) 1273 + static void link_timeout_enable_link(struct timer_list *t) 1274 1274 { 1275 - struct hisi_hba *hisi_hba = (struct hisi_hba *)data; 1275 + struct hisi_hba *hisi_hba = from_timer(hisi_hba, t, timer); 1276 1276 int i, reg_val; 1277 1277 1278 1278 for (i = 0; i < hisi_hba->n_phy; i++) { ··· 1287 1287 } 1288 1288 } 1289 1289 1290 - hisi_hba->timer.function = link_timeout_disable_link; 1290 + hisi_hba->timer.function = (TIMER_FUNC_TYPE)link_timeout_disable_link; 1291 1291 mod_timer(&hisi_hba->timer, jiffies + msecs_to_jiffies(900)); 1292 1292 } 1293 1293 1294 - static void link_timeout_disable_link(unsigned long data) 1294 + static void link_timeout_disable_link(struct timer_list *t) 1295 1295 { 1296 - struct hisi_hba *hisi_hba = (struct hisi_hba *)data; 1296 + struct hisi_hba *hisi_hba = from_timer(hisi_hba, t, timer); 1297 1297 int i, reg_val; 1298 1298 1299 1299 reg_val = hisi_sas_read32(hisi_hba, PHY_STATE); ··· 1308 1308 } 1309 1309 } 1310 1310 1311 - hisi_hba->timer.function = link_timeout_enable_link; 1311 + hisi_hba->timer.function = (TIMER_FUNC_TYPE)link_timeout_enable_link; 1312 1312 mod_timer(&hisi_hba->timer, jiffies + msecs_to_jiffies(100)); 1313 1313 } 1314 1314 1315 1315 static void set_link_timer_quirk(struct hisi_hba *hisi_hba) 1316 1316 { 1317 - hisi_hba->timer.data = (unsigned long)hisi_hba; 1318 - hisi_hba->timer.function = link_timeout_disable_link; 1317 + hisi_hba->timer.function = (TIMER_FUNC_TYPE)link_timeout_disable_link; 1319 1318 hisi_hba->timer.expires = jiffies + msecs_to_jiffies(1000); 1320 1319 add_timer(&hisi_hba->timer); 1321 1320 } ··· 2573 2574 return 0; 2574 2575 } 2575 2576 2576 - static void hisi_sas_internal_abort_quirk_timeout(unsigned long data) 2577 + static void hisi_sas_internal_abort_quirk_timeout(struct timer_list *t) 2577 2578 { 2578 - struct hisi_sas_slot *slot = (struct hisi_sas_slot *)data; 2579 + struct hisi_sas_slot *slot = from_timer(slot, t, internal_abort_timer); 2579 2580 struct hisi_sas_port *port = slot->port; 2580 2581 struct asd_sas_port *asd_sas_port; 2581 2582 struct asd_sas_phy *sas_phy; ··· 2618 2619 struct timer_list *timer = &slot->internal_abort_timer; 2619 2620 2620 2621 /* setup the quirk timer */ 2621 - setup_timer(timer, hisi_sas_internal_abort_quirk_timeout, 2622 - (unsigned long)slot); 2622 + timer_setup(timer, hisi_sas_internal_abort_quirk_timeout, 0); 2623 2623 /* Set the timeout to 10ms less than internal abort timeout */ 2624 2624 mod_timer(timer, jiffies + msecs_to_jiffies(100)); 2625 2625
+1 -1
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
··· 1823 1823 hisi_hba->shost = shost; 1824 1824 SHOST_TO_SAS_HA(shost) = &hisi_hba->sha; 1825 1825 1826 - init_timer(&hisi_hba->timer); 1826 + timer_setup(&hisi_hba->timer, NULL, 0); 1827 1827 1828 1828 if (hisi_sas_get_fw_info(hisi_hba) < 0) 1829 1829 goto err_out;
+4 -4
drivers/scsi/libsas/sas_expander.c
··· 41 41 42 42 /* ---------- SMP task management ---------- */ 43 43 44 - static void smp_task_timedout(unsigned long _task) 44 + static void smp_task_timedout(struct timer_list *t) 45 45 { 46 - struct sas_task *task = (void *) _task; 46 + struct sas_task_slow *slow = from_timer(slow, t, timer); 47 + struct sas_task *task = slow->task; 47 48 unsigned long flags; 48 49 49 50 spin_lock_irqsave(&task->task_state_lock, flags); ··· 92 91 93 92 task->task_done = smp_task_done; 94 93 95 - task->slow_task->timer.data = (unsigned long) task; 96 - task->slow_task->timer.function = smp_task_timedout; 94 + task->slow_task->timer.function = (TIMER_FUNC_TYPE)smp_task_timedout; 97 95 task->slow_task->timer.expires = jiffies + SMP_TIMEOUT*HZ; 98 96 add_timer(&task->slow_task->timer); 99 97
+2 -1
drivers/scsi/libsas/sas_init.c
··· 66 66 } 67 67 68 68 task->slow_task = slow; 69 - init_timer(&slow->timer); 69 + slow->task = task; 70 + timer_setup(&slow->timer, NULL, 0); 70 71 init_completion(&slow->completion); 71 72 72 73 return task;
+1 -1
drivers/scsi/libsas/sas_scsi_host.c
··· 919 919 return; 920 920 if (!del_timer(&slow->timer)) 921 921 return; 922 - slow->timer.function(slow->timer.data); 922 + slow->timer.function((TIMER_DATA_TYPE)&slow->timer); 923 923 return; 924 924 } 925 925
+1 -2
drivers/scsi/mvsas/mv_init.c
··· 95 95 96 96 phy->mvi = mvi; 97 97 phy->port = NULL; 98 - init_timer(&phy->timer); 98 + timer_setup(&phy->timer, NULL, 0); 99 99 sas_phy->enabled = (phy_id < mvi->chip->n_phy) ? 1 : 0; 100 100 sas_phy->class = SAS; 101 101 sas_phy->iproto = SAS_PROTOCOL_ALL; ··· 248 248 mvi->devices[i].dev_type = SAS_PHY_UNUSED; 249 249 mvi->devices[i].device_id = i; 250 250 mvi->devices[i].dev_status = MVS_DEV_NORMAL; 251 - init_timer(&mvi->devices[i].timer); 252 251 } 253 252 254 253 /*
+7 -8
drivers/scsi/mvsas/mv_sas.c
··· 1283 1283 complete(&task->slow_task->completion); 1284 1284 } 1285 1285 1286 - static void mvs_tmf_timedout(unsigned long data) 1286 + static void mvs_tmf_timedout(struct timer_list *t) 1287 1287 { 1288 - struct sas_task *task = (struct sas_task *)data; 1288 + struct sas_task_slow *slow = from_timer(slow, t, timer); 1289 + struct sas_task *task = slow->task; 1289 1290 1290 1291 task->task_state_flags |= SAS_TASK_STATE_ABORTED; 1291 1292 complete(&task->slow_task->completion); ··· 1310 1309 memcpy(&task->ssp_task, parameter, para_len); 1311 1310 task->task_done = mvs_task_done; 1312 1311 1313 - task->slow_task->timer.data = (unsigned long) task; 1314 - task->slow_task->timer.function = mvs_tmf_timedout; 1312 + task->slow_task->timer.function = (TIMER_FUNC_TYPE)mvs_tmf_timedout; 1315 1313 task->slow_task->timer.expires = jiffies + MVS_TASK_TIMEOUT*HZ; 1316 1314 add_timer(&task->slow_task->timer); 1317 1315 ··· 1954 1954 return ret; 1955 1955 } 1956 1956 1957 - static void mvs_sig_time_out(unsigned long tphy) 1957 + static void mvs_sig_time_out(struct timer_list *t) 1958 1958 { 1959 - struct mvs_phy *phy = (struct mvs_phy *)tphy; 1959 + struct mvs_phy *phy = from_timer(phy, t, timer); 1960 1960 struct mvs_info *mvi = phy->mvi; 1961 1961 u8 phy_no; 1962 1962 ··· 2020 2020 MVS_CHIP_DISP->write_port_irq_mask(mvi, phy_no, 2021 2021 tmp | PHYEV_SIG_FIS); 2022 2022 if (phy->timer.function == NULL) { 2023 - phy->timer.data = (unsigned long)phy; 2024 - phy->timer.function = mvs_sig_time_out; 2023 + phy->timer.function = (TIMER_FUNC_TYPE)mvs_sig_time_out; 2025 2024 phy->timer.expires = jiffies + 5*HZ; 2026 2025 add_timer(&phy->timer); 2027 2026 }
-1
drivers/scsi/mvsas/mv_sas.h
··· 247 247 enum sas_device_type dev_type; 248 248 struct mvs_info *mvi_info; 249 249 struct domain_device *sas_device; 250 - struct timer_list timer; 251 250 u32 attached_phy; 252 251 u32 device_id; 253 252 u32 running_req;
+5 -6
drivers/scsi/pm8001/pm8001_sas.c
··· 656 656 complete(&task->slow_task->completion); 657 657 } 658 658 659 - static void pm8001_tmf_timedout(unsigned long data) 659 + static void pm8001_tmf_timedout(struct timer_list *t) 660 660 { 661 - struct sas_task *task = (struct sas_task *)data; 661 + struct sas_task_slow *slow = from_timer(slow, t, timer); 662 + struct sas_task *task = slow->task; 662 663 663 664 task->task_state_flags |= SAS_TASK_STATE_ABORTED; 664 665 complete(&task->slow_task->completion); ··· 695 694 task->task_proto = dev->tproto; 696 695 memcpy(&task->ssp_task, parameter, para_len); 697 696 task->task_done = pm8001_task_done; 698 - task->slow_task->timer.data = (unsigned long)task; 699 - task->slow_task->timer.function = pm8001_tmf_timedout; 697 + task->slow_task->timer.function = (TIMER_FUNC_TYPE)pm8001_tmf_timedout; 700 698 task->slow_task->timer.expires = jiffies + PM8001_TASK_TIMEOUT*HZ; 701 699 add_timer(&task->slow_task->timer); 702 700 ··· 781 781 task->dev = dev; 782 782 task->task_proto = dev->tproto; 783 783 task->task_done = pm8001_task_done; 784 - task->slow_task->timer.data = (unsigned long)task; 785 - task->slow_task->timer.function = pm8001_tmf_timedout; 784 + task->slow_task->timer.function = (TIMER_FUNC_TYPE)pm8001_tmf_timedout; 786 785 task->slow_task->timer.expires = jiffies + PM8001_TASK_TIMEOUT * HZ; 787 786 add_timer(&task->slow_task->timer); 788 787
+1
include/scsi/libsas.h
··· 629 629 */ 630 630 struct timer_list timer; 631 631 struct completion completion; 632 + struct sas_task *task; 632 633 }; 633 634 634 635 #define SAS_TASK_STATE_PENDING 1