]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/log
mirror_ubuntu-bionic-kernel.git
6 years agoscsi: hisi_sas: Init disks after controller reset
Xiaofei Tan [Mon, 21 May 2018 10:09:19 +0000 (18:09 +0800)]
scsi: hisi_sas: Init disks after controller reset

BugLink: https://bugs.launchpad.net/bugs/1774466
After the controller is reset, it is possible that the disks attached still
have outstanding IO to complete.

Thus, when the PHYs come back up after controller reset, it is possible
that these IOs complete at some unknown point later.

We want to ensure that all IOs are complete after the controller reset so
that all associated IPTT and other resources can be recycled safely.

To achieve this, re-init the disks by TMF or softreset (in case of ATA
devices).

If the init fails - maybe because the device was removed or link has not
come up - then do not release the device resources, but rather rely on SCSI
EH to handle the timeout for these resources later on.

This patch also does some cleanup to hisi_sas_init_disk(), including
removing superfluous cases in the switch statement.

Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 6175abdeaeaf2602f3e92bd4eca5916e98efe996 linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: Create a scsi_host_template per HW module
Xiang Chen [Mon, 21 May 2018 10:09:18 +0000 (18:09 +0800)]
scsi: hisi_sas: Create a scsi_host_template per HW module

BugLink: https://bugs.launchpad.net/bugs/1774466
When a SCSI host is registered, the SCSI mid-layer takes a reference to a
module in Scsi_host.hostt.module. In doing this, we are prevented from
removing the driver module for the host in dangerous scenario, like when a
disk is mounted.

Currently there is only one scsi_host_template (sht) for all HW versions,
and this is the main.c module. So this means that we can possibly remove
the HW module in this dangerous scenario, as SCSI mid-layer is only
referencing the main.c module.

To fix this, create a sht per module, referencing that same module to
create the Scsi host.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 235bfc7ff63027e90c25663ed7a976083f5afb47 linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: Reset disks when discovered
Xiang Chen [Mon, 21 May 2018 10:09:17 +0000 (18:09 +0800)]
scsi: hisi_sas: Reset disks when discovered

BugLink: https://bugs.launchpad.net/bugs/1774466
When a disk is discovered, it may be in an error state, or there may be
residual commands remaining in the disk.

To ensure any disk is in good state after discovery, reset via TMF (for SAS
disk) or softreset (for a SATA disk).

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit d5a60dfdb364bd1fa59c2c11be54be80f6990a3d linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: Add LED feature for v3 hw
Xiaofei Tan [Mon, 21 May 2018 10:09:16 +0000 (18:09 +0800)]
scsi: hisi_sas: Add LED feature for v3 hw

BugLink: https://bugs.launchpad.net/bugs/1774467
This patch implements LED feature of directly attached disk for v3 hw.

In fact, this hw has created an SGPIO component for LED feature, and we can
control LEDs just by internal registers.

Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 428f1b3424f4fe750943d8cdd1b0dafad99b0b75 linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: Change common allocation mode of device id
Xiang Chen [Mon, 21 May 2018 10:09:15 +0000 (18:09 +0800)]
scsi: hisi_sas: Change common allocation mode of device id

BugLink: https://bugs.launchpad.net/bugs/1774466
To reduce possibility of hitting unknown SoC bugs and aid debugging and
test, change allocation mode of device id from last used device id instead
of lowest available index.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 1b86518581f6111f5996ff8d4304bde2e3b05eb9 linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: change slot index allocation mode
Xiang Chen [Mon, 21 May 2018 10:09:14 +0000 (18:09 +0800)]
scsi: hisi_sas: change slot index allocation mode

BugLink: https://bugs.launchpad.net/bugs/1774466
Currently we find the lowest available empty bit in the IPTT bitmap to
allocate the IPTT for a command.

To reduce possibility of hitting unknown SoC bugs and also aid in the
debugging of those same bugs, change the allocation mode.

The next allocation method is to use the next free slot adjacent to the
most recently allocated slot, in a round-robin fashion.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit fa3be0f23139ddc4dffbfdef6bbd118e30dfcafe linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: fix a typo in hisi_sas_task_prep()
Wei Yongjun [Sat, 26 May 2018 09:34:22 +0000 (09:34 +0000)]
scsi: hisi_sas: fix a typo in hisi_sas_task_prep()

BugLink: https://bugs.launchpad.net/bugs/1774472
Fix a typo in hisi_sas_task_prep().

Fixes: 7eee4b921822 ("scsi: hisi_sas: relocate smp sg map")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit eb217359ebeae7b9ac51045d50f7a516925bc5c2 linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: add check of device in hisi_sas_task_exec()
Xiaofei Tan [Wed, 9 May 2018 15:10:50 +0000 (23:10 +0800)]
scsi: hisi_sas: add check of device in hisi_sas_task_exec()

BugLink: https://bugs.launchpad.net/bugs/1774472
Currently we don't check that device is not gone before dereferencing
its elements in the function hisi_sas_task_exec() (specifically, the DQ
pointer).

This patch fixes this issue by filling in the DQ pointer in
hisi_sas_task_prep() after we check that the device pointer is still
safe to reference.

[mkp: typo]

Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 2f6bca202b78e2b63a62b46ff5dc26f300785e23 linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: Use device lock to protect slot alloc/free
Xiang Chen [Wed, 9 May 2018 15:10:49 +0000 (23:10 +0800)]
scsi: hisi_sas: Use device lock to protect slot alloc/free

BugLink: https://bugs.launchpad.net/bugs/1774472
The IPTT of a slot is unique, and we currently use hisi_hba lock to
protect it.

Now slot is managed on hisi_sas_device.list, so use DQ lock to protect
for allocating and freeing the slot.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit e85d93b21267fff56110e3a258b9fad8adbfbce3 linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: Don't lock DQ for complete task sending
Xiang Chen [Wed, 9 May 2018 15:10:48 +0000 (23:10 +0800)]
scsi: hisi_sas: Don't lock DQ for complete task sending

BugLink: https://bugs.launchpad.net/bugs/1774472
Currently we lock the DQ to protect whole delivery process.  So this
stops us building slots for the same queue in parallel, and can affect
performance.

To optimise it, only lock the DQ during special periods, specifically
when allocating a slot from the DQ and when delivering a slot to the HW.

This approach is now safe, thanks to the previous patches to ensure that
we always deliver a slot to the HW once allocated.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit fa222db0b036899cd4020a380568699ffb1de08d linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: allocate slot buffer earlier
Xiang Chen [Wed, 9 May 2018 15:10:47 +0000 (23:10 +0800)]
scsi: hisi_sas: allocate slot buffer earlier

BugLink: https://bugs.launchpad.net/bugs/1774472
Currently we allocate the slot's memory buffer after allocating the DQ
slot.

To aid DQ lockout reduction, and allow slots to be built in parallel,
move this step (which can fail) prior to allocating the slot.

Also a stray spin_unlock_irqrestore() is removed from internal task exec
function.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 3de0026dad6b8e83d8a699aef92638c50ba966f7 linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: make return type of prep functions void
Xiang Chen [Wed, 9 May 2018 15:10:46 +0000 (23:10 +0800)]
scsi: hisi_sas: make return type of prep functions void

BugLink: https://bugs.launchpad.net/bugs/1774472
Since the task prep functions now should not fail, adjust the return
types to void.

In addition, some checks in the task prep functions are relocated to the
main module; this is specifically the check for the number of elements
in an sg list exceeded the HW SGE limit.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit a2b3820bddfbffcfbf0e8170e77de65d8b8def98 linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: relocate smp sg map
Xiang Chen [Wed, 9 May 2018 15:10:45 +0000 (23:10 +0800)]
scsi: hisi_sas: relocate smp sg map

