]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/log
mirror_ubuntu-bionic-kernel.git
6 years agoALSA: usb-audio: Fix parsing descriptor of UAC2 processing unit
Kirill Marinushkin [Mon, 19 Mar 2018 06:11:08 +0000 (07:11 +0100)]
ALSA: usb-audio: Fix parsing descriptor of UAC2 processing unit

BugLink: http://bugs.launchpad.net/bugs/1759655
commit a6618f4aedb2b60932d766bd82ae7ce866e842aa upstream.

Currently, the offsets in the UAC2 processing unit descriptor are
calculated incorrectly. It causes an issue when connecting the device which
provides such a feature:

~~~~
[84126.724420] usb 1-1.3.1: invalid Processing Unit descriptor (id 18)
~~~~

After this patch is applied, the UAC2 processing unit inits w/o this error.

Fixes: 23caaf19b11e ("ALSA: usb-mixer: Add support for Audio Class v2.0")
Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoiio: adc: meson-saradc: unlock on error in meson_sar_adc_lock()
Dan Carpenter [Thu, 8 Mar 2018 09:31:53 +0000 (12:31 +0300)]
iio: adc: meson-saradc: unlock on error in meson_sar_adc_lock()

BugLink: http://bugs.launchpad.net/bugs/1759655
commit 3c3e4b3a708a9d6451052e348981f37d2b3e92b0 upstream.

The meson_sar_adc_lock() function is not supposed to hold the
"indio_dev->mlock" on the error path.

