]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/log
mirror_ubuntu-bionic-kernel.git
6 years agoselinux: ensure the context is NUL terminated in security_context_to_sid_core()
Paul Moore [Tue, 28 Nov 2017 23:51:12 +0000 (18:51 -0500)]
selinux: ensure the context is NUL terminated in security_context_to_sid_core()

BugLink: http://bugs.launchpad.net/bugs/1752119
commit ef28df55ac27e1e5cd122e19fa311d886d47a756 upstream.

The syzbot/syzkaller automated tests found a problem in
security_context_to_sid_core() during early boot (before we load the
SELinux policy) where we could potentially feed context strings without
NUL terminators into the strcmp() function.

We already guard against this during normal operation (after the SELinux
policy has been loaded) by making a copy of the context strings and
explicitly adding a NUL terminator to the end.  The patch extends this
protection to the early boot case (no loaded policy) by moving the context
copy earlier in security_context_to_sid_core().

Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Reviewed-By: William Roberts <william.c.roberts@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoptr_ring: try vmalloc() when kmalloc() fails
Jason Wang [Fri, 9 Feb 2018 09:45:50 +0000 (17:45 +0800)]
ptr_ring: try vmalloc() when kmalloc() fails

BugLink: http://bugs.launchpad.net/bugs/1752119
commit 0bf7800f1799b5b1fd7d4f024e9ece53ac489011 upstream.

This patch switch to use kvmalloc_array() for using a vmalloc()
fallback to help in case kmalloc() fails.

Reported-by: syzbot+e4d4f9ddd4295539735d@syzkaller.appspotmail.com
Fixes: 2e0ab8ca83c12 ("ptr_ring: array based FIFO for pointers")
Signed-off-by: Jason Wang <jasowang@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoptr_ring: fail early if queue occupies more than KMALLOC_MAX_SIZE
Jason Wang [Fri, 9 Feb 2018 09:45:49 +0000 (17:45 +0800)]
ptr_ring: fail early if queue occupies more than KMALLOC_MAX_SIZE

BugLink: http://bugs.launchpad.net/bugs/1752119
commit 6e6e41c3112276288ccaf80c70916779b84bb276 upstream.

To avoid slab to warn about exceeded size, fail early if queue
occupies more than KMALLOC_MAX_SIZE.

Reported-by: syzbot+e4d4f9ddd4295539735d@syzkaller.appspotmail.com
Fixes: 2e0ab8ca83c12 ("ptr_ring: array based FIFO for pointers")
Signed-off-by: Jason Wang <jasowang@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agotun: fix tun_napi_alloc_frags() frag allocator
Eric Dumazet [Thu, 15 Feb 2018 22:47:15 +0000 (14:47 -0800)]
tun: fix tun_napi_alloc_frags() frag allocator

BugLink: http://bugs.launchpad.net/bugs/1752119
commit 43a08e0f58b3f236165029710a4e3b303815253b upstream.

<Mark Rutland reported>
    While fuzzing arm64 v4.16-rc1 with Syzkaller, I've been hitting a
    misaligned atomic in __skb_clone:

        atomic_inc(&(skb_shinfo(skb)->dataref));

   where dataref doesn't have the required natural alignment, and the
   atomic operation faults. e.g. i often see it aligned to a single
   byte boundary rather than a four byte boundary.

   AFAICT, the skb_shared_info is misaligned at the instant it's
   allocated in __napi_alloc_skb()  __napi_alloc_skb()
</end of report>

Problem is caused by tun_napi_alloc_frags() using
napi_alloc_frag() with user provided seg sizes,
leading to other users of this API getting unaligned
page fragments.

Since we would like to not necessarily add paddings or alignments to
the frags that tun_napi_alloc_frags() attaches to the skb, switch to
another page frag allocator.

As a bonus skb_page_frag_refill() can use GFP_KERNEL allocations,
meaning that we can not deplete memory reserves as easily.

Fixes: 90e33d459407 ("tun: enable napi_gro_frags() for TUN/TAP driver")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agos390/diag: add diag26c support for VNIC info
Julian Wiedmann [Wed, 27 Dec 2017 16:44:30 +0000 (17:44 +0100)]
s390/diag: add diag26c support for VNIC info

BugLink: http://bugs.launchpad.net/bugs/1747639
With subcode 0x24, diag26c returns all sorts of VNIC-related information.

Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit f22237f61d2f19760b3799ee798d7dc30cdc0785)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agobpf: fix selftests/bpf test_kmod.sh failure when CONFIG_BPF_JIT_ALWAYS_ON=y
Yonghong Song [Sat, 3 Feb 2018 06:37:15 +0000 (22:37 -0800)]
bpf: fix selftests/bpf test_kmod.sh failure when CONFIG_BPF_JIT_ALWAYS_ON=y

BugLink: http://bugs.launchpad.net/bugs/1751234
With CONFIG_BPF_JIT_ALWAYS_ON is defined in the config file,
tools/testing/selftests/bpf/test_kmod.sh failed like below:
  [root@localhost bpf]# ./test_kmod.sh
  sysctl: setting key "net.core.bpf_jit_enable": Invalid argument
  [ JIT enabled:0 hardened:0 ]
  [  132.175681] test_bpf: #297 BPF_MAXINSNS: Jump, gap, jump, ... FAIL to prog_create err=-524 len=4096
  [  132.458834] test_bpf: Summary: 348 PASSED, 1 FAILED, [340/340 JIT'ed]
  [ JIT enabled:1 hardened:0 ]
  [  133.456025] test_bpf: #297 BPF_MAXINSNS: Jump, gap, jump, ... FAIL to prog_create err=-524 len=4096
  [  133.730935] test_bpf: Summary: 348 PASSED, 1 FAILED, [340/340 JIT'ed]
  [ JIT enabled:1 hardened:1 ]
  [  134.769730] test_bpf: #297 BPF_MAXINSNS: Jump, gap, jump, ... FAIL to prog_create err=-524 len=4096
  [  135.050864] test_bpf: Summary: 348 PASSED, 1 FAILED, [340/340 JIT'ed]
  [ JIT enabled:1 hardened:2 ]
  [  136.442882] test_bpf: #297 BPF_MAXINSNS: Jump, gap, jump, ... FAIL to prog_create err=-524 len=4096
  [  136.821810] test_bpf: Summary: 348 PASSED, 1 FAILED, [340/340 JIT'ed]
  [root@localhost bpf]#

The test_kmod.sh load/remove test_bpf.ko multiple times with different
settings for sysctl net.core.bpf_jit_{enable,harden}. The failed test #297
of test_bpf.ko is designed such that JIT always fails.

Commit 290af86629b2 (bpf: introduce BPF_JIT_ALWAYS_ON config)
introduced the following tightening logic:
    ...
        if (!bpf_prog_is_dev_bound(fp->aux)) {
                fp = bpf_int_jit_compile(fp);
    #ifdef CONFIG_BPF_JIT_ALWAYS_ON
                if (!fp->jited) {
                        *err = -ENOTSUPP;
                        return fp;
                }
    #endif
    ...
With this logic, Test #297 always gets return value -ENOTSUPP
when CONFIG_BPF_JIT_ALWAYS_ON is defined, causing the test failure.

This patch fixed the failure by marking Test #297 as expected failure
when CONFIG_BPF_JIT_ALWAYS_ON is defined.

Fixes: 290af86629b2 (bpf: introduce BPF_JIT_ALWAYS_ON config)
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
(cherry picked from commit 09584b406742413ac4c8d7e030374d4daa045b69)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agocxl: Add support for ASB_Notify on POWER9
Christophe Lombard [Thu, 11 Jan 2018 08:55:25 +0000 (09:55 +0100)]
cxl: Add support for ASB_Notify on POWER9

BugLink: http://bugs.launchpad.net/bugs/1746988
The POWER9 core supports a new feature: ASB_Notify which requires the
support of the Special Purpose Register: TIDR.

The ASB_Notify command, generated by the AFU, will attempt to
wake-up the host thread identified by the particular LPID:PID:TID.

This patch assign a unique TIDR (thread id) for the current thread which
will be used in the process element entry.

Signed-off-by: Christophe Lombard <clombard@linux.vnet.ibm.com>
Reviewed-by: Philippe Bergheaud <felix@linux.vnet.ibm.com>
Acked-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Reviewed-by: Vaibhav Jain <vaibhav@linux.vnet.ibm.com>
Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit b1db551324f72fa14ad82ca31237a7ed418104df)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoocxl: add MAINTAINERS entry
Frederic Barrat [Tue, 23 Jan 2018 11:31:48 +0000 (12:31 +0100)]
ocxl: add MAINTAINERS entry

BugLink: http://bugs.launchpad.net/bugs/1746988
Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit 6385d6f85fec82e439856b2759f8c64abf055ee0)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoocxl: Documentation
Frederic Barrat [Tue, 23 Jan 2018 11:31:47 +0000 (12:31 +0100)]
ocxl: Documentation

BugLink: http://bugs.launchpad.net/bugs/1746988
ocxl.rst gives a quick, high-level view of opencapi.

Update ioctl-number.txt to reflect ioctl numbers being used by the
ocxl driver

Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
[mpe: Fix up mixed whitespace as spotted by gregkh]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit 00b96c0e3c54a1fff9e8b909f46a672e43ef9598)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agocxl: Remove support for "Processing accelerators" class
Frederic Barrat [Tue, 23 Jan 2018 11:31:46 +0000 (12:31 +0100)]
cxl: Remove support for "Processing accelerators" class

BugLink: http://bugs.launchpad.net/bugs/1746988
The cxl driver currently declares in its table of supported PCI
devices the class "Processing accelerators". Therefore it may be
called to probe for opencapi devices, which generates errors, as the
config space of a cxl device is not compatible with opencapi.

So remove support for the generic class, as we now have (at least) two
drivers for devices of the same class. Most cxl devices are FPGAs with
a PSL which will show a known device ID of 0x477. Other devices are
really supported by the cxlflash driver and are already listed in the
table. So removing the class is expected to go unnoticed.

Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit 741ddae6c4c19bf2212ca318777320ae4f76c714)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: [Config] CONFIG_OCXL=m for ppc64el
Seth Forshee [Wed, 28 Feb 2018 14:45:17 +0000 (08:45 -0600)]
UBUNTU: [Config] CONFIG_OCXL=m for ppc64el

BugLink: http://bugs.launchpad.net/bugs/1746988
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoocxl: Add Makefile and Kconfig
Frederic Barrat [Tue, 23 Jan 2018 11:31:45 +0000 (12:31 +0100)]
ocxl: Add Makefile and Kconfig

BugLink: http://bugs.launchpad.net/bugs/1746988
OCXL_BASE triggers the platform support needed by the driver.

Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit b97f02246e0d12f70249a16f931153b8b5b249bd)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoocxl: Add trace points
Frederic Barrat [Tue, 23 Jan 2018 11:31:44 +0000 (12:31 +0100)]
ocxl: Add trace points

