From 2c3b28ea8f5e97ed12fcb1d8001611f7cca49d65 Mon Sep 17 00:00:00 2001 From: Steve McIntyre <93sam@debian.org> Date: Sat, 15 Jun 2019 21:21:01 +0100 Subject: [PATCH] [arm64] Improve support for the Huawei TaiShan server platform Closes: #930554 Enable the HNS/ROCE Infiniband driver Backport fixes from 4.20 and 4.21 for HNS3 networking, hisi_sas SAS and HNS/ROCE Infiniband Signed-off-by: Steve McIntyre <93sam@debian.org> --- debian/changelog | 12 + debian/config/arm64/config | 7 + debian/config/defines | 2 + ...ed-back-linkrate-max-min-when-re-att.patch | 40 ++ ...ve-evaluation-of-hisi_hba-in-hisi_sa.patch | 50 ++ ...x-the-race-between-IO-completion-and.patch | 139 ++++++ ...ee-slot-later-in-slot_complete_vx_hw.patch | 69 +++ ...as-unmask-interrupts-ent72-and-ent74.patch | 32 ++ ...Use-block-layer-tag-instead-for-IPTT.patch | 321 +++++++++++++ ...date-v3-hw-AIP_LIMIT-and-CFG_AGING_T.patch | 57 +++ ...x-spin-lock-management-in-slot_index.patch | 36 ++ ...si_sas-use-dma_set_mask_and_coherent.patch | 43 ++ ...eate-separate-host-attributes-per-HB.patch | 129 ++++++ ...d-support-for-interrupt-converge-for.patch | 116 +++++ ...d-support-for-interrupt-coalescing-f.patch | 153 +++++++ ...locate-some-codes-to-avoid-an-unused.patch | 97 ++++ ..._sas-Fix-warnings-detected-by-sparse.patch | 432 ++++++++++++++++++ ...locate-some-code-to-reduce-complexit.patch | 190 ++++++++ ...s-Make-sg_tablesize-consistent-value.patch | 85 ++++ ...unnecessary-configuration-recapture-.patch | 46 ++ ...ns3-remove-1000M-half-support-of-phy.patch | 32 ++ ...nize-speed-and-duplex-from-phy-when-.patch | 35 ++ ...-tx-and-dv-buffer-size-through-firmw.patch | 160 +++++++ ...ning-buffer-size-in-SSU-to-256-bytes.patch | 147 ++++++ ...t-hns3-fix-a-SSU-buffer-checking-bug.patch | 48 ++ ...ns3-change-default-tc-state-to-close.patch | 33 ++ ...-net-hns3-fix-a-bug-caused-by-udelay.patch | 42 ++ ...ve-redundant-variable-initialization.patch | 31 ++ ...s3_nic_net_open-while-doing-HNAE3_UP.patch | 49 ++ ...-bug-with-updating-rq-head-pointer-w.patch | 52 +++ ...for-the-scene-without-receiver-queue.patch | 32 ++ ...straint-on-the-setting-of-local-ACK-.patch | 46 ++ ...odify-the-pbl-ba-page-size-for-hip08.patch | 31 ++ ...s-Assign-rq-head-pointer-when-enable.patch | 66 +++ ...isi_sas-Fix-NULL-pointer-dereference.patch | 63 +++ ...x-calls-to-dma_set_mask_and_coherent.patch | 73 +++ debian/patches/series | 35 ++ 37 files changed, 3031 insertions(+) create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0001-scsi-hisi_sas-Feed-back-linkrate-max-min-when-re-att.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0002-scsi-hisi_sas-Move-evaluation-of-hisi_hba-in-hisi_sa.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0003-scsi-hisi_sas-Fix-the-race-between-IO-completion-and.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0004-scsi-hisi_sas-Free-slot-later-in-slot_complete_vx_hw.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0005-scsi-hisi_sas-unmask-interrupts-ent72-and-ent74.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0006-scsi-hisi_sas-Use-block-layer-tag-instead-for-IPTT.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0007-scsi-hisi_sas-Update-v3-hw-AIP_LIMIT-and-CFG_AGING_T.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0008-scsi-hisi_sas-Fix-spin-lock-management-in-slot_index.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0009-scsi-hisi_sas-use-dma_set_mask_and_coherent.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0010-scsi-hisi_sas-Create-separate-host-attributes-per-HB.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0011-scsi-hisi_sas-Add-support-for-interrupt-converge-for.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0012-scsi-hisi_sas-Add-support-for-interrupt-coalescing-f.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0013-scsi-hisi_sas-Relocate-some-codes-to-avoid-an-unused.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0014-scsi-hisi_sas-Fix-warnings-detected-by-sparse.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0015-scsi-hisi_sas-Relocate-some-code-to-reduce-complexit.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0016-scsi-hisi_sas-Make-sg_tablesize-consistent-value.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0017-net-hns3-remove-unnecessary-configuration-recapture-.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0018-net-hns3-remove-1000M-half-support-of-phy.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0019-net-hns3-synchronize-speed-and-duplex-from-phy-when-.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0020-net-hns3-getting-tx-and-dv-buffer-size-through-firmw.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0021-net-hns3-aligning-buffer-size-in-SSU-to-256-bytes.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0022-net-hns3-fix-a-SSU-buffer-checking-bug.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0023-net-hns3-change-default-tc-state-to-close.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0024-net-hns3-fix-a-bug-caused-by-udelay.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0025-net-hns3-remove-redundant-variable-initialization.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0026-net-hns3-call-hns3_nic_net_open-while-doing-HNAE3_UP.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0027-RDMA-hns-Fix-the-bug-with-updating-rq-head-pointer-w.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0028-RDMA-hns-Bugfix-for-the-scene-without-receiver-queue.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0029-RDMA-hns-Add-constraint-on-the-setting-of-local-ACK-.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0030-RDMA-hns-Modify-the-pbl-ba-page-size-for-hip08.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0031-RDMA-hns-RDMA-hns-Assign-rq-head-pointer-when-enable.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0032-scsi-hisi_sas-Fix-NULL-pointer-dereference.patch create mode 100644 debian/patches/bugfix/arm64/huawei-taishan/0033-scsi-hisi_sas-fix-calls-to-dma_set_mask_and_coherent.patch diff --git a/debian/changelog b/debian/changelog index 129123ad8..8b320dce4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +linux (4.19.37-6) UNRELEASED; urgency=medium + + [ Steve McIntyre ] + * Improve support for the Huawei TaiShan server platform + - Closes: #930554 + - Enable the HNS/ROCE Infiniband driver + - Backport fixes from 4.20 and 4.21 for HNS3 networking, hisi_sas SAS + and HNS/ROCE Infiniband + - Add module:drivers/scsi/hisi_sas/* to the ABI ignore list + + -- Ben Hutchings Wed, 19 Jun 2019 23:16:58 +0100 + linux (4.19.37-5) unstable; urgency=medium [ Romain Perier ] diff --git a/debian/config/arm64/config b/debian/config/arm64/config index 6aedaa096..b9d806a3c 100644 --- a/debian/config/arm64/config +++ b/debian/config/arm64/config @@ -433,6 +433,13 @@ CONFIG_IIO_CROS_EC_LIGHT_PROX=m ## CONFIG_IIO_CROS_EC_BARO=m +## +## file: drivers/infiniband/hw/hns/Kconfig +## +CONFIG_INFINIBAND_HNS=m +CONFIG_INFINIBAND_HNS_HIP06=m +CONFIG_INFINIBAND_HNS_HIP08=m + ## ## file: drivers/input/keyboard/Kconfig ## diff --git a/debian/config/defines b/debian/config/defines index c9be72986..a72467d52 100644 --- a/debian/config/defines +++ b/debian/config/defines @@ -80,6 +80,8 @@ ignore-changes: # Not OOT nf_nat_masquerade_ipv4_register_notifier nf_nat_masquerade_ipv6_register_notifier +# ignore changes to hisi_sas/* + module:drivers/scsi/hisi_sas/* [base] arches: diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0001-scsi-hisi_sas-Feed-back-linkrate-max-min-when-re-att.patch b/debian/patches/bugfix/arm64/huawei-taishan/0001-scsi-hisi_sas-Feed-back-linkrate-max-min-when-re-att.patch new file mode 100644 index 000000000..133afd8a3 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0001-scsi-hisi_sas-Feed-back-linkrate-max-min-when-re-att.patch @@ -0,0 +1,40 @@ +From 97a79982f8b8ddcb129a1be1ecc01cef70ab384d Mon Sep 17 00:00:00 2001 +From: Luo Jiaxing +Date: Mon, 24 Sep 2018 23:06:28 +0800 +Subject: [PATCH 01/31] scsi: hisi_sas: Feed back linkrate(max/min) when + re-attached +Origin: https://git.kernel.org/linus/5a54691f874ab29ec82f08bc6936866a3ccdaa91 + +At directly attached situation, if the user modifies the sysfs interface +of maximum_linkrate and minimum_linkrate to renegotiate the linkrate +between SAS controller and target, the value of both files mentioned +above should have change to user setting after renegotiate is over, but +it remains unchanged. + +To fix this bug, maximum_linkrate and minimum_linkrate will be directly +fed back to relevant sas_phy structure. + +Signed-off-by: Luo Jiaxing +Signed-off-by: John Garry +Signed-off-by: Martin K. Petersen +--- + drivers/scsi/hisi_sas/hisi_sas_main.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c +index fd9d82c9033d..e9747379384b 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_main.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_main.c +@@ -906,6 +906,9 @@ static void hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no, + _r.maximum_linkrate = max; + _r.minimum_linkrate = min; + ++ sas_phy->phy->maximum_linkrate = max; ++ sas_phy->phy->minimum_linkrate = min; ++ + hisi_hba->hw->phy_disable(hisi_hba, phy_no); + msleep(100); + hisi_hba->hw->phy_set_linkrate(hisi_hba, phy_no, &_r); +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0002-scsi-hisi_sas-Move-evaluation-of-hisi_hba-in-hisi_sa.patch b/debian/patches/bugfix/arm64/huawei-taishan/0002-scsi-hisi_sas-Move-evaluation-of-hisi_hba-in-hisi_sa.patch new file mode 100644 index 000000000..b98a6e203 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0002-scsi-hisi_sas-Move-evaluation-of-hisi_hba-in-hisi_sa.patch @@ -0,0 +1,50 @@ +From bbd24b8bdc501fb5dacb43e847b6eeb9a12829f5 Mon Sep 17 00:00:00 2001 +From: Luo Jiaxing +Date: Mon, 24 Sep 2018 23:06:29 +0800 +Subject: [PATCH 02/31] scsi: hisi_sas: Move evaluation of hisi_hba in + hisi_sas_task_prep() +Origin: https://git.kernel.org/linus/1668e3b6f8f8ed2ce685691c92b90dfadeaa3f2f + +In evaluating hisi_hba, the sas_port may be NULL, so for safety relocate +the the check to value possible NULL deference. + +Signed-off-by: Luo Jiaxing +Signed-off-by: John Garry +Signed-off-by: Martin K. Petersen +--- + drivers/scsi/hisi_sas/hisi_sas_main.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c +index e9747379384b..6a959a927e9d 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_main.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_main.c +@@ -288,13 +288,13 @@ static int hisi_sas_task_prep(struct sas_task *task, + int *pass) + { + struct domain_device *device = task->dev; +- struct hisi_hba *hisi_hba = dev_to_hisi_hba(device); ++ struct hisi_hba *hisi_hba; + struct hisi_sas_device *sas_dev = device->lldd_dev; + struct hisi_sas_port *port; + struct hisi_sas_slot *slot; + struct hisi_sas_cmd_hdr *cmd_hdr_base; + struct asd_sas_port *sas_port = device->port; +- struct device *dev = hisi_hba->dev; ++ struct device *dev; + int dlvry_queue_slot, dlvry_queue, rc, slot_idx; + int n_elem = 0, n_elem_req = 0, n_elem_resp = 0; + struct hisi_sas_dq *dq; +@@ -315,6 +315,9 @@ static int hisi_sas_task_prep(struct sas_task *task, + return -ECOMM; + } + ++ hisi_hba = dev_to_hisi_hba(device); ++ dev = hisi_hba->dev; ++ + if (DEV_IS_GONE(sas_dev)) { + if (sas_dev) + dev_info(dev, "task prep: device %d not ready\n", +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0003-scsi-hisi_sas-Fix-the-race-between-IO-completion-and.patch b/debian/patches/bugfix/arm64/huawei-taishan/0003-scsi-hisi_sas-Fix-the-race-between-IO-completion-and.patch new file mode 100644 index 000000000..aa561f30b --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0003-scsi-hisi_sas-Fix-the-race-between-IO-completion-and.patch @@ -0,0 +1,139 @@ +From d754707455238c59350c70ce51123b586fefac52 Mon Sep 17 00:00:00 2001 +From: Xiang Chen +Date: Mon, 24 Sep 2018 23:06:30 +0800 +Subject: [PATCH 03/31] scsi: hisi_sas: Fix the race between IO completion and + timeout for SMP/internal IO +Origin: https://git.kernel.org/linus/584f53fe5f529d877968c711a095923c1ed12307 + +If SMP/internal IO times out, we will possibly free the task immediately. + +However if the IO actually completes at the same time, the IO completion +may refer to task which has been freed. + +So to solve the issue, flush the tasklet to finish IO completion before +free'ing slot/task. + +Signed-off-by: Xiang Chen +Signed-off-by: John Garry +Signed-off-by: Martin K. Petersen +--- + drivers/scsi/hisi_sas/hisi_sas_main.c | 55 ++++++++++++++++++++++----- + 1 file changed, 46 insertions(+), 9 deletions(-) + +diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c +index 6a959a927e9d..2f57a318a71b 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_main.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_main.c +@@ -958,8 +958,7 @@ static int hisi_sas_control_phy(struct asd_sas_phy *sas_phy, enum phy_func func, + + static void hisi_sas_task_done(struct sas_task *task) + { +- if (!del_timer(&task->slow_task->timer)) +- return; ++ del_timer(&task->slow_task->timer); + complete(&task->slow_task->completion); + } + +@@ -968,13 +967,17 @@ static void hisi_sas_tmf_timedout(struct timer_list *t) + struct sas_task_slow *slow = from_timer(slow, t, timer); + struct sas_task *task = slow->task; + unsigned long flags; ++ bool is_completed = true; + + spin_lock_irqsave(&task->task_state_lock, flags); +- if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) ++ if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { + task->task_state_flags |= SAS_TASK_STATE_ABORTED; ++ is_completed = false; ++ } + spin_unlock_irqrestore(&task->task_state_lock, flags); + +- complete(&task->slow_task->completion); ++ if (!is_completed) ++ complete(&task->slow_task->completion); + } + + #define TASK_TIMEOUT 20 +@@ -1025,10 +1028,18 @@ static int hisi_sas_exec_internal_tmf_task(struct domain_device *device, + if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) { + if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { + struct hisi_sas_slot *slot = task->lldd_task; ++ struct hisi_sas_cq *cq = ++ &hisi_hba->cq[slot->dlvry_queue]; + + dev_err(dev, "abort tmf: TMF task timeout and not done\n"); +- if (slot) ++ if (slot) { ++ /* ++ * flush tasklet to avoid free'ing task ++ * before using task in IO completion ++ */ ++ tasklet_kill(&cq->tasklet); + slot->task = NULL; ++ } + + goto ex_err; + } else +@@ -1404,6 +1415,17 @@ static int hisi_sas_abort_task(struct sas_task *task) + + spin_lock_irqsave(&task->task_state_lock, flags); + if (task->task_state_flags & SAS_TASK_STATE_DONE) { ++ struct hisi_sas_slot *slot = task->lldd_task; ++ struct hisi_sas_cq *cq; ++ ++ if (slot) { ++ /* ++ * flush tasklet to avoid free'ing task ++ * before using task in IO completion ++ */ ++ cq = &hisi_hba->cq[slot->dlvry_queue]; ++ tasklet_kill(&cq->tasklet); ++ } + spin_unlock_irqrestore(&task->task_state_lock, flags); + rc = TMF_RESP_FUNC_COMPLETE; + goto out; +@@ -1459,12 +1481,19 @@ static int hisi_sas_abort_task(struct sas_task *task) + /* SMP */ + struct hisi_sas_slot *slot = task->lldd_task; + u32 tag = slot->idx; ++ struct hisi_sas_cq *cq = &hisi_hba->cq[slot->dlvry_queue]; + + rc = hisi_sas_internal_task_abort(hisi_hba, device, + HISI_SAS_INT_ABT_CMD, tag); + if (((rc < 0) || (rc == TMF_RESP_FUNC_FAILED)) && +- task->lldd_task) +- hisi_sas_do_release_task(hisi_hba, task, slot); ++ task->lldd_task) { ++ /* ++ * flush tasklet to avoid free'ing task ++ * before using task in IO completion ++ */ ++ tasklet_kill(&cq->tasklet); ++ slot->task = NULL; ++ } + } + + out: +@@ -1830,9 +1859,17 @@ hisi_sas_internal_task_abort(struct hisi_hba *hisi_hba, + if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) { + if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { + struct hisi_sas_slot *slot = task->lldd_task; +- +- if (slot) ++ struct hisi_sas_cq *cq = ++ &hisi_hba->cq[slot->dlvry_queue]; ++ ++ if (slot) { ++ /* ++ * flush tasklet to avoid free'ing task ++ * before using task in IO completion ++ */ ++ tasklet_kill(&cq->tasklet); + slot->task = NULL; ++ } + dev_err(dev, "internal task abort: timeout and not done.\n"); + res = -EIO; + goto exit; +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0004-scsi-hisi_sas-Free-slot-later-in-slot_complete_vx_hw.patch b/debian/patches/bugfix/arm64/huawei-taishan/0004-scsi-hisi_sas-Free-slot-later-in-slot_complete_vx_hw.patch new file mode 100644 index 000000000..05ac1ba27 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0004-scsi-hisi_sas-Free-slot-later-in-slot_complete_vx_hw.patch @@ -0,0 +1,69 @@ +From 3df1056ee50d09c97e421896a698f74d367282ef Mon Sep 17 00:00:00 2001 +From: Xiang Chen +Date: Mon, 24 Sep 2018 23:06:31 +0800 +Subject: [PATCH 04/31] scsi: hisi_sas: Free slot later in + slot_complete_vx_hw() +Origin: https://git.kernel.org/linus/3e178f3ecfcf91a258e832b0f0843a4cfd9059ac + +If an SSP/SMP IO times out, it may be actually in reality be +simultaneously processing completion of the slot in +slot_complete_vx_hw(). + +Then if the slot is freed in slot_complete_vx_hw() (this IPTT is freed +and it may be re-used by other slot), and we may abort the wrong slot in +hisi_sas_abort_task(). + +So to solve the issue, free the slot after the check of +SAS_TASK_STATE_ABORTED in slot_complete_vx_hw(). + +Signed-off-by: Xiang Chen +Signed-off-by: John Garry +Signed-off-by: Martin K. Petersen +--- + drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 2 +- + drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +index 1c4ea58da1ae..c4774d63d5d0 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +@@ -2481,7 +2481,6 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) + } + + out: +- hisi_sas_slot_task_free(hisi_hba, task, slot); + sts = ts->stat; + spin_lock_irqsave(&task->task_state_lock, flags); + if (task->task_state_flags & SAS_TASK_STATE_ABORTED) { +@@ -2491,6 +2490,7 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) + } + task->task_state_flags |= SAS_TASK_STATE_DONE; + spin_unlock_irqrestore(&task->task_state_lock, flags); ++ hisi_sas_slot_task_free(hisi_hba, task, slot); + + if (!is_internal && (task->task_proto != SAS_PROTOCOL_SMP)) { + spin_lock_irqsave(&device->done_lock, flags); +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +index 3922b17e2ea3..fb2a5969181b 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +@@ -1749,7 +1749,6 @@ slot_complete_v3_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) + } + + out: +- hisi_sas_slot_task_free(hisi_hba, task, slot); + sts = ts->stat; + spin_lock_irqsave(&task->task_state_lock, flags); + if (task->task_state_flags & SAS_TASK_STATE_ABORTED) { +@@ -1759,6 +1758,7 @@ slot_complete_v3_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) + } + task->task_state_flags |= SAS_TASK_STATE_DONE; + spin_unlock_irqrestore(&task->task_state_lock, flags); ++ hisi_sas_slot_task_free(hisi_hba, task, slot); + + if (!is_internal && (task->task_proto != SAS_PROTOCOL_SMP)) { + spin_lock_irqsave(&device->done_lock, flags); +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0005-scsi-hisi_sas-unmask-interrupts-ent72-and-ent74.patch b/debian/patches/bugfix/arm64/huawei-taishan/0005-scsi-hisi_sas-unmask-interrupts-ent72-and-ent74.patch new file mode 100644 index 000000000..e6a7931c3 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0005-scsi-hisi_sas-unmask-interrupts-ent72-and-ent74.patch @@ -0,0 +1,32 @@ +From de1d5713a20562acdb3f94466232432c9dd1d95c Mon Sep 17 00:00:00 2001 +From: Xiang Chen +Date: Mon, 24 Sep 2018 23:06:32 +0800 +Subject: [PATCH 05/31] scsi: hisi_sas: unmask interrupts ent72 and ent74 +Origin: https://git.kernel.org/linus/6ecf5ba13cd5959eb75f617ff32c93bb67790e48 + +The interrupts of ent72 and ent74 are not processed by PCIe AER handling, +so we need to unmask the interrupts and process them first in the driver. + +Signed-off-by: Xiang Chen +Signed-off-by: John Garry +Signed-off-by: Martin K. Petersen +--- + drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +index fb2a5969181b..06824bde9c8d 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +@@ -441,7 +441,7 @@ static void init_reg_v3_hw(struct hisi_hba *hisi_hba) + hisi_sas_write32(hisi_hba, ENT_INT_SRC_MSK1, 0xfefefefe); + hisi_sas_write32(hisi_hba, ENT_INT_SRC_MSK2, 0xfefefefe); + if (pdev->revision >= 0x21) +- hisi_sas_write32(hisi_hba, ENT_INT_SRC_MSK3, 0xffff7fff); ++ hisi_sas_write32(hisi_hba, ENT_INT_SRC_MSK3, 0xffff7aff); + else + hisi_sas_write32(hisi_hba, ENT_INT_SRC_MSK3, 0xfffe20ff); + hisi_sas_write32(hisi_hba, CHNL_PHYUPDOWN_INT_MSK, 0x0); +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0006-scsi-hisi_sas-Use-block-layer-tag-instead-for-IPTT.patch b/debian/patches/bugfix/arm64/huawei-taishan/0006-scsi-hisi_sas-Use-block-layer-tag-instead-for-IPTT.patch new file mode 100644 index 000000000..8bdd59bd3 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0006-scsi-hisi_sas-Use-block-layer-tag-instead-for-IPTT.patch @@ -0,0 +1,321 @@ +From d35bf6fccf7d4064065c078d3d369ffeaad6c731 Mon Sep 17 00:00:00 2001 +From: Xiang Chen +Date: Mon, 24 Sep 2018 23:06:33 +0800 +Subject: [PATCH 06/31] scsi: hisi_sas: Use block layer tag instead for IPTT +Origin: https://git.kernel.org/linus/784b46b7cba0ae914dd293f23848c5057c6ba017 + +Currently we use the IPTT defined in LLDD to identify IOs. Actually for +IOs which are from the block layer, they have tags to identify them. So +for those IOs, use tag of the block layer directly, and for IOs which is +not from the block layer (such as internal IOs from libsas/LLDD), reserve +96 IPTTs for them. + +Signed-off-by: Xiang Chen +Signed-off-by: John Garry +Signed-off-by: Martin K. Petersen +--- + drivers/scsi/hisi_sas/hisi_sas.h | 3 +- + drivers/scsi/hisi_sas/hisi_sas_main.c | 89 +++++++++++++++++--------- + drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 1 - + drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 9 +-- + drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 8 ++- + 5 files changed, 70 insertions(+), 40 deletions(-) + +diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h +index 6c7d2e201abe..0ddb53c8a2e2 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas.h ++++ b/drivers/scsi/hisi_sas/hisi_sas.h +@@ -34,6 +34,7 @@ + #define HISI_SAS_MAX_DEVICES HISI_SAS_MAX_ITCT_ENTRIES + #define HISI_SAS_RESET_BIT 0 + #define HISI_SAS_REJECT_CMD_BIT 1 ++#define HISI_SAS_RESERVED_IPTT_CNT 96 + + #define HISI_SAS_STATUS_BUF_SZ (sizeof(struct hisi_sas_status_buffer)) + #define HISI_SAS_COMMAND_TABLE_SZ (sizeof(union hisi_sas_command_table)) +@@ -217,7 +218,7 @@ struct hisi_sas_hw { + int (*hw_init)(struct hisi_hba *hisi_hba); + void (*setup_itct)(struct hisi_hba *hisi_hba, + struct hisi_sas_device *device); +- int (*slot_index_alloc)(struct hisi_hba *hisi_hba, int *slot_idx, ++ int (*slot_index_alloc)(struct hisi_hba *hisi_hba, + struct domain_device *device); + struct hisi_sas_device *(*alloc_dev)(struct domain_device *device); + void (*sl_notify)(struct hisi_hba *hisi_hba, int phy_no); +diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c +index 2f57a318a71b..c2998d3ac37f 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_main.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_main.c +@@ -184,7 +184,14 @@ static void hisi_sas_slot_index_clear(struct hisi_hba *hisi_hba, int slot_idx) + + static void hisi_sas_slot_index_free(struct hisi_hba *hisi_hba, int slot_idx) + { +- hisi_sas_slot_index_clear(hisi_hba, slot_idx); ++ unsigned long flags; ++ ++ if (hisi_hba->hw->slot_index_alloc || (slot_idx >= ++ hisi_hba->hw->max_command_entries - HISI_SAS_RESERVED_IPTT_CNT)) { ++ spin_lock_irqsave(&hisi_hba->lock, flags); ++ hisi_sas_slot_index_clear(hisi_hba, slot_idx); ++ spin_unlock_irqrestore(&hisi_hba->lock, flags); ++ } + } + + static void hisi_sas_slot_index_set(struct hisi_hba *hisi_hba, int slot_idx) +@@ -194,24 +201,34 @@ static void hisi_sas_slot_index_set(struct hisi_hba *hisi_hba, int slot_idx) + set_bit(slot_idx, bitmap); + } + +-static int hisi_sas_slot_index_alloc(struct hisi_hba *hisi_hba, int *slot_idx) ++static int hisi_sas_slot_index_alloc(struct hisi_hba *hisi_hba, ++ struct scsi_cmnd *scsi_cmnd) + { +- unsigned int index; ++ int index; + void *bitmap = hisi_hba->slot_index_tags; ++ unsigned long flags; + ++ if (scsi_cmnd) ++ return scsi_cmnd->request->tag; ++ ++ spin_lock_irqsave(&hisi_hba->lock, flags); + index = find_next_zero_bit(bitmap, hisi_hba->slot_index_count, +- hisi_hba->last_slot_index + 1); ++ hisi_hba->last_slot_index + 1); + if (index >= hisi_hba->slot_index_count) { +- index = find_next_zero_bit(bitmap, hisi_hba->slot_index_count, +- 0); +- if (index >= hisi_hba->slot_index_count) ++ index = find_next_zero_bit(bitmap, ++ hisi_hba->slot_index_count, ++ hisi_hba->hw->max_command_entries - ++ HISI_SAS_RESERVED_IPTT_CNT); ++ if (index >= hisi_hba->slot_index_count) { ++ spin_unlock_irqrestore(&hisi_hba->lock, flags); + return -SAS_QUEUE_FULL; ++ } + } + hisi_sas_slot_index_set(hisi_hba, index); +- *slot_idx = index; + hisi_hba->last_slot_index = index; ++ spin_unlock_irqrestore(&hisi_hba->lock, flags); + +- return 0; ++ return index; + } + + static void hisi_sas_slot_index_init(struct hisi_hba *hisi_hba) +@@ -250,9 +267,7 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task, + + memset(slot, 0, offsetof(struct hisi_sas_slot, buf)); + +- spin_lock_irqsave(&hisi_hba->lock, flags); + hisi_sas_slot_index_free(hisi_hba, slot->idx); +- spin_unlock_irqrestore(&hisi_hba->lock, flags); + } + EXPORT_SYMBOL_GPL(hisi_sas_slot_task_free); + +@@ -385,16 +400,27 @@ static int hisi_sas_task_prep(struct sas_task *task, + goto err_out_dma_unmap; + } + +- spin_lock_irqsave(&hisi_hba->lock, flags); + if (hisi_hba->hw->slot_index_alloc) +- rc = hisi_hba->hw->slot_index_alloc(hisi_hba, &slot_idx, +- device); +- else +- rc = hisi_sas_slot_index_alloc(hisi_hba, &slot_idx); +- spin_unlock_irqrestore(&hisi_hba->lock, flags); +- if (rc) ++ rc = hisi_hba->hw->slot_index_alloc(hisi_hba, device); ++ else { ++ struct scsi_cmnd *scsi_cmnd = NULL; ++ ++ if (task->uldd_task) { ++ struct ata_queued_cmd *qc; ++ ++ if (dev_is_sata(device)) { ++ qc = task->uldd_task; ++ scsi_cmnd = qc->scsicmd; ++ } else { ++ scsi_cmnd = task->uldd_task; ++ } ++ } ++ rc = hisi_sas_slot_index_alloc(hisi_hba, scsi_cmnd); ++ } ++ if (rc < 0) + goto err_out_dma_unmap; + ++ slot_idx = rc; + slot = &hisi_hba->slot_info[slot_idx]; + + spin_lock_irqsave(&dq->lock, flags); +@@ -455,9 +481,7 @@ static int hisi_sas_task_prep(struct sas_task *task, + return 0; + + err_out_tag: +- spin_lock_irqsave(&hisi_hba->lock, flags); + hisi_sas_slot_index_free(hisi_hba, slot_idx); +- spin_unlock_irqrestore(&hisi_hba->lock, flags); + err_out_dma_unmap: + if (!sas_protocol_ata(task->task_proto)) { + if (task->num_scatter) { +@@ -1742,14 +1766,11 @@ hisi_sas_internal_abort_task_exec(struct hisi_hba *hisi_hba, int device_id, + port = to_hisi_sas_port(sas_port); + + /* simply get a slot and send abort command */ +- spin_lock_irqsave(&hisi_hba->lock, flags); +- rc = hisi_sas_slot_index_alloc(hisi_hba, &slot_idx); +- if (rc) { +- spin_unlock_irqrestore(&hisi_hba->lock, flags); ++ rc = hisi_sas_slot_index_alloc(hisi_hba, NULL); ++ if (rc < 0) + goto err_out; +- } +- spin_unlock_irqrestore(&hisi_hba->lock, flags); + ++ slot_idx = rc; + slot = &hisi_hba->slot_info[slot_idx]; + + spin_lock_irqsave(&dq->lock, flags_dq); +@@ -1785,7 +1806,6 @@ hisi_sas_internal_abort_task_exec(struct hisi_hba *hisi_hba, int device_id, + spin_lock_irqsave(&task->task_state_lock, flags); + task->task_state_flags |= SAS_TASK_AT_INITIATOR; + spin_unlock_irqrestore(&task->task_state_lock, flags); +- + WRITE_ONCE(slot->ready, 1); + /* send abort command to the chip */ + spin_lock_irqsave(&dq->lock, flags); +@@ -1796,9 +1816,7 @@ hisi_sas_internal_abort_task_exec(struct hisi_hba *hisi_hba, int device_id, + return 0; + + err_out_tag: +- spin_lock_irqsave(&hisi_hba->lock, flags); + hisi_sas_slot_index_free(hisi_hba, slot_idx); +- spin_unlock_irqrestore(&hisi_hba->lock, flags); + err_out: + dev_err(dev, "internal abort task prep: failed[%d]!\n", rc); + +@@ -2174,6 +2192,8 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost) + hisi_sas_init_mem(hisi_hba); + + hisi_sas_slot_index_init(hisi_hba); ++ hisi_hba->last_slot_index = hisi_hba->hw->max_command_entries - ++ HISI_SAS_RESERVED_IPTT_CNT; + + hisi_hba->wq = create_singlethread_workqueue(dev_name(dev)); + if (!hisi_hba->wq) { +@@ -2377,8 +2397,15 @@ int hisi_sas_probe(struct platform_device *pdev, + shost->max_channel = 1; + shost->max_cmd_len = 16; + shost->sg_tablesize = min_t(u16, SG_ALL, HISI_SAS_SGE_PAGE_CNT); +- shost->can_queue = hisi_hba->hw->max_command_entries; +- shost->cmd_per_lun = hisi_hba->hw->max_command_entries; ++ if (hisi_hba->hw->slot_index_alloc) { ++ shost->can_queue = hisi_hba->hw->max_command_entries; ++ shost->cmd_per_lun = hisi_hba->hw->max_command_entries; ++ } else { ++ shost->can_queue = hisi_hba->hw->max_command_entries - ++ HISI_SAS_RESERVED_IPTT_CNT; ++ shost->cmd_per_lun = hisi_hba->hw->max_command_entries - ++ HISI_SAS_RESERVED_IPTT_CNT; ++ } + + sha->sas_ha_name = DRV_NAME; + sha->dev = hisi_hba->dev; +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +index 410eccf0bc5e..8df822a4a1bd 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +@@ -1807,7 +1807,6 @@ static struct scsi_host_template sht_v1_hw = { + .scan_start = hisi_sas_scan_start, + .change_queue_depth = sas_change_queue_depth, + .bios_param = sas_bios_param, +- .can_queue = 1, + .this_id = -1, + .sg_tablesize = SG_ALL, + .max_sectors = SCSI_DEFAULT_MAX_SECTORS, +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +index c4774d63d5d0..58a564c75a35 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +@@ -770,7 +770,7 @@ static u32 hisi_sas_phy_read32(struct hisi_hba *hisi_hba, + + /* This function needs to be protected from pre-emption. */ + static int +-slot_index_alloc_quirk_v2_hw(struct hisi_hba *hisi_hba, int *slot_idx, ++slot_index_alloc_quirk_v2_hw(struct hisi_hba *hisi_hba, + struct domain_device *device) + { + int sata_dev = dev_is_sata(device); +@@ -778,6 +778,7 @@ slot_index_alloc_quirk_v2_hw(struct hisi_hba *hisi_hba, int *slot_idx, + struct hisi_sas_device *sas_dev = device->lldd_dev; + int sata_idx = sas_dev->sata_idx; + int start, end; ++ unsigned long flags; + + if (!sata_dev) { + /* +@@ -801,6 +802,7 @@ slot_index_alloc_quirk_v2_hw(struct hisi_hba *hisi_hba, int *slot_idx, + end = 64 * (sata_idx + 2); + } + ++ spin_lock_irqsave(&hisi_hba->lock, flags); + while (1) { + start = find_next_zero_bit(bitmap, + hisi_hba->slot_index_count, start); +@@ -815,8 +817,8 @@ slot_index_alloc_quirk_v2_hw(struct hisi_hba *hisi_hba, int *slot_idx, + } + + set_bit(start, bitmap); +- *slot_idx = start; +- return 0; ++ spin_unlock_irqrestore(&hisi_hba->lock, flags); ++ return start; + } + + static bool sata_index_alloc_v2_hw(struct hisi_hba *hisi_hba, int *idx) +@@ -3558,7 +3560,6 @@ static struct scsi_host_template sht_v2_hw = { + .scan_start = hisi_sas_scan_start, + .change_queue_depth = sas_change_queue_depth, + .bios_param = sas_bios_param, +- .can_queue = 1, + .this_id = -1, + .sg_tablesize = SG_ALL, + .max_sectors = SCSI_DEFAULT_MAX_SECTORS, +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +index 06824bde9c8d..a0fc2d5de787 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +@@ -2096,7 +2096,6 @@ static struct scsi_host_template sht_v3_hw = { + .scan_start = hisi_sas_scan_start, + .change_queue_depth = sas_change_queue_depth, + .bios_param = sas_bios_param, +- .can_queue = 1, + .this_id = -1, + .sg_tablesize = SG_ALL, + .max_sectors = SCSI_DEFAULT_MAX_SECTORS, +@@ -2106,6 +2105,7 @@ static struct scsi_host_template sht_v3_hw = { + .target_destroy = sas_target_destroy, + .ioctl = sas_ioctl, + .shost_attrs = host_attrs, ++ .tag_alloc_policy = BLK_TAG_ALLOC_RR, + }; + + static const struct hisi_sas_hw hisi_sas_v3_hw = { +@@ -2243,8 +2243,10 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id) + shost->max_channel = 1; + shost->max_cmd_len = 16; + shost->sg_tablesize = min_t(u16, SG_ALL, HISI_SAS_SGE_PAGE_CNT); +- shost->can_queue = hisi_hba->hw->max_command_entries; +- shost->cmd_per_lun = hisi_hba->hw->max_command_entries; ++ shost->can_queue = hisi_hba->hw->max_command_entries - ++ HISI_SAS_RESERVED_IPTT_CNT; ++ shost->cmd_per_lun = hisi_hba->hw->max_command_entries - ++ HISI_SAS_RESERVED_IPTT_CNT; + + sha->sas_ha_name = DRV_NAME; + sha->dev = dev; +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0007-scsi-hisi_sas-Update-v3-hw-AIP_LIMIT-and-CFG_AGING_T.patch b/debian/patches/bugfix/arm64/huawei-taishan/0007-scsi-hisi_sas-Update-v3-hw-AIP_LIMIT-and-CFG_AGING_T.patch new file mode 100644 index 000000000..8f72f96bb --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0007-scsi-hisi_sas-Update-v3-hw-AIP_LIMIT-and-CFG_AGING_T.patch @@ -0,0 +1,57 @@ +From 4fdcfb8a09d75fbabf4454a60001224b89245c82 Mon Sep 17 00:00:00 2001 +From: Xiang Chen +Date: Mon, 24 Sep 2018 23:06:34 +0800 +Subject: [PATCH 07/31] scsi: hisi_sas: Update v3 hw AIP_LIMIT and + CFG_AGING_TIME register values +Origin: https://git.kernel.org/linus/3bccfba8312762becfb05b35d698ba8cffd440f2 + +Update registers as follows: +- Default value of AIP timer is 1ms, and it is easy for some expanders to + cause IO error. Change the value to max value 65ms to avoid IO error for + those expanders. + +- A CQ completion will be reported by HW when 4 CQs have occurred or the + aging timer expires, whichever happens first. Sor serial IO scenario, it + will still wait 8us for every IO before it is reported. So in the + situation, the performance is poor. So to improve it, change the limit + time to the least value. + For other scenario, it does little affect to the performance. + +Signed-off-by: Xiang Chen +Signed-off-by: John Garry +Signed-off-by: Martin K. Petersen +--- + drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +index a0fc2d5de787..c3e0be90e19f 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +@@ -127,6 +127,7 @@ + #define PHY_CTRL_RESET_OFF 0 + #define PHY_CTRL_RESET_MSK (0x1 << PHY_CTRL_RESET_OFF) + #define SL_CFG (PORT_BASE + 0x84) ++#define AIP_LIMIT (PORT_BASE + 0x90) + #define SL_CONTROL (PORT_BASE + 0x94) + #define SL_CONTROL_NOTIFY_EN_OFF 0 + #define SL_CONTROL_NOTIFY_EN_MSK (0x1 << SL_CONTROL_NOTIFY_EN_OFF) +@@ -431,6 +432,7 @@ static void init_reg_v3_hw(struct hisi_hba *hisi_hba) + (u32)((1ULL << hisi_hba->queue_count) - 1)); + hisi_sas_write32(hisi_hba, CFG_MAX_TAG, 0xfff0400); + hisi_sas_write32(hisi_hba, HGC_SAS_TXFAIL_RETRY_CTRL, 0x108); ++ hisi_sas_write32(hisi_hba, CFG_AGING_TIME, 0x1); + hisi_sas_write32(hisi_hba, INT_COAL_EN, 0x1); + hisi_sas_write32(hisi_hba, OQ_INT_COAL_TIME, 0x1); + hisi_sas_write32(hisi_hba, OQ_INT_COAL_CNT, 0x1); +@@ -495,6 +497,7 @@ static void init_reg_v3_hw(struct hisi_hba *hisi_hba) + hisi_sas_phy_write32(hisi_hba, i, SAS_SSP_CON_TIMER_CFG, 0x32); + /* used for 12G negotiate */ + hisi_sas_phy_write32(hisi_hba, i, COARSETUNE_TIME, 0x1e); ++ hisi_sas_phy_write32(hisi_hba, i, AIP_LIMIT, 0x2ffff); + } + + for (i = 0; i < hisi_hba->queue_count; i++) { +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0008-scsi-hisi_sas-Fix-spin-lock-management-in-slot_index.patch b/debian/patches/bugfix/arm64/huawei-taishan/0008-scsi-hisi_sas-Fix-spin-lock-management-in-slot_index.patch new file mode 100644 index 000000000..d0083f64e --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0008-scsi-hisi_sas-Fix-spin-lock-management-in-slot_index.patch @@ -0,0 +1,36 @@ +From f27f6edaf4983b00a3c0e2f6ab720cfa3150a147 Mon Sep 17 00:00:00 2001 +From: John Garry +Date: Tue, 16 Oct 2018 23:00:36 +0800 +Subject: [PATCH 08/31] scsi: hisi_sas: Fix spin lock management in + slot_index_alloc_quirk_v2_hw() +Origin: https://git.kernel.org/linus/fe5fb42de36227c1c2dbb1e7403329ec8a915c20 + +Currently a spin_unlock_irqrestore() call is missing on the error path, +so add it. + +Reported-by: Julia Lawall +Signed-off-by: John Garry +Signed-off-by: Martin K. Petersen +--- + drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +index 58a564c75a35..77a85ead483e 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +@@ -806,8 +806,10 @@ slot_index_alloc_quirk_v2_hw(struct hisi_hba *hisi_hba, + while (1) { + start = find_next_zero_bit(bitmap, + hisi_hba->slot_index_count, start); +- if (start >= end) ++ if (start >= end) { ++ spin_unlock_irqrestore(&hisi_hba->lock, flags); + return -SAS_QUEUE_FULL; ++ } + /* + * SAS IPTT bit0 should be 1, and SATA IPTT bit0 should be 0. + */ +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0009-scsi-hisi_sas-use-dma_set_mask_and_coherent.patch b/debian/patches/bugfix/arm64/huawei-taishan/0009-scsi-hisi_sas-use-dma_set_mask_and_coherent.patch new file mode 100644 index 000000000..0bad1af78 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0009-scsi-hisi_sas-use-dma_set_mask_and_coherent.patch @@ -0,0 +1,43 @@ +From 59bc5f2f2492ef9949cd723fc98bafa7d8a6c287 Mon Sep 17 00:00:00 2001 +From: Christoph Hellwig +Date: Thu, 18 Oct 2018 15:10:17 +0200 +Subject: [PATCH 09/31] scsi: hisi_sas: use dma_set_mask_and_coherent +Origin: https://git.kernel.org/linus/e4db40e7a1a2cd6af3b6d5f8f3fba15533872398 + +The driver currently uses pci_set_dma_mask despite otherwise using the +generic DMA API. Switch it over to the better generic DMA API. + +Signed-off-by: Christoph Hellwig +Acked-by: John Garry +Signed-off-by: Martin K. Petersen +--- + drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 13 +++++-------- + 1 file changed, 5 insertions(+), 8 deletions(-) + +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +index c3e0be90e19f..43005d39abe6 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +@@ -2199,14 +2199,11 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id) + if (rc) + goto err_out_disable_device; + +- if ((pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) != 0) || +- (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)) != 0)) { +- if ((pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) != 0) || +- (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)) != 0)) { +- dev_err(dev, "No usable DMA addressing method\n"); +- rc = -EIO; +- goto err_out_regions; +- } ++ if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) || ++ dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) { ++ dev_err(dev, "No usable DMA addressing method\n"); ++ rc = -EIO; ++ goto err_out_regions; + } + + shost = hisi_sas_shost_alloc_pci(pdev); +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0010-scsi-hisi_sas-Create-separate-host-attributes-per-HB.patch b/debian/patches/bugfix/arm64/huawei-taishan/0010-scsi-hisi_sas-Create-separate-host-attributes-per-HB.patch new file mode 100644 index 000000000..15e139004 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0010-scsi-hisi_sas-Create-separate-host-attributes-per-HB.patch @@ -0,0 +1,129 @@ +From 4e63bca6e8c3a7fac800ee6c27f9afab13774fde Mon Sep 17 00:00:00 2001 +From: Xiang Chen +Date: Fri, 9 Nov 2018 22:06:32 +0800 +Subject: [PATCH 10/31] scsi: hisi_sas: Create separate host attributes per HBA +Origin: https://git.kernel.org/linus/c3566f9a617de3288739fd3b8e7539951bf2b04d + +Currently all the three HBA (v1/v2/v3 HW) share the same host attributes. + +To support each HBA having separate attributes in future, create per-HBA +attributes. + +Signed-off-by: Xiang Chen +Signed-off-by: John Garry +Signed-off-by: Martin K. Petersen +--- + drivers/scsi/hisi_sas/hisi_sas.h | 1 - + drivers/scsi/hisi_sas/hisi_sas_main.c | 6 ------ + drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 7 ++++++- + drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 7 ++++++- + drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 7 ++++++- + 5 files changed, 18 insertions(+), 10 deletions(-) + +diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h +index 0ddb53c8a2e2..94a9e13c069c 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas.h ++++ b/drivers/scsi/hisi_sas/hisi_sas.h +@@ -468,7 +468,6 @@ extern int hisi_sas_remove(struct platform_device *pdev); + extern int hisi_sas_slave_configure(struct scsi_device *sdev); + extern int hisi_sas_scan_finished(struct Scsi_Host *shost, unsigned long time); + extern void hisi_sas_scan_start(struct Scsi_Host *shost); +-extern struct device_attribute *host_attrs[]; + extern int hisi_sas_host_reset(struct Scsi_Host *shost, int reset_type); + extern void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy); + extern void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, +diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c +index c2998d3ac37f..dc71f8d83551 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_main.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_main.c +@@ -2009,12 +2009,6 @@ EXPORT_SYMBOL_GPL(hisi_sas_kill_tasklets); + struct scsi_transport_template *hisi_sas_stt; + EXPORT_SYMBOL_GPL(hisi_sas_stt); + +-struct device_attribute *host_attrs[] = { +- &dev_attr_phy_event_threshold, +- NULL, +-}; +-EXPORT_SYMBOL_GPL(host_attrs); +- + static struct sas_domain_function_template hisi_sas_transport_ops = { + .lldd_dev_found = hisi_sas_dev_found, + .lldd_dev_gone = hisi_sas_dev_gone, +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +index 8df822a4a1bd..e8e3a876e493 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +@@ -1797,6 +1797,11 @@ static int hisi_sas_v1_init(struct hisi_hba *hisi_hba) + return 0; + } + ++static struct device_attribute *host_attrs_v1_hw[] = { ++ &dev_attr_phy_event_threshold, ++ NULL ++}; ++ + static struct scsi_host_template sht_v1_hw = { + .name = DRV_NAME, + .module = THIS_MODULE, +@@ -1815,7 +1820,7 @@ static struct scsi_host_template sht_v1_hw = { + .eh_target_reset_handler = sas_eh_target_reset_handler, + .target_destroy = sas_target_destroy, + .ioctl = sas_ioctl, +- .shost_attrs = host_attrs, ++ .shost_attrs = host_attrs_v1_hw, + }; + + static const struct hisi_sas_hw hisi_sas_v1_hw = { +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +index 77a85ead483e..574a269e2865 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +@@ -3552,6 +3552,11 @@ static void wait_cmds_complete_timeout_v2_hw(struct hisi_hba *hisi_hba, + dev_dbg(dev, "wait commands complete %dms\n", time); + } + ++struct device_attribute *host_attrs_v2_hw[] = { ++ &dev_attr_phy_event_threshold, ++ NULL ++}; ++ + static struct scsi_host_template sht_v2_hw = { + .name = DRV_NAME, + .module = THIS_MODULE, +@@ -3570,7 +3575,7 @@ static struct scsi_host_template sht_v2_hw = { + .eh_target_reset_handler = sas_eh_target_reset_handler, + .target_destroy = sas_target_destroy, + .ioctl = sas_ioctl, +- .shost_attrs = host_attrs, ++ .shost_attrs = host_attrs_v2_hw, + }; + + static const struct hisi_sas_hw hisi_sas_v2_hw = { +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +index 43005d39abe6..1d0896959fbb 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +@@ -2089,6 +2089,11 @@ static void wait_cmds_complete_timeout_v3_hw(struct hisi_hba *hisi_hba, + dev_dbg(dev, "wait commands complete %dms\n", time); + } + ++struct device_attribute *host_attrs_v3_hw[] = { ++ &dev_attr_phy_event_threshold, ++ NULL ++}; ++ + static struct scsi_host_template sht_v3_hw = { + .name = DRV_NAME, + .module = THIS_MODULE, +@@ -2107,7 +2112,7 @@ static struct scsi_host_template sht_v3_hw = { + .eh_target_reset_handler = sas_eh_target_reset_handler, + .target_destroy = sas_target_destroy, + .ioctl = sas_ioctl, +- .shost_attrs = host_attrs, ++ .shost_attrs = host_attrs_v3_hw, + .tag_alloc_policy = BLK_TAG_ALLOC_RR, + }; + +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0011-scsi-hisi_sas-Add-support-for-interrupt-converge-for.patch b/debian/patches/bugfix/arm64/huawei-taishan/0011-scsi-hisi_sas-Add-support-for-interrupt-converge-for.patch new file mode 100644 index 000000000..fab91f300 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0011-scsi-hisi_sas-Add-support-for-interrupt-converge-for.patch @@ -0,0 +1,116 @@ +From 7e5e4c2dfd67e156956e46c4d503466726a5359c Mon Sep 17 00:00:00 2001 +From: Xiang Chen +Date: Fri, 9 Nov 2018 22:06:33 +0800 +Subject: [PATCH 11/31] scsi: hisi_sas: Add support for interrupt converge for + v3 hw +Origin: https://git.kernel.org/linus/488cf558e3d7c95daf737d9cae165019ee3f2840 + +If CQ_INT_CONVERGE_EN is enabled, the interrupts of all the 16 CQ queues +will be reported by CQ0. + +So we need to change the process of CQ tasklet for this situation. + +Signed-off-by: Xiang Chen +Signed-off-by: John Garry +Signed-off-by: Martin K. Petersen +--- + drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 29 +++++++++++++++++++++----- + 1 file changed, 24 insertions(+), 5 deletions(-) + +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +index 1d0896959fbb..b70190936f1b 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +@@ -42,6 +42,7 @@ + #define MAX_CON_TIME_LIMIT_TIME 0xa4 + #define BUS_INACTIVE_LIMIT_TIME 0xa8 + #define REJECT_TO_OPEN_LIMIT_TIME 0xac ++#define CQ_INT_CONVERGE_EN 0xb0 + #define CFG_AGING_TIME 0xbc + #define HGC_DFX_CFG2 0xc0 + #define CFG_ABT_SET_QUERY_IPTT 0xd4 +@@ -371,6 +372,9 @@ struct hisi_sas_err_record_v3 { + ((fis.command == ATA_CMD_DEV_RESET) && \ + ((fis.control & ATA_SRST) != 0))) + ++static bool hisi_sas_intr_conv; ++MODULE_PARM_DESC(intr_conv, "interrupt converge enable (0-1)"); ++ + static u32 hisi_sas_read32(struct hisi_hba *hisi_hba, u32 off) + { + void __iomem *regs = hisi_hba->regs + off; +@@ -436,6 +440,8 @@ static void init_reg_v3_hw(struct hisi_hba *hisi_hba) + hisi_sas_write32(hisi_hba, INT_COAL_EN, 0x1); + hisi_sas_write32(hisi_hba, OQ_INT_COAL_TIME, 0x1); + hisi_sas_write32(hisi_hba, OQ_INT_COAL_CNT, 0x1); ++ hisi_sas_write32(hisi_hba, CQ_INT_CONVERGE_EN, ++ hisi_sas_intr_conv); + hisi_sas_write32(hisi_hba, OQ_INT_SRC, 0xffff); + hisi_sas_write32(hisi_hba, ENT_INT_SRC1, 0xffffffff); + hisi_sas_write32(hisi_hba, ENT_INT_SRC2, 0xffffffff); +@@ -1878,10 +1884,12 @@ static int interrupt_init_v3_hw(struct hisi_hba *hisi_hba) + for (i = 0; i < hisi_hba->queue_count; i++) { + struct hisi_sas_cq *cq = &hisi_hba->cq[i]; + struct tasklet_struct *t = &cq->tasklet; ++ int nr = hisi_sas_intr_conv ? 16 : 16 + i; ++ unsigned long irqflags = hisi_sas_intr_conv ? IRQF_SHARED : 0; + +- rc = devm_request_irq(dev, pci_irq_vector(pdev, i+16), +- cq_interrupt_v3_hw, 0, +- DRV_NAME " cq", cq); ++ rc = devm_request_irq(dev, pci_irq_vector(pdev, nr), ++ cq_interrupt_v3_hw, irqflags, ++ DRV_NAME " cq", cq); + if (rc) { + dev_err(dev, + "could not request cq%d interrupt, rc=%d\n", +@@ -1898,8 +1906,9 @@ static int interrupt_init_v3_hw(struct hisi_hba *hisi_hba) + free_cq_irqs: + for (k = 0; k < i; k++) { + struct hisi_sas_cq *cq = &hisi_hba->cq[k]; ++ int nr = hisi_sas_intr_conv ? 16 : 16 + k; + +- free_irq(pci_irq_vector(pdev, k+16), cq); ++ free_irq(pci_irq_vector(pdev, nr), cq); + } + free_irq(pci_irq_vector(pdev, 11), hisi_hba); + free_chnl_interrupt: +@@ -2089,8 +2098,16 @@ static void wait_cmds_complete_timeout_v3_hw(struct hisi_hba *hisi_hba, + dev_dbg(dev, "wait commands complete %dms\n", time); + } + ++static ssize_t intr_conv_v3_hw_show(struct device *dev, ++ struct device_attribute *attr, char *buf) ++{ ++ return scnprintf(buf, PAGE_SIZE, "%u\n", hisi_sas_intr_conv); ++} ++static DEVICE_ATTR_RO(intr_conv_v3_hw); ++ + struct device_attribute *host_attrs_v3_hw[] = { + &dev_attr_phy_event_threshold, ++ &dev_attr_intr_conv_v3_hw, + NULL + }; + +@@ -2303,8 +2320,9 @@ hisi_sas_v3_destroy_irqs(struct pci_dev *pdev, struct hisi_hba *hisi_hba) + free_irq(pci_irq_vector(pdev, 11), hisi_hba); + for (i = 0; i < hisi_hba->queue_count; i++) { + struct hisi_sas_cq *cq = &hisi_hba->cq[i]; ++ int nr = hisi_sas_intr_conv ? 16 : 16 + i; + +- free_irq(pci_irq_vector(pdev, i+16), cq); ++ free_irq(pci_irq_vector(pdev, nr), cq); + } + pci_free_irq_vectors(pdev); + } +@@ -2626,6 +2644,7 @@ static struct pci_driver sas_v3_pci_driver = { + }; + + module_pci_driver(sas_v3_pci_driver); ++module_param_named(intr_conv, hisi_sas_intr_conv, bool, 0444); + + MODULE_LICENSE("GPL"); + MODULE_AUTHOR("John Garry "); +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0012-scsi-hisi_sas-Add-support-for-interrupt-coalescing-f.patch b/debian/patches/bugfix/arm64/huawei-taishan/0012-scsi-hisi_sas-Add-support-for-interrupt-coalescing-f.patch new file mode 100644 index 000000000..fa038117d --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0012-scsi-hisi_sas-Add-support-for-interrupt-coalescing-f.patch @@ -0,0 +1,153 @@ +From 20ca5e4f2c4a2c08340225f074c56f7be1c86f5b Mon Sep 17 00:00:00 2001 +From: Xiang Chen +Date: Fri, 9 Nov 2018 22:06:34 +0800 +Subject: [PATCH 12/31] scsi: hisi_sas: Add support for interrupt coalescing + for v3 hw +Origin: https://git.kernel.org/linus/37359798ec44ae03fab383a9bef3b7c9df819063 + +If INT_COAL_EN is enabled, configure time and count of interrupt +coalescing. Then if CQ collects count of CQ entries in time, it will +report the interrupt. Or if CQ doesn't collect enough CQ entries in time, +it will report the interrupt at timeout. + +As all the registers are not supported to be changed dynamically, we need +to config those register between disable and enable PHYs. + +Signed-off-by: Xiang Chen +Signed-off-by: John Garry +Signed-off-by: Martin K. Petersen +--- + drivers/scsi/hisi_sas/hisi_sas.h | 2 + + drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 100 +++++++++++++++++++++++++ + 2 files changed, 102 insertions(+) + +diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h +index 94a9e13c069c..535c61391250 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas.h ++++ b/drivers/scsi/hisi_sas/hisi_sas.h +@@ -322,6 +322,8 @@ struct hisi_hba { + unsigned long sata_dev_bitmap[BITS_TO_LONGS(HISI_SAS_MAX_DEVICES)]; + struct work_struct rst_work; + u32 phy_state; ++ u32 intr_coal_ticks; /* Time of interrupt coalesce in us */ ++ u32 intr_coal_count; /* Interrupt count to coalesce */ + }; + + /* Generic HW DMA host memory structures */ +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +index b70190936f1b..7d7cb73e4bee 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +@@ -2105,9 +2105,109 @@ static ssize_t intr_conv_v3_hw_show(struct device *dev, + } + static DEVICE_ATTR_RO(intr_conv_v3_hw); + ++static void config_intr_coal_v3_hw(struct hisi_hba *hisi_hba) ++{ ++ /* config those registers between enable and disable PHYs */ ++ hisi_sas_stop_phys(hisi_hba); ++ ++ if (hisi_hba->intr_coal_ticks == 0 || ++ hisi_hba->intr_coal_count == 0) { ++ hisi_sas_write32(hisi_hba, INT_COAL_EN, 0x1); ++ hisi_sas_write32(hisi_hba, OQ_INT_COAL_TIME, 0x1); ++ hisi_sas_write32(hisi_hba, OQ_INT_COAL_CNT, 0x1); ++ } else { ++ hisi_sas_write32(hisi_hba, INT_COAL_EN, 0x3); ++ hisi_sas_write32(hisi_hba, OQ_INT_COAL_TIME, ++ hisi_hba->intr_coal_ticks); ++ hisi_sas_write32(hisi_hba, OQ_INT_COAL_CNT, ++ hisi_hba->intr_coal_count); ++ } ++ phys_init_v3_hw(hisi_hba); ++} ++ ++static ssize_t intr_coal_ticks_v3_hw_show(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct Scsi_Host *shost = class_to_shost(dev); ++ struct hisi_hba *hisi_hba = shost_priv(shost); ++ ++ return scnprintf(buf, PAGE_SIZE, "%u\n", ++ hisi_hba->intr_coal_ticks); ++} ++ ++static ssize_t intr_coal_ticks_v3_hw_store(struct device *dev, ++ struct device_attribute *attr, ++ const char *buf, size_t count) ++{ ++ struct Scsi_Host *shost = class_to_shost(dev); ++ struct hisi_hba *hisi_hba = shost_priv(shost); ++ u32 intr_coal_ticks; ++ int ret; ++ ++ ret = kstrtou32(buf, 10, &intr_coal_ticks); ++ if (ret) { ++ dev_err(dev, "Input data of interrupt coalesce unmatch\n"); ++ return -EINVAL; ++ } ++ ++ if (intr_coal_ticks >= BIT(24)) { ++ dev_err(dev, "intr_coal_ticks must be less than 2^24!\n"); ++ return -EINVAL; ++ } ++ ++ hisi_hba->intr_coal_ticks = intr_coal_ticks; ++ ++ config_intr_coal_v3_hw(hisi_hba); ++ ++ return count; ++} ++static DEVICE_ATTR_RW(intr_coal_ticks_v3_hw); ++ ++static ssize_t intr_coal_count_v3_hw_show(struct device *dev, ++ struct device_attribute ++ *attr, char *buf) ++{ ++ struct Scsi_Host *shost = class_to_shost(dev); ++ struct hisi_hba *hisi_hba = shost_priv(shost); ++ ++ return scnprintf(buf, PAGE_SIZE, "%u\n", ++ hisi_hba->intr_coal_count); ++} ++ ++static ssize_t intr_coal_count_v3_hw_store(struct device *dev, ++ struct device_attribute ++ *attr, const char *buf, size_t count) ++{ ++ struct Scsi_Host *shost = class_to_shost(dev); ++ struct hisi_hba *hisi_hba = shost_priv(shost); ++ u32 intr_coal_count; ++ int ret; ++ ++ ret = kstrtou32(buf, 10, &intr_coal_count); ++ if (ret) { ++ dev_err(dev, "Input data of interrupt coalesce unmatch\n"); ++ return -EINVAL; ++ } ++ ++ if (intr_coal_count >= BIT(8)) { ++ dev_err(dev, "intr_coal_count must be less than 2^8!\n"); ++ return -EINVAL; ++ } ++ ++ hisi_hba->intr_coal_count = intr_coal_count; ++ ++ config_intr_coal_v3_hw(hisi_hba); ++ ++ return count; ++} ++static DEVICE_ATTR_RW(intr_coal_count_v3_hw); ++ + struct device_attribute *host_attrs_v3_hw[] = { + &dev_attr_phy_event_threshold, + &dev_attr_intr_conv_v3_hw, ++ &dev_attr_intr_coal_ticks_v3_hw, ++ &dev_attr_intr_coal_count_v3_hw, + NULL + }; + +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0013-scsi-hisi_sas-Relocate-some-codes-to-avoid-an-unused.patch b/debian/patches/bugfix/arm64/huawei-taishan/0013-scsi-hisi_sas-Relocate-some-codes-to-avoid-an-unused.patch new file mode 100644 index 000000000..5e52eb5c0 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0013-scsi-hisi_sas-Relocate-some-codes-to-avoid-an-unused.patch @@ -0,0 +1,97 @@ +From 22834ed6cec2690817120e960d43bbf76ddfda17 Mon Sep 17 00:00:00 2001 +From: Xiang Chen +Date: Fri, 9 Nov 2018 22:06:35 +0800 +Subject: [PATCH 13/31] scsi: hisi_sas: Relocate some codes to avoid an unused + check +Origin: https://git.kernel.org/linus/745b6847634c11dda1079d0290781a443eddb4b7 + +In function hisi_sas_task_prep(), we check asd_sas_port, but in function +hisi_sas_task_exec(), we already refer to asd_sas_port by using function +dev_to_hisi_hba() implicitly. So to avoid this possible invalid +dereference, relocate the check to function hisi_sas_task_prep(). + +Signed-off-by: Xiang Chen +Signed-off-by: John Garry +Signed-off-by: Martin K. Petersen +--- + drivers/scsi/hisi_sas/hisi_sas_main.c | 44 ++++++++++++++------------- + 1 file changed, 23 insertions(+), 21 deletions(-) + +diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c +index dc71f8d83551..15360d797760 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_main.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_main.c +@@ -303,36 +303,19 @@ static int hisi_sas_task_prep(struct sas_task *task, + int *pass) + { + struct domain_device *device = task->dev; +- struct hisi_hba *hisi_hba; ++ struct hisi_hba *hisi_hba = dev_to_hisi_hba(device); + struct hisi_sas_device *sas_dev = device->lldd_dev; + struct hisi_sas_port *port; + struct hisi_sas_slot *slot; + struct hisi_sas_cmd_hdr *cmd_hdr_base; + struct asd_sas_port *sas_port = device->port; +- struct device *dev; ++ struct device *dev = hisi_hba->dev; + int dlvry_queue_slot, dlvry_queue, rc, slot_idx; + int n_elem = 0, n_elem_req = 0, n_elem_resp = 0; + struct hisi_sas_dq *dq; + unsigned long flags; + int wr_q_index; + +- if (!sas_port) { +- struct task_status_struct *ts = &task->task_status; +- +- ts->resp = SAS_TASK_UNDELIVERED; +- ts->stat = SAS_PHY_DOWN; +- /* +- * libsas will use dev->port, should +- * not call task_done for sata +- */ +- if (device->dev_type != SAS_SATA_DEV) +- task->task_done(task); +- return -ECOMM; +- } +- +- hisi_hba = dev_to_hisi_hba(device); +- dev = hisi_hba->dev; +- + if (DEV_IS_GONE(sas_dev)) { + if (sas_dev) + dev_info(dev, "task prep: device %d not ready\n", +@@ -507,10 +490,29 @@ static int hisi_sas_task_exec(struct sas_task *task, gfp_t gfp_flags, + u32 rc; + u32 pass = 0; + unsigned long flags; +- struct hisi_hba *hisi_hba = dev_to_hisi_hba(task->dev); +- struct device *dev = hisi_hba->dev; ++ struct hisi_hba *hisi_hba; ++ struct device *dev; ++ struct domain_device *device = task->dev; ++ struct asd_sas_port *sas_port = device->port; + struct hisi_sas_dq *dq = NULL; + ++ if (!sas_port) { ++ struct task_status_struct *ts = &task->task_status; ++ ++ ts->resp = SAS_TASK_UNDELIVERED; ++ ts->stat = SAS_PHY_DOWN; ++ /* ++ * libsas will use dev->port, should ++ * not call task_done for sata ++ */ ++ if (device->dev_type != SAS_SATA_DEV) ++ task->task_done(task); ++ return -ECOMM; ++ } ++ ++ hisi_hba = dev_to_hisi_hba(device); ++ dev = hisi_hba->dev; ++ + if (unlikely(test_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags))) { + if (in_softirq()) + return -EINVAL; +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0014-scsi-hisi_sas-Fix-warnings-detected-by-sparse.patch b/debian/patches/bugfix/arm64/huawei-taishan/0014-scsi-hisi_sas-Fix-warnings-detected-by-sparse.patch new file mode 100644 index 000000000..b3746e519 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0014-scsi-hisi_sas-Fix-warnings-detected-by-sparse.patch @@ -0,0 +1,432 @@ +From 13dda01985003ca1b930b42bb3927f7522f4ce69 Mon Sep 17 00:00:00 2001 +From: John Garry +Date: Thu, 6 Dec 2018 21:34:40 +0800 +Subject: [PATCH 14/31] scsi: hisi_sas: Fix warnings detected by sparse +Origin: https://git.kernel.org/linus/735bcc77e6ba83e464665cea9041072190ede37e + +This patchset fixes some warnings detected by the sparse tool, like these: +drivers/scsi/hisi_sas/hisi_sas_main.c:1469:52: warning: incorrect type in assignment (different base types) +drivers/scsi/hisi_sas/hisi_sas_main.c:1469:52: expected unsigned short [unsigned] [assigned] [usertype] tag_of_task_to_be_managed +drivers/scsi/hisi_sas/hisi_sas_main.c:1469:52: got restricted __le16 [usertype] +drivers/scsi/hisi_sas/hisi_sas_main.c:1723:52: warning: incorrect type in assignment (different base types) +drivers/scsi/hisi_sas/hisi_sas_main.c:1723:52: expected unsigned short [unsigned] [assigned] [usertype] tag_of_task_to_be_managed +drivers/scsi/hisi_sas/hisi_sas_main.c:1723:52: got restricted __le16 [usertype] + +Signed-off-by: John Garry +Signed-off-by: Martin K. Petersen +--- + drivers/scsi/hisi_sas/hisi_sas.h | 2 +- + drivers/scsi/hisi_sas/hisi_sas_main.c | 6 +-- + drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 15 +++--- + drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 66 +++++++++++++++----------- + drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 37 +++++++++------ + 5 files changed, 71 insertions(+), 55 deletions(-) + +diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h +index 535c61391250..912d2342a5fe 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas.h ++++ b/drivers/scsi/hisi_sas/hisi_sas.h +@@ -211,7 +211,7 @@ struct hisi_sas_slot { + /* Do not reorder/change members after here */ + void *buf; + dma_addr_t buf_dma; +- int idx; ++ u16 idx; + }; + + struct hisi_sas_hw { +diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c +index 15360d797760..ab6c7938e172 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_main.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_main.c +@@ -1463,12 +1463,12 @@ static int hisi_sas_abort_task(struct sas_task *task) + if (task->lldd_task && task->task_proto & SAS_PROTOCOL_SSP) { + struct scsi_cmnd *cmnd = task->uldd_task; + struct hisi_sas_slot *slot = task->lldd_task; +- u32 tag = slot->idx; ++ u16 tag = slot->idx; + int rc2; + + int_to_scsilun(cmnd->device->lun, &lun); + tmf_task.tmf = TMF_ABORT_TASK; +- tmf_task.tag_of_task_to_be_managed = cpu_to_le16(tag); ++ tmf_task.tag_of_task_to_be_managed = tag; + + rc = hisi_sas_debug_issue_ssp_tmf(task->dev, lun.scsi_lun, + &tmf_task); +@@ -1722,7 +1722,7 @@ static int hisi_sas_query_task(struct sas_task *task) + + int_to_scsilun(cmnd->device->lun, &lun); + tmf_task.tmf = TMF_QUERY_TASK; +- tmf_task.tag_of_task_to_be_managed = cpu_to_le16(tag); ++ tmf_task.tag_of_task_to_be_managed = tag; + + rc = hisi_sas_debug_issue_ssp_tmf(device, + lun.scsi_lun, +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +index e8e3a876e493..cb1198f0ddde 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +@@ -510,6 +510,7 @@ static void setup_itct_v1_hw(struct hisi_hba *hisi_hba, + struct hisi_sas_itct *itct = &hisi_hba->itct[device_id]; + struct asd_sas_port *sas_port = device->port; + struct hisi_sas_port *port = to_hisi_sas_port(sas_port); ++ u64 sas_addr; + + memset(itct, 0, sizeof(*itct)); + +@@ -534,8 +535,8 @@ static void setup_itct_v1_hw(struct hisi_hba *hisi_hba, + itct->qw0 = cpu_to_le64(qw0); + + /* qw1 */ +- memcpy(&itct->sas_addr, device->sas_addr, SAS_ADDR_SIZE); +- itct->sas_addr = __swab64(itct->sas_addr); ++ memcpy(&sas_addr, device->sas_addr, SAS_ADDR_SIZE); ++ itct->sas_addr = cpu_to_le64(__swab64(sas_addr)); + + /* qw2 */ + itct->qw2 = cpu_to_le64((500ULL << ITCT_HDR_IT_NEXUS_LOSS_TL_OFF) | +@@ -561,7 +562,7 @@ static void clear_itct_v1_hw(struct hisi_hba *hisi_hba, + reg_val &= ~CFG_AGING_TIME_ITCT_REL_MSK; + hisi_sas_write32(hisi_hba, CFG_AGING_TIME, reg_val); + +- qw0 = cpu_to_le64(itct->qw0); ++ qw0 = le64_to_cpu(itct->qw0); + qw0 &= ~ITCT_HDR_VALID_MSK; + itct->qw0 = cpu_to_le64(qw0); + } +@@ -1100,7 +1101,7 @@ static void slot_err_v1_hw(struct hisi_hba *hisi_hba, + case SAS_PROTOCOL_SSP: + { + int error = -1; +- u32 dma_err_type = cpu_to_le32(err_record->dma_err_type); ++ u32 dma_err_type = le32_to_cpu(err_record->dma_err_type); + u32 dma_tx_err_type = ((dma_err_type & + ERR_HDR_DMA_TX_ERR_TYPE_MSK)) >> + ERR_HDR_DMA_TX_ERR_TYPE_OFF; +@@ -1108,9 +1109,9 @@ static void slot_err_v1_hw(struct hisi_hba *hisi_hba, + ERR_HDR_DMA_RX_ERR_TYPE_MSK)) >> + ERR_HDR_DMA_RX_ERR_TYPE_OFF; + u32 trans_tx_fail_type = +- cpu_to_le32(err_record->trans_tx_fail_type); ++ le32_to_cpu(err_record->trans_tx_fail_type); + u32 trans_rx_fail_type = +- cpu_to_le32(err_record->trans_rx_fail_type); ++ le32_to_cpu(err_record->trans_rx_fail_type); + + if (dma_tx_err_type) { + /* dma tx err */ +@@ -1558,7 +1559,7 @@ static irqreturn_t cq_interrupt_v1_hw(int irq, void *p) + u32 cmplt_hdr_data; + + complete_hdr = &complete_queue[rd_point]; +- cmplt_hdr_data = cpu_to_le32(complete_hdr->data); ++ cmplt_hdr_data = le32_to_cpu(complete_hdr->data); + idx = (cmplt_hdr_data & CMPLT_HDR_IPTT_MSK) >> + CMPLT_HDR_IPTT_OFF; + slot = &hisi_hba->slot_info[idx]; +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +index 574a269e2865..c17dd500fba1 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +@@ -934,6 +934,7 @@ static void setup_itct_v2_hw(struct hisi_hba *hisi_hba, + struct domain_device *parent_dev = device->parent; + struct asd_sas_port *sas_port = device->port; + struct hisi_sas_port *port = to_hisi_sas_port(sas_port); ++ u64 sas_addr; + + memset(itct, 0, sizeof(*itct)); + +@@ -966,8 +967,8 @@ static void setup_itct_v2_hw(struct hisi_hba *hisi_hba, + itct->qw0 = cpu_to_le64(qw0); + + /* qw1 */ +- memcpy(&itct->sas_addr, device->sas_addr, SAS_ADDR_SIZE); +- itct->sas_addr = __swab64(itct->sas_addr); ++ memcpy(&sas_addr, device->sas_addr, SAS_ADDR_SIZE); ++ itct->sas_addr = cpu_to_le64(__swab64(sas_addr)); + + /* qw2 */ + if (!dev_is_sata(device)) +@@ -2044,11 +2045,11 @@ static void slot_err_v2_hw(struct hisi_hba *hisi_hba, + struct task_status_struct *ts = &task->task_status; + struct hisi_sas_err_record_v2 *err_record = + hisi_sas_status_buf_addr_mem(slot); +- u32 trans_tx_fail_type = cpu_to_le32(err_record->trans_tx_fail_type); +- u32 trans_rx_fail_type = cpu_to_le32(err_record->trans_rx_fail_type); +- u16 dma_tx_err_type = cpu_to_le16(err_record->dma_tx_err_type); +- u16 sipc_rx_err_type = cpu_to_le16(err_record->sipc_rx_err_type); +- u32 dma_rx_err_type = cpu_to_le32(err_record->dma_rx_err_type); ++ u32 trans_tx_fail_type = le32_to_cpu(err_record->trans_tx_fail_type); ++ u32 trans_rx_fail_type = le32_to_cpu(err_record->trans_rx_fail_type); ++ u16 dma_tx_err_type = le16_to_cpu(err_record->dma_tx_err_type); ++ u16 sipc_rx_err_type = le16_to_cpu(err_record->sipc_rx_err_type); ++ u32 dma_rx_err_type = le32_to_cpu(err_record->dma_rx_err_type); + int error = -1; + + if (err_phase == 1) { +@@ -2059,8 +2060,7 @@ static void slot_err_v2_hw(struct hisi_hba *hisi_hba, + trans_tx_fail_type); + } else if (err_phase == 2) { + /* error in RX phase, the priority is: DW1 > DW3 > DW2 */ +- error = parse_trans_rx_err_code_v2_hw( +- trans_rx_fail_type); ++ error = parse_trans_rx_err_code_v2_hw(trans_rx_fail_type); + if (error == -1) { + error = parse_dma_rx_err_code_v2_hw( + dma_rx_err_type); +@@ -2358,6 +2358,7 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) + &complete_queue[slot->cmplt_queue_slot]; + unsigned long flags; + bool is_internal = slot->is_internal; ++ u32 dw0; + + if (unlikely(!task || !task->lldd_task || !task->dev)) + return -EINVAL; +@@ -2382,8 +2383,9 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) + } + + /* Use SAS+TMF status codes */ +- switch ((complete_hdr->dw0 & CMPLT_HDR_ABORT_STAT_MSK) +- >> CMPLT_HDR_ABORT_STAT_OFF) { ++ dw0 = le32_to_cpu(complete_hdr->dw0); ++ switch ((dw0 & CMPLT_HDR_ABORT_STAT_MSK) >> ++ CMPLT_HDR_ABORT_STAT_OFF) { + case STAT_IO_ABORTED: + /* this io has been aborted by abort command */ + ts->stat = SAS_ABORTED_TASK; +@@ -2408,9 +2410,8 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) + break; + } + +- if ((complete_hdr->dw0 & CMPLT_HDR_ERX_MSK) && +- (!(complete_hdr->dw0 & CMPLT_HDR_RSPNS_XFRD_MSK))) { +- u32 err_phase = (complete_hdr->dw0 & CMPLT_HDR_ERR_PHASE_MSK) ++ if ((dw0 & CMPLT_HDR_ERX_MSK) && (!(dw0 & CMPLT_HDR_RSPNS_XFRD_MSK))) { ++ u32 err_phase = (dw0 & CMPLT_HDR_ERR_PHASE_MSK) + >> CMPLT_HDR_ERR_PHASE_OFF; + u32 *error_info = hisi_sas_status_buf_addr_mem(slot); + +@@ -2526,22 +2527,23 @@ static void prep_ata_v2_hw(struct hisi_hba *hisi_hba, + struct hisi_sas_tmf_task *tmf = slot->tmf; + u8 *buf_cmd; + int has_data = 0, hdr_tag = 0; +- u32 dw1 = 0, dw2 = 0; ++ u32 dw0, dw1 = 0, dw2 = 0; + + /* create header */ + /* dw0 */ +- hdr->dw0 = cpu_to_le32(port->id << CMD_HDR_PORT_OFF); ++ dw0 = port->id << CMD_HDR_PORT_OFF; + if (parent_dev && DEV_IS_EXPANDER(parent_dev->dev_type)) +- hdr->dw0 |= cpu_to_le32(3 << CMD_HDR_CMD_OFF); ++ dw0 |= 3 << CMD_HDR_CMD_OFF; + else +- hdr->dw0 |= cpu_to_le32(4 << CMD_HDR_CMD_OFF); ++ dw0 |= 4 << CMD_HDR_CMD_OFF; + + if (tmf && tmf->force_phy) { +- hdr->dw0 |= CMD_HDR_FORCE_PHY_MSK; +- hdr->dw0 |= cpu_to_le32((1 << tmf->phy_id) +- << CMD_HDR_PHY_ID_OFF); ++ dw0 |= CMD_HDR_FORCE_PHY_MSK; ++ dw0 |= (1 << tmf->phy_id) << CMD_HDR_PHY_ID_OFF; + } + ++ hdr->dw0 = cpu_to_le32(dw0); ++ + /* dw1 */ + switch (task->data_dir) { + case DMA_TO_DEVICE: +@@ -3152,20 +3154,24 @@ static void cq_tasklet_v2_hw(unsigned long val) + + /* Check for NCQ completion */ + if (complete_hdr->act) { +- u32 act_tmp = complete_hdr->act; ++ u32 act_tmp = le32_to_cpu(complete_hdr->act); + int ncq_tag_count = ffs(act_tmp); ++ u32 dw1 = le32_to_cpu(complete_hdr->dw1); + +- dev_id = (complete_hdr->dw1 & CMPLT_HDR_DEV_ID_MSK) >> ++ dev_id = (dw1 & CMPLT_HDR_DEV_ID_MSK) >> + CMPLT_HDR_DEV_ID_OFF; + itct = &hisi_hba->itct[dev_id]; + + /* The NCQ tags are held in the itct header */ + while (ncq_tag_count) { +- __le64 *ncq_tag = &itct->qw4_15[0]; ++ __le64 *_ncq_tag = &itct->qw4_15[0], __ncq_tag; ++ u64 ncq_tag; + +- ncq_tag_count -= 1; +- iptt = (ncq_tag[ncq_tag_count / 5] +- >> (ncq_tag_count % 5) * 12) & 0xfff; ++ ncq_tag_count--; ++ __ncq_tag = _ncq_tag[ncq_tag_count / 5]; ++ ncq_tag = le64_to_cpu(__ncq_tag); ++ iptt = (ncq_tag >> (ncq_tag_count % 5) * 12) & ++ 0xfff; + + slot = &hisi_hba->slot_info[iptt]; + slot->cmplt_queue_slot = rd_point; +@@ -3176,7 +3182,9 @@ static void cq_tasklet_v2_hw(unsigned long val) + ncq_tag_count = ffs(act_tmp); + } + } else { +- iptt = (complete_hdr->dw1) & CMPLT_HDR_IPTT_MSK; ++ u32 dw1 = le32_to_cpu(complete_hdr->dw1); ++ ++ iptt = dw1 & CMPLT_HDR_IPTT_MSK; + slot = &hisi_hba->slot_info[iptt]; + slot->cmplt_queue_slot = rd_point; + slot->cmplt_queue = queue; +@@ -3552,7 +3560,7 @@ static void wait_cmds_complete_timeout_v2_hw(struct hisi_hba *hisi_hba, + dev_dbg(dev, "wait commands complete %dms\n", time); + } + +-struct device_attribute *host_attrs_v2_hw[] = { ++static struct device_attribute *host_attrs_v2_hw[] = { + &dev_attr_phy_event_threshold, + NULL + }; +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +index 7d7cb73e4bee..23f40b57b298 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +@@ -628,6 +628,7 @@ static void setup_itct_v3_hw(struct hisi_hba *hisi_hba, + struct domain_device *parent_dev = device->parent; + struct asd_sas_port *sas_port = device->port; + struct hisi_sas_port *port = to_hisi_sas_port(sas_port); ++ u64 sas_addr; + + memset(itct, 0, sizeof(*itct)); + +@@ -660,8 +661,8 @@ static void setup_itct_v3_hw(struct hisi_hba *hisi_hba, + itct->qw0 = cpu_to_le64(qw0); + + /* qw1 */ +- memcpy(&itct->sas_addr, device->sas_addr, SAS_ADDR_SIZE); +- itct->sas_addr = __swab64(itct->sas_addr); ++ memcpy(&sas_addr, device->sas_addr, SAS_ADDR_SIZE); ++ itct->sas_addr = cpu_to_le64(__swab64(sas_addr)); + + /* qw2 */ + if (!dev_is_sata(device)) +@@ -1590,15 +1591,16 @@ slot_err_v3_hw(struct hisi_hba *hisi_hba, struct sas_task *task, + &complete_queue[slot->cmplt_queue_slot]; + struct hisi_sas_err_record_v3 *record = + hisi_sas_status_buf_addr_mem(slot); +- u32 dma_rx_err_type = record->dma_rx_err_type; +- u32 trans_tx_fail_type = record->trans_tx_fail_type; ++ u32 dma_rx_err_type = le32_to_cpu(record->dma_rx_err_type); ++ u32 trans_tx_fail_type = le32_to_cpu(record->trans_tx_fail_type); ++ u32 dw3 = le32_to_cpu(complete_hdr->dw3); + + switch (task->task_proto) { + case SAS_PROTOCOL_SSP: + if (dma_rx_err_type & RX_DATA_LEN_UNDERFLOW_MSK) { + ts->residual = trans_tx_fail_type; + ts->stat = SAS_DATA_UNDERRUN; +- } else if (complete_hdr->dw3 & CMPLT_HDR_IO_IN_TARGET_MSK) { ++ } else if (dw3 & CMPLT_HDR_IO_IN_TARGET_MSK) { + ts->stat = SAS_QUEUE_FULL; + slot->abort = 1; + } else { +@@ -1612,7 +1614,7 @@ slot_err_v3_hw(struct hisi_hba *hisi_hba, struct sas_task *task, + if (dma_rx_err_type & RX_DATA_LEN_UNDERFLOW_MSK) { + ts->residual = trans_tx_fail_type; + ts->stat = SAS_DATA_UNDERRUN; +- } else if (complete_hdr->dw3 & CMPLT_HDR_IO_IN_TARGET_MSK) { ++ } else if (dw3 & CMPLT_HDR_IO_IN_TARGET_MSK) { + ts->stat = SAS_PHY_DOWN; + slot->abort = 1; + } else { +@@ -1645,6 +1647,7 @@ slot_complete_v3_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) + &complete_queue[slot->cmplt_queue_slot]; + unsigned long flags; + bool is_internal = slot->is_internal; ++ u32 dw0, dw1, dw3; + + if (unlikely(!task || !task->lldd_task || !task->dev)) + return -EINVAL; +@@ -1668,11 +1671,14 @@ slot_complete_v3_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) + goto out; + } + ++ dw0 = le32_to_cpu(complete_hdr->dw0); ++ dw1 = le32_to_cpu(complete_hdr->dw1); ++ dw3 = le32_to_cpu(complete_hdr->dw3); ++ + /* + * Use SAS+TMF status codes + */ +- switch ((complete_hdr->dw0 & CMPLT_HDR_ABORT_STAT_MSK) +- >> CMPLT_HDR_ABORT_STAT_OFF) { ++ switch ((dw0 & CMPLT_HDR_ABORT_STAT_MSK) >> CMPLT_HDR_ABORT_STAT_OFF) { + case STAT_IO_ABORTED: + /* this IO has been aborted by abort command */ + ts->stat = SAS_ABORTED_TASK; +@@ -1695,7 +1701,7 @@ slot_complete_v3_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) + } + + /* check for erroneous completion */ +- if ((complete_hdr->dw0 & CMPLT_HDR_CMPLT_MSK) == 0x3) { ++ if ((dw0 & CMPLT_HDR_CMPLT_MSK) == 0x3) { + u32 *error_info = hisi_sas_status_buf_addr_mem(slot); + + slot_err_v3_hw(hisi_hba, task, slot); +@@ -1704,8 +1710,7 @@ slot_complete_v3_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) + "CQ hdr: 0x%x 0x%x 0x%x 0x%x " + "Error info: 0x%x 0x%x 0x%x 0x%x\n", + slot->idx, task, sas_dev->device_id, +- complete_hdr->dw0, complete_hdr->dw1, +- complete_hdr->act, complete_hdr->dw3, ++ dw0, dw1, complete_hdr->act, dw3, + error_info[0], error_info[1], + error_info[2], error_info[3]); + if (unlikely(slot->abort)) +@@ -1803,11 +1808,13 @@ static void cq_tasklet_v3_hw(unsigned long val) + while (rd_point != wr_point) { + struct hisi_sas_complete_v3_hdr *complete_hdr; + struct device *dev = hisi_hba->dev; ++ u32 dw1; + int iptt; + + complete_hdr = &complete_queue[rd_point]; ++ dw1 = le32_to_cpu(complete_hdr->dw1); + +- iptt = (complete_hdr->dw1) & CMPLT_HDR_IPTT_MSK; ++ iptt = dw1 & CMPLT_HDR_IPTT_MSK; + if (likely(iptt < HISI_SAS_COMMAND_ENTRIES_V3_HW)) { + slot = &hisi_hba->slot_info[iptt]; + slot->cmplt_queue_slot = rd_point; +@@ -2203,7 +2210,7 @@ static ssize_t intr_coal_count_v3_hw_store(struct device *dev, + } + static DEVICE_ATTR_RW(intr_coal_count_v3_hw); + +-struct device_attribute *host_attrs_v3_hw[] = { ++static struct device_attribute *host_attrs_v3_hw[] = { + &dev_attr_phy_event_threshold, + &dev_attr_intr_conv_v3_hw, + &dev_attr_intr_coal_ticks_v3_hw, +@@ -2649,7 +2656,7 @@ static int hisi_sas_v3_suspend(struct pci_dev *pdev, pm_message_t state) + struct hisi_hba *hisi_hba = sha->lldd_ha; + struct device *dev = hisi_hba->dev; + struct Scsi_Host *shost = hisi_hba->shost; +- u32 device_state; ++ pci_power_t device_state; + int rc; + + if (!pdev->pm_cap) { +@@ -2695,7 +2702,7 @@ static int hisi_sas_v3_resume(struct pci_dev *pdev) + struct Scsi_Host *shost = hisi_hba->shost; + struct device *dev = hisi_hba->dev; + unsigned int rc; +- u32 device_state = pdev->current_state; ++ pci_power_t device_state = pdev->current_state; + + dev_warn(dev, "resuming from operating state [D%d]\n", + device_state); +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0015-scsi-hisi_sas-Relocate-some-code-to-reduce-complexit.patch b/debian/patches/bugfix/arm64/huawei-taishan/0015-scsi-hisi_sas-Relocate-some-code-to-reduce-complexit.patch new file mode 100644 index 000000000..37cbfb23b --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0015-scsi-hisi_sas-Relocate-some-code-to-reduce-complexit.patch @@ -0,0 +1,190 @@ +From 9e9903e8e143c32498565cb49a7aab6081734782 Mon Sep 17 00:00:00 2001 +From: Xiang Chen +Date: Thu, 6 Dec 2018 21:34:41 +0800 +Subject: [PATCH 15/31] scsi: hisi_sas: Relocate some code to reduce complexity +Origin: https://git.kernel.org/linus/6e1b731b535231e199c7810451c851398afccd33 + +Relocate the codes related to dma_map/unmap in hisi_sas_task_prep() to +reduce complexity, with a view to add DIF/DIX support. + +Signed-off-by: Xiang Chen +Signed-off-by: John Garry +Signed-off-by: Martin K. Petersen +--- + drivers/scsi/hisi_sas/hisi_sas_main.c | 146 ++++++++++++++++---------- + 1 file changed, 90 insertions(+), 56 deletions(-) + +diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c +index ab6c7938e172..18062e4ab9a5 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_main.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_main.c +@@ -297,6 +297,90 @@ static void hisi_sas_task_prep_abort(struct hisi_hba *hisi_hba, + device_id, abort_flag, tag_to_abort); + } + ++static void hisi_sas_dma_unmap(struct hisi_hba *hisi_hba, ++ struct sas_task *task, int n_elem, ++ int n_elem_req, int n_elem_resp) ++{ ++ struct device *dev = hisi_hba->dev; ++ ++ if (!sas_protocol_ata(task->task_proto)) { ++ if (task->num_scatter) { ++ if (n_elem) ++ dma_unmap_sg(dev, task->scatter, ++ task->num_scatter, ++ task->data_dir); ++ } else if (task->task_proto & SAS_PROTOCOL_SMP) { ++ if (n_elem_req) ++ dma_unmap_sg(dev, &task->smp_task.smp_req, ++ 1, DMA_TO_DEVICE); ++ if (n_elem_resp) ++ dma_unmap_sg(dev, &task->smp_task.smp_resp, ++ 1, DMA_FROM_DEVICE); ++ } ++ } ++} ++ ++static int hisi_sas_dma_map(struct hisi_hba *hisi_hba, ++ struct sas_task *task, int *n_elem, ++ int *n_elem_req, int *n_elem_resp) ++{ ++ struct device *dev = hisi_hba->dev; ++ int rc; ++ ++ if (sas_protocol_ata(task->task_proto)) { ++ *n_elem = task->num_scatter; ++ } else { ++ unsigned int req_len, resp_len; ++ ++ if (task->num_scatter) { ++ *n_elem = dma_map_sg(dev, task->scatter, ++ task->num_scatter, task->data_dir); ++ if (!*n_elem) { ++ rc = -ENOMEM; ++ goto prep_out; ++ } ++ } else if (task->task_proto & SAS_PROTOCOL_SMP) { ++ *n_elem_req = dma_map_sg(dev, &task->smp_task.smp_req, ++ 1, DMA_TO_DEVICE); ++ if (!*n_elem_req) { ++ rc = -ENOMEM; ++ goto prep_out; ++ } ++ req_len = sg_dma_len(&task->smp_task.smp_req); ++ if (req_len & 0x3) { ++ rc = -EINVAL; ++ goto err_out_dma_unmap; ++ } ++ *n_elem_resp = dma_map_sg(dev, &task->smp_task.smp_resp, ++ 1, DMA_FROM_DEVICE); ++ if (!*n_elem_resp) { ++ rc = -ENOMEM; ++ goto err_out_dma_unmap; ++ } ++ resp_len = sg_dma_len(&task->smp_task.smp_resp); ++ if (resp_len & 0x3) { ++ rc = -EINVAL; ++ goto err_out_dma_unmap; ++ } ++ } ++ } ++ ++ if (*n_elem > HISI_SAS_SGE_PAGE_CNT) { ++ dev_err(dev, "task prep: n_elem(%d) > HISI_SAS_SGE_PAGE_CNT", ++ *n_elem); ++ rc = -EINVAL; ++ goto err_out_dma_unmap; ++ } ++ return 0; ++ ++err_out_dma_unmap: ++ /* It would be better to call dma_unmap_sg() here, but it's messy */ ++ hisi_sas_dma_unmap(hisi_hba, task, *n_elem, ++ *n_elem_req, *n_elem_resp); ++prep_out: ++ return rc; ++} ++ + static int hisi_sas_task_prep(struct sas_task *task, + struct hisi_sas_dq **dq_pointer, + bool is_tmf, struct hisi_sas_tmf_task *tmf, +@@ -339,49 +423,10 @@ static int hisi_sas_task_prep(struct sas_task *task, + return -ECOMM; + } + +- if (!sas_protocol_ata(task->task_proto)) { +- unsigned int req_len, resp_len; +- +- if (task->num_scatter) { +- n_elem = dma_map_sg(dev, task->scatter, +- task->num_scatter, task->data_dir); +- if (!n_elem) { +- rc = -ENOMEM; +- goto prep_out; +- } +- } else if (task->task_proto & SAS_PROTOCOL_SMP) { +- n_elem_req = dma_map_sg(dev, &task->smp_task.smp_req, +- 1, DMA_TO_DEVICE); +- if (!n_elem_req) { +- rc = -ENOMEM; +- goto prep_out; +- } +- req_len = sg_dma_len(&task->smp_task.smp_req); +- if (req_len & 0x3) { +- rc = -EINVAL; +- goto err_out_dma_unmap; +- } +- n_elem_resp = dma_map_sg(dev, &task->smp_task.smp_resp, +- 1, DMA_FROM_DEVICE); +- if (!n_elem_resp) { +- rc = -ENOMEM; +- goto err_out_dma_unmap; +- } +- resp_len = sg_dma_len(&task->smp_task.smp_resp); +- if (resp_len & 0x3) { +- rc = -EINVAL; +- goto err_out_dma_unmap; +- } +- } +- } else +- n_elem = task->num_scatter; +- +- if (n_elem > HISI_SAS_SGE_PAGE_CNT) { +- dev_err(dev, "task prep: n_elem(%d) > HISI_SAS_SGE_PAGE_CNT", +- n_elem); +- rc = -EINVAL; +- goto err_out_dma_unmap; +- } ++ rc = hisi_sas_dma_map(hisi_hba, task, &n_elem, ++ &n_elem_req, &n_elem_resp); ++ if (rc < 0) ++ goto prep_out; + + if (hisi_hba->hw->slot_index_alloc) + rc = hisi_hba->hw->slot_index_alloc(hisi_hba, device); +@@ -466,19 +511,8 @@ static int hisi_sas_task_prep(struct sas_task *task, + err_out_tag: + hisi_sas_slot_index_free(hisi_hba, slot_idx); + err_out_dma_unmap: +- if (!sas_protocol_ata(task->task_proto)) { +- if (task->num_scatter) { +- dma_unmap_sg(dev, task->scatter, task->num_scatter, +- task->data_dir); +- } else if (task->task_proto & SAS_PROTOCOL_SMP) { +- if (n_elem_req) +- dma_unmap_sg(dev, &task->smp_task.smp_req, +- 1, DMA_TO_DEVICE); +- if (n_elem_resp) +- dma_unmap_sg(dev, &task->smp_task.smp_resp, +- 1, DMA_FROM_DEVICE); +- } +- } ++ hisi_sas_dma_unmap(hisi_hba, task, n_elem, ++ n_elem_req, n_elem_resp); + prep_out: + dev_err(dev, "task prep: failed[%d]!\n", rc); + return rc; +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0016-scsi-hisi_sas-Make-sg_tablesize-consistent-value.patch b/debian/patches/bugfix/arm64/huawei-taishan/0016-scsi-hisi_sas-Make-sg_tablesize-consistent-value.patch new file mode 100644 index 000000000..b9411ffcc --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0016-scsi-hisi_sas-Make-sg_tablesize-consistent-value.patch @@ -0,0 +1,85 @@ +From 8baf75dd36d8e311434162c6a2c74a45262dc0d4 Mon Sep 17 00:00:00 2001 +From: Xiang Chen +Date: Thu, 6 Dec 2018 21:34:42 +0800 +Subject: [PATCH 16/31] scsi: hisi_sas: Make sg_tablesize consistent value +Origin: https://git.kernel.org/linus/6db831f4ef764ca19d7300d56ab9455af3cb930d + +Sht->sg_tablesize is set in the driver, and it will be assigned to +shost->sg_tablesize in SCSI mid-layer. So it is not necessary to assign +shost->sg_table one more time in the driver. + +In addition to the change, change each scsi_host_template.sg_tablesize +to HISI_SAS_SGE_PAGE_CNT instead of SG_ALL. + +Signed-off-by: Xiang Chen +Signed-off-by: John Garry +Signed-off-by: Martin K. Petersen +--- + drivers/scsi/hisi_sas/hisi_sas_main.c | 1 - + drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 2 +- + drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 2 +- + drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 3 +-- + 4 files changed, 3 insertions(+), 5 deletions(-) + +diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c +index 18062e4ab9a5..764d651879cf 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_main.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_main.c +@@ -2426,7 +2426,6 @@ int hisi_sas_probe(struct platform_device *pdev, + shost->max_lun = ~0; + shost->max_channel = 1; + shost->max_cmd_len = 16; +- shost->sg_tablesize = min_t(u16, SG_ALL, HISI_SAS_SGE_PAGE_CNT); + if (hisi_hba->hw->slot_index_alloc) { + shost->can_queue = hisi_hba->hw->max_command_entries; + shost->cmd_per_lun = hisi_hba->hw->max_command_entries; +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +index cb1198f0ddde..ef23d26b2271 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +@@ -1814,7 +1814,7 @@ static struct scsi_host_template sht_v1_hw = { + .change_queue_depth = sas_change_queue_depth, + .bios_param = sas_bios_param, + .this_id = -1, +- .sg_tablesize = SG_ALL, ++ .sg_tablesize = HISI_SAS_SGE_PAGE_CNT, + .max_sectors = SCSI_DEFAULT_MAX_SECTORS, + .use_clustering = ENABLE_CLUSTERING, + .eh_device_reset_handler = sas_eh_device_reset_handler, +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +index c17dd500fba1..0341fa72d97e 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +@@ -3576,7 +3576,7 @@ static struct scsi_host_template sht_v2_hw = { + .change_queue_depth = sas_change_queue_depth, + .bios_param = sas_bios_param, + .this_id = -1, +- .sg_tablesize = SG_ALL, ++ .sg_tablesize = HISI_SAS_SGE_PAGE_CNT, + .max_sectors = SCSI_DEFAULT_MAX_SECTORS, + .use_clustering = ENABLE_CLUSTERING, + .eh_device_reset_handler = sas_eh_device_reset_handler, +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +index 23f40b57b298..6d584f232204 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +@@ -2229,7 +2229,7 @@ static struct scsi_host_template sht_v3_hw = { + .change_queue_depth = sas_change_queue_depth, + .bios_param = sas_bios_param, + .this_id = -1, +- .sg_tablesize = SG_ALL, ++ .sg_tablesize = HISI_SAS_SGE_PAGE_CNT, + .max_sectors = SCSI_DEFAULT_MAX_SECTORS, + .use_clustering = ENABLE_CLUSTERING, + .eh_device_reset_handler = sas_eh_device_reset_handler, +@@ -2371,7 +2371,6 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id) + shost->max_lun = ~0; + shost->max_channel = 1; + shost->max_cmd_len = 16; +- shost->sg_tablesize = min_t(u16, SG_ALL, HISI_SAS_SGE_PAGE_CNT); + shost->can_queue = hisi_hba->hw->max_command_entries - + HISI_SAS_RESERVED_IPTT_CNT; + shost->cmd_per_lun = hisi_hba->hw->max_command_entries - +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0017-net-hns3-remove-unnecessary-configuration-recapture-.patch b/debian/patches/bugfix/arm64/huawei-taishan/0017-net-hns3-remove-unnecessary-configuration-recapture-.patch new file mode 100644 index 000000000..10fa425d9 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0017-net-hns3-remove-unnecessary-configuration-recapture-.patch @@ -0,0 +1,46 @@ +From 341487a9b370af5c2566fb0c3fe5384c96bdbda7 Mon Sep 17 00:00:00 2001 +From: Huazhong Tan +Date: Tue, 18 Dec 2018 19:37:52 +0800 +Subject: [PATCH 17/31] net: hns3: remove unnecessary configuration recapture + while resetting +Origin: https://git.kernel.org/linus/b51c366df70da0100193d13975980f1990a2d47b + +When doing reset, it is unnecessary to get the hardware's default +configuration again, otherwise, the user's configuration will be +overwritten. + +Fixes: 4ed340ab8f49 ("net: hns3: Add reset process in hclge_main") +Signed-off-by: Huazhong Tan +Signed-off-by: Peng Li +Signed-off-by: David S. Miller +--- + .../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 13 ------------- + 1 file changed, 13 deletions(-) + +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +index 340baf6a470c..1dada183456c 100644 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +@@ -5812,19 +5812,6 @@ static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev) + return ret; + } + +- ret = hclge_get_cap(hdev); +- if (ret) { +- dev_err(&pdev->dev, "get hw capability error, ret = %d.\n", +- ret); +- return ret; +- } +- +- ret = hclge_configure(hdev); +- if (ret) { +- dev_err(&pdev->dev, "Configure dev error, ret = %d.\n", ret); +- return ret; +- } +- + ret = hclge_map_tqp(hdev); + if (ret) { + dev_err(&pdev->dev, "Map tqp error, ret = %d.\n", ret); +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0018-net-hns3-remove-1000M-half-support-of-phy.patch b/debian/patches/bugfix/arm64/huawei-taishan/0018-net-hns3-remove-1000M-half-support-of-phy.patch new file mode 100644 index 000000000..4704d1327 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0018-net-hns3-remove-1000M-half-support-of-phy.patch @@ -0,0 +1,32 @@ +From 7740fe91e657e23f25e750d9e34da059a6f607ac Mon Sep 17 00:00:00 2001 +From: Fuyun Liang +Date: Tue, 18 Dec 2018 19:37:55 +0800 +Subject: [PATCH 18/31] net: hns3: remove 1000M/half support of phy +Origin: https://git.kernel.org/linus/8362089d787724bb252f13f942921051943369c7 + +Our phy does not support 1000M/half, this patch removes 1000M/half from +PHY_SUPPORTED_FEATURES. + +Signed-off-by: Fuyun Liang +Signed-off-by: Peng Li +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c +index 398971a062f4..a75b70ce41f8 100644 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c +@@ -14,7 +14,7 @@ + SUPPORTED_Asym_Pause | \ + PHY_10BT_FEATURES | \ + PHY_100BT_FEATURES | \ +- PHY_1000BT_FEATURES) ++ SUPPORTED_1000baseT_Full) + + enum hclge_mdio_c22_op_seq { + HCLGE_MDIO_C22_WRITE = 1, +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0019-net-hns3-synchronize-speed-and-duplex-from-phy-when-.patch b/debian/patches/bugfix/arm64/huawei-taishan/0019-net-hns3-synchronize-speed-and-duplex-from-phy-when-.patch new file mode 100644 index 000000000..48cf8519d --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0019-net-hns3-synchronize-speed-and-duplex-from-phy-when-.patch @@ -0,0 +1,35 @@ +From 4f28c6b52ffb62eb5a0a5a85af4fa10658fecee5 Mon Sep 17 00:00:00 2001 +From: Peng Li +Date: Tue, 18 Dec 2018 19:37:56 +0800 +Subject: [PATCH 19/31] net: hns3: synchronize speed and duplex from phy when + phy link up +Origin: https://git.kernel.org/linus/0ad5ea5dbd6cb1e62bac547db5e61bab15af4f44 + +Driver calls phy_connect_direct and registers hclge_mac_adjust_link +to synchronize mac speed and duplex from phy. It is better to +synchronize mac speed and duplex from phy when phy link up. + +Signed-off-by: Peng Li +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c +index a75b70ce41f8..bdbec85265f4 100644 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c +@@ -181,6 +181,10 @@ static void hclge_mac_adjust_link(struct net_device *netdev) + int duplex, speed; + int ret; + ++ /* When phy link down, do nothing */ ++ if (netdev->phydev->link == 0) ++ return; ++ + speed = netdev->phydev->speed; + duplex = netdev->phydev->duplex; + +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0020-net-hns3-getting-tx-and-dv-buffer-size-through-firmw.patch b/debian/patches/bugfix/arm64/huawei-taishan/0020-net-hns3-getting-tx-and-dv-buffer-size-through-firmw.patch new file mode 100644 index 000000000..d9f68ee2b --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0020-net-hns3-getting-tx-and-dv-buffer-size-through-firmw.patch @@ -0,0 +1,160 @@ +From caeef6247aa6f5250d14108b33cef5458ba6c58e Mon Sep 17 00:00:00 2001 +From: Yunsheng Lin +Date: Tue, 18 Dec 2018 19:37:57 +0800 +Subject: [PATCH 20/31] net: hns3: getting tx and dv buffer size through + firmware +Origin: https://git.kernel.org/linus/368686be234daf365ef184a6ee1c4a6c18ede3b1 + +This patch adds support of getting tx and dv buffer size through +firmware, because different version of hardware requires different +size of tx and dv buffer. + +This patch also add dv_buf_size to tc' private buffer size even if +pfc is not enable for the tc. + +Signed-off-by: Yunsheng Lin +Signed-off-by: Peng Li +Signed-off-by: David S. Miller +--- + .../hisilicon/hns3/hns3pf/hclge_cmd.h | 5 ++- + .../hisilicon/hns3/hns3pf/hclge_main.c | 41 ++++++++++++++----- + .../hisilicon/hns3/hns3pf/hclge_main.h | 3 ++ + 3 files changed, 38 insertions(+), 11 deletions(-) + +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h +index 821d4c2f84bd..827e8b13b545 100644 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h +@@ -365,7 +365,9 @@ struct hclge_pf_res_cmd { + #define HCLGE_PF_VEC_NUM_M GENMASK(7, 0) + __le16 pf_intr_vector_number; + __le16 pf_own_fun_number; +- __le32 rsv[3]; ++ __le16 tx_buf_size; ++ __le16 dv_buf_size; ++ __le32 rsv[2]; + }; + + #define HCLGE_CFG_OFFSET_S 0 +@@ -791,6 +793,7 @@ struct hclge_serdes_lb_cmd { + #define HCLGE_TOTAL_PKT_BUF 0x108000 /* 1.03125M bytes */ + #define HCLGE_DEFAULT_DV 0xA000 /* 40k byte */ + #define HCLGE_DEFAULT_NON_DCB_DV 0x7800 /* 30K byte */ ++#define HCLGE_NON_DCB_ADDITIONAL_BUF 0x200 /* 512 byte */ + + #define HCLGE_TYPE_CRQ 0 + #define HCLGE_TYPE_CSQ 1 +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +index 1dada183456c..47cbf06ea405 100644 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +@@ -932,6 +932,18 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev) + hdev->num_tqps = __le16_to_cpu(req->tqp_num); + hdev->pkt_buf_size = __le16_to_cpu(req->buf_size) << HCLGE_BUF_UNIT_S; + ++ if (req->tx_buf_size) ++ hdev->tx_buf_size = ++ __le16_to_cpu(req->tx_buf_size) << HCLGE_BUF_UNIT_S; ++ else ++ hdev->tx_buf_size = HCLGE_DEFAULT_TX_BUF; ++ ++ if (req->dv_buf_size) ++ hdev->dv_buf_size = ++ __le16_to_cpu(req->dv_buf_size) << HCLGE_BUF_UNIT_S; ++ else ++ hdev->dv_buf_size = HCLGE_DEFAULT_DV; ++ + if (hnae3_dev_roce_supported(hdev)) { + hdev->roce_base_msix_offset = + hnae3_get_field(__le16_to_cpu(req->msixcap_localid_ba_rocee), +@@ -1592,9 +1604,10 @@ static bool hclge_is_rx_buf_ok(struct hclge_dev *hdev, + pfc_enable_num = hclge_get_pfc_enalbe_num(hdev); + + if (hnae3_dev_dcb_supported(hdev)) +- shared_buf_min = 2 * hdev->mps + HCLGE_DEFAULT_DV; ++ shared_buf_min = 2 * hdev->mps + hdev->dv_buf_size; + else +- shared_buf_min = 2 * hdev->mps + HCLGE_DEFAULT_NON_DCB_DV; ++ shared_buf_min = hdev->mps + HCLGE_NON_DCB_ADDITIONAL_BUF ++ + hdev->dv_buf_size; + + shared_buf_tc = pfc_enable_num * hdev->mps + + (tc_num - pfc_enable_num) * hdev->mps / 2 + +@@ -1607,8 +1620,15 @@ static bool hclge_is_rx_buf_ok(struct hclge_dev *hdev, + + shared_buf = rx_all - rx_priv; + buf_alloc->s_buf.buf_size = shared_buf; +- buf_alloc->s_buf.self.high = shared_buf; +- buf_alloc->s_buf.self.low = 2 * hdev->mps; ++ if (hnae3_dev_dcb_supported(hdev)) { ++ buf_alloc->s_buf.self.high = shared_buf - hdev->dv_buf_size; ++ buf_alloc->s_buf.self.low = buf_alloc->s_buf.self.high ++ - hdev->mps / 2; ++ } else { ++ buf_alloc->s_buf.self.high = hdev->mps + ++ HCLGE_NON_DCB_ADDITIONAL_BUF; ++ buf_alloc->s_buf.self.low = hdev->mps / 2; ++ } + + for (i = 0; i < HCLGE_MAX_TC_NUM; i++) { + if ((hdev->hw_tc_map & BIT(i)) && +@@ -1635,11 +1655,11 @@ static int hclge_tx_buffer_calc(struct hclge_dev *hdev, + for (i = 0; i < HCLGE_MAX_TC_NUM; i++) { + struct hclge_priv_buf *priv = &buf_alloc->priv_buf[i]; + +- if (total_size < HCLGE_DEFAULT_TX_BUF) ++ if (total_size < hdev->tx_buf_size) + return -ENOMEM; + + if (hdev->hw_tc_map & BIT(i)) +- priv->tx_buf_size = HCLGE_DEFAULT_TX_BUF; ++ priv->tx_buf_size = hdev->tx_buf_size; + else + priv->tx_buf_size = 0; + +@@ -1685,11 +1705,12 @@ static int hclge_rx_buffer_calc(struct hclge_dev *hdev, + priv->wl.low = aligned_mps; + priv->wl.high = priv->wl.low + aligned_mps; + priv->buf_size = priv->wl.high + +- HCLGE_DEFAULT_DV; ++ hdev->dv_buf_size; + } else { + priv->wl.low = 0; + priv->wl.high = 2 * aligned_mps; +- priv->buf_size = priv->wl.high; ++ priv->buf_size = priv->wl.high + ++ hdev->dv_buf_size; + } + } else { + priv->enable = 0; +@@ -1721,11 +1742,11 @@ static int hclge_rx_buffer_calc(struct hclge_dev *hdev, + if (hdev->tm_info.hw_pfc_map & BIT(i)) { + priv->wl.low = 128; + priv->wl.high = priv->wl.low + aligned_mps; +- priv->buf_size = priv->wl.high + HCLGE_DEFAULT_DV; ++ priv->buf_size = priv->wl.high + hdev->dv_buf_size; + } else { + priv->wl.low = 0; + priv->wl.high = aligned_mps; +- priv->buf_size = priv->wl.high; ++ priv->buf_size = priv->wl.high + hdev->dv_buf_size; + } + } + +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +index 1528fb3fa6be..629ee0148d4e 100644 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +@@ -545,6 +545,9 @@ struct hclge_dev { + u32 flag; + + u32 pkt_buf_size; /* Total pf buf size for tx/rx */ ++ u32 tx_buf_size; /* Tx buffer size for each TC */ ++ u32 dv_buf_size; /* Dv buffer size for each TC */ ++ + u32 mps; /* Max packet size */ + + enum hclge_mta_dmac_sel_type mta_mac_sel_type; +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0021-net-hns3-aligning-buffer-size-in-SSU-to-256-bytes.patch b/debian/patches/bugfix/arm64/huawei-taishan/0021-net-hns3-aligning-buffer-size-in-SSU-to-256-bytes.patch new file mode 100644 index 000000000..5c2e01244 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0021-net-hns3-aligning-buffer-size-in-SSU-to-256-bytes.patch @@ -0,0 +1,147 @@ +From 234c314e892d40daa37e97e9057e04d3e3a0c285 Mon Sep 17 00:00:00 2001 +From: Yunsheng Lin +Date: Tue, 18 Dec 2018 19:37:58 +0800 +Subject: [PATCH 21/31] net: hns3: aligning buffer size in SSU to 256 bytes +Origin: https://git.kernel.org/linus/b9a400ac295728b2d47445e09814e1880409b311 + +The hardware expects the buffer size set to SSU is aligned to +256 bytes, this patch aligns the buffer size to 256 byte using +roundup or rounddown function. + +Signed-off-by: Yunsheng Lin +Signed-off-by: Peng Li +Signed-off-by: David S. Miller +--- + .../hisilicon/hns3/hns3pf/hclge_main.c | 45 ++++++++++++------- + 1 file changed, 28 insertions(+), 17 deletions(-) + +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +index 47cbf06ea405..42a38ca966d1 100644 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +@@ -31,6 +31,10 @@ static int hclge_set_mta_filter_mode(struct hclge_dev *hdev, + enum hclge_mta_dmac_sel_type mta_mac_sel, + bool enable); + static int hclge_set_mtu(struct hnae3_handle *handle, int new_mtu); ++ ++#define HCLGE_BUF_SIZE_UNIT 256 ++ ++static int hclge_set_mac_mtu(struct hclge_dev *hdev, int new_mps); + static int hclge_init_vlan_config(struct hclge_dev *hdev); + static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev); + +@@ -938,12 +942,16 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev) + else + hdev->tx_buf_size = HCLGE_DEFAULT_TX_BUF; + ++ hdev->tx_buf_size = roundup(hdev->tx_buf_size, HCLGE_BUF_SIZE_UNIT); ++ + if (req->dv_buf_size) + hdev->dv_buf_size = + __le16_to_cpu(req->dv_buf_size) << HCLGE_BUF_UNIT_S; + else + hdev->dv_buf_size = HCLGE_DEFAULT_DV; + ++ hdev->dv_buf_size = roundup(hdev->dv_buf_size, HCLGE_BUF_SIZE_UNIT); ++ + if (hnae3_dev_roce_supported(hdev)) { + hdev->roce_base_msix_offset = + hnae3_get_field(__le16_to_cpu(req->msixcap_localid_ba_rocee), +@@ -1596,48 +1604,50 @@ static bool hclge_is_rx_buf_ok(struct hclge_dev *hdev, + { + u32 shared_buf_min, shared_buf_tc, shared_std; + int tc_num, pfc_enable_num; +- u32 shared_buf; ++ u32 shared_buf, aligned_mps; + u32 rx_priv; + int i; + + tc_num = hclge_get_tc_num(hdev); + pfc_enable_num = hclge_get_pfc_enalbe_num(hdev); ++ aligned_mps = roundup(hdev->mps, HCLGE_BUF_SIZE_UNIT); + + if (hnae3_dev_dcb_supported(hdev)) +- shared_buf_min = 2 * hdev->mps + hdev->dv_buf_size; ++ shared_buf_min = 2 * aligned_mps + hdev->dv_buf_size; + else +- shared_buf_min = hdev->mps + HCLGE_NON_DCB_ADDITIONAL_BUF ++ shared_buf_min = aligned_mps + HCLGE_NON_DCB_ADDITIONAL_BUF + + hdev->dv_buf_size; + +- shared_buf_tc = pfc_enable_num * hdev->mps + +- (tc_num - pfc_enable_num) * hdev->mps / 2 + +- hdev->mps; ++ shared_buf_tc = pfc_enable_num * aligned_mps + ++ (tc_num - pfc_enable_num) * aligned_mps / 2 + ++ aligned_mps; + shared_std = max_t(u32, shared_buf_min, shared_buf_tc); + + rx_priv = hclge_get_rx_priv_buff_alloced(buf_alloc); + if (rx_all <= rx_priv + shared_std) + return false; + +- shared_buf = rx_all - rx_priv; ++ shared_buf = rounddown(rx_all - rx_priv, HCLGE_BUF_SIZE_UNIT); + buf_alloc->s_buf.buf_size = shared_buf; + if (hnae3_dev_dcb_supported(hdev)) { + buf_alloc->s_buf.self.high = shared_buf - hdev->dv_buf_size; + buf_alloc->s_buf.self.low = buf_alloc->s_buf.self.high +- - hdev->mps / 2; ++ - roundup(aligned_mps / 2, HCLGE_BUF_SIZE_UNIT); + } else { +- buf_alloc->s_buf.self.high = hdev->mps + ++ buf_alloc->s_buf.self.high = aligned_mps + + HCLGE_NON_DCB_ADDITIONAL_BUF; +- buf_alloc->s_buf.self.low = hdev->mps / 2; ++ buf_alloc->s_buf.self.low = ++ roundup(aligned_mps / 2, HCLGE_BUF_SIZE_UNIT); + } + + for (i = 0; i < HCLGE_MAX_TC_NUM; i++) { + if ((hdev->hw_tc_map & BIT(i)) && + (hdev->tm_info.hw_pfc_map & BIT(i))) { +- buf_alloc->s_buf.tc_thrd[i].low = hdev->mps; +- buf_alloc->s_buf.tc_thrd[i].high = 2 * hdev->mps; ++ buf_alloc->s_buf.tc_thrd[i].low = aligned_mps; ++ buf_alloc->s_buf.tc_thrd[i].high = 2 * aligned_mps; + } else { + buf_alloc->s_buf.tc_thrd[i].low = 0; +- buf_alloc->s_buf.tc_thrd[i].high = hdev->mps; ++ buf_alloc->s_buf.tc_thrd[i].high = aligned_mps; + } + } + +@@ -1677,7 +1687,6 @@ static int hclge_tx_buffer_calc(struct hclge_dev *hdev, + static int hclge_rx_buffer_calc(struct hclge_dev *hdev, + struct hclge_pkt_buf_alloc *buf_alloc) + { +-#define HCLGE_BUF_SIZE_UNIT 128 + u32 rx_all = hdev->pkt_buf_size, aligned_mps; + int no_pfc_priv_num, pfc_priv_num; + struct hclge_priv_buf *priv; +@@ -1703,9 +1712,11 @@ static int hclge_rx_buffer_calc(struct hclge_dev *hdev, + priv->enable = 1; + if (hdev->tm_info.hw_pfc_map & BIT(i)) { + priv->wl.low = aligned_mps; +- priv->wl.high = priv->wl.low + aligned_mps; ++ priv->wl.high = ++ roundup(priv->wl.low + aligned_mps, ++ HCLGE_BUF_SIZE_UNIT); + priv->buf_size = priv->wl.high + +- hdev->dv_buf_size; ++ hdev->dv_buf_size; + } else { + priv->wl.low = 0; + priv->wl.high = 2 * aligned_mps; +@@ -1740,7 +1751,7 @@ static int hclge_rx_buffer_calc(struct hclge_dev *hdev, + priv->enable = 1; + + if (hdev->tm_info.hw_pfc_map & BIT(i)) { +- priv->wl.low = 128; ++ priv->wl.low = 256; + priv->wl.high = priv->wl.low + aligned_mps; + priv->buf_size = priv->wl.high + hdev->dv_buf_size; + } else { +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0022-net-hns3-fix-a-SSU-buffer-checking-bug.patch b/debian/patches/bugfix/arm64/huawei-taishan/0022-net-hns3-fix-a-SSU-buffer-checking-bug.patch new file mode 100644 index 000000000..a5278d652 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0022-net-hns3-fix-a-SSU-buffer-checking-bug.patch @@ -0,0 +1,48 @@ +From 4d887b7901d59b472df97bd8a2f8bdeb43be7ced Mon Sep 17 00:00:00 2001 +From: Yunsheng Lin +Date: Tue, 18 Dec 2018 19:37:59 +0800 +Subject: [PATCH 22/31] net: hns3: fix a SSU buffer checking bug +Origin: https://git.kernel.org/linus/af854724e51e4047f534ac6d19b3ef9fb3c35c49 + +When caculating the SSU buffer, it first allocate tx and +rx private buffer, then the remaining buffer is for rx +shared buffer. The remaining buffer size should be at +least bigger than or equal to the shared_std, which is the +minimum shared buffer size required by the driver, but +currently if the remaining buffer size is equal to the +shared_std, it returns failure, which causes SSU buffer +allocation failure problem. + +This patch fixes this problem by rounding up shared_std before +checking the the remaining buffer size bigger than or equal to +the shared_std. + +Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support") +Signed-off-by: Yunsheng Lin +Signed-off-by: Peng Li +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +index 42a38ca966d1..79232f584531 100644 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +@@ -1621,10 +1621,11 @@ static bool hclge_is_rx_buf_ok(struct hclge_dev *hdev, + shared_buf_tc = pfc_enable_num * aligned_mps + + (tc_num - pfc_enable_num) * aligned_mps / 2 + + aligned_mps; +- shared_std = max_t(u32, shared_buf_min, shared_buf_tc); ++ shared_std = roundup(max_t(u32, shared_buf_min, shared_buf_tc), ++ HCLGE_BUF_SIZE_UNIT); + + rx_priv = hclge_get_rx_priv_buff_alloced(buf_alloc); +- if (rx_all <= rx_priv + shared_std) ++ if (rx_all < rx_priv + shared_std) + return false; + + shared_buf = rounddown(rx_all - rx_priv, HCLGE_BUF_SIZE_UNIT); +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0023-net-hns3-change-default-tc-state-to-close.patch b/debian/patches/bugfix/arm64/huawei-taishan/0023-net-hns3-change-default-tc-state-to-close.patch new file mode 100644 index 000000000..adfa4b935 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0023-net-hns3-change-default-tc-state-to-close.patch @@ -0,0 +1,33 @@ +From ea3eff7a2ef69730c8e48715fbf965cb9da8b0bc Mon Sep 17 00:00:00 2001 +From: Jian Shen +Date: Thu, 20 Dec 2018 11:51:59 +0800 +Subject: [PATCH 23/31] net: hns3: change default tc state to close +Origin: https://git.kernel.org/linus/a298797532d9dc244abf349d7c2ed063732c6ba3 + +In original codes, default tc value is set to the max tc. It's more +reasonable to close tc by changing default tc value to 1. Users can +enable it with lldp tool when they want to use tc. + +Signed-off-by: Jian Shen +Signed-off-by: Peng Li +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +index 79232f584531..8cc08ffee76f 100644 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +@@ -1201,7 +1201,7 @@ static int hclge_configure(struct hclge_dev *hdev) + hdev->pfc_max = hdev->tc_max; + } + +- hdev->tm_info.num_tc = hdev->tc_max; ++ hdev->tm_info.num_tc = 1; + + /* Currently not support uncontiuous tc */ + for (i = 0; i < hdev->tm_info.num_tc; i++) +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0024-net-hns3-fix-a-bug-caused-by-udelay.patch b/debian/patches/bugfix/arm64/huawei-taishan/0024-net-hns3-fix-a-bug-caused-by-udelay.patch new file mode 100644 index 000000000..a038a9ccf --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0024-net-hns3-fix-a-bug-caused-by-udelay.patch @@ -0,0 +1,42 @@ +From 0f27af14383edac1efaf140d7cbe2d7dfdab7318 Mon Sep 17 00:00:00 2001 +From: Peng Li +Date: Thu, 20 Dec 2018 11:52:00 +0800 +Subject: [PATCH 24/31] net: hns3: fix a bug caused by udelay +Origin: https://git.kernel.org/linus/1b7d7b0581173219b82abbd81c88cf8aa7d402c2 + +udelay() in driver may always occupancy processor. If there is only +one cpu in system, the VF driver may initialize fail when insmod +PF and VF driver in the same system. This patch use msleep() to free +cpu when VF wait PF message. + +Signed-off-by: Peng Li +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c +index e9d5a4f96304..499131840041 100644 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c +@@ -26,7 +26,7 @@ static int hclgevf_get_mbx_resp(struct hclgevf_dev *hdev, u16 code0, u16 code1, + u8 *resp_data, u16 resp_len) + { + #define HCLGEVF_MAX_TRY_TIMES 500 +-#define HCLGEVF_SLEEP_USCOEND 1000 ++#define HCLGEVF_SLEEP_USECOND 1000 + struct hclgevf_mbx_resp_status *mbx_resp; + u16 r_code0, r_code1; + int i = 0; +@@ -40,7 +40,7 @@ static int hclgevf_get_mbx_resp(struct hclgevf_dev *hdev, u16 code0, u16 code1, + } + + while ((!hdev->mbx_resp.received_resp) && (i < HCLGEVF_MAX_TRY_TIMES)) { +- udelay(HCLGEVF_SLEEP_USCOEND); ++ usleep_range(HCLGEVF_SLEEP_USECOND, HCLGEVF_SLEEP_USECOND * 2); + i++; + } + +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0025-net-hns3-remove-redundant-variable-initialization.patch b/debian/patches/bugfix/arm64/huawei-taishan/0025-net-hns3-remove-redundant-variable-initialization.patch new file mode 100644 index 000000000..b724c37cc --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0025-net-hns3-remove-redundant-variable-initialization.patch @@ -0,0 +1,31 @@ +From 883a7a53d7f6a6494e3a0df73fb02f76ecc42bc1 Mon Sep 17 00:00:00 2001 +From: Peng Li +Date: Thu, 20 Dec 2018 11:52:06 +0800 +Subject: [PATCH 25/31] net: hns3: remove redundant variable initialization +Origin: https://git.kernel.org/linus/1154bb26c879fea51c20aee167ddce4345caa255 + +This patch removes the redundant variable initialization, +as driver will devm_kzalloc to set value to hdev soon. + +Signed-off-by: Peng Li +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +index 5570fb5dc2eb..dca51d9cfa4f 100644 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +@@ -1360,7 +1360,7 @@ static int hclgevf_configure(struct hclgevf_dev *hdev) + static int hclgevf_alloc_hdev(struct hnae3_ae_dev *ae_dev) + { + struct pci_dev *pdev = ae_dev->pdev; +- struct hclgevf_dev *hdev = ae_dev->priv; ++ struct hclgevf_dev *hdev; + + hdev = devm_kzalloc(&pdev->dev, sizeof(*hdev), GFP_KERNEL); + if (!hdev) +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0026-net-hns3-call-hns3_nic_net_open-while-doing-HNAE3_UP.patch b/debian/patches/bugfix/arm64/huawei-taishan/0026-net-hns3-call-hns3_nic_net_open-while-doing-HNAE3_UP.patch new file mode 100644 index 000000000..fcf93fd11 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0026-net-hns3-call-hns3_nic_net_open-while-doing-HNAE3_UP.patch @@ -0,0 +1,49 @@ +From a4e5945057386872cb9add271aea76ca2413f481 Mon Sep 17 00:00:00 2001 +From: Huazhong Tan +Date: Mon, 31 Dec 2018 10:58:29 +0800 +Subject: [PATCH 26/31] net: hns3: call hns3_nic_net_open() while doing + HNAE3_UP_CLIENT +Origin: https://git.kernel.org/linus/e888402789b9db5de4fcda361331d66dbf0cd9fd + +For HNAE3_DOWN_CLIENT calling hns3_nic_net_stop(), HNAE3_UP_CLIENT +should call hns3_nic_net_open(), since if the number of queue or +the map of TC has is changed before HHAE3_UP_CLIENT is called, +it will cause problem. + +Also the HNS3_NIC_STATE_RESETTING flag needs to be cleared before +hns3_nic_net_open() called, and set it back while hns3_nic_net_open() +failed. + +Fixes: bb6b94a896d4 ("net: hns3: Add reset interface implementation in client") +Signed-off-by: Huazhong Tan +Signed-off-by: Yunsheng Lin +Signed-off-by: Peng Li +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +index 0ccfa6a84535..895c43fd1d81 100644 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +@@ -3439,11 +3439,15 @@ static int hns3_reset_notify_down_enet(struct hnae3_handle *handle) + static int hns3_reset_notify_up_enet(struct hnae3_handle *handle) + { + struct hnae3_knic_private_info *kinfo = &handle->kinfo; ++ struct hns3_nic_priv *priv = netdev_priv(kinfo->netdev); + int ret = 0; + ++ clear_bit(HNS3_NIC_STATE_RESETTING, &priv->state); ++ + if (netif_running(kinfo->netdev)) { +- ret = hns3_nic_net_up(kinfo->netdev); ++ ret = hns3_nic_net_open(kinfo->netdev); + if (ret) { ++ set_bit(HNS3_NIC_STATE_RESETTING, &priv->state); + netdev_err(kinfo->netdev, + "hns net up fail, ret=%d!\n", ret); + return ret; +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0027-RDMA-hns-Fix-the-bug-with-updating-rq-head-pointer-w.patch b/debian/patches/bugfix/arm64/huawei-taishan/0027-RDMA-hns-Fix-the-bug-with-updating-rq-head-pointer-w.patch new file mode 100644 index 000000000..b897d9320 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0027-RDMA-hns-Fix-the-bug-with-updating-rq-head-pointer-w.patch @@ -0,0 +1,52 @@ +From 42472e368c1bbe74d7316d549ae4f83097f54c87 Mon Sep 17 00:00:00 2001 +From: Lijun Ou +Date: Wed, 12 Dec 2018 17:49:06 +0800 +Subject: [PATCH 27/31] RDMA/hns: Fix the bug with updating rq head pointer + when flush cqe +Origin: https://git.kernel.org/linus/9c6ccc035c209dda07685e8dba829a203ba17499 + +When flush cqe with srq, the driver disable to update the rq head pointer +into the hardware. + +Signed-off-by: Lijun Ou +Signed-off-by: Jason Gunthorpe +--- + drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +index a442b29e7611..c7843d9817de 100644 +--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c ++++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +@@ -3499,13 +3499,16 @@ static int hns_roce_v2_modify_qp(struct ib_qp *ibqp, + roce_set_field(qpc_mask->byte_160_sq_ci_pi, + V2_QPC_BYTE_160_SQ_PRODUCER_IDX_M, + V2_QPC_BYTE_160_SQ_PRODUCER_IDX_S, 0); +- roce_set_field(context->byte_84_rq_ci_pi, ++ ++ if (!ibqp->srq) { ++ roce_set_field(context->byte_84_rq_ci_pi, + V2_QPC_BYTE_84_RQ_PRODUCER_IDX_M, + V2_QPC_BYTE_84_RQ_PRODUCER_IDX_S, + hr_qp->rq.head); +- roce_set_field(qpc_mask->byte_84_rq_ci_pi, ++ roce_set_field(qpc_mask->byte_84_rq_ci_pi, + V2_QPC_BYTE_84_RQ_PRODUCER_IDX_M, + V2_QPC_BYTE_84_RQ_PRODUCER_IDX_S, 0); ++ } + } + + if (attr_mask & IB_QP_AV) { +@@ -3967,7 +3970,8 @@ static void hns_roce_set_qps_to_err(struct hns_roce_dev *hr_dev, u32 qpn) + if (hr_qp->ibqp.uobject) { + if (hr_qp->sdb_en == 1) { + hr_qp->sq.head = *(int *)(hr_qp->sdb.virt_addr); +- hr_qp->rq.head = *(int *)(hr_qp->rdb.virt_addr); ++ if (hr_qp->rdb_en == 1) ++ hr_qp->rq.head = *(int *)(hr_qp->rdb.virt_addr); + } else { + dev_warn(hr_dev->dev, "flush cqe is unsupported in userspace!\n"); + return; +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0028-RDMA-hns-Bugfix-for-the-scene-without-receiver-queue.patch b/debian/patches/bugfix/arm64/huawei-taishan/0028-RDMA-hns-Bugfix-for-the-scene-without-receiver-queue.patch new file mode 100644 index 000000000..a597b9a47 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0028-RDMA-hns-Bugfix-for-the-scene-without-receiver-queue.patch @@ -0,0 +1,32 @@ +From 0adf3f4bef9346c9cd3d1ecb7af4ee8f27d3b48a Mon Sep 17 00:00:00 2001 +From: Lijun Ou +Date: Wed, 12 Dec 2018 17:49:07 +0800 +Subject: [PATCH 28/31] RDMA/hns: Bugfix for the scene without receiver queue +Origin: https://git.kernel.org/linus/4d103905eb1e4f14cb62fcf962c9d35da7005dea + +In some application scenario, the user could not have receive queue when +run rdma write or read operation. + +Signed-off-by: Lijun Ou +Signed-off-by: Jason Gunthorpe +--- + drivers/infiniband/hw/hns/hns_roce_qp.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c +index efb7e961ca65..de1676e25828 100644 +--- a/drivers/infiniband/hw/hns/hns_roce_qp.c ++++ b/drivers/infiniband/hw/hns/hns_roce_qp.c +@@ -503,7 +503,8 @@ static int hns_roce_qp_has_sq(struct ib_qp_init_attr *attr) + static int hns_roce_qp_has_rq(struct ib_qp_init_attr *attr) + { + if (attr->qp_type == IB_QPT_XRC_INI || +- attr->qp_type == IB_QPT_XRC_TGT || attr->srq) ++ attr->qp_type == IB_QPT_XRC_TGT || attr->srq || ++ !attr->cap.max_recv_wr) + return 0; + + return 1; +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0029-RDMA-hns-Add-constraint-on-the-setting-of-local-ACK-.patch b/debian/patches/bugfix/arm64/huawei-taishan/0029-RDMA-hns-Add-constraint-on-the-setting-of-local-ACK-.patch new file mode 100644 index 000000000..aa69c2ef4 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0029-RDMA-hns-Add-constraint-on-the-setting-of-local-ACK-.patch @@ -0,0 +1,46 @@ +From 84193e72c505286e4681b3c566c64eea3e25f7fd Mon Sep 17 00:00:00 2001 +From: Lijun Ou +Date: Wed, 12 Dec 2018 17:49:08 +0800 +Subject: [PATCH 29/31] RDMA/hns: Add constraint on the setting of local ACK + timeout +Origin: https://git.kernel.org/linus/44754b95dd35ee07c462b5425ae9c4cde8c7e7c8 + +According to IB protocol, local ACK timeout shall be a 5 bit +value. Currently, hip08 could not support the possible max value 31. Fail +the request in this case. + +Signed-off-by: Yixian Liu +Signed-off-by: Lijun Ou +Signed-off-by: Jason Gunthorpe +--- + drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +index c7843d9817de..627f77a6e0a9 100644 +--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c ++++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +@@ -3398,10 +3398,16 @@ static int modify_qp_rtr_to_rts(struct ib_qp *ibqp, + V2_QPC_BYTE_212_LSN_S, 0); + + if (attr_mask & IB_QP_TIMEOUT) { +- roce_set_field(context->byte_28_at_fl, V2_QPC_BYTE_28_AT_M, +- V2_QPC_BYTE_28_AT_S, attr->timeout); +- roce_set_field(qpc_mask->byte_28_at_fl, V2_QPC_BYTE_28_AT_M, +- V2_QPC_BYTE_28_AT_S, 0); ++ if (attr->timeout < 31) { ++ roce_set_field(context->byte_28_at_fl, ++ V2_QPC_BYTE_28_AT_M, V2_QPC_BYTE_28_AT_S, ++ attr->timeout); ++ roce_set_field(qpc_mask->byte_28_at_fl, ++ V2_QPC_BYTE_28_AT_M, V2_QPC_BYTE_28_AT_S, ++ 0); ++ } else { ++ dev_warn(dev, "Local ACK timeout shall be 0 to 30.\n"); ++ } + } + + roce_set_field(context->byte_172_sq_psn, V2_QPC_BYTE_172_SQ_CUR_PSN_M, +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0030-RDMA-hns-Modify-the-pbl-ba-page-size-for-hip08.patch b/debian/patches/bugfix/arm64/huawei-taishan/0030-RDMA-hns-Modify-the-pbl-ba-page-size-for-hip08.patch new file mode 100644 index 000000000..138d7f9f9 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0030-RDMA-hns-Modify-the-pbl-ba-page-size-for-hip08.patch @@ -0,0 +1,31 @@ +From 454bc02382f8ed2eb3ebc7db4867ed419e3f0241 Mon Sep 17 00:00:00 2001 +From: Lijun Ou +Date: Wed, 12 Dec 2018 17:49:09 +0800 +Subject: [PATCH 30/31] RDMA/hns: Modify the pbl ba page size for hip08 +Origin: https://git.kernel.org/linus/91fb4d83b88a7b544ce564c44167aad29d4154f0 + +Modify the pbl ba page size to 16K for in order to support 4G MR size. + +Signed-off-by: Wei Hu (Xavier) +Signed-off-by: Lijun Ou +Signed-off-by: Jason Gunthorpe +--- + drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +index 627f77a6e0a9..e521cc740120 100644 +--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c ++++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +@@ -1235,7 +1235,7 @@ static int hns_roce_v2_profile(struct hns_roce_dev *hr_dev) + caps->mpt_ba_pg_sz = 0; + caps->mpt_buf_pg_sz = 0; + caps->mpt_hop_num = HNS_ROCE_CONTEXT_HOP_NUM; +- caps->pbl_ba_pg_sz = 0; ++ caps->pbl_ba_pg_sz = 2; + caps->pbl_buf_pg_sz = 0; + caps->pbl_hop_num = HNS_ROCE_PBL_HOP_NUM; + caps->mtt_ba_pg_sz = 0; +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0031-RDMA-hns-RDMA-hns-Assign-rq-head-pointer-when-enable.patch b/debian/patches/bugfix/arm64/huawei-taishan/0031-RDMA-hns-RDMA-hns-Assign-rq-head-pointer-when-enable.patch new file mode 100644 index 000000000..ec1312b8e --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0031-RDMA-hns-RDMA-hns-Assign-rq-head-pointer-when-enable.patch @@ -0,0 +1,66 @@ +From 07a7830061e657ce352e690dbe0a794ffb10d22e Mon Sep 17 00:00:00 2001 +From: Lijun Ou +Date: Sat, 12 Jan 2019 18:36:29 +0800 +Subject: [PATCH 31/31] RDMA/hns: RDMA/hns: Assign rq head pointer when enable + rq record db +Origin: https://git.kernel.org/linus/de77503a59403e7045c18c6bb0a10c245a99b648 + +When flush cqe, it needs to get the pointer of rq and sq from db address +space of user and update it into qp context by modified qp. if rq does not +exist, it will not get the value from db address space of user. + +Signed-off-by: Lijun Ou +Signed-off-by: Jason Gunthorpe +--- + drivers/infiniband/hw/hns/hns_roce_qp.c | 19 ++++++++++--------- + 1 file changed, 10 insertions(+), 9 deletions(-) + +diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c +index de1676e25828..b3ad35310925 100644 +--- a/drivers/infiniband/hw/hns/hns_roce_qp.c ++++ b/drivers/infiniband/hw/hns/hns_roce_qp.c +@@ -652,6 +652,10 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, + dev_err(dev, "rq record doorbell map failed!\n"); + goto err_sq_dbmap; + } ++ ++ /* indicate kernel supports rq record db */ ++ resp.cap_flags |= HNS_ROCE_SUPPORT_RQ_RECORD_DB; ++ hr_qp->rdb_en = 1; + } + } else { + if (init_attr->create_flags & +@@ -760,16 +764,11 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, + else + hr_qp->doorbell_qpn = cpu_to_le64(hr_qp->qpn); + +- if (ib_pd->uobject && (udata->outlen >= sizeof(resp)) && +- (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB)) { +- +- /* indicate kernel supports rq record db */ +- resp.cap_flags |= HNS_ROCE_SUPPORT_RQ_RECORD_DB; +- ret = ib_copy_to_udata(udata, &resp, sizeof(resp)); ++ if (udata) { ++ ret = ib_copy_to_udata(udata, &resp, ++ min(udata->outlen, sizeof(resp))); + if (ret) + goto err_qp; +- +- hr_qp->rdb_en = 1; + } + hr_qp->event = hns_roce_ib_qp_event; + +@@ -946,7 +945,9 @@ int hns_roce_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, + (attr_mask & IB_QP_STATE) && new_state == IB_QPS_ERR) { + if (hr_qp->sdb_en == 1) { + hr_qp->sq.head = *(int *)(hr_qp->sdb.virt_addr); +- hr_qp->rq.head = *(int *)(hr_qp->rdb.virt_addr); ++ ++ if (hr_qp->rdb_en == 1) ++ hr_qp->rq.head = *(int *)(hr_qp->rdb.virt_addr); + } else { + dev_warn(dev, "flush cqe is not supported in userspace!\n"); + goto out; +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0032-scsi-hisi_sas-Fix-NULL-pointer-dereference.patch b/debian/patches/bugfix/arm64/huawei-taishan/0032-scsi-hisi_sas-Fix-NULL-pointer-dereference.patch new file mode 100644 index 000000000..0e9e9cd44 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0032-scsi-hisi_sas-Fix-NULL-pointer-dereference.patch @@ -0,0 +1,63 @@ +From 19c36e6a73724c2ec33980b9ab88145428b68412 Mon Sep 17 00:00:00 2001 +From: "Gustavo A. R. Silva" +Date: Thu, 18 Oct 2018 18:59:39 +0200 +Subject: [PATCH] scsi: hisi_sas: Fix NULL pointer dereference +Origin: https://git.kernel.org/linus/f4445bb93d82a984657b469e63118c2794a4c3d3 + +There is a NULL pointer dereference in case *slot* happens to be NULL at +lines 1053 and 1878: + +struct hisi_sas_cq *cq = + &hisi_hba->cq[slot->dlvry_queue]; + +Notice that *slot* is being NULL checked at lines 1057 and 1881: +if (slot), which implies it may be NULL. + +Fix this by placing the declaration and definition of variable cq, which +contains the pointer dereference slot->dlvry_queue, after slot has been +properly NULL checked. + +Addresses-Coverity-ID: 1474515 ("Dereference before null check") +Addresses-Coverity-ID: 1474520 ("Dereference before null check") +Fixes: 584f53fe5f52 ("scsi: hisi_sas: Fix the race between IO completion and timeout for SMP/internal IO") +Signed-off-by: Gustavo A. R. Silva +Reviewed-by: Xiang Chen +Signed-off-by: Martin K. Petersen +--- + drivers/scsi/hisi_sas/hisi_sas_main.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c +index 764d651879cf..3c03de9d18dd 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_main.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_main.c +@@ -1088,11 +1088,11 @@ static int hisi_sas_exec_internal_tmf_task(struct domain_device *device, + if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) { + if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { + struct hisi_sas_slot *slot = task->lldd_task; +- struct hisi_sas_cq *cq = +- &hisi_hba->cq[slot->dlvry_queue]; + + dev_err(dev, "abort tmf: TMF task timeout and not done\n"); + if (slot) { ++ struct hisi_sas_cq *cq = ++ &hisi_hba->cq[slot->dlvry_queue]; + /* + * flush tasklet to avoid free'ing task + * before using task in IO completion +@@ -1913,10 +1913,10 @@ hisi_sas_internal_task_abort(struct hisi_hba *hisi_hba, + if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) { + if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { + struct hisi_sas_slot *slot = task->lldd_task; +- struct hisi_sas_cq *cq = +- &hisi_hba->cq[slot->dlvry_queue]; + + if (slot) { ++ struct hisi_sas_cq *cq = ++ &hisi_hba->cq[slot->dlvry_queue]; + /* + * flush tasklet to avoid free'ing task + * before using task in IO completion +-- +2.20.1 + diff --git a/debian/patches/bugfix/arm64/huawei-taishan/0033-scsi-hisi_sas-fix-calls-to-dma_set_mask_and_coherent.patch b/debian/patches/bugfix/arm64/huawei-taishan/0033-scsi-hisi_sas-fix-calls-to-dma_set_mask_and_coherent.patch new file mode 100644 index 000000000..cefc0d202 --- /dev/null +++ b/debian/patches/bugfix/arm64/huawei-taishan/0033-scsi-hisi_sas-fix-calls-to-dma_set_mask_and_coherent.patch @@ -0,0 +1,73 @@ +From badecc38102204f5297ad6ce1d7c7875e514c6f7 Mon Sep 17 00:00:00 2001 +From: Hannes Reinecke +Date: Mon, 18 Feb 2019 08:34:25 +0100 +Subject: [PATCH] scsi: hisi_sas: fix calls to dma_set_mask_and_coherent() +Origin: https://git.kernel.org/linus/d9a00459effc30f6de2cdd887b64f15c6c54ae71 + +The change to use dma_set_mask_and_coherent() incorrectly made a second +call with the 32 bit DMA mask value when the call with the 64 bit DMA +mask value succeeded. + +[mkp: fixed commit message] + +Fixes: e4db40e7a1a2 ("scsi: hisi_sas: use dma_set_mask_and_coherent") +Cc: +Suggested-by: Ewan D. Milne +Signed-off-by: Hannes Reinecke +Reviewed-by: Christoph Hellwig +Signed-off-by: Hannes Reinecke +Signed-off-by: Martin K. Petersen +--- + drivers/scsi/hisi_sas/hisi_sas_main.c | 8 ++++++-- + drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 8 +++++--- + 2 files changed, 11 insertions(+), 5 deletions(-) + +diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c +index 3c03de9d18dd..8aeb92d9144e 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_main.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_main.c +@@ -2339,6 +2339,7 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev, + struct Scsi_Host *shost; + struct hisi_hba *hisi_hba; + struct device *dev = &pdev->dev; ++ int error; + + shost = scsi_host_alloc(hw->sht, sizeof(*hisi_hba)); + if (!shost) { +@@ -2359,8 +2360,11 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev, + if (hisi_sas_get_fw_info(hisi_hba) < 0) + goto err_out; + +- if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)) && +- dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32))) { ++ error = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)); ++ if (error) ++ error = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32)); ++ ++ if (error) { + dev_err(dev, "No usable DMA addressing method\n"); + goto err_out; + } +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +index 6d584f232204..434f017afadc 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +@@ -2328,10 +2328,12 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id) + if (rc) + goto err_out_disable_device; + +- if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) || +- dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) { ++ rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); ++ if (rc) ++ rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); ++ if (rc) { + dev_err(dev, "No usable DMA addressing method\n"); +- rc = -EIO; ++ rc = -ENODEV; + goto err_out_regions; + } + +-- +2.20.1 + diff --git a/debian/patches/series b/debian/patches/series index 92ec3cc25..fee6f0c84 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -279,5 +279,40 @@ features/all/ena/0016-net-ena-fix-compilation-error-in-xtensa-architecture.patch features/all/ena/0017-net-ena-fix-crash-during-ena_remove.patch features/all/ena/0018-net-ena-update-driver-version-from-2.0.1-to-2.0.2.patch +# Backported bugfixes from 4.20/4.21 for the Huawei TaiShan server platform (aka D06) +bugfix/arm64/huawei-taishan/0001-scsi-hisi_sas-Feed-back-linkrate-max-min-when-re-att.patch +bugfix/arm64/huawei-taishan/0002-scsi-hisi_sas-Move-evaluation-of-hisi_hba-in-hisi_sa.patch +bugfix/arm64/huawei-taishan/0003-scsi-hisi_sas-Fix-the-race-between-IO-completion-and.patch +bugfix/arm64/huawei-taishan/0004-scsi-hisi_sas-Free-slot-later-in-slot_complete_vx_hw.patch +bugfix/arm64/huawei-taishan/0005-scsi-hisi_sas-unmask-interrupts-ent72-and-ent74.patch +bugfix/arm64/huawei-taishan/0006-scsi-hisi_sas-Use-block-layer-tag-instead-for-IPTT.patch +bugfix/arm64/huawei-taishan/0007-scsi-hisi_sas-Update-v3-hw-AIP_LIMIT-and-CFG_AGING_T.patch +bugfix/arm64/huawei-taishan/0008-scsi-hisi_sas-Fix-spin-lock-management-in-slot_index.patch +bugfix/arm64/huawei-taishan/0009-scsi-hisi_sas-use-dma_set_mask_and_coherent.patch +bugfix/arm64/huawei-taishan/0010-scsi-hisi_sas-Create-separate-host-attributes-per-HB.patch +bugfix/arm64/huawei-taishan/0011-scsi-hisi_sas-Add-support-for-interrupt-converge-for.patch +bugfix/arm64/huawei-taishan/0012-scsi-hisi_sas-Add-support-for-interrupt-coalescing-f.patch +bugfix/arm64/huawei-taishan/0013-scsi-hisi_sas-Relocate-some-codes-to-avoid-an-unused.patch +bugfix/arm64/huawei-taishan/0014-scsi-hisi_sas-Fix-warnings-detected-by-sparse.patch +bugfix/arm64/huawei-taishan/0015-scsi-hisi_sas-Relocate-some-code-to-reduce-complexit.patch +bugfix/arm64/huawei-taishan/0016-scsi-hisi_sas-Make-sg_tablesize-consistent-value.patch +bugfix/arm64/huawei-taishan/0017-net-hns3-remove-unnecessary-configuration-recapture-.patch +bugfix/arm64/huawei-taishan/0018-net-hns3-remove-1000M-half-support-of-phy.patch +bugfix/arm64/huawei-taishan/0019-net-hns3-synchronize-speed-and-duplex-from-phy-when-.patch +bugfix/arm64/huawei-taishan/0020-net-hns3-getting-tx-and-dv-buffer-size-through-firmw.patch +bugfix/arm64/huawei-taishan/0021-net-hns3-aligning-buffer-size-in-SSU-to-256-bytes.patch +bugfix/arm64/huawei-taishan/0022-net-hns3-fix-a-SSU-buffer-checking-bug.patch +bugfix/arm64/huawei-taishan/0023-net-hns3-change-default-tc-state-to-close.patch +bugfix/arm64/huawei-taishan/0024-net-hns3-fix-a-bug-caused-by-udelay.patch +bugfix/arm64/huawei-taishan/0025-net-hns3-remove-redundant-variable-initialization.patch +bugfix/arm64/huawei-taishan/0026-net-hns3-call-hns3_nic_net_open-while-doing-HNAE3_UP.patch +bugfix/arm64/huawei-taishan/0027-RDMA-hns-Fix-the-bug-with-updating-rq-head-pointer-w.patch +bugfix/arm64/huawei-taishan/0028-RDMA-hns-Bugfix-for-the-scene-without-receiver-queue.patch +bugfix/arm64/huawei-taishan/0029-RDMA-hns-Add-constraint-on-the-setting-of-local-ACK-.patch +bugfix/arm64/huawei-taishan/0030-RDMA-hns-Modify-the-pbl-ba-page-size-for-hip08.patch +bugfix/arm64/huawei-taishan/0031-RDMA-hns-RDMA-hns-Assign-rq-head-pointer-when-enable.patch +bugfix/arm64/huawei-taishan/0032-scsi-hisi_sas-Fix-NULL-pointer-dereference.patch +bugfix/arm64/huawei-taishan/0033-scsi-hisi_sas-fix-calls-to-dma_set_mask_and_coherent.patch + # ABI maintenance debian/abi/tcp-avoid-abi-change-for-dos-fixes.patch