Fixes: 3adbf3427330 ("iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoiio: st_pressure: st_accel: pass correct platform data to init
Michael Nosthoff [Fri, 9 Mar 2018 09:02:45 +0000 (10:02 +0100)]
iio: st_pressure: st_accel: pass correct platform data to init

BugLink: http://bugs.launchpad.net/bugs/1759655
commit 8b438686a001db64c21782d04ef68111e53c45d9 upstream.

Commit 7383d44b added a pointer pdata which get set to the default
platform_data when non was defined in the device. But it did not
pass this pointer to the st_sensors_init_sensor call but still
used the maybe uninitialized platform_data from dev.

This breaks initialization when no platform_data is given and
the optional st,drdy-int-pin devicetree option is not set.

This commit fixes this.

Cc: stable@vger.kernel.org
Fixes: 7383d44b ("iio: st_pressure: st_accel: Initialise sensor platform data properly")
Signed-off-by: Michael Nosthoff <committed@heine.so>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoiio: chemical: ccs811: Corrected firmware boot/application mode transition
Richard Lai [Sat, 17 Feb 2018 16:28:24 +0000 (16:28 +0000)]
iio: chemical: ccs811: Corrected firmware boot/application mode transition

BugLink: http://bugs.launchpad.net/bugs/1759655
commit b91e146c38b003c899710ede6d05fc824675e386 upstream.

CCS811 has different I2C register maps in boot and application mode. When
CCS811 is in boot mode, register APP_START (0xF4) is used to transit the
firmware state from boot to application mode. However, APP_START is not a
valid register location when CCS811 is in application mode (refer to
"CCS811 Bootloader Register Map" and "CCS811 Application Register Map" in
CCS811 datasheet). The driver should not attempt to perform a write to
APP_START while CCS811 is in application mode, as this is not a valid or
documented register location.

When prob function is being called, the driver assumes the CCS811 sensor
is in boot mode, and attempts to perform a write to APP_START. Although
CCS811 powers-up in boot mode, it may have already been transited to
application mode by previous instances, e.g. unload and reload device
driver by the system, or explicitly by user. Depending on the system
design, CCS811 sensor may be permanently connected to system power source
rather than power controlled by GPIO, hence it is possible that the sensor
is never power reset, thus the firmware could be in either boot or
application mode at any given time when driver prob function is being
called.

This patch checks the STATUS register before attempting to send a write to
APP_START. Only if the firmware is not in application mode and has valid
firmware application loaded, then it will continue to start transiting the
firmware boot to application mode.

Signed-off-by: Richard Lai <richard@richardman.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoMIPS: lantiq: ase: Enable MFD_SYSCON
Mathias Kresin [Fri, 16 Mar 2018 20:27:30 +0000 (21:27 +0100)]
MIPS: lantiq: ase: Enable MFD_SYSCON

BugLink: http://bugs.launchpad.net/bugs/1759655
commit a821328c2f3003b908880792d71b2781b44fa53c upstream.

Enable syscon to use it for the RCU MFD on Amazon SE as well.

The Amazon SE also has similar reset controller system as Danube and
XWAY and use their drivers mostly. As these drivers now need syscon also
activate the syscon subsystem for for Amazon SE.

Fixes: 2b6639d4c794 ("MIPS: lantiq: Enable MFD_SYSCON to be able to use it for the RCU MFD")
Signed-off-by: Mathias Kresin <dev@kresin.me>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: John Crispin <john@phrozen.org>
Cc: linux-mips@linux-mips.org
Cc: <stable@vger.kernel.org> # 4.14+
Patchwork: https://patchwork.linux-mips.org/patch/18817/
Signed-off-by: James Hogan <jhogan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoMIPS: lantiq: Enable AHB Bus for USB
Mathias Kresin [Fri, 16 Mar 2018 20:27:29 +0000 (21:27 +0100)]
MIPS: lantiq: Enable AHB Bus for USB

BugLink: http://bugs.launchpad.net/bugs/1759655
commit 3223a5a7d3a606dcb7d9190a788b9544a45441ee upstream.

On Danube and AR9 the USB core is connected though a AHB bus to the main
system cross bar, hence we need to enable the gating clock of the AHB
Bus as well to make the USB controller work.

Fixes: dea54fbad332 ("phy: Add an USB PHY driver for the Lantiq SoCs using the RCU module")
Signed-off-by: Mathias Kresin <dev@kresin.me>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: John Crispin <john@phrozen.org>
Cc: linux-mips@linux-mips.org
Cc: <stable@vger.kernel.org> # 4.14+
Patchwork: https://patchwork.linux-mips.org/patch/18814/
Signed-off-by: James Hogan <jhogan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoMIPS: lantiq: Fix Danube USB clock
Mathias Kresin [Fri, 16 Mar 2018 20:27:28 +0000 (21:27 +0100)]
MIPS: lantiq: Fix Danube USB clock

BugLink: http://bugs.launchpad.net/bugs/1759655
commit 214cbc14734958fe533916fdb4194f5983ad4bc4 upstream.

On Danube the USB0 controller registers are at 1e101000 and the USB0 PHY
register is at 1f203018 similar to all other lantiq SoCs. Activate the
USB controller gating clock thorough the USB controller driver and not
the PHY.

This fixes a problem introduced in a previous commit.

Fixes: dea54fbad332 ("phy: Add an USB PHY driver for the Lantiq SoCs using the RCU module")
Signed-off-by: Mathias Kresin <dev@kresin.me>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: John Crispin <john@phrozen.org>
Cc: linux-mips@linux-mips.org
Cc: <stable@vger.kernel.org> # 4.14+
Patchwork: https://patchwork.linux-mips.org/patch/18816/
Signed-off-by: James Hogan <jhogan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoMIPS: ralink: Fix booting on MT7621
NeilBrown [Wed, 21 Mar 2018 03:02:10 +0000 (14:02 +1100)]
MIPS: ralink: Fix booting on MT7621

BugLink: http://bugs.launchpad.net/bugs/1759655
commit a63d706ea719190a79a6c769e898f70680044d3e upstream.

Since commit 3af5a67c86a3 ("MIPS: Fix early CM probing") the MT7621 has
not been able to boot.

This commit caused mips_cm_probe() to be called before
mt7621.c::proc_soc_init().

prom_soc_init() has a comment explaining that mips_cm_probe() "wipes out
the bootloader config" and means that configuration registers are no
longer available. It has some code to re-enable this config.

Before this re-enable code is run, the sysc register cannot be read, so
when SYSC_REG_CHIP_NAME0 is read, a garbage value is returned and
panic() is called.

If we move the config-repair code to the top of prom_soc_init(), the
registers can be read and boot can proceed.

Very occasionally, the first register read after the reconfiguration
returns garbage, so add a call to __sync().

Fixes: 3af5a67c86a3 ("MIPS: Fix early CM probing")
Signed-off-by: NeilBrown <neil@brown.name>
Reviewed-by: Matt Redfearn <matt.redfearn@mips.com>
Cc: John Crispin <john@phrozen.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: <stable@vger.kernel.org> # 4.5+
Patchwork: https://patchwork.linux-mips.org/patch/18859/
Signed-off-by: James Hogan <jhogan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoMIPS: ralink: Remove ralink_halt()
NeilBrown [Tue, 20 Mar 2018 08:29:51 +0000 (19:29 +1100)]
MIPS: ralink: Remove ralink_halt()

BugLink: http://bugs.launchpad.net/bugs/1759655
commit 891731f6a5dbe508d12443175a7e166a2fba616a upstream.

ralink_halt() does nothing that machine_halt() doesn't already do, so it
adds no value.

It actually causes incorrect behaviour due to the "unreachable()" at the
end. This tells the compiler that the end of the function will never be
reached, which isn't true. The compiler responds by not adding a
'return' instruction, so control simply moves on to whatever bytes come
afterwards in memory. In my tested, that was the ralink_restart()
function. This means that an attempt to 'halt' the machine would
actually cause a reboot.

So remove ralink_halt() so that a 'halt' really does halt.

Fixes: c06e836ada59 ("MIPS: ralink: adds reset code")
Signed-off-by: NeilBrown <neil@brown.name>
Cc: John Crispin <john@phrozen.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: <stable@vger.kernel.org> # 3.9+
Patchwork: https://patchwork.linux-mips.org/patch/18851/
Signed-off-by: James Hogan <jhogan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agothunderbolt: Add support for Intel Titan Ridge
Radion Mirchevsky [Wed, 28 Mar 2018 12:31:26 +0000 (20:31 +0800)]
thunderbolt: Add support for Intel Titan Ridge

BugLink: http://bugs.launchpad.net/bugs/1730775
Intel Titan Ridge is the next Thunderbolt 3 controller. The ICM firmware
message format in Titan Ridge differs from Falcon Ridge and Alpine Ridge
somewhat because it is using route strings addressing devices. In
addition to that the DMA port of 4-channel (two port) controller is in
different port number than the previous controllers. There are some
other minor differences as well.

This patch add support for Intel Titan Ridge and the new ICM firmware
message format.

Signed-off-by: Radion Mirchevsky <radion.mirchevsky@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
(cherry picked from commit 4bac471da0d6bab6094c42cf82e08280f361fd31 linux-next)
Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agothunderbolt: Introduce USB only (SL4) security level
Mika Westerberg [Wed, 28 Mar 2018 12:31:25 +0000 (20:31 +0800)]
thunderbolt: Introduce USB only (SL4) security level

BugLink: http://bugs.launchpad.net/bugs/1730775
This new security level works so that it creates one PCIe tunnel to the
connected Thunderbolt dock, removing PCIe links downstream of the dock.
This leaves only the internal USB controller visible.

Display Port tunnels are created normally.

While there make sure security sysfs attribute returns "unknown" for any
future security level.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
(cherry picked from commit 6fc14e1a44e53c472865252b47398346a27d600e linux-next)
Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoDocumentation/admin-guide: fixes for thunderbolt.rst
Randy Dunlap [Wed, 28 Mar 2018 12:31:24 +0000 (20:31 +0800)]
Documentation/admin-guide: fixes for thunderbolt.rst

BugLink: http://bugs.launchpad.net/bugs/1730775
Edits for grammar, punctuation, and a doubled-up word.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Andreas Noever <andreas.noever@gmail.com>
Cc: Michael Jamet <michael.jamet@intel.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Yehezkel Bernat <yehezkel.bernat@intel.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
(cherry picked from commit 54e36a2dc554685463af54b4ac97a5ec022bd09c)
Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agothunderbolt: Add support for preboot ACL
Mika Westerberg [Wed, 28 Mar 2018 12:31:23 +0000 (20:31 +0800)]
thunderbolt: Add support for preboot ACL

BugLink: http://bugs.launchpad.net/bugs/1730775
Preboot ACL is a mechanism that allows connecting Thunderbolt devices
boot time in more secure way than the legacy Thunderbolt boot support.
As with the legacy boot option, this also needs to be enabled from the
BIOS before booting is allowed. Difference to the legacy mode is that
the userspace software explicitly adds device UUIDs by sending a special
message to the ICM firmware. Only the devices listed in the boot ACL are
connected automatically during the boot. This works in both "user" and
"secure" security levels.

We implement this in Linux by exposing a new sysfs attribute (boot_acl)
below each Thunderbolt domain. The userspace software can then update
the full list as needed.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
(cherry picked from commit 9aaa3b8b4c56d24210acef37b7c800ca218c3d40 linux-next)
Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agothunderbolt: Add 'boot' attribute for devices
Yehezkel Bernat [Wed, 28 Mar 2018 12:31:22 +0000 (20:31 +0800)]
thunderbolt: Add 'boot' attribute for devices

BugLink: http://bugs.launchpad.net/bugs/1730775
In various cases, Thunderbolt device can be connected by ICM on boot
without waiting for approval from user. Most cases are related to
OEM-specific BIOS configurations. This information is interesting for
user-space as if the device isn't in SW ACL, it may create a friction in
the user experience where the device is automatically authorized if it's
connected on boot but requires an explicit user action if connected
after OS is up. User-space can use this information to suggest adding
the device to SW ACL for auto-authorization on later connections.

Signed-off-by: Yehezkel Bernat <yehezkel.bernat@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
(cherry picked from commit 14862ee308bbcaae0ac9927b6cbccccb51386b6c linux-next)
Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agothunderbolt: Move driver ready handling to struct icm
Mika Westerberg [Wed, 28 Mar 2018 12:31:21 +0000 (20:31 +0800)]
thunderbolt: Move driver ready handling to struct icm

BugLink: http://bugs.launchpad.net/bugs/1730775
Intel Titan Ridge uses slightly different format for ICM driver ready
response, so add a new ->driver_ready() callback to struct icm and move
the existing handling to a separate function which we then use in Falcon
Ridge and Alpine Ridge.

No functional changes intended.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
(cherry picked from commit 3080e197e936ab7cdcf66cacec22abe5c6c1007a linux-next)
Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agothunderbolt: Add constant for approval timeout
Mika Westerberg [Wed, 28 Mar 2018 12:31:20 +0000 (20:31 +0800)]
thunderbolt: Add constant for approval timeout

BugLink: http://bugs.launchpad.net/bugs/1730775
We will be using this from Titan Ridge support code as well so make it
constant.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
(cherry picked from commit 0b0a0bd06ee031b0e439a11a1b15573d9845b4be linux-next)
Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agothunderbolt: Add tb_xdomain_find_by_route()
Radion Mirchevsky [Wed, 28 Mar 2018 12:31:19 +0000 (20:31 +0800)]
thunderbolt: Add tb_xdomain_find_by_route()

BugLink: http://bugs.launchpad.net/bugs/1730775
This is needed by the new ICM interface to find xdomains by route string
instead of link and depth.

While there update existing tb_xdomain_find_* functions to use
tb_xdomain_get() instead of open-coding the same.

Signed-off-by: Radion Mirchevsky <radion.mirchevsky@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
(cherry picked from commit 484cb153fe5ffcd0b7cf423cf29aaeadd0e862b1 linux-next)
Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agothunderbolt: Add tb_switch_find_by_route()
Radion Mirchevsky [Wed, 28 Mar 2018 12:31:18 +0000 (20:31 +0800)]
thunderbolt: Add tb_switch_find_by_route()

BugLink: http://bugs.launchpad.net/bugs/1730775
With the new ICM messaging there is need for find switch by route string
instead of link and depth. Add new function that makes it possible.

Signed-off-by: Radion Mirchevsky <radion.mirchevsky@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
(cherry picked from commit 8e9267bb3559065fddecf344cb54501704fcb68e linux-next)
Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agothunderbolt: Add tb_switch_get()
Mika Westerberg [Wed, 28 Mar 2018 12:31:17 +0000 (20:31 +0800)]
thunderbolt: Add tb_switch_get()

BugLink: http://bugs.launchpad.net/bugs/1730775
Sometimes there is need for increasing reference count of a switch as
well. This also follows what we have for xdomains.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
(cherry picked from commit b6b0ea70f4254139e204870937cdb24d88dfac68 linux-next)
Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agothunderbolt: Correct function name in kernel-doc comment
Radion Mirchevsky [Wed, 28 Mar 2018 12:31:16 +0000 (20:31 +0800)]
thunderbolt: Correct function name in kernel-doc comment

BugLink: http://bugs.launchpad.net/bugs/1730775
Use correct name in kernel-doc of tb_switch_find_by_uuid().

Signed-off-by: Radion Mirchevsky <radion.mirchevsky@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
(cherry picked from commit 432019d644878dbefd8ec2482cb01ec68b8722b9 linux-next)
Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agothunderbolt: Factor common ICM add and update operations out
Mika Westerberg [Wed, 28 Mar 2018 12:31:15 +0000 (20:31 +0800)]
thunderbolt: Factor common ICM add and update operations out

BugLink: http://bugs.launchpad.net/bugs/1730775
The newer ICM will not use link and depth to address devices. Instead it
uses route strings. In order to take advantage of the existing code
factor out common operations so that we can use the same functions with
the new ICM as well.

No functional changes intended.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
(cherry picked from commit ee487dd2447a43dd318bd7ba2c54e59e707ad851 linux-next)
Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agothunderbolt: Handle rejected Thunderbolt devices
Mika Westerberg [Wed, 28 Mar 2018 12:31:14 +0000 (20:31 +0800)]
thunderbolt: Handle rejected Thunderbolt devices

BugLink: http://bugs.launchpad.net/bugs/1730775
The ICM firmware rejects devices if the maximum topology limit is
exceeded (more than 6 devices are connected). If that happens just log a
message to the kernel message buffer and bail out.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
(cherry picked from commit cb653eecde3dc37c67d3e7297ac5445d16f7be13 linux-next)
Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agothunderbolt: Wait a bit longer for ICM to authenticate the active NVM
Mika Westerberg [Wed, 28 Mar 2018 12:31:13 +0000 (20:31 +0800)]
thunderbolt: Wait a bit longer for ICM to authenticate the active NVM

BugLink: http://bugs.launchpad.net/bugs/1730775
Sometimes during cold boot ICM has not yet authenticated the active NVM
image leading to timeout and failing the driver probe. Allow ICM to take
some more time and increase the timeout to 3 seconds before we give up.

While there fix icm_firmware_init() to return the real error code
without overwriting it with -ENODEV.

Fixes: f67cf491175a ("thunderbolt: Add support for Internal Connection Manager (ICM)")
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: stable@vger.kernel.org
(cherry picked from commit e4be8c9b6a512e274cb6bbac4ac869d73880a8b3 linux-next)
Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agothunderbolt: Wait a bit longer for root switch config space
Mika Westerberg [Wed, 28 Mar 2018 12:31:12 +0000 (20:31 +0800)]
thunderbolt: Wait a bit longer for root switch config space

BugLink: http://bugs.launchpad.net/bugs/1730775
In some case reading root switch config space takes longer than what we
are currently waiting in the driver resulting timeout and failure.
Increase number of retries to allow some more time for the root switch
config space to become accesssible.

Also log an error if the timeout is exceeded so we know why the driver
probe failed.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
(cherry picked from commit 44b51bbb16d033ac1984123349ec055bae09b623 linux-next)
Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agothunderbolt: Do not overwrite error code when domain adding fails
Mika Westerberg [Wed, 28 Mar 2018 12:31:11 +0000 (20:31 +0800)]
thunderbolt: Do not overwrite error code when domain adding fails

BugLink: http://bugs.launchpad.net/bugs/1730775
If the Thunderbolt domain adding fails for some reason we currently
always return -EIO instead of the real error code. To make debugging
easier return the actual error code instead.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
(cherry picked from commit 68a7a2ace13156b8a3d8cd6cceab6c30b52e2923 linux-next)
Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agothunderbolt: Handle connecting device in place of host properly
Mika Westerberg [Wed, 28 Mar 2018 12:31:10 +0000 (20:31 +0800)]
thunderbolt: Handle connecting device in place of host properly

BugLink: http://bugs.launchpad.net/bugs/1730775
If the system is suspended and user disconnects cable to another host
and connects it to a Thunderbolt device instead we get a warning from
driver core about adding duplicate sysfs attribute and adding the new
device fails.

Handle this properly so that we first remove the existing XDomain
connection before adding new devices.

Fixes: d1ff70241a27 ("thunderbolt: Add support for XDomain discovery protocol")
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: stable@vger.kernel.org
(cherry picked from commit 79fae987518a3aa6c3c7b2e3ad5fe1e4080c12bc linux-next)
Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agothunderbolt: Serialize PCIe tunnel creation with PCI rescan
Mika Westerberg [Wed, 28 Mar 2018 12:31:09 +0000 (20:31 +0800)]
thunderbolt: Serialize PCIe tunnel creation with PCI rescan

BugLink: http://bugs.launchpad.net/bugs/1730775
We need to make sure a new PCIe tunnel is not created in a middle of
previous PCI rescan because otherwise the rescan code might find too
much and fail to reconfigure devices properly. This is important when
native PCIe hotplug is used. In BIOS assisted hotplug there should be no
such issue.

Fixes: f67cf491175a ("thunderbolt: Add support for Internal Connection Manager (ICM)")
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: stable@vger.kernel.org
(cherry picked from commit a03e828915c00ed0ea5aa40647c81472cfa7a984 linux-next)
Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agothunderbolt: Resume control channel after hibernation image is created
Mika Westerberg [Wed, 28 Mar 2018 12:31:08 +0000 (20:31 +0800)]
thunderbolt: Resume control channel after hibernation image is created

BugLink: http://bugs.launchpad.net/bugs/1730775
The driver misses implementation of PM hook that undoes what
->freeze_noirq() does after the hibernation image is created. This means
the control channel is not resumed properly and the Thunderbolt bus
becomes useless in later stages of hibernation (when the image is stored
or if the operation fails).

Fix this by pointing ->thaw_noirq to driver nhi_resume_noirq(). This
makes sure the control channel is resumed properly.

Fixes: 23dd5bb49d98 ("thunderbolt: Add suspend/hibernate support")
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: stable@vger.kernel.org
(cherry picked from commit f2a659f7d8d5da803836583aa16df06bdf324252 linux-next)
Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoath10k: update the IRAM bank number for QCA9377
Ryan Hsu [Wed, 28 Mar 2018 02:44:32 +0000 (10:44 +0800)]
ath10k: update the IRAM bank number for QCA9377

BugLink: https://bugs.launchpad.net/bugs/1748345
Preparation for a new QCA9377 firmware release. The new firmware release
requires more IRAM banks, hence update that on ath10k.

The IRAM banks promotion won't break any backwards compatibility, as those IRAM
banks were not getting used in previous firmware releases.

Signed-off-by: Ryan Hsu <ryanhsu@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
(cherry picked from commit fc8b92635f79cfc4dd3015384bebafada0b08f19 linux-next)
Signed-off-by: AceLan Kao <acelan.kao@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agonfp: forbid disabling hw-tc-offload on representors while offload active
Jakub Kicinski [Thu, 8 Feb 2018 04:55:24 +0000 (20:55 -0800)]
nfp: forbid disabling hw-tc-offload on representors while offload active

BugLink: http://bugs.launchpad.net/bugs/1752828
All netdevs which can accept TC offloads must implement
.ndo_set_features().  nfp_reprs currently do not do that, which
means hw-tc-offload can be turned on and off even when offloads
are active.

Whether the offloads are active is really a question to nfp_ports,
so remove the per-app tc_busy callback indirection thing, and
simply count the number of offloaded items in nfp_port structure.

Fixes: 8a2768732a4d ("nfp: provide infrastructure for offloading flower based TC filters")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Tested-by: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(back-ported from commit d692403e5cf8008f31f5664a6f3ce3e65d54f458)
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agonfp: don't advertise hw-tc-offload on non-port netdevs
Jakub Kicinski [Thu, 8 Feb 2018 04:55:23 +0000 (20:55 -0800)]
nfp: don't advertise hw-tc-offload on non-port netdevs

BugLink: http://bugs.launchpad.net/bugs/1752828
nfp_port is a structure which represents an ASIC port, both
PCIe vNIC (on a PF or a VF) or the external MAC port.  vNIC
netdev (struct nfp_net) and pure representor netdev (struct
nfp_repr) both have a pointer to this structure.  nfp_reprs
always have a port associated.  nfp_nets, however, only represent
a device port in legacy mode, where they are considered the
MAC port. In switchdev mode they are just the CPU's side of
the PCIe link.

By definition TC offloads only apply to device ports.  Don't
set the flag on vNICs without a port (i.e. in switchdev mode).

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Tested-by: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 0b9de4ca853b6ba2c92ff0b4602281001b166639)
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agonfp: bpf: require ETH table
Jakub Kicinski [Thu, 8 Feb 2018 04:55:22 +0000 (20:55 -0800)]
nfp: bpf: require ETH table