BugLink: http://bugs.launchpad.net/bugs/1746988
Define a few trace points so that we can use the standard tracing
mechanism for debug and/or monitoring.

Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit 92add22e84788d44e978662ca6bcd585f9ac081e)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoocxl: Add a kernel API for other opencapi drivers
Frederic Barrat [Tue, 23 Jan 2018 11:31:43 +0000 (12:31 +0100)]
ocxl: Add a kernel API for other opencapi drivers

BugLink: http://bugs.launchpad.net/bugs/1746988
Some of the functions done by the generic driver should also be needed
by other opencapi drivers: attaching a context to an adapter,
translation fault handling, AFU interrupt allocation...

So to avoid code duplication, the driver provides a kernel API that
other drivers can use, similar to calling a in-kernel library.

It is still a bit theoretical, for lack of real hardware, and will
likely need adjustements down the road. But we used the cxlflash
driver as a guinea pig.

Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit 280b983ce2b8759722d911ea4b5af66e95d84e09)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoocxl: Add AFU interrupt support
Frederic Barrat [Tue, 23 Jan 2018 11:31:42 +0000 (12:31 +0100)]
ocxl: Add AFU interrupt support

BugLink: http://bugs.launchpad.net/bugs/1746988
Add user APIs through ioctl to allocate, free, and be notified of an
AFU interrupt.

For opencapi, an AFU can trigger an interrupt on the host by sending a
specific command targeting a 64-bit object handle. On POWER9, this is
implemented by mapping a special page in the address space of a
process and a write to that page will trigger an interrupt.

Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit aeddad1760aeb206d912b27b230269407efd5b06)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoocxl: Driver code for 'generic' opencapi devices
Frederic Barrat [Tue, 23 Jan 2018 11:31:41 +0000 (12:31 +0100)]
ocxl: Driver code for 'generic' opencapi devices

BugLink: http://bugs.launchpad.net/bugs/1746988
Add an ocxl driver to handle generic opencapi devices. Of course, it's
not meant to be the only opencapi driver, any device is free to
implement its own. But if a host application only needs basic services
like attaching to an opencapi adapter, have translation faults handled
or allocate AFU interrupts, it should suffice.

The AFU config space must follow the opencapi specification and use
the expected vendor/device ID to be seen by the generic driver.

The driver exposes the device AFUs as a char device in /dev/ocxl/

Note that the driver currently doesn't handle memory attached to the
opencapi device.

Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit 5ef3166e8a32d78dfa985a323aa45ed485ff663a)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agopowerpc/powernv: Capture actag information for the device
Frederic Barrat [Tue, 23 Jan 2018 11:31:40 +0000 (12:31 +0100)]
powerpc/powernv: Capture actag information for the device

BugLink: http://bugs.launchpad.net/bugs/1746988
In the opencapi protocol, host memory contexts are referenced by a
'actag'. During setup, a driver must tell the device how many actags
it can used, and what values are acceptable.

On POWER9, the NPU can handle 64 actags per link, so they must be
shared between all the PCI functions of the link. To get a global
picture of how many actags are used by each AFU of every function, we
capture some data at the end of PCI enumeration, so that actags can be
shared fairly if needed.

This is not powernv specific per say, but rather a consequence of the
opencapi configuration specification being quite general. The number
of available actags on POWER9 makes it more likely to be hit. This is
somewhat mitigated by the fact that existing AFUs are coded by
requesting a reasonable count of actags and existing devices carry
only one AFU.

Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit 2cb3d64b26984703a6bb80e66adcc3727ad37f9f)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agopowerpc/powernv: Add platform-specific services for opencapi
Frederic Barrat [Tue, 23 Jan 2018 11:31:39 +0000 (12:31 +0100)]
powerpc/powernv: Add platform-specific services for opencapi

BugLink: http://bugs.launchpad.net/bugs/1746988
Implement a few platform-specific calls which can be used by drivers:

- provide the Transaction Layer capabilities of the host, so that the
  driver can find some common ground and configure the device and host
  appropriately.

- provide the hw interrupt to be used for translation faults raised by
  the NPU

- map/unmap some NPU mmio registers to get the fault context when the
  NPU raises an address translation fault

The rest are wrappers around the previously-introduced opal calls.

Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit 6914c757118e2a60ba826d9959ccf5532779781b)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agopowerpc/powernv: Add opal calls for opencapi
Frederic Barrat [Tue, 23 Jan 2018 11:31:38 +0000 (12:31 +0100)]
powerpc/powernv: Add opal calls for opencapi

BugLink: http://bugs.launchpad.net/bugs/1746988
Add opal calls to interact with the NPU:

OPAL_NPU_SPA_SETUP: set the Shared Process Area (SPA)
The SPA is a table containing one entry (Process Element) per memory
context which can be accessed by the opencapi device.

OPAL_NPU_SPA_CLEAR_CACHE: clear the context cache
The NPU keeps a cache of recently accessed memory contexts. When a
Process Element is removed from the SPA, the cache for the link must
be cleared.

OPAL_NPU_TL_SET: configure the Transaction Layer
The Transaction Layer specification defines several templates for
messages to be exchanged on the link. During link setup, the host and
device must negotiate what templates are supported on both sides and
at what rates those messages can be sent.

Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit 74d656d219b98ef3b96f92439337aa6392a7577d)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agopowerpc/powernv: Set correct configuration space size for opencapi devices
Andrew Donnellan [Tue, 23 Jan 2018 11:31:37 +0000 (12:31 +0100)]
powerpc/powernv: Set correct configuration space size for opencapi devices

BugLink: http://bugs.launchpad.net/bugs/1746988
The configuration space for opencapi devices doesn't have a PCI
Express capability, therefore confusing linux in thinking it's of an
old PCI type with a 256-byte configuration space size, instead of the
desired 4k. So add a PCI fixup to declare the correct size.

Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit 228c2f4103788ba2a8df636f383ec2df33b47b73)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agopowerpc/powernv: Introduce new PHB type for opencapi links
Frederic Barrat [Tue, 23 Jan 2018 11:31:36 +0000 (12:31 +0100)]
powerpc/powernv: Introduce new PHB type for opencapi links