BugLink: https://bugs.launchpad.net/bugs/1774472
Currently we use DQ lock to protect delivery of DQ entry one by one.

To optimise to allow more than one slot to be built for a single DQ in
parallel, we need to remove the DQ lock when preparing slots, prior to
delivery.

To achieve this, we rearrange the slot build order to ensure that once
we allocate a slot for a task, we do cannot fail to deliver the task.

In this patch, we rearrange the slot building for SMP tasks to ensure
that sg mapping part (which can fail) happens before we allocate the
slot in the DQ.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 7eee4b921822addfb67c2ced5772f003bb083520 linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: workaround a v3 hw hilink bug
Xiaofei Tan [Wed, 2 May 2018 15:56:34 +0000 (23:56 +0800)]
scsi: hisi_sas: workaround a v3 hw hilink bug

BugLink: https://bugs.launchpad.net/bugs/1774467
There is an SoC bug of v3 hw development version. When hot- unplugging a
directly attached disk, the PHY down interrupt may not happen. It is
very easy to appear on some boards.

When this issue occurs, the controller will receive many invalid dword
frames, and the "alos" fields of register HILINK_ERR_DFX can indicate
that disk was unplugged.

As an workaround solution, this patch detects this issue in the channel
interrupt, and workaround it by following steps:

 - Disable the PHY
 - Clear error code and interrupt
 - Enable the PHY

Then the HW will reissue PHY down interrupt.

Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit f70c1251deb5ab17dec70119c03f2428288ebada linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: add readl poll timeout helper wrappers
John Garry [Wed, 2 May 2018 15:56:33 +0000 (23:56 +0800)]
scsi: hisi_sas: add readl poll timeout helper wrappers

BugLink: https://bugs.launchpad.net/bugs/1774467
It is common to use readl poll timeout helpers in the driver, so create
custom wrappers.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 9b8addf3024eb57a215d0af2e1c95cd44b94ccab linux-next)
[ dannf: Included only as a dependency for the next patch ]
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: remove redundant handling to event95 for v3
Xiaofei Tan [Wed, 2 May 2018 15:56:32 +0000 (23:56 +0800)]
scsi: hisi_sas: remove redundant handling to event95 for v3

BugLink: https://bugs.launchpad.net/bugs/1774467
Event95 is used for DFX purpose. The relevant bit for this interrupt in
the ENT_INT_SRC_MSK3 register has been disabled, so remove the
processing.

Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit bf081d5da4fa3a0d0ef640868de1b9f644f633e0 linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: config ATA de-reset as an constrained command for v3 hw
Xiang Chen [Wed, 2 May 2018 15:56:31 +0000 (23:56 +0800)]
scsi: hisi_sas: config ATA de-reset as an constrained command for v3 hw

BugLink: https://bugs.launchpad.net/bugs/1774467
As a unconstrained command, a command can be sent to SATA disk even if
SATA disk status is BUSY, ERR or DRQ.

If an ATA reset assert is successful but ATA reset de-assert fails, then
it will retry the reset de-assert. If reset de- assert retry is
successful, we think it is okay to probe the device but actually it
still has Err status.

Apparently we need to retry the ATA reset assertion and de- assertion
instead for this mentioned scenario.

As such, we config ATA reset assert as a constrained command, if ATA
reset de-assert fails, then ATA reset de-assert retry will also
fail. Then we will retry the proper process of ATA reset assert and
de-assert again.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 9413532788df7470297dd0475995c5dc5b07f362 linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: update PHY linkrate after a controller reset
Xiang Chen [Wed, 2 May 2018 15:56:30 +0000 (23:56 +0800)]
scsi: hisi_sas: update PHY linkrate after a controller reset

BugLink: https://bugs.launchpad.net/bugs/1774466
After the controller is reset, we currently may not honour the PHY max
linkrate set via sysfs, in that after a reset we always revert to max
linkrate of 12Gbps, ignoring the value set via sysfs.

This patch modifies to policy to set the programmed PHY linkrate,
honouring the max linkrate programmed via sysfs.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit c2c1d9ded0a2c06df300e244220708f5c1f1db77 linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: stop controller timer for reset
John Garry [Wed, 2 May 2018 15:56:29 +0000 (23:56 +0800)]
scsi: hisi_sas: stop controller timer for reset

BugLink: https://bugs.launchpad.net/bugs/1774466
We should only have the timer enabled after PHY up after controller
reset, so disable prior to reset.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 6f7c32d6057cad05cf057b14c910659a8d06c975 linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: check sas_dev gone earlier in hisi_sas_abort_task()
Xiang Chen [Wed, 2 May 2018 15:56:28 +0000 (23:56 +0800)]
scsi: hisi_sas: check sas_dev gone earlier in hisi_sas_abort_task()

BugLink: https://bugs.launchpad.net/bugs/1774466
It is possible to dereference a NULL-pointer in hisi_sas_abort_task() in
special scenario when the device has been removed.

If an SMP task times-out, it will call hisi_sas_abort_task() to
recover. And currently there is a check in hisi_sas_abort_task() to
avoid the situation of processing the abort for the removed device.

However we have an ordering problem, in that we may reference a task for
the removed device before checking if the device has been removed.

Fix this by only referencing the sas_dev after we know it is still
present.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit c6ef895472696cac8e50f0ce69b301cc10233a67 linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: fix PI memory size
Xiang Chen [Wed, 2 May 2018 15:56:27 +0000 (23:56 +0800)]
scsi: hisi_sas: fix PI memory size

BugLink: https://bugs.launchpad.net/bugs/1774467
There are 28 bytes of protection information record of SSP for v3 hw, 16
bytes for v2 hw, and probably 24 for v1 hw (forgotten now).

So use a value big enough in hisi_sas_command_table_ssp.prot to cover
all cases.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit a14da7a20d499c54ebe53e430283e3bc17d3e89f linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: check host frozen before calling "done" function
Xiang Chen [Wed, 2 May 2018 15:56:26 +0000 (23:56 +0800)]
scsi: hisi_sas: check host frozen before calling "done" function

BugLink: https://bugs.launchpad.net/bugs/1774466
When the host is frozen in SCSI EH state, at any point after the LLDD
sets SAS_TASK_STATE_DONE for the sas_task task state, libsas may free
the task; see sas_scsi_find_task().

This puts the LLDD in a difficult position, in that once it sets
SAS_TASK_STATE_DONE for the task state it should not reference the
sas_task again. But the LLDD needs will check the sas_task indirectly in
calling task->task_done()->sas_scsi_task_done() or sas_ata_task_done()
(to check if the host is frozen state actually).