BugLink: http://bugs.launchpad.net/bugs/1752828
Upcoming changes will require all netdevs supporting TC offloads
to have a full struct nfp_port.  Require those for BPF offload.
The operation without management FW reporting information about
Ethernet ports is something we only support for very old and very
basic NIC firmwares anyway.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Tested-by: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(back-ported from commit e3ac6c0737e2b17bf11210e3fd66565e9b818b87)
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoACPI / PM: Allow deeper wakeup power states with no _SxD nor _SxW
Daniel Drake [Wed, 28 Mar 2018 08:55:30 +0000 (16:55 +0800)]
ACPI / PM: Allow deeper wakeup power states with no _SxD nor _SxW

BugLink: https://bugs.launchpad.net/bugs/1759511
acpi_dev_pm_get_state() is used to determine the range of allowable
device power states when going into S3 suspend. This is implemented
by executing the _S3D and _S3W ACPI methods.

Linux follows the ACPI spec behaviour in that when _S3D is implemented
and _S3W is not, Linux will not go into a power state deeper than the one
returned by _S3D for a wakeup-enabled device.

However, this same logic is being applied to the case when neither
_S3D nor _S3W are present, and the result is that this function
decides that the device must stay in D0 (fully on) state.

This is breaking USB wakeups on Asus V222GA and Acer XC-830. _S3D and
_S3W are not present, so the USB controller is left in the D0 running
state during S3, and hence it is unable to generate a PME# wake event.