BugLink: http://bugs.launchpad.net/bugs/1746988
The NPU was already abstracted by opal as a virtual PHB for nvlink,
but it helps to be able to differentiate between a nvlink or opencapi
PHB, as it's not completely transparent to linux. In particular, PE
assignment differs and we'll also need the information in later
patches.

So rename existing PNV_PHB_NPU type to PNV_PHB_NPU_NVLINK and add a
new type PNV_PHB_NPU_OCAPI.

Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit 7f2c39e91f61fcd2abed3b39c14e7037c060c6f1)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Delay for rescan worker needs to be 10 seconds
Raghava Aditya Renukunta [Wed, 10 Jan 2018 21:13:10 +0000 (13:13 -0800)]
scsi: aacraid: Delay for rescan worker needs to be 10 seconds

BugLink: http://bugs.launchpad.net/bugs/1746801
The delay for the rescan worker needs to 10 seconds, missed the HZ in
there.

Fixes: a1367e4adee207fe (scsi: aacraid: Reschedule host scan in case of failure)
Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit cfc350ab0efb932f456436d65db65f0e77993148)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Get correct lun count
Raghava Aditya Renukunta [Wed, 10 Jan 2018 21:13:09 +0000 (13:13 -0800)]
scsi: aacraid: Get correct lun count

BugLink: http://bugs.launchpad.net/bugs/1746801
The correct lun count needs to be divided by 24, missed it in the
previous patch set.

Fixes: 4b00022753550055 (scsi: aacraid: Create helper functions to get lun info)
Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit bbd16d96d1ec531f6ad950d01b542422040033b8)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: remove redundant setting of variable c
Colin Ian King [Fri, 5 Jan 2018 15:31:06 +0000 (15:31 +0000)]
scsi: aacraid: remove redundant setting of variable c

BugLink: http://bugs.launchpad.net/bugs/1746801
A previous commit no longer stores the contents of c, so we now have a
situation where c is being updated but the value is never read. Clean up
the code by removing the now redundant setting of variable c.

Cleans up clang warning:
drivers/scsi/aacraid/aachba.c:943:3: warning: Value stored to 'c' is
never read

Fixes: f4e8708d3104 ("scsi: aacraid: Fix udev inquiry race condition")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 91814744646351a470f256fbcb853fb5a7229a9f)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Fix driver oops with dead battery
Meelis Roos [Wed, 3 Jan 2018 09:11:09 +0000 (11:11 +0200)]
scsi: aacraid: Fix driver oops with dead battery

BugLink: http://bugs.launchpad.net/bugs/1746801
The battery in my HP NetRAID-4M died of old age, and the aacraid driver
started oopsing with NULL pointer dereference on startup after that.

Fix it by reordering the init sequence to fill in function pointers
before ioremapping memory, or dev->a_ops.adapter_ioremap pointer will be
NULL.

Other subtypes of aacraid seem to have the order already correct.

This was the call trace:

 ? aac_probe_one+0x7a5/0xb30 [aacraid]
 pci_device_probe+0xc0/0x1a0
 driver_probe_device+0x1df/0x3b0
 __driver_attach+0xa9/0xe0
 ? driver_probe_device+0x3b0/0x3b0
 bus_for_each_dev+0x4c/0x90
 driver_attach+0x1d/0x40
 ? driver_probe_device+0x3b0/0x3b0
 bus_add_driver+0x1a7/0x2a0
 driver_register+0x6e/0x130
 __pci_register_driver+0x54/0x90
 ? 0xf81f4000
 aac_init+0x2b/0x1000 [aacraid]
 do_one_initcall+0x45/0x1e0
 ? kfree_skbmem+0x74/0xa0
 ? kfree+0x16d/0x240
 ? kvfree+0x45/0x50
 ? kvfree+0x45/0x50
 ? __vunmap+0x99/0x120
 ? do_init_module+0x1a/0x245
 do_init_module+0x83/0x245
 load_module+0x2764/0x34a0
 ? kernel_read_file+0x150/0x320
 SyS_finit_module+0x82/0xa0
 do_fast_syscall_32+0xba/0x340

Signed-off-by: Meelis Roos <mroos@linux.ee>
Reviewed-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit bef4e68830a102142fc4cb0c0ad4f1877d2ee557)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Update driver version to 50877
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:51 +0000 (20:34 -0800)]
scsi: aacraid: Update driver version to 50877

BugLink: http://bugs.launchpad.net/bugs/1746801
Update driver Version to 50877

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 1cdb74b80f93343d7b44b5d99b28d9b0c46375ba)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Remove AAC_HIDE_DISK check in queue command
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:50 +0000 (20:34 -0800)]
scsi: aacraid: Remove AAC_HIDE_DISK check in queue command

BugLink: http://bugs.launchpad.net/bugs/1746801
Earlier driver would scan throgh all supported buses and targets and add
devices that responded. It would add devices that were _hidden_ by the fw.
Driver would invalidate commands sent to _hidden_ devices via the
AAC_HIDE_DISK check.

Since the driver now adds only the devices that are supposed to be
exposed, this code can be removed.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit e51c4d703d22ba9590c9d538ccc567835a23caaf)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Remove unused rescan variable
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:49 +0000 (20:34 -0800)]
scsi: aacraid: Remove unused rescan variable

BugLink: http://bugs.launchpad.net/bugs/1746801
Remove unused rescan variable.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 75be67cd155d95658507b15ffe905c36243526ae)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Skip schedule rescan in case of kdump
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:48 +0000 (20:34 -0800)]
scsi: aacraid: Skip schedule rescan in case of kdump

BugLink: http://bugs.launchpad.net/bugs/1746801
There is a chance of the driver to be stuck in kdump if drives start
acting up in kdump discovery process and the kernel decides to send eh
resets, which would prompt rescan to be scheduled.

Do not perform a rescan in kdump context, since we do not expect a hotplug
event during kdump and all the devices are going to go away anyway.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit fe5237590bb033ad6b7312b0ef62a2d7d5c4141f)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Fix hang while scanning in eh recovery
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:47 +0000 (20:34 -0800)]
scsi: aacraid: Fix hang while scanning in eh recovery

BugLink: http://bugs.launchpad.net/bugs/1746801
Add back the ability to scan for hotplug changes while eh was in progress.

Schedule a rescan for a later time in the eh recovery code and wait for
eh to complete in the rescan worker.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 8a30e50b72ca08c78474db514531ce5d9ae00fa4)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Reschedule host scan in case of failure
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:46 +0000 (20:34 -0800)]
scsi: aacraid: Reschedule host scan in case of failure

BugLink: http://bugs.launchpad.net/bugs/1746801
If the driver fails to retrieve information from the fw (could happen when
the fw is not fully in its senses), the driver does nothing and change is
not processed correctly by the driver

Schedule host rescan in case of failure. This is only for SAFW, since
the information retrieval failure will happen on SAFW devices.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit a1367e4adee207fee7f14fdf2166022461fe76c4)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Use hotplug handling function in place of scsi_scan_host
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:45 +0000 (20:34 -0800)]
scsi: aacraid: Use hotplug handling function in place of scsi_scan_host

BugLink: http://bugs.launchpad.net/bugs/1746801
Driver uses scsi_scan_host to add new devices in the driver init path,
which adds all the fw exposed devices. The drivers resorts to queue
command checks to block out commands to _hidden_ devices.

Use the hotplug handler code to add new devices during driver init and
other areas, this is only for safw. For ARC scsi_scan_host will still
apply.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 8ebaa67fc23a09bcf2b285ae4130508256b31923)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Block concurrent hotplug event handling
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:44 +0000 (20:34 -0800)]
scsi: aacraid: Block concurrent hotplug event handling

BugLink: http://bugs.launchpad.net/bugs/1746801
Currently driver will attempt to process hotplug events concurrently based
on the FW interrupt.

Protect safw update function with a scan mutex.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 3395614e48e26c6b05f87662ef354bca38999d2a)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Merge adapter setup with resolve luns
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:43 +0000 (20:34 -0800)]
scsi: aacraid: Merge adapter setup with resolve luns

BugLink: http://bugs.launchpad.net/bugs/1746801
The device hotplug events are processed only after retrieving the updated
lun information from the fw. Does not make sense to keep them separate.