And the LLDD cannot set SAS_TASK_STATE_DONE for the task state after
task->task_done() is called (as the sas_task is free'd at this point).

This situation would seem to be a problem made by libsas.

To work around, check in the LLDD whether the host is in frozen state to
ensure it is ok to call task->task_done() function. If in the frozen
state, we rely on SCSI EH and libsas to free the sas_task directly.

We do not do this for the following IO types:

 - SMP - they are managed in libsas directly, outside SCSI EH
 - Any internally originated IO, for similar reason

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit cd938e535e909b80948f26d284ba7475adee0c08 linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: Add some checks to avoid free'ing a sas_task twice
Xiang Chen [Wed, 2 May 2018 15:56:25 +0000 (23:56 +0800)]
scsi: hisi_sas: Add some checks to avoid free'ing a sas_task twice

BugLink: https://bugs.launchpad.net/bugs/1774466
If the SCSI host enters EH, any pending IO will be processed by SCSI
EH. However it is possible that SCSI EH will try to abort the IO and
also at the same time the IO completes in the driver. In this situation
there is a small chance of freeing the sas_task twice.

Then if another IO re-uses freed sas_task before the second time of
free'ing sas_task, it is possible to free incorrect sas_task.

To avoid this situation, add some checks to increase reliability.  The
sas_task task state flag SAS_TASK_STATE_ABORTED is used to mutually
protect the LLDD and libsas freeing the task.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit b81b6cce58b7912e0d35f0b5bf526cb798f8e7aa linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: optimise the usage of DQ locking
Xiang Chen [Wed, 2 May 2018 15:56:24 +0000 (23:56 +0800)]
scsi: hisi_sas: optimise the usage of DQ locking

BugLink: https://bugs.launchpad.net/bugs/1774472
In the DQ tasklet processing it is not necessary to take the DQ lock, as
there is no contention between adding slots to the CQ and removing slots
from the matching DQ.

In addition, since we run each DQ in a separate tasklet context, there
would be no possible contention between DQ processing running for the
same queue in parallel.

It is still necessary to take hisi_hba lock when free'ing slots.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 24cf43612d4d851e660ac85f36cf389650c5a3ba linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: print device id for errors
John Garry [Fri, 23 Mar 2018 16:05:14 +0000 (00:05 +0800)]
scsi: hisi_sas: print device id for errors

BugLink: https://bugs.launchpad.net/bugs/1774466
When we find an erroneous slot completion, to help aid debugging add the
device index to the current debug log.

Signed-off-by: John Garry <john.garry@huawei.com>
Reviewed-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 381ed6c081ae423b03d82ce1a0bb79bbec2b033e linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: check IPTT is valid before using it for v3 hw
Xiaofei Tan [Fri, 23 Mar 2018 16:05:13 +0000 (00:05 +0800)]
scsi: hisi_sas: check IPTT is valid before using it for v3 hw

BugLink: https://bugs.launchpad.net/bugs/1774467
There is a bug of v3 hw development version. When AXI error happen, hw
may return an abnormal CQ that IPTT value is 0xffff.  This will cause
IPTT out-of-bounds reference.

This patch adds a check of IPTT in cq_tasklet_v3_hw() and discards
invalid slot. This workaround scheme is just to enhance fault-tolerance
of the driver. So, we will apply this scheme for all version of v3 hw,
although release version has fixed this SoC bug.

Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 327f242fa806c199a183c2197592e94d336c8266 linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: delete timer when removing hisi_sas driver
Xiang Chen [Fri, 23 Mar 2018 16:05:10 +0000 (00:05 +0800)]
scsi: hisi_sas: delete timer when removing hisi_sas driver

BugLink: https://bugs.launchpad.net/bugs/1774466
Delete timer for v1 and v3 hw when removing hisi_sas driver.

Signed-off-by: Xiang chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 5df41af4b18720061b1024f93f54b957864cdd44 linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: update RAS feature for later revision of v3 HW
Xiaofei Tan [Fri, 23 Mar 2018 16:05:09 +0000 (00:05 +0800)]
scsi: hisi_sas: update RAS feature for later revision of v3 HW

BugLink: https://bugs.launchpad.net/bugs/1774467
There is an modification for later revision of v3 hw. More HW errors are
reported through RAS interrupt. These errors were originally reported
only through MSI.

When report to RAS, some combinations are done to port AXI errors and
FIFO OMIT errors. For example, each port has 4 AXI errors, and they are
combined to one when report to RAS.

This patch does two things:

1. Enable RAS interrupt of these errors and handle them in PCI
   error handlers.

2. Disable MSI interrupts of these errors for this later revision hw.

Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 61573630918bf29a1974e08ef5d4b8889fb9dd7f linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: hisi_sas: initialize dq spinlock before use
Xiang Chen [Fri, 8 Dec 2017 17:16:32 +0000 (01:16 +0800)]
scsi: hisi_sas: initialize dq spinlock before use

BugLink: https://bugs.launchpad.net/bugs/1774472
It is required to initialize the dq spinlock before use, which was not being
done, so fix it. This issue can be detected when CONFIG_DEBUG_SPINLOCK is
enabled.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 39bade0c9fb11e04945a5749e01e65a376e4eb02)
[dannf: Included as a dependency for later patch
 "scsi: hisi_sas: Don't lock DQ for complete task sending"]
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: (no-up) cxlflash: OCXL diff between v2 and v3
Uma Krishnan [Fri, 1 Jun 2018 15:23:54 +0000 (11:23 -0400)]
UBUNTU: SAUCE: (no-up) cxlflash: OCXL diff between v2 and v3

BugLink: http://bugs.launchpad.net/bugs/1768431
This is a SAUCE commit specific to Ubuntu 18.04 (bionic) release.
After sending the OCXL feature patches (v2) to community, a request
was submitted to Canonical to pick them as SAUCE patches. There was
a small revision made to the v2 set and was submitted as v3 to the
community. This revision did not make it on time to be included in
bionic GA. To bring the bionic code upto speed with what is accepted
in the community I'm submitting this revision patch which contains
only the revision. That way, the entire series of 38 patches need
not be reverted and reapplied with the latest version.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
Acked-by: Khalid Elmously <khalid.elmously@canonical.com>
Acked-by: Kleber Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: cxlflash: Synchronize reset and remove ops
Uma Krishnan [Fri, 1 Jun 2018 15:23:55 +0000 (11:23 -0400)]
scsi: cxlflash: Synchronize reset and remove ops

BugLink: http://bugs.launchpad.net/bugs/1768431
The following Oops can be encountered if a device removal or system shutdown
is initiated while an EEH recovery is in process:

[c000000ff2f479c0c008000015256f18 cxlflash_pci_slot_reset+0xa0/0x100
                                      [cxlflash]
[c000000ff2f47a30c00800000dae22e0 cxl_pci_slot_reset+0x168/0x290 [cxl]
[c000000ff2f47ae0c00000000003ef1c eeh_report_reset+0xec/0x170
[c000000ff2f47b20c00000000003d0b8 eeh_pe_dev_traverse+0x98/0x170
[c000000ff2f47bb0c00000000003f80c eeh_handle_normal_event+0x56c/0x580
[c000000ff2f47c60c00000000003fba4 eeh_handle_event+0x2a4/0x338
[c000000ff2f47d10c0000000000400b8 eeh_event_handler+0x1f8/0x200
[c000000ff2f47dc0c00000000013da48 kthread+0x1a8/0x1b0
[c000000ff2f47e30c00000000000b528 ret_from_kernel_thread+0x5c/0xb4

The remove handler frees AFU memory while the EEH recovery is in progress,
leading to a race condition. This can result in a crash if the recovery thread
tries to access this memory.

To resolve this issue, the cxlflash remove handler will evaluate the device
state and yield to any active reset or probing threads.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from linux-next commit a3feb6ef50def7c91244d7bd15a3625b7b49b81f)
Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
Acked-by: Khalid Elmously <khalid.elmously@canonical.com>
Acked-by: Kleber Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: cxlflash: Remove commmands from pending list on timeout
Uma Krishnan [Fri, 1 Jun 2018 15:23:56 +0000 (11:23 -0400)]
scsi: cxlflash: Remove commmands from pending list on timeout

BugLink: http://bugs.launchpad.net/bugs/1768431
The following Oops can occur if an internal command sent to the AFU does not
complete within the timeout:

[c000000ff101b810c008000016020d94 term_mc+0xfc/0x1b0 [cxlflash]
[c000000ff101b8a0c008000016020fb0 term_afu+0x168/0x280 [cxlflash]
[c000000ff101b930c0080000160232ec cxlflash_pci_error_detected+0x184/0x230
                                       [cxlflash]
[c000000ff101b9e0c00800000d95d468 cxl_vphb_error_detected+0x90/0x150[cxl]
[c000000ff101ba20c00800000d95f27c cxl_pci_error_detected+0xa4/0x240 [cxl]
[c000000ff101bac0c00000000003eaf8 eeh_report_error+0xd8/0x1b0
[c000000ff101bb20c00000000003d0b8 eeh_pe_dev_traverse+0x98/0x170
[c000000ff101bbb0c00000000003f438 eeh_handle_normal_event+0x198/0x580
[c000000ff101bc60c00000000003fba4 eeh_handle_event+0x2a4/0x338
[c000000ff101bd10c0000000000400b8 eeh_event_handler+0x1f8/0x200
[c000000ff101bdc0c00000000013da48 kthread+0x1a8/0x1b0
[c000000ff101be30c00000000000b528 ret_from_kernel_thread+0x5c/0xb4

When an internal command times out, the command buffer is freed while it is
still in the pending commands list of the context. This corrupts the list and
when the context is cleaned up, a crash is encountered.

To resolve this issue, when an AFU command or TMF command times out, the
command should be deleted from the hardware queue pending command list before
freeing the buffer.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from linux-next commit 9a597cd4c0cebd61657f7449cb8bcb681f464500)
Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
Acked-by: Khalid Elmously <khalid.elmously@canonical.com>
Acked-by: Kleber Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoscsi: cxlflash: Handle spurious interrupts
Uma Krishnan [Fri, 1 Jun 2018 15:23:57 +0000 (11:23 -0400)]
scsi: cxlflash: Handle spurious interrupts

BugLink: http://bugs.launchpad.net/bugs/1768431
The following Oops can occur when there is heavy I/O traffic and the host is
reset by a tool such as sg_reset.

[c000200fff3fbc90c00800001690117c process_cmd_doneq+0x104/0x500
                                       [cxlflash] (unreliable)
[c000200fff3fbd80c008000016901648 cxlflash_rrq_irq+0xd0/0x150 [cxlflash]
[c000200fff3fbde0c000000000193130 __handle_irq_event_percpu+0xa0/0x310
[c000200fff3fbea0c0000000001933d8 handle_irq_event_percpu+0x38/0x90
[c000200fff3fbee0c000000000193494 handle_irq_event+0x64/0xb0
[c000200fff3fbf10c000000000198ea0 handle_fasteoi_irq+0xc0/0x230
[c000200fff3fbf40c00000000019182c generic_handle_irq+0x4c/0x70
[c000200fff3fbf60c00000000001794c __do_irq+0x7c/0x1c0
[c000200fff3fbf90c00000000002a390 call_do_irq+0x14/0x24
[c000200e5828fab0c000000000017b2c do_IRQ+0x9c/0x130
[c000200e5828fb00c000000000009b04 h_virt_irq_common+0x114/0x120

When a context is reset, the pending commands are flushed and the AFU is
notified. Before the AFU handles this request there could be command
completion interrupts queued to PHB which are yet to be delivered to the
context. In this scenario, a context could receive an interrupt for a command
that has been flushed, leading to a possible crash when the memory for the
flushed command is accessed.

To resolve this problem, a boolean will indicate if the hardware queue is
ready to process interrupts or not. This can be evaluated in the interrupt
handler before proessing an interrupt.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from linux-next commit d2d354a606d5309fbfe81d5fca01122159e38c6e)
Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
Acked-by: Khalid Elmously <khalid.elmously@canonical.com>
Acked-by: Kleber Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: Revert "drm/i915/edp: Allow alternate fixed mode for eDP if available."
Jani Nikula [Fri, 1 Jun 2018 15:46:35 +0000 (11:46 -0400)]
UBUNTU: SAUCE: Revert "drm/i915/edp: Allow alternate fixed mode for eDP if available."

BugLink: http://bugs.launchpad.net/bugs/1773520
This reverts commit dc911f5bd8aacfcf8aabd5c26c88e04c837a938e.

Per the report, no matter what display mode you select with xrandr, the
i915 driver will always select the alternate fixed mode. For the
reporter this means that the display will always run at 40Hz which is
quite annoying. This may be due to the mode comparison.

But there are some other potential issues. The choice of alt_fixed_mode
seems dubious. It's the first non-preferred mode, but there are no
guarantees that the only difference would be refresh rate. Similarly,
there may be more than one preferred mode in the probed modes list, and
the commit changes the preferred mode selection to choose the last one
on the list instead of the first.

(Note that the probed modes list is the raw, unfiltered, unsorted list
of modes from drm_add_edid_modes(), not the pretty result after a
drm_helper_probe_single_connector_modes() call.)

Finally, we already have eerily similar code in place to find the
downclock mode for DRRS that seems like could be reused here.

Back to the drawing board.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105469
Reported-by: Rune Petersen <rune@megahurts.dk>
Reported-by: Mark Spencer <n7u4722r35@ynzlx.anonbox.net>
Fixes: dc911f5bd8aa ("drm/i915/edp: Allow alternate fixed mode for eDP if available.")
Cc: Clint Taylor <clinton.a.taylor@intel.com>
Cc: David Weinehall <david.weinehall@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Jim Bride <jim.bride@linux.intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v4.14+
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180516080110.22770-1-jani.nikula@intel.com
Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
Acked-by: Khalid Elmously <khalid.elmously@canonical.com>
Acked-by: Kleber Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: Input: elan_i2c - add ELAN0612 to the ACPI table
Johannes Wienke [Fri, 1 Jun 2018 16:21:29 +0000 (12:21 -0400)]
UBUNTU: SAUCE: Input: elan_i2c - add ELAN0612 to the ACPI table

BugLink: http://bugs.launchpad.net/bugs/1773509
ELAN0612 touchpad uses elan_i2c as its driver.  ELAN0612 is being included in
newer laptops, so add it to ACPI table to enable the touchpad.

Signed-off-by: Johannes Wienke <languitar@semipol.de>
Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
Acked-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
Acked-by: Juerg Haefliger <juerg.haefliger@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: CacheFiles: fix a read_waiter/read_copier race
Lei Xue [Mon, 4 Jun 2018 06:42:16 +0000 (16:42 +1000)]
UBUNTU: SAUCE: CacheFiles: fix a read_waiter/read_copier race

BugLink: https://bugs.launchpad.net/bugs/1774336
There is a potential race in fscache operation enqueuing for reading and
copying multiple pages from cachefiles to netfs.

If this race occurs, an oops similar to the following is seen:

[585042.202316] FS-Cache:
[585042.202343] FS-Cache: Assertion failed
[585042.202367] FS-Cache: 6 == 5 is false
[585042.202452] ------------[ cut here ]------------
[585042.202480] kernel BUG at fs/fscache/operation.c:494!
...
[585042.209600] Call Trace:
[585042.211233]  [<ffffffffc034c29a>] fscache_op_work_func+0x2a/0x50 [fscache]
[585042.212677]  [<ffffffff81095a70>] process_one_work+0x150/0x3f0
[585042.213550]  [<ffffffff810961ea>] worker_thread+0x11a/0x470
...

The race occurs in the following situation:

One thread is in cachefiles_read_waiter:
 1) object->work_lock is taken.
 2) the operation is added to the to_do list.
 3) the work lock is dropped.
 4) fscache_enqueue_retrieval is called, which takes a reference.

Another thread is in cachefiles_read_copier:
 1) object->work_lock is taken
 2) an item is popped off the to_do list.
 3) object->work_lock is dropped.
 4) some processing is done on the item, and fscache_put_retrieval()
    is called, dropping a reference.

Now if the this process in cachefiles_read_copier takes place
*between* steps 3 and 4 in cachefiles_read_waiter, a reference will be
dropped before it is taken, which leads to the object's reference count
hitting zero, which leads to lifecycle events for the object happening
too soon, leading to the assertion failure later on.

Move fscache_enqueue_retrieval under the lock in
cachefiles_read_waiter. This means that the object cannot be popped
off the to_do list until it is in a fully consistent state with the
reference taken.

Signed-off-by: Lei Xue <carmark.dlut@gmail.com>
Reviewed-by: Daniel Axtens <dja@axtens.net>
[dja: rewrite and expand commit message]
(From https://www.redhat.com/archives/linux-cachefs/2018-February/msg00000.html
 This patch has been sitting on the mailing list for months with no
 response from the maintainer. A similar patch fixing the same issue
 was posted as far back as May 2017, and likewise had no response:
 https://www.redhat.com/archives/linux-cachefs/2017-May/msg00002.html
 I poked the list recently and also got nothing:
 https://www.redhat.com/archives/linux-cachefs/2018-May/msg00000.html
 and the problem was again reported and this patch validated by
 another user:
 https://www.redhat.com/archives/linux-cachefs/2018-May/msg00001.html
 Hence the submission as a sauce patch.)
Signed-off-by: Daniel Axtens <daniel.axtens@canonical.com>
Acked-by: Khalid Elmously <khalid.elmously@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: net: hns3: Optimize PF CMDQ interrupt switching process
Xi Wang [Tue, 5 Jun 2018 22:21:04 +0000 (16:21 -0600)]
UBUNTU: SAUCE: net: hns3: Optimize PF CMDQ interrupt switching process

BugLink: https://bugs.launchpad.net/bugs/1768670
When the PF frequently switches the CMDQ interrupt, if the CMDQ_SRC is
not cleared before the hardware interrupt is generated, the new interrupt
will not be reported.

This patch optimizes this problem by clearing CMDQ_SRC and RESET_STS
before enabling interrupt and syncing pending IRQ handlers after disabling
interrupt.

Fixes: 466b0c00391b ("net: hns3: Add support for misc interrupt")
Signed-off-by: Xi Wang <wangxi11@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: net: hns3: Fix for VF mailbox receiving unknown message
Xi Wang [Tue, 5 Jun 2018 22:19:34 +0000 (16:19 -0600)]
UBUNTU: SAUCE: net: hns3: Fix for VF mailbox receiving unknown message

BugLink: https://bugs.launchpad.net/bugs/1768670
Before the firmware updates the crq's tail pointer, if the VF driver
reads the data in the crq, the data may be incomplete at this time,
which will lead to the driver read an unknown message.

This patch fixes it by checking if crq is empty before reading the
message.

Fixes: b11a0bb231f3 ("net: hns3: Add mailbox support to VF driver")
Signed-off-by: Xi Wang <wangxi11@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: net: hns3: Fix for VF mailbox cannot receiving PF response
Xi Wang [Tue, 5 Jun 2018 22:15:38 +0000 (16:15 -0600)]
UBUNTU: SAUCE: net: hns3: Fix for VF mailbox cannot receiving PF response

BugLink: https://bugs.launchpad.net/bugs/1768670
When the VF frequently switches the CMDQ interrupt, if the CMDQ_SRC is not
cleared, the VF will not receive the new PF response after the interrupt
is re-enabled, the corresponding log is as follows:

[  317.482222] hns3 0000:00:03.0: VF could not get mbx resp(=0) from PF
in 500 tries
[  317.483137] hns3 0000:00:03.0: VF request to get tqp info from PF
failed -5

This patch fixes this problem by clearing CMDQ_SRC before enabling
interrupt and syncing pending IRQ handlers after disabling interrupt.

Fixes: e2cb1dec9779 ("net: hns3: Add HNS3 VF HCL(Hardware Compatibility Layer) Support")
Signed-off-by: Xi Wang <wangxi11@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: fix comments for hclge_get_ring_chain_from_mbx
Fuyun Liang [Mon, 14 May 2018 14:46:35 +0000 (22:46 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: fix comments for hclge_get_ring_chain_from_mbx

BugLink: https://bugs.launchpad.net/bugs/1768670
Actually, hclge_get_ring_chain_from_mbx is used to get ring type, tqp id,
and int_gl index from mailbox message. So the comments is incorrect. This
patch fixes it.

Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: fix for using wrong mask and shift in hclge_get_ri...
Fuyun Liang [Mon, 14 May 2018 14:46:34 +0000 (22:46 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: fix for using wrong mask and shift in hclge_get_ring_chain_from_mbx

BugLink: https://bugs.launchpad.net/bugs/1768670
HCLGE_INT_GL_IDX_M and HCLGE_INT_GL_IDX_S are used to set fireware
cmd. When getting int_gl value from mailbox message, we should use
HNAE3_RING_GL_IDX_M and HNAE3_RING_GL_IDX_S.

Fixes: 79eee4108541 ("net: hns3: add int_gl_idx setup for VF")
Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: fix for reset_level default assignment probelm
Yunsheng Lin [Thu, 10 May 2018 11:35:53 +0000 (19:35 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: fix for reset_level default assignment probelm

BugLink: https://bugs.launchpad.net/bugs/1768670
handle->reset_level is assigned to HNAE3_NONE_RESET when client is
initialized, if a tx timeout happens right after initialization,
then handle->reset_level is not resetted to HNAE3_FUNC_RESET in
hclge_reset_event, which will cause reset event not properly
handled problem.

This patch fixes it by setting handle->reset_level properly when
client is initialized.

Fixes: 6d4c3981a8d8 ("net: hns3: Changes to make enet watchdog timeout func common for PF/VF")
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: remove unnecessary ring configuration operation...
Huazhong Tan [Fri, 11 May 2018 07:01:10 +0000 (15:01 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: remove unnecessary ring configuration operation while resetting

BugLink: https://bugs.launchpad.net/bugs/1768670
The configuration of the ring will be used to reinitialize the
ring after the hardware reset is completed. So we should not
release and reacquire this configuration during reset.

Fixes: bb6b94a896d4 ("net: hns3: Add reset interface implementation in client")
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: fix return value error in hns3_reset_notify_down_enet
Huazhong Tan [Wed, 9 May 2018 12:39:32 +0000 (20:39 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: fix return value error in hns3_reset_notify_down_enet

BugLink: https://bugs.launchpad.net/bugs/1768670
When doing reset, netdev has not been brought up is not an error,
it means that we do not need do the stop operation, so just return
zero.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: net: hns3: Fix for phy link issue when using marvell phy driver
Jian Shen [Tue, 8 May 2018 10:01:42 +0000 (18:01 +0800)]
UBUNTU: SAUCE: net: hns3: Fix for phy link issue when using marvell phy driver

BugLink: https://bugs.launchpad.net/bugs/1768670
For marvell phy m88e1510, bit SUPPORTED_FIBRE of phydev->supported
is default on. Both phy_resume() and phy_suspend() will check the
SUPPORTED_FIBRE bit and write register of fibre page.

Currently in hns3 driver, the SUPPORTED_FIBRE bit will be cleared
after phy_connect_direct() finished. Because phy_resume() is called
in phy_connect_direct(), and phy_suspend() is called when disconnect
phy device, so the operation for fibre page register is not symmetrical.
It will cause phy link issue when reload hns3 driver.

This patch fixes it by disable the SUPPORTED_FIBRE before connecting
phy.

This is a temporary scheme for DTS2018050311542. I'm contacking with
the FAE of marvell phy, wish to get a better way to deal with it.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: separate roce from nic when resetting
Huazhong Tan [Mon, 7 May 2018 06:42:55 +0000 (14:42 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: separate roce from nic when resetting

BugLink: https://bugs.launchpad.net/bugs/1768670
While doing resetting, roce should do its uninitailization part
before nic's, and do its initialization part after nic's.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: correct reset event status register
Huazhong Tan [Mon, 7 May 2018 06:42:54 +0000 (14:42 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: correct reset event status register

BugLink: https://bugs.launchpad.net/bugs/1768670
According to hardware's description, driver should get reset event
from VECTOR0_PF_OTHER_INT_ST(0x20800) instead of
VECTOR0_PF_OTHER_INT_SRC(0x20700).

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: prevent to request reset frequently
Huazhong Tan [Mon, 7 May 2018 06:42:53 +0000 (14:42 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: prevent to request reset frequently

BugLink: https://bugs.launchpad.net/bugs/1768670
Netdevice reset should not be requested frequently, a new one
must wait a moment since there may be some work not completed.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: reset net device with rtnl_lock
Huazhong Tan [Mon, 7 May 2018 06:42:52 +0000 (14:42 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: reset net device with rtnl_lock

BugLink: https://bugs.launchpad.net/bugs/1768670
Since current locking was not covering certain code where
netdev was being accesses or manipulated, this patch fixes
it.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: modify the order of initializeing command queue...
Huazhong Tan [Mon, 7 May 2018 06:42:51 +0000 (14:42 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: modify the order of initializeing command queue register

BugLink: https://bugs.launchpad.net/bugs/1768670
According to hardware's description, the head pointer register should
be written before the tail pointer register while doing command queue
initialization.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: prevent sending command during global or core...
Huazhong Tan [Mon, 7 May 2018 06:42:50 +0000 (14:42 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: prevent sending command during global or core reset

BugLink: https://bugs.launchpad.net/bugs/1768670
According to hardware's description, driver should not send command to
IMP while hardware doing global or core reset.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: Use roce handle when calling roce callback function
Wei Hu (Xavier) [Sat, 5 May 2018 09:25:39 +0000 (17:25 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: Use roce handle when calling roce callback function

BugLink: https://bugs.launchpad.net/bugs/1768670
This patch replaces nic handle with roce handle when calling
roce callback function when link status change.

Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: remove the warning when clear reset cause
Peng Li [Thu, 3 May 2018 14:07:36 +0000 (22:07 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: remove the warning when clear reset cause

BugLink: https://bugs.launchpad.net/bugs/1768670
Only the core/global/IMP reset need clear cause, other type does not
need do it. The warning may be treated as error as it is normal. This
patch removes the warning.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: fix get_vector ops in hclgevf_main module
Yunsheng Lin [Fri, 4 May 2018 10:29:47 +0000 (18:29 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: fix get_vector ops in hclgevf_main module

BugLink: https://bugs.launchpad.net/bugs/1768670
The hclgevf_free_vector function expects the caller to pass
the vector_id to it, and hclgevf_put_vector pass vector to
it now, which will cause vector allocation problem.

This patch fixes it by converting vector into vector_id before
calling hclgevf_free_vector.

Fixes: e2cb1dec9779 ("net: hns3: Add HNS3 VF HCL(Hardware Compatibility Layer) Support")
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: fix warning bug when doing lp selftest
Yunsheng Lin [Wed, 2 May 2018 08:47:17 +0000 (16:47 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: fix warning bug when doing lp selftest

BugLink: https://bugs.launchpad.net/bugs/1768670
The napi_alloc_skb is excepted to be called under the
non-preemptible code path when it is called by hns3_clean_rx_ring
during loopback selftest, otherwise the below warnging will be
logged:

[   92.420780] BUG: using smp_processor_id() in preemptible
[00000000] code: ethtool/1873
[   92.428699] caller is debug_smp_processor_id+0x1c/0x28
[   92.433834] CPU: 0 PID: 1873 Comm: ethtool Not tainted
4.16.0-rc1-g14491cb-dirty #452
[   92.441651] Hardware name: Huawei D06/D06, BIOS Hisilicon
D06 UEFI Nemo 2.0 RC0 - B203 04/18/2018
[   92.450509] Call trace:
[   92.452945]  dump_backtrace+0x0/0x1a8
[   92.456596]  show_stack+0x24/0x30
[   92.459900]  dump_stack+0x8c/0xb0
[   92.463202]  check_preemption_disabled+0xf8/0x100
[   92.467893]  debug_smp_processor_id+0x1c/0x28
[   92.472239]  __napi_alloc_skb+0x30/0x130
[   92.476158]  hns3_clean_rx_ring+0x118/0x5f0 [hns3]
[   92.480941]  hns3_self_test+0x32c/0x4d0 [hns3]
[   92.485375]  ethtool_self_test+0xdc/0x1e8
[   92.489372]  dev_ethtool+0x1020/0x1da8
[   92.493109]  dev_ioctl+0x188/0x3a0
[   92.496499]  sock_do_ioctl+0xf4/0x208
[   92.500148]  sock_ioctl+0x228/0x3e8
[   92.503626]  do_vfs_ioctl+0xc4/0x880
[   92.507189]  SyS_ioctl+0x94/0xa8
[   92.510404]  el0_svc_naked+0x30/0x34

This patch fix it by disabling preemption when calling
hns3_clean_rx_ring during loopback selftest.

Fixes: c39c4d98dc65 ("net: hns3: Add mac loopback selftest support in hns3 driver")
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: Add configure for mac minimal frame size
Jian Shen [Sat, 5 May 2018 03:18:28 +0000 (11:18 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: Add configure for mac minimal frame size

BugLink: https://bugs.launchpad.net/bugs/1768670
When change the mtu, the minimal frame size of mac will be set
to zero, it is incorrect. This patch fixes it by set it to the
default value.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: fix for mailbox message truncated problem
Fuyun Liang [Fri, 4 May 2018 14:44:46 +0000 (22:44 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: fix for mailbox message truncated problem

BugLink: https://bugs.launchpad.net/bugs/1768670
The payload of mailbox message is 16 byte and the value of
HCLGE_MBX_MAX_ARQ_MSG_SIZE is 8. A message truncated problem will
happen when mailbox message is converted to ARQ message. This patch
replaces HCLGE_MBX_MAX_ARQ_MSG_SIZE with the size of ARQ message in
hclgevf_mbx_handler to fix this problem.

Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: fix for l4 checksum offload bug
Yunsheng Lin [Fri, 27 Apr 2018 10:04:19 +0000 (18:04 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: fix for l4 checksum offload bug

BugLink: https://bugs.launchpad.net/bugs/1768670
Hardware only support tcp/udp/sctp l4 checksum offload, but
the driver currently tell hardware to do l4 checksum offlad when
l3 is IPv4 or IPv6, which may cause checksumm error.

This patch fixes it by only enabling the l4 offload when l4 is
tcp/udp/sctp.

Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08
SoC")
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: fix for waterline not setting correctly
Yunsheng Lin [Fri, 27 Apr 2018 09:51:10 +0000 (17:51 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: fix for waterline not setting correctly

BugLink: https://bugs.launchpad.net/bugs/1768670
The HCLGE_RX_PRIV_EN_B is used to tell the firmware whether
to update the specific waterline value, if the is not set,
the firmware will ignore the value.

This patch fixes by setting the HCLGE_RX_PRIV_EN_B even if
the updated value is zero.

Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: fix for mac pause not disable in pfc mode
Yunsheng Lin [Tue, 24 Apr 2018 01:54:01 +0000 (09:54 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: fix for mac pause not disable in pfc mode

BugLink: https://bugs.launchpad.net/bugs/1768670
When pfc pause mode is enable, the mac pause mode need to be
disabled, otherwise the pfc pause packet will not be sent when
congestion happens.

This patch fixes by disabling the mac pause when pfc pause is
enabled.

Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: fix tc setup when netdev is first up
Yunsheng Lin [Tue, 24 Apr 2018 01:54:00 +0000 (09:54 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: fix tc setup when netdev is first up

BugLink: https://bugs.launchpad.net/bugs/1768670
Currently, tc related configuration is not setup when the
netdev is first up, which cause the stack only using tc 0
problem.

This patch fixes it by setting the tc related configuration
using the info from NCL_CONFIG when netdev is first up.

Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: Add calling roce callback function when link statu...
Wei Hu (Xavier) [Fri, 27 Apr 2018 06:44:26 +0000 (14:44 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: Add calling roce callback function when link status change

BugLink: https://bugs.launchpad.net/bugs/1768670
This patch adds calling roce callback function when link status
change.

Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: optimize the process of notifying roce client
Wei Hu (Xavier) [Fri, 27 Apr 2018 06:44:25 +0000 (14:44 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: optimize the process of notifying roce client

BugLink: https://bugs.launchpad.net/bugs/1768670
This patch optimizes the process of notifying roce client.

Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: Add pf reset for hip08 RoCE
Lijun Ou [Wed, 15 Nov 2017 09:52:50 +0000 (17:52 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: Add pf reset for hip08 RoCE

BugLink: https://bugs.launchpad.net/bugs/1768670
After hw reset is ok, RoCE need to free sw resource and
re-init. This patch mainly register a client for RoCE when
hns3 notify reset.

Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: Add SPDX tags to hns3 driver
Jian Shen [Wed, 18 Apr 2018 10:28:13 +0000 (18:28 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: Add SPDX tags to hns3 driver

BugLink: https://bugs.launchpad.net/bugs/1768670
Add the SPDX identifiers to hns3 driver.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: remove unused struct member and definition
Jian Shen [Wed, 18 Apr 2018 10:28:12 +0000 (18:28 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: remove unused struct member and definition

BugLink: https://bugs.launchpad.net/bugs/1768670
The struct hclge_desc_cb and hclge_desc_cb are never used in
anywhere. This patch removes them.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: fix mislead parameter name
Jian Shen [Wed, 18 Apr 2018 10:28:11 +0000 (18:28 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: fix mislead parameter name

BugLink: https://bugs.launchpad.net/bugs/1768670
The input parameter "dev" of hns3_irq_handle() is indeed
used as a tqp vector, it is misleadin.

The struct member "flag" is used to indicate ring type,
so rename it.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: modify inconsistent bit mask macros
Jian Shen [Wed, 18 Apr 2018 10:28:10 +0000 (18:28 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: modify inconsistent bit mask macros

BugLink: https://bugs.launchpad.net/bugs/1768670
Use BIT() and GENMASK() to convert the bit mask, modify
the inconsistent ones, and remove useless ones.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: use decimal for bit offset macros
Jian Shen [Wed, 18 Apr 2018 10:28:09 +0000 (18:28 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: use decimal for bit offset macros

BugLink: https://bugs.launchpad.net/bugs/1768670
Using hex for bit offsets is inconsistent with the rest
of the file. Change them to decimal.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: fix unreasonable code comments
Jian Shen [Wed, 18 Apr 2018 10:28:08 +0000 (18:28 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: fix unreasonable code comments

BugLink: https://bugs.launchpad.net/bugs/1768670
This patch fixes some comment spelling errors, removes
redundant comments, rewrites misleading comments, and
adds some necessary comments.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: remove extra space and brackets
Jian Shen [Wed, 18 Apr 2018 10:28:07 +0000 (18:28 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: remove extra space and brackets

BugLink: https://bugs.launchpad.net/bugs/1768670
Remove extra space and brackets.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: standardize the handle of return value
Jian Shen [Wed, 18 Apr 2018 10:28:05 +0000 (18:28 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: standardize the handle of return value

BugLink: https://bugs.launchpad.net/bugs/1768670
Apply the standard minor cleanup by returning ret outside
the brackets.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: remove some redundant assignments
Jian Shen [Wed, 18 Apr 2018 10:28:04 +0000 (18:28 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: remove some redundant assignments

BugLink: https://bugs.launchpad.net/bugs/1768670
Remove some redundant assignments, because they have
been set to zero when allocate hdev.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: fix unused function warning in VF driver
Xi Wang [Wed, 18 Apr 2018 04:18:18 +0000 (12:18 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: fix unused function warning in VF driver

BugLink: https://bugs.launchpad.net/bugs/1768670
This patch fixes the following warning from compile:

drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c:731:12:
warning: 'hclgevf_cfg_func_mta_filter' defined but not used
[-Wunused-function]

hclgevf_cfg_func_mta_filter is no longer used, so delete it.

Signed-off-by: Xi Wang <wangxi11@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: modify hnae_ to hnae3_
Huazhong Tan [Wed, 18 Apr 2018 02:55:52 +0000 (10:55 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: modify hnae_ to hnae3_

BugLink: https://bugs.launchpad.net/bugs/1768670
For consistency, prefix hnae_ should be modified to hnae3_.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
[dannf: ported to Ubuntu base]
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: use dma_zalloc_coherent instead of kzalloc/dma_map...
Huazhong Tan [Wed, 18 Apr 2018 02:55:51 +0000 (10:55 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: use dma_zalloc_coherent instead of kzalloc/dma_map_single

BugLink: https://bugs.launchpad.net/bugs/1768670
Reference to Documentation/DMA-API-HOWTO.txt,
Streaming DMA mappings which are usually mapped for one DMA transfer,
Network card DMA ring descriptors should use Consistent DMA mappings.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: give default option while dependency HNS3 set
Huazhong Tan [Wed, 18 Apr 2018 02:55:50 +0000 (10:55 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: give default option while dependency HNS3 set

BugLink: https://bugs.launchpad.net/bugs/1768670
Give default option for HNS3_HCLGE and HNS3_ENET will be helpful,
while dependency HNS3 is set. Meanwhile, use "if HNS3" section
instead of all the "depends on HNS3".

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: remove some unused members of some structures
Huazhong Tan [Wed, 18 Apr 2018 02:55:49 +0000 (10:55 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: remove some unused members of some structures

BugLink: https://bugs.launchpad.net/bugs/1768670
Some members in struct hns3_enet_tqp_vector, struct hnae3_client
and struct hnae3_ae_algo are unused.
This patch removes them.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: remove a redundant hclge_cmd_csq_done
Huazhong Tan [Wed, 18 Apr 2018 02:55:48 +0000 (10:55 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: remove a redundant hclge_cmd_csq_done

BugLink: https://bugs.launchpad.net/bugs/1768670
Set complete in the first hclge_cmd_csq_done of hclge_cmd_send,
and check if complete later, unnecessary to do hclge_cmd_csq_done
again.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: using modulo for cyclic counters in hclge_cmd_send
Huazhong Tan [Wed, 18 Apr 2018 02:55:46 +0000 (10:55 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: using modulo for cyclic counters in hclge_cmd_send

BugLink: https://bugs.launchpad.net/bugs/1768670
There are some codes in hclge_cmd.c which can be simplified by
used %= operator.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: simplify hclge_cmd_csq_clean
Huazhong Tan [Wed, 18 Apr 2018 02:55:45 +0000 (10:55 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: simplify hclge_cmd_csq_clean

BugLink: https://bugs.launchpad.net/bugs/1768670
csq is used as a ring buffer, the value of the desc will be replaced
in next use. This patch removes the unnecessary memset, and just
updates the next_to_clean.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: remove some redundant assignments
Huazhong Tan [Wed, 18 Apr 2018 02:55:44 +0000 (10:55 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: remove some redundant assignments

BugLink: https://bugs.launchpad.net/bugs/1768670
Remove some redundant assignments.
desc->flag = cpu_to_le16(HCLGE_CMD_FLAG_NO_INTR | HCLGE_CMD_FLAG_IN)
has set bit HCLGE_CMD_FLAG_WR to zero, so does others.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: remove useless code in hclge_cmd_send
Huazhong Tan [Wed, 18 Apr 2018 02:55:43 +0000 (10:55 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: remove useless code in hclge_cmd_send

BugLink: https://bugs.launchpad.net/bugs/1768670
There are some useless type cast, print in hclge_cmd_send.
This patch removes them.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: remove unused hclge_ring_to_dma_dir
Huazhong Tan [Wed, 18 Apr 2018 02:55:42 +0000 (10:55 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: remove unused hclge_ring_to_dma_dir

BugLink: https://bugs.launchpad.net/bugs/1768670
hclge_ring_to_dma_dir is unused anywhere.
This patch removes it.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: use lower_32_bits and upper_32_bits
Huazhong Tan [Wed, 18 Apr 2018 02:55:41 +0000 (10:55 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: use lower_32_bits and upper_32_bits

BugLink: https://bugs.launchpad.net/bugs/1768670
MACRO lower_32_bits and upper_32_bits can help to get bits 0-31
and bits 32-63 of a number, so just use it.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: remove back in struct hclge_hw
Huazhong Tan [Wed, 18 Apr 2018 02:55:40 +0000 (10:55 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: remove back in struct hclge_hw

BugLink: https://bugs.launchpad.net/bugs/1768670
hclge_hw is embedded in hclge_dev, so use container_of instead of
back to get hclge_dev.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: add unlikely for error check
Peng Li [Tue, 17 Apr 2018 08:31:17 +0000 (16:31 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: add unlikely for error check

BugLink: https://bugs.launchpad.net/bugs/1768670
The first bd of a packet is invalid and invalid ring head for tx
IRQ is not offen, they may occur when there is error,
Add unlikely for error check branch is better for performance.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: remove the Redundant put_vector in hns3_client_uninit
Peng Li [Fri, 13 Apr 2018 02:05:34 +0000 (10:05 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: remove the Redundant put_vector in hns3_client_uninit

BugLink: https://bugs.launchpad.net/bugs/1768670
The interface h->ae_algo->ops->put_vector is called in both
hns3_nic_dealloc_vector_data and hns3_nic_uninit_vector_data in
hns3_client_uninit, this will cause vector freed twice.
This patch remove the Redundant put_vector to make vector freed
only once.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: print the ret value in error information
Peng Li [Fri, 13 Apr 2018 02:05:33 +0000 (10:05 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: print the ret value in error information

BugLink: https://bugs.launchpad.net/bugs/1768670
Print the ret value in error information can help find the reason.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: extraction an interface for state state init|uninit
Peng Li [Fri, 13 Apr 2018 02:05:32 +0000 (10:05 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: extraction an interface for state state init|uninit

BugLink: https://bugs.launchpad.net/bugs/1768670
Extraction an interface for state init|uninit to make the code
easier to read.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: remove unused head file in hnae3.c
Peng Li [Fri, 13 Apr 2018 02:05:31 +0000 (10:05 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: remove unused head file in hnae3.c

BugLink: https://bugs.launchpad.net/bugs/1768670
linux/slab.h is not used in hnae3.h, this patch removes it.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: add l4_type check for both ipv4 and ipv6
Peng Li [Fri, 13 Apr 2018 02:05:29 +0000 (10:05 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: add l4_type check for both ipv4 and ipv6

BugLink: https://bugs.launchpad.net/bugs/1768670
HW supports UDP, TCP and SCTP packets checksum for both ipv4 and
ipv6,  but do not support other type packets checksum for ipv4 or
ipv6.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: add vector status check before free vector
Peng Li [Fri, 13 Apr 2018 02:05:28 +0000 (10:05 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: add vector status check before free vector

BugLink: https://bugs.launchpad.net/bugs/1768670
If the hdev->vector_status[vector_id] is already HCLGE_INVALID_VPORT,
should log the error and return.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: rename the interface for init_client_instance...
Peng Li [Fri, 13 Apr 2018 02:05:27 +0000 (10:05 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: rename the interface for init_client_instance and uninit_client_instance

BugLink: https://bugs.launchpad.net/bugs/1768670
The interface init_client_instance and uninit_client_instance
do not register anything, only initialize the client instance.
This patch rename the related interface to make the function
name to indicate the purpose.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: remove hclge_get_vector_index from hclge_bind_ring...
Peng Li [Fri, 13 Apr 2018 02:05:26 +0000 (10:05 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: remove hclge_get_vector_index from hclge_bind_ring_with_vector

BugLink: https://bugs.launchpad.net/bugs/1768670
In hclge_unmap_ring_frm_vector, there are 2 steps:
step 1: get vector index.
step 2 unbind ring with vector.

But it gets vector id again in step 2 interface. This patch
removes hclge_get_vector_index from hclge_bind_ring_with_vector,
and make the step the same with hns3 PF driver.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: RX BD information valid only in last BD except...
Peng Li [Fri, 30 Mar 2018 08:26:22 +0000 (16:26 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: RX BD information valid only in last BD except VLD bit and buffer size

BugLink: https://bugs.launchpad.net/bugs/1768670
This patch will change the use of BD to support multi Hi162X NIC
system.

For the next generation Hi162X NIC system, Only VLD bit and current
data size valid in each BD, the other information valid only the last
BD for a packet.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Reviewed-by: Yisen Zhuang <yisen.zhuang@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agoUBUNTU: SAUCE: {topost} net: hns3: add support for serdes loopback selftest
Yunsheng Lin [Tue, 3 Apr 2018 01:08:54 +0000 (09:08 +0800)]
UBUNTU: SAUCE: {topost} net: hns3: add support for serdes loopback selftest

BugLink: https://bugs.launchpad.net/bugs/1768670
This patch adds support for serdes loopback selftest in hns3
driver.

Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agonet: hns3: Optimize the VF's process of updating multicast MAC
Xi Wang [Fri, 1 Jun 2018 16:52:11 +0000 (17:52 +0100)]
net: hns3: Optimize the VF's process of updating multicast MAC

BugLink: https://bugs.launchpad.net/bugs/1768670
In the update flow of the new PF driver, if a multicast address is in mta
table, the VF deletion action will not take effect.

This patch adds the VF adaptation according to the new flow of PF'driver.

Signed-off-by: Xi Wang <wangxi11@huawei.com>
Reviewed-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 3a678b5806e66d0b75086bf423ecaf80ff0237c7 linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agonet: hns3: Optimize the PF's process of updating multicast MAC
Xi Wang [Fri, 1 Jun 2018 16:52:10 +0000 (17:52 +0100)]
net: hns3: Optimize the PF's process of updating multicast MAC

BugLink: https://bugs.launchpad.net/bugs/1768670
In the current process, the multicast MAC is added to both MAC_VLAN
table and MTA table, this will reduce the utilization of the resource.

This patch improves the process of adding multicast MAC address, the
new process starts using the MTA table to add multicast MAC after the
MAC_VLAN table is full, and the MTA is disable if it is no longer used.

Signed-off-by: Xi Wang <wangxi11@huawei.com>
Reviewed-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 40cca1c587c1c39fcc7fa1b2c5d315d72361dfe1 linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
6 years agonet: hns3: Fix for vxlan tx checksum bug
Yunsheng Lin [Fri, 1 Jun 2018 16:52:09 +0000 (17:52 +0100)]
net: hns3: Fix for vxlan tx checksum bug

BugLink: https://bugs.launchpad.net/bugs/1768670
when skb->encapsulation is 0, skb->ip_summed is CHECKSUM_PARTIAL
and it is udp packet, which has a dest port as the IANA assigned.
the hardware is expected to do the checksum offload, but the
hardware will not do the checksum offload when udp dest port is
4789.

This patch fixes it by doing the checksum in software.

Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC")
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 3db084d28dc04e6ebe9123e0d4f6e8ef5a775ff0 linux-next)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>