The ACPI spec is unclear on which power states are permissable for
wakeup-enabled devices when both _S3D and _S3W are missing.
However, USB wakeups work fine on these platforms under Windows, where
device manager shows that they are using D3 device state for the USB
controller in S3.

I assume that the "max = min" clamping done by the code here is
specifically written for the _S3D but no _S3W case. By making the
code true to those conditions, avoiding them on these platforms,
the controller will be put into D3 state and USB wakeups start working.

Additionally I feel that this change makes the code more directly
mirror the wording of the ACPI spec and it's associated lack of clarity.

Thanks to Mathias Nyman for pointing us in the right direction.

Signed-off-by: Daniel Drake <drake@endlessm.com>
Link: http://lkml.kernel.org/r/CAB4CAwf_k-WsF3zL4epm9TKAOu0h=Bv1XhXV_gY3bziOo_NPKA@mail.gmail.com
https://phabricator.endlessm.com/T21410
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit bf8c6184e0c3d4d5e005e085e9f96f478a267b20 git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next)
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Hui Wang<hui.wang@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: [Config] retpoine -- switch to new format
Andy Whitcroft [Mon, 26 Mar 2018 07:49:49 +0000 (08:49 +0100)]
UBUNTU: [Config] retpoine -- switch to new format

BugLink: http://bugs.launchpad.net/bugs/1758856
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: vga_set_mode -- avoid jump tables
Andy Whitcroft [Wed, 21 Mar 2018 09:49:40 +0000 (09:49 +0000)]
UBUNTU: SAUCE: vga_set_mode -- avoid jump tables

BugLink: http://bugs.launchpad.net/bugs/1758856
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: early/late -- annotate indirect calls in early/late initialisation...
Andy Whitcroft [Tue, 20 Mar 2018 12:50:00 +0000 (12:50 +0000)]
UBUNTU: SAUCE: early/late -- annotate indirect calls in early/late initialisation code

BugLink: http://bugs.launchpad.net/bugs/1758856
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: EFI -- annotate indirect calls within firmware_restrict_branch_specula...
Andy Whitcroft [Tue, 20 Mar 2018 12:23:48 +0000 (12:23 +0000)]
UBUNTU: SAUCE: EFI -- annotate indirect calls within firmware_restrict_branch_speculation_{start,end}

BugLink: http://bugs.launchpad.net/bugs/1758856
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: apm -- annotate indirect calls within firmware_restrict_branch_specula...
Andy Whitcroft [Tue, 20 Mar 2018 12:19:52 +0000 (12:19 +0000)]
UBUNTU: SAUCE: apm -- annotate indirect calls within firmware_restrict_branch_speculation_{start,end}

BugLink: http://bugs.launchpad.net/bugs/1758856
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: [Packaging] retpoline -- clear hint information from packages
Andy Whitcroft [Mon, 26 Mar 2018 09:51:17 +0000 (10:51 +0100)]
UBUNTU: [Packaging] retpoline -- clear hint information from packages

BugLink: http://bugs.launchpad.net/bugs/1758856
Signed-off-by: Andy Whitcroft <apw@canonical.com>
[ saf: Use 'rm -f' to prevent error if no hint files present ]
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: [Packaging] retpoline -- elide %rip relative indirections
Andy Whitcroft [Sun, 25 Mar 2018 10:05:54 +0000 (11:05 +0100)]
UBUNTU: [Packaging] retpoline -- elide %rip relative indirections

BugLink: http://bugs.launchpad.net/bugs/1758856
These are always safe because there is no way rip can be an unknown.

Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: [Packaging] retpoline -- widen indirect call/jmp detection
Andy Whitcroft [Fri, 23 Mar 2018 11:11:18 +0000 (11:11 +0000)]
UBUNTU: [Packaging] retpoline -- widen indirect call/jmp detection

BugLink: http://bugs.launchpad.net/bugs/1758856
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: [Packaging] retpoline-check -- only report additions
Andy Whitcroft [Tue, 20 Mar 2018 12:36:54 +0000 (12:36 +0000)]
UBUNTU: [Packaging] retpoline-check -- only report additions

BugLink: http://bugs.launchpad.net/bugs/1758856
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: [Packaging] retpoline -- add safe usage hint support
Andy Whitcroft [Thu, 8 Mar 2018 15:48:31 +0000 (15:48 +0000)]
UBUNTU: [Packaging] retpoline -- add safe usage hint support