Merge both the hotplug handling and safw adapter setup code into single
function.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 6f44a22b2c96acd018b407ee28407e1730370169)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Refactor resolve luns code and scsi functions
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:42 +0000 (20:34 -0800)]
scsi: aacraid: Refactor resolve luns code and scsi functions

BugLink: http://bugs.launchpad.net/bugs/1746801
Resolve luns checks the if a sdev is already present in the os to figure
out if it needs to be removed. Internally the driver exposes HBA on bus
2 even though its bus 1 in the fw. Its mildly confusing.

Refactor out the sdev lookup into its function to check if sdev has been
added to the kernel or not. Add helper functions to add, remove and put
devices based on their fw bus and target number.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 3031c6565f04d4d6d1d4a04788c394a68b1d285b)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Added macros to help loop through known buses and targets
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:41 +0000 (20:34 -0800)]
scsi: aacraid: Added macros to help loop through known buses and targets

BugLink: http://bugs.launchpad.net/bugs/1746801
Added macros to loop through the MAX SUPPORTED Buses and Targets. This
will make the code a bit easier to read.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 2290678fed775194ef84d65949d93a4f524765b0)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Process hba and container hot plug events in single function
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:40 +0000 (20:34 -0800)]
scsi: aacraid: Process hba and container hot plug events in single function

BugLink: http://bugs.launchpad.net/bugs/1746801
The hotplug handler code is duplicated for hba handling and container
handling.

Merged function to handle hba and container hot plug events into the
resolve luns functions. Added a bunch of helper functions to check the
validity of a given target and to check if bus, target is container
device.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit f2d2cabadba00f13786a5962a9813079a3767ce4)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Merge func to get container information
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:39 +0000 (20:34 -0800)]
scsi: aacraid: Merge func to get container information

BugLink: http://bugs.launchpad.net/bugs/1746801
Merge aac_get_containers to setup target function, so that information
about all the present devices can be retrieved in one shot.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 1d1fec53dc13d56c80b02d391c7d593d9a502d6d)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Add helper function to set queue depth
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:38 +0000 (20:34 -0800)]
scsi: aacraid: Add helper function to set queue depth

BugLink: http://bugs.launchpad.net/bugs/1746801
Add helper function to set queue depth from information retrieved from
the bmic phy structure.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 0bcb45fb20c2195fe0ae175d4775241e672a5fd3)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Save bmic phy information for each phy
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:37 +0000 (20:34 -0800)]
scsi: aacraid: Save bmic phy information for each phy

BugLink: http://bugs.launchpad.net/bugs/1746801
Save the bmic information for each phy, so that it can processed in
target setup function.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit e2ee8c948010bdb6c4ce26fd7408065495f51fad)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Create helper functions to get lun info
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:36 +0000 (20:34 -0800)]
scsi: aacraid: Create helper functions to get lun info

BugLink: http://bugs.launchpad.net/bugs/1746801
Created inline function to retrieve lun info for each device from the
phy luns structure.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 4b000227535500550547313bf20e3be9083dc724)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Move function around to match existing code
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:35 +0000 (20:34 -0800)]
scsi: aacraid: Move function around to match existing code

BugLink: http://bugs.launchpad.net/bugs/1746801
Move the function to get phy luns information to the top of function
to set target information

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit a25b6ca1a9225610671cb850432eade5e057edc1)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Untangle targets setup from report phy luns
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:34 +0000 (20:34 -0800)]
scsi: aacraid: Untangle targets setup from report phy luns

BugLink: http://bugs.launchpad.net/bugs/1746801
Remove function call to process targets from the report phy luns function
and make it a function in its own right. This will help understand the
flow of the code.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 3edfb8b2e20b30456359718805bea052bf1b0895)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Add target setup helper function
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:33 +0000 (20:34 -0800)]
scsi: aacraid: Add target setup helper function

BugLink: http://bugs.launchpad.net/bugs/1746801
Add helper function to setup targets devices and create the base for the
upcoming patches

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit fc0fdd9abcc60bd207151b2c8a82dc5ee4b45226)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Refactor and rename to make mirror existing changes
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:32 +0000 (20:34 -0800)]
scsi: aacraid: Refactor and rename to make mirror existing changes

BugLink: http://bugs.launchpad.net/bugs/1746801
Rename variables and functions to make bmic identify, report phy luns
to make them consistent across code internal existing code bases

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit b5a475e944447faa6a2110eea0419a7d2a156a0c)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Change phy luns function to use common bmic function
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:31 +0000 (20:34 -0800)]
scsi: aacraid: Change phy luns function to use common bmic function

BugLink: http://bugs.launchpad.net/bugs/1746801
Edit function that retrieves phy lun information to use common
bmic function

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 5480aa18375e6f1b42ec6029c23a57600b5b1c08)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Create bmic submission function from bmic identify
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:30 +0000 (20:34 -0800)]
scsi: aacraid: Create bmic submission function from bmic identify

BugLink: http://bugs.launchpad.net/bugs/1746801
safw command submission is duplicated across many functions.

Move the safw submission code from bmic identify into its own function
for common use

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 8fb391827f57e5aea4157f7e1b8b005cd126545a)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Move code to wait for IO completion to shutdown func
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:29 +0000 (20:34 -0800)]
scsi: aacraid: Move code to wait for IO completion to shutdown func

BugLink: http://bugs.launchpad.net/bugs/1746801
Ideally driver needs to wait for IO to be submitted or responded to before
shutdown.

Move code to wait for IO completion into shutdown path

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 216ced02fa1638088d7908149d6500627b79b9f0)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Refactor reset_host store function
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:28 +0000 (20:34 -0800)]
scsi: aacraid: Refactor reset_host store function

BugLink: http://bugs.launchpad.net/bugs/1746801
Refactored the reset_host store function to make consistent across code
bases

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 97a4e8ac3f8a90fbec56bd3611d3e9dafffcdf2d)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Allow reset_host sysfs var to recover Panicked Fw
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:27 +0000 (20:34 -0800)]
scsi: aacraid: Allow reset_host sysfs var to recover Panicked Fw

BugLink: http://bugs.launchpad.net/bugs/1746801
It is possible to restart the controller via the use of the reset_host
sysfs variable. This does work for controllers that can no longer respond,
since driver will attempt to send down a shutdown in this path.

Check if the controller is able to receive commands before sending down
a shutdown

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit d1471eb0faef9edd65cd44c1a3c1ff13c251fead)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Fix ioctl reset hang
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:26 +0000 (20:34 -0800)]
scsi: aacraid: Fix ioctl reset hang

BugLink: http://bugs.launchpad.net/bugs/1746801
Driver would hang when attempting to send reset from the ioctl interface,
since it would wait to retrieve the ioctl mutex at send shutdown.

Set adapter shutdown and unlock mutex before sending down reset request.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit f3a2327725b4f922dabb89e46ff66713cfa461c2)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Do not remove offlined devices
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:25 +0000 (20:34 -0800)]
scsi: aacraid: Do not remove offlined devices

BugLink: http://bugs.launchpad.net/bugs/1746801
As part of the recovery process, the drivers removes offline devices (
done by the kernel) and then tries to add them back in the rescan code.
Removing the device is like taking a sledgehammer to a nail.

Set the device as running if it is marked offline.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 95900629fa7dd0af7be5e9a8fdbc9d902fa3c8c7)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: Do not attempt abort when Fw panicked
Raghava Aditya Renukunta [Wed, 27 Dec 2017 04:34:23 +0000 (20:34 -0800)]
scsi: aacraid: Do not attempt abort when Fw panicked

BugLink: http://bugs.launchpad.net/bugs/1746801
Check if the adapter can receive abort requests, before sending aborts

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit dfb92a1f93345f51851f76d567a608da09eb2347)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: aacraid: remove unused variable managed_request_id
Colin Ian King [Wed, 15 Nov 2017 16:53:41 +0000 (16:53 +0000)]
scsi: aacraid: remove unused variable managed_request_id

BugLink: http://bugs.launchpad.net/bugs/1746801
Variable managed_request_id is being assigned but it is never read,
hence it is redundant and can be removed. Cleans up clang warning:

drivers/scsi/aacraid/linit.c:706:5: warning: Value stored to
'managed_request_id' is never read

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit efbbbb10235a218119573e95968f1042ffda2972)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agopowerpc/modules: Improve restore_r2() error message
Josh Poimboeuf [Tue, 14 Nov 2017 09:29:10 +0000 (04:29 -0500)]
powerpc/modules: Improve restore_r2() error message