BugLink: http://bugs.launchpad.net/bugs/1758856
Use the upstream retpoline safe hinting support to clear out known
safe retpoline sequences from those detected.  At the same time
switch to extracting the indirect sequences and associated hints
to .o generation time.  This allows it to be run on the cache hot
data and to be run in parallel on the builders.

Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: Fix non-prefaulted page deadlock (LP: #1754584)
Colin Ian King [Wed, 28 Mar 2018 10:19:25 +0000 (11:19 +0100)]
UBUNTU: SAUCE: Fix non-prefaulted page deadlock (LP: #1754584)

BugLink: https://bugs.launchpad.net/bugs/1754584
Fix mmap'd libaio read on non-prefaulted page deadlock. This is a hot fix
from ZFS upstream that ensure pages do not deadlock and replaces the original
fix as it is a far better solution.

Performing a read with the target data in a mmap'd page that is map'd into
the same blocks that are being read causes a lock on the page and a further
lock on the same page when the page is being faulted in, causing deadlock.

This is an improved fix from the original fix which ensures the pages don't
deadlock and removes the original potentially racy pre-faulting fix

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoRevert "UBUNTU: SAUCE: Fix non-prefaulted page deadlock (LP: #1754584)"
Colin Ian King [Wed, 28 Mar 2018 10:19:24 +0000 (11:19 +0100)]
Revert "UBUNTU: SAUCE: Fix non-prefaulted page deadlock (LP: #1754584)"

BugLink: https://bugs.launchpad.net/bugs/1754584
Remove original hotfix to replace it with an improved fix

This reverts commit bc0adba16e0600a898435fa22c803f15e3caa866.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoKVM: PPC: Book3S HV: Fix duplication of host SLB entries
Paul Mackerras [Wed, 21 Mar 2018 22:48:54 +0000 (09:48 +1100)]
KVM: PPC: Book3S HV: Fix duplication of host SLB entries

BugLink: http://bugs.launchpad.net/bugs/1759045
Since commit 6964e6a4e489 ("KVM: PPC: Book3S HV: Do SLB load/unload
with guest LPCR value loaded", 2018-01-11), we have been seeing
occasional machine check interrupts on POWER8 systems when running
KVM guests, due to SLB multihit errors.

This turns out to be due to the guest exit code reloading the host
SLB entries from the SLB shadow buffer when the SLB was not previously
cleared in the guest entry path.  This can happen because the path
which skips from the guest entry code to the guest exit code without
entering the guest now does the skip before the SLB is cleared and
loaded with guest values, but the host values are loaded after the
point in the guest exit path that we skip to.

To fix this, we move the code that reloads the host SLB values up
so that it occurs just before the point in the guest exit code (the
label guest_bypass:) where we skip to from the guest entry path.

Reported-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Fixes: 6964e6a4e489 ("KVM: PPC: Book3S HV: Do SLB load/unload with guest LPCR value loaded")
Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
(cherry picked from commit cda4a14733138b8f15b0b69d97ec198dc41eccae linux-next)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoKVM: PPC: Book3S HV: Fix trap number return from __kvmppc_vcore_entry
Paul Mackerras [Wed, 7 Mar 2018 11:17:20 +0000 (22:17 +1100)]
KVM: PPC: Book3S HV: Fix trap number return from __kvmppc_vcore_entry

BugLink: http://bugs.launchpad.net/bugs/1759045
This fixes a bug where the trap number that is returned by
__kvmppc_vcore_entry gets corrupted.  The effect of the corruption
is that IPIs get ignored on POWER9 systems when the IPI is sent via
a doorbell interrupt to a CPU which is executing in a KVM guest.
The effect of the IPI being ignored is often that another CPU locks
up inside smp_call_function_many() (and if that CPU is holding a
spinlock, other CPUs then lock up inside raw_spin_lock()).

The trap number is currently held in register r12 for most of the
assembly-language part of the guest exit path.  In that path, we
call kvmppc_subcore_exit_guest(), which is a C function, without
restoring r12 afterwards.  Depending on the kernel config and the
compiler, it may modify r12 or it may not, so some config/compiler
combinations see the bug and others don't.

To fix this, we arrange for the trap number to be stored on the
stack from the 'guest_bypass:' label until the end of the function,
then the trap number is loaded and returned in r12 as before.

Cc: stable@vger.kernel.org # v4.8+
Fixes: fd7bacbca47a ("KVM: PPC: Book3S HV: Fix TB corruption in guest exit path on HMI interrupt")
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
(cherry picked from commit a8b48a4dccea77e29462e59f1dbf0d5aa1ff167c)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoKVM: PPC: Book3S: Fix compile error that occurs with some gcc versions
Paul Mackerras [Tue, 13 Feb 2018 04:45:21 +0000 (15:45 +1100)]
KVM: PPC: Book3S: Fix compile error that occurs with some gcc versions

BugLink: http://bugs.launchpad.net/bugs/1759045
Some versions of gcc generate a warning that the variable "emulated"
may be used uninitialized in function kvmppc_handle_load128_by2x64().
It would be used uninitialized if kvmppc_handle_load128_by2x64 was
ever called with vcpu->arch.mmio_vmx_copy_nums == 0, but neither of
the callers ever do that, so there is no actual bug.  When gcc
generates a warning, it causes the build to fail because arch/powerpc
is compiled with -Werror.

This silences the warning by initializing "emulated" to EMULATE_DONE.

Fixes: 09f984961c13 ("KVM: PPC: Book3S: Add MMIO emulation for VMX instructions")
Reported-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
(cherry picked from commit 6df3877fc962c2bb3d0438633dfd24a185af6838)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoKVM: PPC: Book3S: Add MMIO emulation for VMX instructions
Jose Ricardo Ziviani [Sat, 3 Feb 2018 20:24:26 +0000 (18:24 -0200)]
KVM: PPC: Book3S: Add MMIO emulation for VMX instructions

BugLink: http://bugs.launchpad.net/bugs/1759045
This patch provides the MMIO load/store vector indexed
X-Form emulation.

Instructions implemented:
lvx: the quadword in storage addressed by the result of EA &
0xffff_ffff_ffff_fff0 is loaded into VRT.

stvx: the contents of VRS are stored into the quadword in storage
addressed by the result of EA & 0xffff_ffff_ffff_fff0.

Reported-by: Gopesh Kumar Chaudhary <gopchaud@in.ibm.com>
Reported-by: Balamuruhan S <bala24@linux.vnet.ibm.com>
Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
(cherry picked from commit 09f984961c137c4b252c368adab7e1c9f035fa59)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoKVM: PPC: Book3S HV: Make HPT resizing work on POWER9
David Gibson [Fri, 2 Feb 2018 03:29:08 +0000 (14:29 +1100)]
KVM: PPC: Book3S HV: Make HPT resizing work on POWER9

BugLink: http://bugs.launchpad.net/bugs/1759045
This adds code to enable the HPT resizing code to work on POWER9,
which uses a slightly modified HPT entry format compared to POWER8.
On POWER9, we convert HPTEs read from the HPT from the new format to
the old format so that the rest of the HPT resizing code can work as
before.  HPTEs written to the new HPT are converted to the new format
as the last step before writing them into the new HPT.

This takes out the checks added by commit bcd3bb63dbc8 ("KVM: PPC:
Book3S HV: Disable HPT resizing on POWER9 for now", 2017-02-18),
now that HPT resizing works on POWER9.

On POWER9, when we pivot to the new HPT, we now call
kvmppc_setup_partition_table() to update the partition table in order
to make the hardware use the new HPT.

[paulus@ozlabs.org - added kvmppc_setup_partition_table() call,
 wrote commit message.]

Tested-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
(cherry picked from commit 790a9df5fbef982f2a6992194fe497dd2b794a3d)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoKVM: PPC: Book3S HV: Fix handling of secondary HPTEG in HPT resizing code
Paul Mackerras [Wed, 7 Feb 2018 08:49:54 +0000 (19:49 +1100)]
KVM: PPC: Book3S HV: Fix handling of secondary HPTEG in HPT resizing code

BugLink: http://bugs.launchpad.net/bugs/1759045
This fixes the computation of the HPTE index to use when the HPT
resizing code encounters a bolted HPTE which is stored in its
secondary HPTE group.  The code inverts the HPTE group number, which
is correct, but doesn't then mask it with new_hash_mask.  As a result,
new_pteg will be effectively negative, resulting in new_hptep
pointing before the new HPT, which will corrupt memory.

In addition, this removes two BUG_ON statements.  The condition that
the BUG_ONs were testing -- that we have computed the hash value
incorrectly -- has never been observed in testing, and if it did
occur, would only affect the guest, not the host.  Given that
BUG_ON should only be used in conditions where the kernel (i.e.
the host kernel, in this case) can't possibly continue execution,
it is not appropriate here.

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
(cherry picked from commit 05f2bb0313a2855e491dadfc8319b7da261d7074)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoKVM: PPC: Book3S HV: Do SLB load/unload with guest LPCR value loaded
Paul Mackerras [Thu, 11 Jan 2018 03:51:02 +0000 (14:51 +1100)]
KVM: PPC: Book3S HV: Do SLB load/unload with guest LPCR value loaded

BugLink: http://bugs.launchpad.net/bugs/1759045
This moves the code that loads and unloads the guest SLB values so that
it is done while the guest LPCR value is loaded in the LPCR register.
The reason for doing this is that on POWER9, the behaviour of the
slbmte instruction depends on the LPCR[UPRT] bit.  If UPRT is 1, as
it is for a radix host (or guest), the SLB index is truncated to
2 bits.  This means that for a HPT guest on a radix host, the SLB
was not being loaded correctly, causing the guest to crash.

The SLB is now loaded much later in the guest entry path, after the
LPCR is loaded, which for a secondary thread is after it sees that
the primary thread has switched the MMU to the guest.  The loop that
waits for the primary thread has a branch out to the exit code that
is taken if it sees that other threads have commenced exiting the
guest.  Since we have now not loaded the SLB at this point, we make
this path branch to a new label 'guest_bypass' and we move the SLB
unload code to before this label.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
(cherry picked from commit 6964e6a4e4894c707e42d51d9d30683c57f43201)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: crypto: thunderx_zip: Fix fallout from CONFIG_VMAP_STACK
Jan Glauber [Tue, 27 Mar 2018 10:31:53 +0000 (12:31 +0200)]
UBUNTU: SAUCE: crypto: thunderx_zip: Fix fallout from CONFIG_VMAP_STACK

BugLink: http://bugs.launchpad.net/bugs/1755073
Enabling virtual mapped kernel stacks breaks the thunderx_zip
driver. On compression or decompression the executing CPU hangs
in an endless loop. The reason for this is the usage of __pa()
by the driver that does not work for an address that is
not part of the 1:1 mapping.

The zip driver allocates a result struct on the stack and needs
to tell the hardware the pysical address within this struct
that is used to signal the completion of the request.
With CONFIG_VMAP_STACK __pa() is no longer usable for a stack address.

As the hardware gets the wrong address it writes the result byte
to an arbitrary address. The zip driver then waits forever for the
completion byte to contain a non-zero value.

Allocating the result struct from 1:1 mapped memory resolves this
bug.

Note that there are more outstanding issues with the used completion
mechanism:
- volatile is used for a bitfield
- no barriers at all re used
- the completion loop should have a retry counter and not run forever
- polling for the result should use a delay
- interrupts for completion and error notification should be used

Signed-off-by: Jan Glauber <jglauber@cavium.com>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
6 years agoocxl: Add get_metadata IOCTL to share OCXL information to userspace
Alastair D'Silva [Thu, 22 Feb 2018 04:17:38 +0000 (15:17 +1100)]
ocxl: Add get_metadata IOCTL to share OCXL information to userspace

BugLink: http://bugs.launchpad.net/bugs/1755161
Some required information is not exposed to userspace currently (eg. the
PASID), pass this information back, along with other information which
is currently communicated via sysfs, which saves some parsing effort in
userspace.

Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Acked-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit 07c5ccd70ad702e561fcda8e4df494f098a42742)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoocxl: Fix potential bad errno on irq allocation
Frederic Barrat [Fri, 16 Feb 2018 13:01:18 +0000 (14:01 +0100)]
ocxl: Fix potential bad errno on irq allocation

BugLink: http://bugs.launchpad.net/bugs/1755161
Fix some issues found by a static checker:

When allocating an AFU interrupt, if the driver cannot copy the output
parameters to userland, the errno value was not set to EFAULT

Remove a (now) useless cast.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
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 423688abd9ab654044bddd82eb5983189eb9630d)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoocxl: fix signed comparison with less than zero
Colin Ian King [Tue, 30 Jan 2018 15:11:44 +0000 (15:11 +0000)]
ocxl: fix signed comparison with less than zero

BugLink: http://bugs.launchpad.net/bugs/1755161
Currently the comparison of used < 0 is always false because
uses is a size_t. Fix this by making used a ssize_t type.

Detected by Coccinelle:
drivers/misc/ocxl/file.c:320:6-10: WARNING: Unsigned expression
compared with zero: used < 0

Fixes: 5ef3166e8a32 ("ocxl: Driver code for 'generic' opencapi devices")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Acked-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit dedab7f0d3137441a97fe7cf9b9ca5dbd20ca9a5)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Enable OCXL operations
Uma Krishnan [Wed, 14 Feb 2018 00:16:13 +0000 (18:16 -0600)]
UBUNTU: SAUCE: cxlflash: Enable OCXL operations

BugLink: http://bugs.launchpad.net/bugs/1752672
This commit enables the OCXL operations for the OCXL devices.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Support AFU reset
Uma Krishnan [Tue, 20 Feb 2018 21:24:37 +0000 (15:24 -0600)]
UBUNTU: SAUCE: cxlflash: Support AFU reset

BugLink: http://bugs.launchpad.net/bugs/1752672
The cxlflash core driver resets the AFU when the master contexts are
created in the initialization or recovery paths. Today, the OCXL
provider service to perform this operation is pending implementation.
To avoid a crash due to a missing fop, log an error once and return
success to continue with execution.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Register for translation errors
Uma Krishnan [Tue, 13 Feb 2018 23:25:18 +0000 (17:25 -0600)]
UBUNTU: SAUCE: cxlflash: Register for translation errors

BugLink: http://bugs.launchpad.net/bugs/1752672
While enabling a context on the link, a predefined callback can be
registered with the OCXL provider services to be notified on translation
errors. These errors can in turn be passed back to the user on a read
operation.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Introduce OCXL context state machine
Uma Krishnan [Tue, 13 Feb 2018 22:38:17 +0000 (16:38 -0600)]
UBUNTU: SAUCE: cxlflash: Introduce OCXL context state machine

BugLink: http://bugs.launchpad.net/bugs/1752672
In order to protect the OCXL hardware contexts from getting clobbered,
a simple state machine is added to indicate when a context is in open,
close or start state. The expected states are validated throughout the
code to prevent illegal operations on a context. A mutex is added to
protect writes to the context state field.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Update synchronous interrupt status bits
Uma Krishnan [Mon, 12 Feb 2018 18:10:18 +0000 (12:10 -0600)]
UBUNTU: SAUCE: cxlflash: Update synchronous interrupt status bits

BugLink: http://bugs.launchpad.net/bugs/1752672
The SISLite specification has been updated to define new synchronous
interrupt status bits. These bits are set by the AFU when a given PASID or
EA is bad and a synchronous interrupt is triggered.

The SISLite header file is updated to support these new bits. Note that
there are also some formatting updates to some of the existing bits to
allow all of the definitions to line up uniformly.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Setup LISNs for master contexts
Uma Krishnan [Wed, 14 Feb 2018 00:03:10 +0000 (18:03 -0600)]
UBUNTU: SAUCE: cxlflash: Setup LISNs for master contexts

BugLink: http://bugs.launchpad.net/bugs/1752672
Similar to user contexts, master contexts also require that the per-context
LISN registers be programmed for certain AFUs. The mapped trigger page is
obtained from underlying transport and registered with AFU for each master
context.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Setup LISNs for user contexts
Uma Krishnan [Fri, 2 Feb 2018 10:08:42 +0000 (04:08 -0600)]
UBUNTU: SAUCE: cxlflash: Setup LISNs for user contexts

BugLink: http://bugs.launchpad.net/bugs/1752672
The SISLite specification has been updated for OCXL to support
communicating data to generate AFU interrupts to the AFU. This includes
a new capability bit that is advertised for OCXL AFUs and new registers
to hold the object handle and translation PASID of each interrupt. For
Power, the object handle is the mapped trigger page. Note that because
these mappings are kernel only, the PASID of a kernel context must be
used to satisfy the translation.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Introduce object handle fop
Uma Krishnan [Fri, 2 Feb 2018 07:18:21 +0000 (01:18 -0600)]
UBUNTU: SAUCE: cxlflash: Introduce object handle fop

BugLink: http://bugs.launchpad.net/bugs/1752672
OCXL requires that AFUs use an opaque object handle to represent
an AFU interrupt. The specification does not provide a common means
to communicate the object handle to the AFU - each AFU must define
this within the AFU specification. To support this model, the object
handle must be passed back to the core driver as it manages the AFU
specification (SISLite) for cxlflash. Note that for Power systems,
the object handle is the effective address of the trigger page.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Support file descriptor mapping
Uma Krishnan [Mon, 20 Nov 2017 21:43:14 +0000 (15:43 -0600)]
UBUNTU: SAUCE: cxlflash: Support file descriptor mapping

BugLink: http://bugs.launchpad.net/bugs/1752672
The cxlflash core fop API requires a way to invoke the fault and release
handlers of underlying transports using their native file-based APIs. This
provides the core with the ability to insert selectively itself into the
processing stream of these operations for cleanup. Implement these two
fops to map and release when requested.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Support adapter context mmap and release
Uma Krishnan [Mon, 29 Jan 2018 19:24:04 +0000 (13:24 -0600)]
UBUNTU: SAUCE: cxlflash: Support adapter context mmap and release

BugLink: http://bugs.launchpad.net/bugs/1752672
The cxlflash userspace API requires that users be able to mmap and release
the adapter context. Support mapping by implementing the AFU mmap fop to
map the context MMIO space and install the corresponding page table entry
upon page fault. Similarly, implement the AFU release fop to terminate and
clean up the context when invoked.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Support adapter context reading
Uma Krishnan [Tue, 23 Jan 2018 20:20:06 +0000 (14:20 -0600)]
UBUNTU: SAUCE: cxlflash: Support adapter context reading

BugLink: http://bugs.launchpad.net/bugs/1752672
The cxlflash userspace API requires that users be able to read the adapter
context for any pending events or interrupts from the AFU. Support reading
various events by implementing the AFU read fop to copy out event data.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Support adapter context polling
Uma Krishnan [Tue, 23 Jan 2018 19:44:27 +0000 (13:44 -0600)]
UBUNTU: SAUCE: cxlflash: Support adapter context polling

BugLink: http://bugs.launchpad.net/bugs/1752672
The cxlflash userspace API requires that users be able to poll the adapter
context for any pending events or interrupts from the AFU. Support polling
on various events by implementing the AFU poll fop using a waitqueue.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Support starting user contexts
Uma Krishnan [Thu, 18 Jan 2018 20:31:11 +0000 (14:31 -0600)]
UBUNTU: SAUCE: cxlflash: Support starting user contexts

BugLink: http://bugs.launchpad.net/bugs/1752672
User contexts request interrupts and are started using the "start work"
interface. Populate the start_work() fop to allocate and map interrupts
before starting the user context. As part of starting the context, update
the user process identification logic to properly derive the data required
by the SPA. Also, introduce a skeleton interrupt handler using a bitmap,
flag, and spinlock to track interrupts. This handler will be expanded in
future commits.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Support AFU interrupt mapping and registration
Uma Krishnan [Wed, 20 Dec 2017 19:32:03 +0000 (13:32 -0600)]
UBUNTU: SAUCE: cxlflash: Support AFU interrupt mapping and registration

BugLink: http://bugs.launchpad.net/bugs/1752672
Add support to map and unmap the irq space and manage irq registrations
with the kernel for each allocated AFU interrupt. Also support mapping
the physical trigger page to obtain an effective address that will be
provided to the cxlflash core in a future commit.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Support AFU interrupt management
Uma Krishnan [Wed, 20 Dec 2017 05:32:40 +0000 (23:32 -0600)]
UBUNTU: SAUCE: cxlflash: Support AFU interrupt management

BugLink: http://bugs.launchpad.net/bugs/1752672
Add support to allocate and free AFU interrupts using the OCXL provider
services. The trigger page returned upon successful allocation will be
mapped and exposed to the cxlflash core in a future commit.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Support process element lifecycle
Uma Krishnan [Fri, 17 Nov 2017 22:03:24 +0000 (16:03 -0600)]
UBUNTU: SAUCE: cxlflash: Support process element lifecycle

BugLink: http://bugs.launchpad.net/bugs/1752672
As part of the context lifecycle, the associated process element within
the Shared Process Area (SPA) of the link must be updated. Each process
is defined by various parameters (pid, tid, PASID mm) that are stored in
the SPA upon starting a context and invalidated when a context is stopped.

Use the OCXL provider services to configure the SPA with the appropriate
data that is unique to the process when starting a context. Initially only
kernel contexts are supported and therefore these process values are not
applicable. Note that the OCXL service used has an optional callback for
translation fault error notification. While not used here, it will be
expanded in a future commit.

Also add a service to stop a context by terminating the corresponding
PASID and remove the process element from the SPA.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Setup OCXL transaction layer
Uma Krishnan [Thu, 16 Nov 2017 21:18:17 +0000 (15:18 -0600)]
UBUNTU: SAUCE: cxlflash: Setup OCXL transaction layer

BugLink: http://bugs.launchpad.net/bugs/1752672
The first function of the link needs to configure the transaction layer
between the host and device. This is accomplished by a call to the OCXL
provider services.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Setup function OCXL link
Uma Krishnan [Thu, 16 Nov 2017 21:13:24 +0000 (15:13 -0600)]
UBUNTU: SAUCE: cxlflash: Setup function OCXL link

BugLink: http://bugs.launchpad.net/bugs/1752672
After reading and modifying the function configuration, setup the OCXL
link using the OCXL provider services. The link is released when the
adapter is unconfigured.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Support reading adapter VPD data
Uma Krishnan [Tue, 14 Nov 2017 19:45:00 +0000 (13:45 -0600)]
UBUNTU: SAUCE: cxlflash: Support reading adapter VPD data

BugLink: http://bugs.launchpad.net/bugs/1752672
Use the PCI VPD services to support reading the VPD data of the
underlying adapter.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Support AFU state toggling
Uma Krishnan [Tue, 14 Nov 2017 19:13:06 +0000 (13:13 -0600)]
UBUNTU: SAUCE: cxlflash: Support AFU state toggling

BugLink: http://bugs.launchpad.net/bugs/1752672
The AFU should be enabled following a successful configuration and
disabled near the end of the cleanup path.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Support process specific mappings
Uma Krishnan [Mon, 13 Nov 2017 22:20:53 +0000 (16:20 -0600)]
UBUNTU: SAUCE: cxlflash: Support process specific mappings

BugLink: http://bugs.launchpad.net/bugs/1752672
Once the context is started, the assigned MMIO space can be mapped
and unmapped. Provide means to map and unmap the context MMIO space.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Support starting an adapter context
Uma Krishnan [Mon, 13 Nov 2017 21:59:43 +0000 (15:59 -0600)]
UBUNTU: SAUCE: cxlflash: Support starting an adapter context

BugLink: http://bugs.launchpad.net/bugs/1752672
Once the adapter context is created, it needs to be started by assigning
the MMIO space for the context and by enabling the process element in the
link. This commit adds the skeleton for starting the context and assigns
the context specific MMIO space. Master contexts have access to the global
MMIO space while the rest have access to the context specific space.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: MMIO map the AFU
Uma Krishnan [Tue, 31 Oct 2017 19:30:35 +0000 (14:30 -0500)]
UBUNTU: SAUCE: cxlflash: MMIO map the AFU

BugLink: http://bugs.launchpad.net/bugs/1752672
When the AFU is configured, the global and per process MMIO regions
are presented by the configuration space. Save these regions and
map the global MMIO region that is used to access all of the control
and provisioning data in the AFU.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Support image reload policy modification
Uma Krishnan [Tue, 24 Oct 2017 19:32:41 +0000 (14:32 -0500)]
UBUNTU: SAUCE: cxlflash: Support image reload policy modification

BugLink: http://bugs.launchpad.net/bugs/1752672
On a PERST, the AFU image can be reloaded or left intact. Provide means to
set this image reload policy.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Support adapter context discovery
Uma Krishnan [Mon, 30 Oct 2017 20:45:55 +0000 (15:45 -0500)]
UBUNTU: SAUCE: cxlflash: Support adapter context discovery

BugLink: http://bugs.launchpad.net/bugs/1752672
Provide means to obtain the process element of an adapter context as well
as locate an adapter context by file.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Support adapter file descriptors for OCXL
Uma Krishnan [Mon, 30 Oct 2017 18:37:38 +0000 (13:37 -0500)]
UBUNTU: SAUCE: cxlflash: Support adapter file descriptors for OCXL

BugLink: http://bugs.launchpad.net/bugs/1752672
Allocate a file descriptor for an adapter context when requested. In order
to allocate inodes for the file descriptors, a pseudo filesystem is created
and used.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Use IDR to manage adapter contexts
Uma Krishnan [Thu, 26 Oct 2017 19:35:21 +0000 (14:35 -0500)]
UBUNTU: SAUCE: cxlflash: Use IDR to manage adapter contexts

BugLink: http://bugs.launchpad.net/bugs/1752672
A range of PASIDs are used as identifiers for the adapter contexts. These
contexts may be destroyed and created randomly. Use an IDR to keep track
of contexts that are in use and assign a unique identifier to new ones.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Adapter context support for OCXL
Uma Krishnan [Thu, 26 Oct 2017 17:41:19 +0000 (12:41 -0500)]
UBUNTU: SAUCE: cxlflash: Adapter context support for OCXL

BugLink: http://bugs.launchpad.net/bugs/1752672
Add support to create and release the adapter contexts for OCXL and
provide means to specify certain contexts as a master.

The existing cxlflash core has a design requirement that each host will
have a single host context available by default. To satisfy this
requirement, one host adapter context is created when the hardware AFU is
initialized. This is returned by the get_context() fop.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Setup AFU PASID
Uma Krishnan [Tue, 7 Nov 2017 20:04:36 +0000 (14:04 -0600)]
UBUNTU: SAUCE: cxlflash: Setup AFU PASID

BugLink: http://bugs.launchpad.net/bugs/1752672
Per the OCXL specification, the maximum PASID supported by the AFU is
indicated by a field within the configuration space. Similar to acTags,
implementations can choose to use any sub-range of PASID within their
assigned range. For cxlflash, the entire range is used.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Setup AFU acTag range
Uma Krishnan [Tue, 7 Nov 2017 19:40:55 +0000 (13:40 -0600)]
UBUNTU: SAUCE: cxlflash: Setup AFU acTag range

BugLink: http://bugs.launchpad.net/bugs/1752672
The OCXL specification supports distributing acTags amongst different
AFUs and functions on the link. As cxlflash devices are expected to only
support a single AFU and function, the entire range that was assigned to
the function is also assigned to the AFU.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Read host AFU configuration
Uma Krishnan [Tue, 7 Nov 2017 18:01:19 +0000 (12:01 -0600)]
UBUNTU: SAUCE: cxlflash: Read host AFU configuration

BugLink: http://bugs.launchpad.net/bugs/1752672
The host AFU configuration is read on the initialization path to identify
the features and configuration of the AFU. This data is cached for use in
later configuration steps.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Setup function acTag range
Uma Krishnan [Tue, 7 Nov 2017 17:05:40 +0000 (11:05 -0600)]
UBUNTU: SAUCE: cxlflash: Setup function acTag range

BugLink: http://bugs.launchpad.net/bugs/1752672
The OCXL specification supports distributing acTags amongst different
AFUs and functions on the link. The platform-specific acTag range for the
link is obtained using the OCXL provider services and then assigned to the
host function based on implementation. For cxlflash devices only a single
function per host is expected and thus the entire range is assigned.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Read host function configuration
Uma Krishnan [Tue, 31 Oct 2017 19:12:43 +0000 (14:12 -0500)]
UBUNTU: SAUCE: cxlflash: Read host function configuration

BugLink: http://bugs.launchpad.net/bugs/1752672
Per the OCXL specification, the underlying host can have multiple AFUs
per function with each function supporting its own configuration. The host
function configuration is read on the initialization path to evaluate the
number of functions present and identify the features and configuration of
the functions present. This data is cached for use in later configuration
steps. Note that for the OCXL hardware supported by the cxlflash driver,
only one AFU per function is expected.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Hardware AFU for OCXL
Uma Krishnan [Tue, 24 Oct 2017 19:04:29 +0000 (14:04 -0500)]
UBUNTU: SAUCE: cxlflash: Hardware AFU for OCXL

BugLink: http://bugs.launchpad.net/bugs/1752672
When an adapter is initialized, transport specific configuration and MMIO
mapping details need to be saved. For CXL, this data is managed by the
underlying kernel module. To maintain a separation between the cxlflash
core and underlying transports, introduce a new structure to store data
specific to the OCXL AFU.

Initially only the pointers to underlying PCI and generic devices are
added to this new structure - it will be expanded further in future
commits. Services to create and destroy this hardware AFU are added and
integrated in the probe and exit paths of the driver.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Introduce OCXL backend
Uma Krishnan [Tue, 17 Oct 2017 20:11:03 +0000 (15:11 -0500)]
UBUNTU: SAUCE: cxlflash: Introduce OCXL backend

BugLink: http://bugs.launchpad.net/bugs/1752672
Add initial infrastructure to support a new cxlflash transport, OCXL.

Claim a dependency on OCXL and add a new file, ocxl_hw.c, which will host
the backend routines that are specific to OCXL.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Add argument identifier names
Uma Krishnan [Mon, 12 Feb 2018 21:56:37 +0000 (15:56 -0600)]
UBUNTU: SAUCE: cxlflash: Add argument identifier names

BugLink: http://bugs.launchpad.net/bugs/1752672
Checkpatch throws a warning when the argument identifier names are not
included in the function definitions.

To avoid these warnings, argument identifiers are added in the existing
function definitions.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Avoid clobbering context control register value
Matthew R. Ochs [Mon, 12 Feb 2018 06:25:09 +0000 (00:25 -0600)]
UBUNTU: SAUCE: cxlflash: Avoid clobbering context control register value

BugLink: http://bugs.launchpad.net/bugs/1752672
The SISLite specification originally defined the context control
register with a single field of bits to represent the LISN and
also stipulated that the register reset value be 0. The cxlflash
driver took advantage of this when programming the LISN for the
master contexts via an unconditional write - no other bits were
preserved.

When unmap support was added, SISLite was updated to define bit
0 of the context control register as a way for the AFU to notify
the context owner that unmap operations were supported. Thus the
assumptions under which the register is setup changed and the
existing unconditional write is clobbering the unmap state for
master contexts. This is presently not an issue due to the order
in which the context control register is programmed in relation to
the unmap bit being queried but should be addressed to avoid a
future regression in the event this code is moved elsewhere.

To remedy this issue, preserve the bits when programming the LISN
field in the context control register. Since the LISN will now be
programmed using a read value, assert that the initial state of the
LISN field is as described in SISLite (0).

Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoUBUNTU: SAUCE: cxlflash: Preserve number of interrupts for master contexts
Uma Krishnan [Tue, 20 Feb 2018 01:27:04 +0000 (19:27 -0600)]
UBUNTU: SAUCE: cxlflash: Preserve number of interrupts for master contexts

BugLink: http://bugs.launchpad.net/bugs/1752672
The number of interrupts requested for user contexts are stored in the
context specific structures and utilized to manage the interrupts. For the
master contexts, this number is only used once and therefore not saved.

To prepare for future commits where the number of interrupts will be
required in more than one place, preserve the value in the master context
structure.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: cxlflash: Staging to support future accelerators
Matthew R. Ochs [Wed, 3 Jan 2018 22:55:26 +0000 (16:55 -0600)]
scsi: cxlflash: Staging to support future accelerators

BugLink: http://bugs.launchpad.net/bugs/1752672
As staging to support future accelerator transports, add a shim layer
such that the underlying services the cxlflash driver requires can be
conditional upon the accelerator infrastructure.

Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 25b8e08e83b5bc58967aae566730548f407c0439)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: cxlflash: Adapter context init can return error
Uma Krishnan [Wed, 3 Jan 2018 22:55:04 +0000 (16:55 -0600)]
scsi: cxlflash: Adapter context init can return error

BugLink: http://bugs.launchpad.net/bugs/1752672
Adapter context creation can return either NULL or an error pointer.
Updating the check condition to reflect this.

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 commit 0df69c6024cd089144d3b38f12352899dd4e40b1)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: cxlflash: Remove embedded CXL work structures
Matthew R. Ochs [Wed, 3 Jan 2018 22:54:50 +0000 (16:54 -0600)]
scsi: cxlflash: Remove embedded CXL work structures

BugLink: http://bugs.launchpad.net/bugs/1752672
The CXL-specific work structure used to request the number of interrupts
currently resides as a nested member of both the context information and
hardware queue structures. It is used to cache values (specifically the
number of interrupts) required by the CXL layer when starting a context.

To facilitate staging that will ultimately allow the cxlflash core to
become agnostic of the underlying accelerator transport, remove these
embedded work structures.

Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 8762353106c4376deabd76473e1bd7ba36dd529c)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: cxlflash: Explicitly cache number of interrupts per context
Matthew R. Ochs [Wed, 3 Jan 2018 22:54:37 +0000 (16:54 -0600)]
scsi: cxlflash: Explicitly cache number of interrupts per context

BugLink: http://bugs.launchpad.net/bugs/1752672
The number of interrupts a user requests during a context attach is
presently stored within the CXL work ioctl structure that is nested
alongside the per context metadata. Keeping this data in a structure
that is tied to a particular hardware implementation (CXL) will only
complicate matters when supporting newer accelerator transports.