BugLink: http://bugs.launchpad.net/bugs/1741992
Print the function address associated with the restore_r2() error to
make it easier to debug the problem.

Also clarify the wording a bit.

Before:

  module_64: patch_foo: Expect noop after relocate, got 3c820000

After:

  module_64: patch_foo: Expected nop after call, got 7c630034 at netdev_has_upper_dev+0x54/0xb0 [patch_foo]

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
[mpe: Change noop to nop, as that's the name of the instruction]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit 1ea61ea23985c0f15c027e4c0ac02224efdfb243)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agopowerpc/modules: Don't try to restore r2 after a sibling call
Josh Poimboeuf [Thu, 16 Nov 2017 17:45:37 +0000 (11:45 -0600)]
powerpc/modules: Don't try to restore r2 after a sibling call

BugLink: http://bugs.launchpad.net/bugs/1741992
When attempting to load a livepatch module, I got the following error:

  module_64: patch_module: Expect noop after relocate, got 3c820000

The error was triggered by the following code in
unregister_netdevice_queue():

  14c:   00 00 00 48     b       14c <unregister_netdevice_queue+0x14c>
                         14c: R_PPC64_REL24      net_set_todo
  150:   00 00 82 3c     addis   r4,r2,0

GCC didn't insert a nop after the branch to net_set_todo() because it's
a sibling call, so it never returns.  The nop isn't needed after the
branch in that case.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Acked-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Reviewed-and-tested-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit b9eab08d012fa093947b230f9a87257c27fb829b)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agopowerpc/modules: Add REL24 relocation support of livepatch symbols
Kamalesh Babulal [Tue, 14 Nov 2017 09:29:08 +0000 (04:29 -0500)]
powerpc/modules: Add REL24 relocation support of livepatch symbols

BugLink: http://bugs.launchpad.net/bugs/1741992
Livepatch re-uses module loader function apply_relocate_add() to write
relocations, instead of managing them by arch-dependent
klp_write_module_reloc() function.

apply_relocate_add() doesn't understand livepatch symbols (marked with
SHN_LIVEPATCH symbol section index) and assumes them to be local
symbols by default for R_PPC64_REL24 relocation type. It fails with an
error, when trying to calculate offset with local_entry_offset():

  module_64: kpatch_meminfo: REL24 -1152921504897399800 out of range!

Whereas livepatch symbols are essentially SHN_UNDEF, should be called
via stub used for global calls. This issue can be fixed by teaching
apply_relocate_add() to handle both SHN_UNDEF/SHN_LIVEPATCH symbols
via the same stub. This patch extends SHN_UNDEF code to handle
livepatch symbols too.

Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit a443bf6e8a7674b86221f4922cae82d67dc9e8ad)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoibmvnic: Fix early release of login buffer
Thomas Falcon [Tue, 27 Feb 2018 15:12:15 +0000 (12:12 -0300)]
ibmvnic: Fix early release of login buffer

BugLink: https://bugs.launchpad.net/bugs/1748517
The login buffer is released before the driver can perform
sanity checks between resources the driver requested and what
firmware will provide. Don't release the login buffer until
the sanity check is performed.

Fixes: 34f0f4e3f488 ("ibmvnic: Fix login buffer memory leaks")
Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit a2c0f039bbd0f9ebf375176d05b056e3f3b5c4f7)
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoibmvnic: Check for NULL skb's in NAPI poll routine
Thomas Falcon [Tue, 27 Feb 2018 15:12:14 +0000 (12:12 -0300)]
ibmvnic: Check for NULL skb's in NAPI poll routine

BugLink: https://bugs.launchpad.net/bugs/1748517
After introduction of commit d0869c0071e4, there were some instances of
RX queue entries from a previous session (before the device was closed
and reopened) returned to the NAPI polling routine. Since the corresponding
socket buffers were freed, this resulted in a panic on reopen. Include
a check for a NULL skb here to avoid this.

Fixes: d0869c0071e4 ("ibmvnic: Clean RX pool buffers during device close")
Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit abe27a885d9e6575e663a16176dabc58ce9d7188)
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoibmvnic: Clean RX pool buffers during device close
Thomas Falcon [Tue, 27 Feb 2018 15:12:13 +0000 (12:12 -0300)]
ibmvnic: Clean RX pool buffers during device close

BugLink: https://bugs.launchpad.net/bugs/1748517
During device close or reset, there were some cases of outstanding
RX socket buffers not being freed. Include a function similar to the
one that already exists to clean TX socket buffers in this case.

Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit d0869c0071e40c4407d1a4d7c9497653cf47253b)
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoibmvnic: Free RX socket buffer in case of adapter error
Thomas Falcon [Tue, 27 Feb 2018 15:12:12 +0000 (12:12 -0300)]
ibmvnic: Free RX socket buffer in case of adapter error

BugLink: https://bugs.launchpad.net/bugs/1748517
If a RX buffer is returned to the client driver with an error, free the
corresponding socket buffer before continuing.

Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 4b9b0f01350500173f17e2b2e65beb4df4ef99c7)
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoibmvnic: Fix NAPI structures memory leak
Thomas Falcon [Tue, 27 Feb 2018 15:12:11 +0000 (12:12 -0300)]
ibmvnic: Fix NAPI structures memory leak

BugLink: https://bugs.launchpad.net/bugs/1748517
This memory is allocated during initialization but never freed,
so do that now.

Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 6e4842ddfc2b08931ebd6c0bc95322dd56e5232b)
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoibmvnic: Fix login buffer memory leaks
Thomas Falcon [Tue, 27 Feb 2018 15:12:10 +0000 (12:12 -0300)]
ibmvnic: Fix login buffer memory leaks

BugLink: https://bugs.launchpad.net/bugs/1748517
During device bringup, the driver exchanges login buffers with
firmware. These buffers contain information such number of TX
and RX queues alloted to the device, RX buffer size, etc. These
buffers weren't being properly freed on device reset or close.

We can free the buffer we send to firmware as soon as we get
a response. There is information in the response buffer that
the driver needs for normal operation so retain it until the
next reset or removal.

Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 34f0f4e3f48810b0ba080bf2a65370b0cc179c51)
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoibmvnic: Wait until reset is complete to set carrier on
Thomas Falcon [Tue, 27 Feb 2018 15:12:09 +0000 (12:12 -0300)]
ibmvnic: Wait until reset is complete to set carrier on

BugLink: https://bugs.launchpad.net/bugs/1748517
Pushes back setting the carrier on until the end of the reset
code. This resolves a bug where a watchdog timer was detecting
that a TX queue had stalled before the adapter reset was complete.

Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit cc85c02edfe48a34865ae00f7d22298a3fdd17aa)
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoibmvnic: Remove skb->protocol checks in ibmvnic_xmit
John Allen [Tue, 27 Feb 2018 15:12:08 +0000 (12:12 -0300)]
ibmvnic: Remove skb->protocol checks in ibmvnic_xmit

BugLink: https://bugs.launchpad.net/bugs/1748517
Having these checks in ibmvnic_xmit causes problems with VLAN
tagging and balance-alb/tlb bonding modes. The restriction they
imposed can be removed.

Signed-off-by: John Allen <jallen@linux.vnet.ibm.com>
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 2fa56a494484f19e06bf4f3464b2155a92beafac)
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoibmvnic: Reset long term map ID counter
Thomas Falcon [Tue, 27 Feb 2018 15:12:07 +0000 (12:12 -0300)]
ibmvnic: Reset long term map ID counter

BugLink: https://bugs.launchpad.net/bugs/1748517
When allocating RX or TX buffer pools, the driver needs to provide a
unique mapping ID to firmware for each pool. This value is assigned
using a counter which is incremented after a new pool is created. The
ID can be an integer ranging from 1-255. When migrating to a device
that requests a different number of queues, this value was not being
reset properly. As a result, after enough migrations, the counter
exceeded the upper bound and pool creation failed. This is fixed by
resetting the counter to one in this case.

Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit faefaa97215a0c05105d7ae180fe1a3b5979ad1f)
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoibmvnic: queue reset when CRQ gets closed during reset
Nathan Fontenot [Tue, 27 Feb 2018 15:12:06 +0000 (12:12 -0300)]
ibmvnic: queue reset when CRQ gets closed during reset

BugLink: https://bugs.launchpad.net/bugs/1748517
While handling a driver reset we get a H_CLOSED return trying
to send a CRQ event. When this occurs we need to queue up another
reset attempt. Without doing this we see instances where the driver
is left in a closed state because the reset failed and there is no
further attempts to reset the driver.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit ec95dffa408f0c24c0b358f3723c6ba262190965)
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoibmvnic: Ensure that buffers are NULL after free
Thomas Falcon [Tue, 27 Feb 2018 15:12:05 +0000 (12:12 -0300)]
ibmvnic: Ensure that buffers are NULL after free

BugLink: https://bugs.launchpad.net/bugs/1748517
This change will guard against a double free in the case that the
buffers were previously freed at some other time, such as during
a device reset. It resolves a kernel oops that occurred when changing
the VNIC device's MTU.

Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit b0992eca00c490c0923044b7d8b853c212b3cacc)
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoibmvnic: Fix rx queue cleanup for non-fatal resets
John Allen [Tue, 27 Feb 2018 15:12:04 +0000 (12:12 -0300)]
ibmvnic: Fix rx queue cleanup for non-fatal resets

BugLink: https://bugs.launchpad.net/bugs/1748517
At some point, a check was added to exit the polling routine during resets.
This makes sense for most reset conditions, but for a non-fatal error, we
expect the polling routine to continue running to properly clean up the rx
queues. This patch checks if we are performing a non-fatal reset and if we
are, continues normal polling operation.

Signed-off-by: John Allen <jallen@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 3468656fd7599b0cb1092bb1ee717d1a984e93ee)
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoibmvnic: fix empty firmware version and errors cleanup
Desnes Augusto Nunes do Rosario [Tue, 27 Feb 2018 15:12:03 +0000 (12:12 -0300)]
ibmvnic: fix empty firmware version and errors cleanup

BugLink: https://bugs.launchpad.net/bugs/1748517
This patch makes sure that the firmware version is never NULL. Moreover,
it also performs some cleanup on the error messages.

Fixes: a107311d7fdf ("ibmvnic: fix firmware version when no firmware level
has been provided by the VIOS server")
Signed-off-by: Desnes A. Nunes do Rosario <desnesn@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 21a2545bbea02ce39e91d47c9e3ef0ccd0fb0b14)
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoibmvnic: fix firmware version when no firmware level has been provided by the VIOS...
Desnes Augusto Nunes do Rosario [Tue, 27 Feb 2018 15:12:02 +0000 (12:12 -0300)]
ibmvnic: fix firmware version when no firmware level has been provided by the VIOS server

BugLink: https://bugs.launchpad.net/bugs/1748517
Older versions of VIOS servers do not send the firmware level in the VPD
buffer for the ibmvnic driver. Thus, not only the current message is mis-
leading but the firmware version in the ethtool will be NULL. Therefore,
this patch fixes the firmware string and its warning.

Fixes: 4e6759be28e4 ("ibmvnic: Feature implementation of VPD for the ibmvnic driver")
Signed-off-by: Desnes A. Nunes do Rosario <desnesn@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit a107311d7fdf6b826f3737c4a90fd0e0046e7a3a)
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoibmvnic: Wait for device response when changing MAC
Thomas Falcon [Tue, 27 Feb 2018 15:12:01 +0000 (12:12 -0300)]
ibmvnic: Wait for device response when changing MAC

BugLink: https://bugs.launchpad.net/bugs/1748517
Wait for a response from the VNIC server before exiting after setting
the MAC address. The resolves an issue with bonding a VNIC client in
ALB or TLB modes. The bonding driver was changing the MAC address more
rapidly than the device could respond, causing the following errors.

"bond0: the hw address of slave eth2 is in use by the bond;
couldn't find a slave with a free hw address to give it
(this should not have happened)"

If the function waits until the change is finalized, these errors are
avoided.

Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit f813614f531114db796ad66ced75c5dc8db7aa3a)
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoibmvnic: Don't handle RX interrupts when not up.
Nathan Fontenot [Tue, 27 Feb 2018 15:12:00 +0000 (12:12 -0300)]
ibmvnic: Don't handle RX interrupts when not up.

BugLink: https://bugs.launchpad.net/bugs/1748517
Initiating a kdump via the command line can cause a pending interrupt
to be handled by the ibmvnic driver when initializing the sub-CRQ
irqs during driver initialization.

NIP [d000000000ca34f0] ibmvnic_interrupt_rx+0x40/0xd0 [ibmvnic]
LR [c000000008132ef0] __handle_irq_event_percpu+0xa0/0x2f0
Call Trace:
[c000000047fcfde0] [c000000008132ef0] __handle_irq_event_percpu+0xa0/0x2f0
[c000000047fcfea0] [c00000000813317c] handle_irq_event_percpu+0x3c/0x90
[c000000047fcfee0] [c00000000813323c] handle_irq_event+0x6c/0xd0
[c000000047fcff10] [c0000000081385e0] handle_fasteoi_irq+0xf0/0x250
[c000000047fcff40] [c0000000081320a0] generic_handle_irq+0x50/0x80
[c000000047fcff60] [c000000008014984] __do_irq+0x84/0x1d0
[c000000047fcff90] [c000000008027564] call_do_irq+0x14/0x24
[c00000003c92af00] [c000000008014b70] do_IRQ+0xa0/0x120
[c00000003c92af50] [c000000008002594] hardware_interrupt_common+0x114/0x180

Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 09fb35ead58cd557aa9b20576d15816bc91a4deb)
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoibmvnic: Include header descriptor support for ARP packets
Thomas Falcon [Tue, 27 Feb 2018 15:11:59 +0000 (12:11 -0300)]
ibmvnic: Include header descriptor support for ARP packets

BugLink: https://bugs.launchpad.net/bugs/1748517
In recent tests with new adapters, it was discovered that ARP
packets were not being properly processed. This patch adds
support for ARP packet headers to be passed to backing adapters,
if necessary.

Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 4eb50ceb5c156a166c0b00ac27f0ff3a0943cdfb)
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoibmvnic: Increase maximum number of RX/TX queues
Thomas Falcon [Tue, 27 Feb 2018 15:11:58 +0000 (12:11 -0300)]
ibmvnic: Increase maximum number of RX/TX queues

BugLink: https://bugs.launchpad.net/bugs/1748517
Increase the number of queues allocated to accommodate recent
network adapter inclusions on the IBM vNIC platform.

Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 269431e737d29da0f496b60188a580822d290a37)
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoibmvnic: Rename IBMVNIC_MAX_TX_QUEUES to IBMVNIC_MAX_QUEUES
Thomas Falcon [Tue, 27 Feb 2018 15:11:57 +0000 (12:11 -0300)]
ibmvnic: Rename IBMVNIC_MAX_TX_QUEUES to IBMVNIC_MAX_QUEUES

BugLink: https://bugs.launchpad.net/bugs/1748517
This value denotes the maximum number of TX queues but is used
to allocate both RX and TX queues.

Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit d45cc3a43c43f867668bdd7ace12b1e6aa68bf46)
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoKVM: PPC: Book3S HV: Improve handling of debug-trigger HMIs on POWER9
Paul Mackerras [Wed, 17 Jan 2018 09:51:13 +0000 (20:51 +1100)]
KVM: PPC: Book3S HV: Improve handling of debug-trigger HMIs on POWER9

BugLink: http://bugs.launchpad.net/bugs/1751834
Hypervisor maintenance interrupts (HMIs) are generated by various
causes, signalled by bits in the hypervisor maintenance exception
register (HMER).  In most cases calling OPAL to handle the interrupt
is the correct thing to do, but the "debug trigger" HMIs signalled by
PPC bit 17 (bit 46) of HMER are used to invoke software workarounds
for hardware bugs, and OPAL does not have any code to handle this
cause.  The debug trigger HMI is used in POWER9 DD2.0 and DD2.1 chips
to work around a hardware bug in executing vector load instructions to
cache inhibited memory.  In POWER9 DD2.2 chips, it is generated when
conditions are detected relating to threads being in TM (transactional
memory) suspended mode when the core SMT configuration needs to be
reconfigured.

The kernel currently has code to detect the vector CI load condition,
but only when the HMI occurs in the host, not when it occurs in a
guest.  If a HMI occurs in the guest, it is always passed to OPAL, and
then we always re-sync the timebase, because the HMI cause might have
been a timebase error, for which OPAL would re-sync the timebase, thus
removing the timebase offset which KVM applied for the guest.  Since
we don't know what OPAL did, we don't know whether to subtract the
timebase offset from the timebase, so instead we re-sync the timebase.