Instead of relying upon the number of interrupts being cached within
a CXL-specific structure, explicitly cache the value within the context
information structure.

Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit af2047ec00bfd61b46b653e856dcf1e0bc567619)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoscsi: cxlflash: Update cxl-specific arguments to generic cookie
Uma Krishnan [Wed, 3 Jan 2018 22:54:25 +0000 (16:54 -0600)]
scsi: cxlflash: Update cxl-specific arguments to generic cookie

BugLink: http://bugs.launchpad.net/bugs/1752672
Convert cxl-specific pointers to generic cookies to facilitate future
enhancements.

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 commit b070545db112e4c815fbfce25449495eff20c170)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
6 years agoplatform/x86: intel_pmc_core: Special case for Coffeelake
Rajneesh Bhardwaj [Fri, 2 Feb 2018 13:43:37 +0000 (19:13 +0530)]
platform/x86: intel_pmc_core: Special case for Coffeelake

BugLink: http://bugs.launchpad.net/bugs/1730770
Intel CoffeeLake SoC uses CPU ID of KabyLake but has Cannonlake PCH, so in
this case PMC register details from Cannonlake PCH must be used.

In order to identify whether the given platform is Coffeelake, scan for the
Sunrisepoint PMC PCI Id.

 KBL CPUID SPT PCIID
------------------------------------
KBL | Y | Y   |
------------------------------------
CFL | Y | N   |
------------------------------------

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
(cherry picked from commit 661405bd817b209ac9bd4812c63d90873a7f2993)
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>