This adds code to determine explicitly what the cause of a debug
trigger HMI will be.  This is based on a new device-tree property
under the CPU nodes called ibm,hmi-special-triggers, if it is
present, or otherwise based on the PVR (processor version register).
The handling of debug trigger HMIs is pulled out into a separate
function which can be called from the KVM guest exit code.  If this
function handles and clears the HMI, and no other HMI causes remain,
then we skip calling OPAL and we proceed to subtract the guest
timebase offset from the timebase.

The overall handling for HMIs that occur in the host (i.e. not in a
KVM guest) is largely unchanged, except that we now don't set the flag
for the vector CI load workaround on DD2.2 processors.

This also removes a BUG_ON in the KVM code.  BUG_ON is generally not
useful in KVM guest entry/exit code since it is difficult to handle
the resulting trap gracefully.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit d075745d893c78730e4a3b7a60fca23c2f764081)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: d-i: add cxgb4 to nic-modules
Thadeu Lima de Souza Cascardo [Mon, 26 Feb 2018 16:10:09 +0000 (13:10 -0300)]
UBUNTU: d-i: add cxgb4 to nic-modules

BugLink: https://bugs.launchpad.net/bugs/1745927
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agotg3: APE heartbeat changes
Prashant Sreedharan [Mon, 26 Feb 2018 12:01:58 +0000 (09:01 -0300)]
tg3: APE heartbeat changes

BugLink: http://bugs.launchpad.net/bugs/1751337
In ungraceful host shutdown or driver crash case BMC connectivity is
lost. APE firmware is missing the driver state in this
case to keep the BMC connectivity alive.
This patch has below change to address this issue.

Heartbeat mechanism with APE firmware. This heartbeat mechanism
is needed to notify the APE firmware about driver state.

This patch also has the change in wait time for APE event from
1ms to 20ms as there can be some delay in getting response.

v2: Drop inline keyword as per David suggestion.

Signed-off-by: Prashant Sreedharan <prashant.sreedharan@broadcom.com>
Signed-off-by: Satish Baddipadige <satish.baddipadige@broadcom.com>
Signed-off-by: Siva Reddy Kallam <siva.kallam@broadcom.com>
Acked-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 506b0a395f26e52b3f18827e0de1be051acb77ab)
Signed-off-by: Mauro S. M. Rodrigues <maurosr@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: Start new release
Seth Forshee [Mon, 26 Feb 2018 17:38:46 +0000 (11:38 -0600)]
UBUNTU: Start new release

Ignore: yes
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: Ubuntu-4.15.0-11.12 Ubuntu-4.15.0-11.12
Seth Forshee [Fri, 23 Feb 2018 14:31:44 +0000 (08:31 -0600)]
UBUNTU: Ubuntu-4.15.0-11.12

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: [Config] fix up removed retpoline call sites
Seth Forshee [Fri, 23 Feb 2018 15:32:49 +0000 (09:32 -0600)]
UBUNTU: [Config] fix up removed retpoline call sites

A few exploitable call sites have been removed, so remove these
sites from the call sites list in the previous abi.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: MAINTAINERS: Add maintainer for HiSilicon LPC driver
John Garry [Mon, 19 Feb 2018 17:48:40 +0000 (01:48 +0800)]
UBUNTU: SAUCE: MAINTAINERS: Add maintainer for HiSilicon LPC driver

BugLink: https://bugs.launchpad.net/bugs/1677319
Added maintainer for drivers/bus/hisi_lpc.c

Signed-off-by: John Garry <john.garry@huawei.com>
[ v14 submittal ]
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: HISI LPC: Add ACPI support
John Garry [Mon, 19 Feb 2018 17:48:39 +0000 (01:48 +0800)]
UBUNTU: SAUCE: HISI LPC: Add ACPI support

BugLink: https://bugs.launchpad.net/bugs/1677319
Based on the previous patches, this patch supports the
LPC host on hip06/hip07 for ACPI FW.

It is the responsibility of the LPC host driver to
enumerate the child devices, as the ACPI scan code will
not enumerate children of "indirect IO" hosts.

The ACPI table for the LPC host controller and the child
devices is in the following format:
  Device (LPC0) {
    Name (_HID, "HISI0191")  // HiSi LPC
    Name (_CRS, ResourceTemplate () {
      Memory32Fixed (ReadWrite, 0xa01b0000, 0x1000)
    })
  }

  Device (LPC0.IPMI) {
    Name (_HID, "IPI0001")
    Name (LORS, ResourceTemplate() {
      QWordIO (
        ResourceConsumer,
MinNotFixed,     // _MIF
MaxNotFixed,     // _MAF
PosDecode,
EntireRange,
0x0,             // _GRA
0xe4,            // _MIN
0x3fff,          // _MAX
0x0,             // _TRA
0x04,            // _LEN
, ,
BTIO
      )
    })

Since the IO resources of the child devices need to be
translated from LPC bus addresses to logical PIO addresses,
and we shouldn't modify the resources of the devices
generated in the FW scan, a per-child MFD is created as
a substitute. The MFD IO resources will be the translated
bus addresses of the ACPI child.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Zhichang Yuan <yuanzhichang@hisilicon.com>
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@huawei.com>
[ v14 submittal ]
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: ACPI / scan: do not enumerate Indirect IO host children
John Garry [Mon, 19 Feb 2018 17:48:38 +0000 (01:48 +0800)]
UBUNTU: SAUCE: ACPI / scan: do not enumerate Indirect IO host children

BugLink: https://bugs.launchpad.net/bugs/1677319
Through the logical PIO framework systems which otherwise have
no IO space access to legacy ISA/LPC devices may access these
devices through so-called "indirect IO" method. In this, IO
space accesses for non-PCI hosts are redirected to a host
LLDD to manually generate the IO space (bus) accesses. Hosts
are able to register a region in logical PIO space to map to
its bus address range.

Indirect IO child devices have an associated host-specific bus
address. Special translation is required to map between
a logical PIO address for a device and it's host bus address.

Since in the ACPI tables the child device IO resources would
be the host-specific values, it is required the ACPI scan code
should not enumerate these devices, and that this should be
the responsibility of the host driver so that it can "fixup"
the resources so that they map to the appropriate logical PIO
addresses.

To avoid enumerating these child devices, we check whether
the parent for a device is a member of a known list of
"indirect IO" hosts. For now, the HiSilicon LPC host
controller ID is added.

To flag a device to not be enumerated, we reuse the existing
serial bus slave flag.

Signed-off-by: John Garry <john.garry@huawei.com>
[ v14 submittal ]
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: HISI LPC: Support the LPC host on Hip06/Hip07 with DT bindings
Zhichang Yuan [Mon, 19 Feb 2018 17:48:37 +0000 (01:48 +0800)]
UBUNTU: SAUCE: HISI LPC: Support the LPC host on Hip06/Hip07 with DT bindings

BugLink: https://bugs.launchpad.net/bugs/1677319
The low-pin-count(LPC) interface of Hip06/Hip07 accesses the peripherals in
I/O port addresses. This patch implements the LPC host controller driver
which perform the I/O operations on the underlying hardware.
We don't want to touch those existing peripherals' driver, such as ipmi-bt.
So this driver applies the indirect-IO introduced in the previous patch
after registering an indirect-IO node to the indirect-IO devices list which
will be searched in the I/O accessors to retrieve the host-local I/O port.

The driver config is set as a bool instead of a trisate. The reason
here is that, by the very nature of the driver providing a logical
PIO range, it does not make sense to have this driver as a loadable
module. Another more specific reason is that the Huawei D03 board
which includes hip06 SoC requires the LPC bus for UART console, so
should be built in.

Signed-off-by: Zou Rongrong <zourongrong@huawei.com>
Signed-off-by: Zhichang Yuan <yuanzhichang@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Acked-by: Rob Herring <robh@kernel.org> #dts part
[ v14 submittal ]
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: [Config] CONFIG_HISILICON_LPC=y
dann frazier [Fri, 2 Feb 2018 21:55:33 +0000 (14:55 -0700)]
UBUNTU: [Config] CONFIG_HISILICON_LPC=y

BugLink: https://bugs.launchpad.net/bugs/1677319
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: OF: Add missing I/O range exception for indirect-IO devices
Zhichang Yuan [Mon, 19 Feb 2018 17:48:36 +0000 (01:48 +0800)]
UBUNTU: SAUCE: OF: Add missing I/O range exception for indirect-IO devices

BugLink: https://bugs.launchpad.net/bugs/1677319
There are some special ISA/LPC devices that work on a specific I/O range
where it is not correct to specify a 'ranges' property in DTS parent node
as cpu addresses translated from DTS node are only for memory space on
some architectures, such as Arm64. Without the parent 'ranges' property,
current of_translate_address() return an error.
Here we add special handlings for this case.
During the OF address translation, some checkings will be perfromed to
identify whether the device node is registered as indirect-IO. If yes,
the I/O translation will be done in a different way from that one of PCI
MMIO. In this way, the I/O 'reg' property of the special ISA/LPC devices
will be parsed correctly.

Signed-off-by: Zhichang Yuan <yuanzhichang@hisilicon.com>
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@huawei.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de> #earlier draft
Acked-by: Rob Herring <robh@kernel.org>
[ v14 submittal ]
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: PCI: Apply the new generic I/O management on PCI IO hosts
Zhichang Yuan [Mon, 19 Feb 2018 17:48:35 +0000 (01:48 +0800)]
UBUNTU: SAUCE: PCI: Apply the new generic I/O management on PCI IO hosts

BugLink: https://bugs.launchpad.net/bugs/1677319
After introducing the new generic I/O space management in logic pio, the
original PCI MMIO relevant helpers need to be updated based on the new
interfaces.
This patch adapts the corresponding code to match the changes introduced
by logic pio.

Signed-off-by: Zhichang Yuan <yuanzhichang@hisilicon.com>
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@huawei.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de> #earlier draft
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
[ v14 submittal ]
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: PCI: Add fwnode handler as input param of pci_register_io_range()
Gabriele Paoloni [Mon, 19 Feb 2018 17:48:34 +0000 (01:48 +0800)]
UBUNTU: SAUCE: PCI: Add fwnode handler as input param of pci_register_io_range()

BugLink: https://bugs.launchpad.net/bugs/1677319
In preparation for having the PCI MMIO helpers to use the new generic
I/O space management(logical PIO) we need to add the fwnode handler as
extra input parameter.
This patch changes the signature of pci_register_io_range() and of
its callers as needed.

Signed-off-by: Gabriele Paoloni <gabriele.paoloni@huawei.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rob Herring <robh@kernel.org>
[ v14 submittal ]
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: PCI: Remove unused __weak attribute in pci_register_io_range()
Gabriele Paoloni [Mon, 19 Feb 2018 17:48:33 +0000 (01:48 +0800)]
UBUNTU: SAUCE: PCI: Remove unused __weak attribute in pci_register_io_range()

BugLink: https://bugs.launchpad.net/bugs/1677319
Currently pci_register_io_range() has only one definition;
therefore there is no use of the __weak attribute.

Signed-off-by: Gabriele Paoloni <gabriele.paoloni@huawei.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
[ v14 submittal ]
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: LIB: Introduce a generic PIO mapping method
Zhichang Yuan [Mon, 19 Feb 2018 17:48:32 +0000 (01:48 +0800)]
UBUNTU: SAUCE: LIB: Introduce a generic PIO mapping method

BugLink: https://bugs.launchpad.net/bugs/1677319
In commit 41f8bba7f555 ("of/pci: Add pci_register_io_range() and
pci_pio_to_address()"), a new I/O space management was supported. With
that driver, the I/O ranges configured for PCI/PCIe hosts on some
architectures can be mapped to logical PIO, converted easily between
CPU address and the corresponding logicial PIO. Based on this, PCI
I/O devices can be accessed in a memory read/write way through the
unified in/out accessors.

But on some archs/platforms, there are bus hosts which access I/O
peripherals with host-local I/O port addresses rather than memory
addresses after memory-mapped.

To support those devices, a more generic I/O mapping method is introduced
here. Through this patch, both the CPU addresses and the host-local port
can be mapped into the logical PIO space with different logical/fake PIOs.
After this, all the I/O accesses to either PCI MMIO devices or host-local
I/O peripherals can be unified into the existing I/O accessors defined in
asm-generic/io.h and be redirected to the right device-specific hooks
based on the input logical PIO.

Signed-off-by: Zhichang Yuan <yuanzhichang@hisilicon.com>
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
[ v14 submittal ]
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: [Config] CONFIG_INDIRECT_PIO=y
dann frazier [Fri, 2 Feb 2018 21:54:11 +0000 (14:54 -0700)]
UBUNTU: [Config] CONFIG_INDIRECT_PIO=y

BugLink: https://bugs.launchpad.net/bugs/1677319
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: [Config] Disable i386 retpoline check for next upload
Seth Forshee [Thu, 22 Feb 2018 20:39:46 +0000 (14:39 -0600)]
UBUNTU: [Config] Disable i386 retpoline check for next upload

A bug in retpoline-extract resulted in no tracker information for
the last upload, causing an error during final checks. Ignore the
retpoline checks on i386 for that abi.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoLinux 4.15.5
Greg Kroah-Hartman [Thu, 22 Feb 2018 14:40:12 +0000 (15:40 +0100)]
Linux 4.15.5

BugLink: http://bugs.launchpad.net/bugs/1751131
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agommc: sdhci-of-esdhc: fix the mmc error after sleep on ls1046ardb
yinbo.zhu [Fri, 1 Dec 2017 07:09:34 +0000 (15:09 +0800)]
mmc: sdhci-of-esdhc: fix the mmc error after sleep on ls1046ardb

BugLink: http://bugs.launchpad.net/bugs/1751131
commit f2bc600008bd6f7f5d0b6b56238d14f95cd454d2 upstream.

When system wakes up from sleep on ls1046ardb, the SD operation fails
with mmc error messages since ESDHC_TB_EN bit couldn't be cleaned by
eSDHC_SYSCTL[RSTA]. It's proper to clean this bit in esdhc_reset()
rather than in probe.

Signed-off-by: yinbo.zhu <yinbo.zhu@nxp.com>
Acked-by: Yangbo Lu <yangbo.lu@nxp.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agommc: sdhci-of-esdhc: fix eMMC couldn't work after kexec
yinbo.zhu [Wed, 8 Nov 2017 09:09:50 +0000 (17:09 +0800)]
mmc: sdhci-of-esdhc: fix eMMC couldn't work after kexec

BugLink: http://bugs.launchpad.net/bugs/1751131
commit 97618aca1440b5addc5c3d78659d3e176be23b80 upstream.

The bit eSDHC_TBCTL[TB_EN] couldn't be reset by eSDHC_SYSCTL[RSTA] which is
used to reset for all. The driver should make sure it's cleared before card
initialization, otherwise the initialization would fail.

Signed-off-by: yinbo.zhu <yinbo.zhu@nxp.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agomedia: r820t: fix r820t_write_reg for KASAN
Arnd Bergmann [Thu, 30 Nov 2017 11:08:05 +0000 (06:08 -0500)]
media: r820t: fix r820t_write_reg for KASAN

BugLink: http://bugs.launchpad.net/bugs/1751131
commit 16c3ada89cff9a8c2a0eea34ffa1aa20af3f6008 upstream.

With CONFIG_KASAN, we get an overly long stack frame due to inlining
the register access functions:

drivers/media/tuners/r820t.c: In function 'generic_set_freq.isra.7':
drivers/media/tuners/r820t.c:1334:1: error: the frame size of 2880 bytes is larger than 2048 bytes [-Werror=frame-larger-than=]

This is caused by a gcc bug that has now been fixed in gcc-8.
To work around the problem, we can pass the register data
through a local variable that older gcc versions can optimize
out as well.

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoARM: dts: Delete bogus reference to the charlcd
Linus Walleij [Tue, 2 Jan 2018 07:57:17 +0000 (08:57 +0100)]
ARM: dts: Delete bogus reference to the charlcd

BugLink: http://bugs.launchpad.net/bugs/1751131
commit 586b2a4befad88cd87b372a1cea01e58c6811ea9 upstream.

The EB MP board probably has a character LCD but the board manual does
not really state which IRQ it has assigned to this device. The invalid
assignment was a mistake by me during submission of the DTSI where I was
looking for the reference, didn't find it and didn't fill it in.

Delete this for now: it can probably be fixed but that requires access
to the actual board for some trial-and-error experiments.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoarm: dts: mt2701: Add reset-cells
Matthias Brugger [Fri, 1 Dec 2017 12:07:08 +0000 (13:07 +0100)]
arm: dts: mt2701: Add reset-cells

BugLink: http://bugs.launchpad.net/bugs/1751131
commit ae72e95b5e4ded145bfc6926ad9457b74e3af41a upstream.

The hifsys and ethsys needs the definition of the reset-cells
property. Fix this.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>