]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Feb 2018 14:26:59 +0000 (15:26 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Feb 2018 14:26:59 +0000 (15:26 +0100)
added patches:
ahci-add-intel-cannon-lake-pch-h-pci-id.patch
ahci-add-pci-ids-for-intel-bay-trail-cherry-trail-and-apollo-lake-ahci.patch
ahci-allow-setting-a-default-lpm-policy-for-mobile-chipsets.patch
ahci-annotate-pci-ids-for-mobile-intel-chipsets-as-such.patch
kernfs-fix-regression-in-kernfs_fop_write-caused-by-wrong-type.patch
mtd-cfi-convert-inline-functions-to-macros.patch
mtd-nand-brcmnand-disable-prefetch-by-default.patch
mtd-nand-fix-nand_do_read_oob-return-value.patch
mtd-nand-sunxi-fix-ecc-strength-choice.patch
nfs-add-a-cond_resched-to-nfs_commit_release_pages.patch
nfs-commit-direct-writes-even-if-they-fail-partially.patch
nfs-pnfs-fix-nfs_direct_req-ref-leak-when-i-o-falls-back-to-the-mds.patch
nfs-reject-request-for-id_legacy-key-without-auxdata.patch
ubi-block-fix-locking-for-idr_alloc-idr_remove.patch

15 files changed:
queue-4.4/ahci-add-intel-cannon-lake-pch-h-pci-id.patch [new file with mode: 0644]
queue-4.4/ahci-add-pci-ids-for-intel-bay-trail-cherry-trail-and-apollo-lake-ahci.patch [new file with mode: 0644]
queue-4.4/ahci-allow-setting-a-default-lpm-policy-for-mobile-chipsets.patch [new file with mode: 0644]
queue-4.4/ahci-annotate-pci-ids-for-mobile-intel-chipsets-as-such.patch [new file with mode: 0644]
queue-4.4/kernfs-fix-regression-in-kernfs_fop_write-caused-by-wrong-type.patch [new file with mode: 0644]
queue-4.4/mtd-cfi-convert-inline-functions-to-macros.patch [new file with mode: 0644]
queue-4.4/mtd-nand-brcmnand-disable-prefetch-by-default.patch [new file with mode: 0644]
queue-4.4/mtd-nand-fix-nand_do_read_oob-return-value.patch [new file with mode: 0644]
queue-4.4/mtd-nand-sunxi-fix-ecc-strength-choice.patch [new file with mode: 0644]
queue-4.4/nfs-add-a-cond_resched-to-nfs_commit_release_pages.patch [new file with mode: 0644]
queue-4.4/nfs-commit-direct-writes-even-if-they-fail-partially.patch [new file with mode: 0644]
queue-4.4/nfs-pnfs-fix-nfs_direct_req-ref-leak-when-i-o-falls-back-to-the-mds.patch [new file with mode: 0644]
queue-4.4/nfs-reject-request-for-id_legacy-key-without-auxdata.patch [new file with mode: 0644]
queue-4.4/series
queue-4.4/ubi-block-fix-locking-for-idr_alloc-idr_remove.patch [new file with mode: 0644]

diff --git a/queue-4.4/ahci-add-intel-cannon-lake-pch-h-pci-id.patch b/queue-4.4/ahci-add-intel-cannon-lake-pch-h-pci-id.patch
new file mode 100644 (file)
index 0000000..4038e57
--- /dev/null
@@ -0,0 +1,29 @@
+From f919dde0772a894c693a1eeabc77df69d6a9b937 Mon Sep 17 00:00:00 2001
+From: Mika Westerberg <mika.westerberg@linux.intel.com>
+Date: Thu, 11 Jan 2018 15:55:50 +0300
+Subject: ahci: Add Intel Cannon Lake PCH-H PCI ID
+
+From: Mika Westerberg <mika.westerberg@linux.intel.com>
+
+commit f919dde0772a894c693a1eeabc77df69d6a9b937 upstream.
+
+Add Intel Cannon Lake PCH-H PCI ID to the list of supported controllers.
+
+Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
+Signed-off-by: Tejun Heo <tj@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/ata/ahci.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/ata/ahci.c
++++ b/drivers/ata/ahci.c
+@@ -390,6 +390,7 @@ static const struct pci_device_id ahci_p
+       { PCI_VDEVICE(INTEL, 0xa20e), board_ahci }, /* Lewisburg RAID*/
+       { PCI_VDEVICE(INTEL, 0xa252), board_ahci }, /* Lewisburg RAID*/
+       { PCI_VDEVICE(INTEL, 0xa256), board_ahci }, /* Lewisburg RAID*/
++      { PCI_VDEVICE(INTEL, 0xa356), board_ahci }, /* Cannon Lake PCH-H RAID */
+       { PCI_VDEVICE(INTEL, 0x0f22), board_ahci_mobile }, /* Bay Trail AHCI */
+       { PCI_VDEVICE(INTEL, 0x0f23), board_ahci_mobile }, /* Bay Trail AHCI */
+       { PCI_VDEVICE(INTEL, 0x22a3), board_ahci_mobile }, /* Cherry Tr. AHCI */
diff --git a/queue-4.4/ahci-add-pci-ids-for-intel-bay-trail-cherry-trail-and-apollo-lake-ahci.patch b/queue-4.4/ahci-add-pci-ids-for-intel-bay-trail-cherry-trail-and-apollo-lake-ahci.patch
new file mode 100644 (file)
index 0000000..82922ef
--- /dev/null
@@ -0,0 +1,34 @@
+From 998008b779e424bd7513c434d0ab9c1268459009 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Wed, 6 Dec 2017 16:41:09 +0100
+Subject: ahci: Add PCI ids for Intel Bay Trail, Cherry Trail and Apollo Lake AHCI
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+commit 998008b779e424bd7513c434d0ab9c1268459009 upstream.
+
+Add PCI ids for Intel Bay Trail, Cherry Trail and Apollo Lake AHCI
+SATA controllers. This commit is a preparation patch for allowing a
+different default sata link powermanagement policy for mobile chipsets.
+
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: Tejun Heo <tj@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/ata/ahci.c |    4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/drivers/ata/ahci.c
++++ b/drivers/ata/ahci.c
+@@ -382,6 +382,10 @@ static const struct pci_device_id ahci_p
+       { PCI_VDEVICE(INTEL, 0xa20e), board_ahci }, /* Lewisburg RAID*/
+       { PCI_VDEVICE(INTEL, 0xa252), board_ahci }, /* Lewisburg RAID*/
+       { PCI_VDEVICE(INTEL, 0xa256), board_ahci }, /* Lewisburg RAID*/
++      { PCI_VDEVICE(INTEL, 0x0f22), board_ahci }, /* Bay Trail AHCI */
++      { PCI_VDEVICE(INTEL, 0x0f23), board_ahci }, /* Bay Trail AHCI */
++      { PCI_VDEVICE(INTEL, 0x22a3), board_ahci }, /* Cherry Trail AHCI */
++      { PCI_VDEVICE(INTEL, 0x5ae3), board_ahci }, /* Apollo Lake AHCI */
+       /* JMicron 360/1/3/5/6, match class to avoid IDE function */
+       { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
diff --git a/queue-4.4/ahci-allow-setting-a-default-lpm-policy-for-mobile-chipsets.patch b/queue-4.4/ahci-allow-setting-a-default-lpm-policy-for-mobile-chipsets.patch
new file mode 100644 (file)
index 0000000..516b5e5
--- /dev/null
@@ -0,0 +1,268 @@
+From ebb82e3c79d2a956366d0848304a53648bd6350b Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Mon, 11 Dec 2017 17:52:16 +0100
+Subject: ahci: Allow setting a default LPM policy for mobile chipsets
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+commit ebb82e3c79d2a956366d0848304a53648bd6350b upstream.
+
+On many laptops setting a different LPM policy then unknown /
+max_performance can lead to power-savings of 1.0 - 1.5 Watts (when idle).
+
+Modern ultrabooks idle around 6W (at 50% screen brightness), 1.0 - 1.5W
+is a significant chunk of this.
+
+There are some performance / latency costs to enabling LPM by default,
+so it is desirable to make it possible to set a different LPM policy
+for mobile / laptop variants of chipsets / "South Bridges" vs their
+desktop / server counterparts. Also enabling LPM by default is not
+entirely without risk of regressions. At least min_power is known to
+cause issues with some disks, including some reports of data corruption.
+
+This commits adds a new ahci.mobile_lpm_policy kernel cmdline option,
+which defaults to a new SATA_MOBILE_LPM_POLICY Kconfig option so that
+Linux distributions can choose to set a LPM policy for mobile chipsets
+by default.
+
+The reason to have both a kernel cmdline option and a Kconfig default
+value for it, is to allow easy overriding of the default to allow
+trouble-shooting without needing to rebuild the kernel.
+
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: Tejun Heo <tj@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/ata/Kconfig |   19 ++++++++++
+ drivers/ata/ahci.c  |   97 ++++++++++++++++++++++++++++++----------------------
+ drivers/ata/ahci.h  |    3 +
+ 3 files changed, 78 insertions(+), 41 deletions(-)
+
+--- a/drivers/ata/Kconfig
++++ b/drivers/ata/Kconfig
+@@ -90,6 +90,25 @@ config SATA_AHCI
+         If unsure, say N.
++config SATA_MOBILE_LPM_POLICY
++      int "Default SATA Link Power Management policy for mobile chipsets"
++      range 0 4
++      default 0
++      depends on SATA_AHCI
++      help
++        Select the Default SATA Link Power Management (LPM) policy to use
++        for mobile / laptop variants of chipsets / "South Bridges".
++
++        The value set has the following meanings:
++              0 => Keep firmware settings
++              1 => Maximum performance
++              2 => Medium power
++              3 => Medium power with Device Initiated PM enabled
++              4 => Minimum power
++
++        Note "Minimum power" is known to cause issues, including disk
++        corruption, with some disks and should not be used.
++
+ config SATA_AHCI_PLATFORM
+       tristate "Platform AHCI SATA support"
+       help
+--- a/drivers/ata/ahci.c
++++ b/drivers/ata/ahci.c
+@@ -62,6 +62,7 @@ enum board_ids {
+       /* board IDs by feature in alphabetical order */
+       board_ahci,
+       board_ahci_ign_iferr,
++      board_ahci_mobile,
+       board_ahci_nomsi,
+       board_ahci_noncq,
+       board_ahci_nosntf,
+@@ -132,6 +133,13 @@ static const struct ata_port_info ahci_p
+               .udma_mask      = ATA_UDMA6,
+               .port_ops       = &ahci_ops,
+       },
++      [board_ahci_mobile] = {
++              AHCI_HFLAGS     (AHCI_HFLAG_IS_MOBILE),
++              .flags          = AHCI_FLAG_COMMON,
++              .pio_mask       = ATA_PIO4,
++              .udma_mask      = ATA_UDMA6,
++              .port_ops       = &ahci_ops,
++      },
+       [board_ahci_nomsi] = {
+               AHCI_HFLAGS     (AHCI_HFLAG_NO_MSI),
+               .flags          = AHCI_FLAG_COMMON,
+@@ -244,13 +252,13 @@ static const struct pci_device_id ahci_p
+       { PCI_VDEVICE(INTEL, 0x2924), board_ahci }, /* ICH9 */
+       { PCI_VDEVICE(INTEL, 0x2925), board_ahci }, /* ICH9 */
+       { PCI_VDEVICE(INTEL, 0x2927), board_ahci }, /* ICH9 */
+-      { PCI_VDEVICE(INTEL, 0x2929), board_ahci }, /* ICH9M */
+-      { PCI_VDEVICE(INTEL, 0x292a), board_ahci }, /* ICH9M */
+-      { PCI_VDEVICE(INTEL, 0x292b), board_ahci }, /* ICH9M */
+-      { PCI_VDEVICE(INTEL, 0x292c), board_ahci }, /* ICH9M */
+-      { PCI_VDEVICE(INTEL, 0x292f), board_ahci }, /* ICH9M */
++      { PCI_VDEVICE(INTEL, 0x2929), board_ahci_mobile }, /* ICH9M */
++      { PCI_VDEVICE(INTEL, 0x292a), board_ahci_mobile }, /* ICH9M */
++      { PCI_VDEVICE(INTEL, 0x292b), board_ahci_mobile }, /* ICH9M */
++      { PCI_VDEVICE(INTEL, 0x292c), board_ahci_mobile }, /* ICH9M */
++      { PCI_VDEVICE(INTEL, 0x292f), board_ahci_mobile }, /* ICH9M */
+       { PCI_VDEVICE(INTEL, 0x294d), board_ahci }, /* ICH9 */
+-      { PCI_VDEVICE(INTEL, 0x294e), board_ahci }, /* ICH9M */
++      { PCI_VDEVICE(INTEL, 0x294e), board_ahci_mobile }, /* ICH9M */
+       { PCI_VDEVICE(INTEL, 0x502a), board_ahci }, /* Tolapai */
+       { PCI_VDEVICE(INTEL, 0x502b), board_ahci }, /* Tolapai */
+       { PCI_VDEVICE(INTEL, 0x3a05), board_ahci }, /* ICH10 */
+@@ -260,9 +268,9 @@ static const struct pci_device_id ahci_p
+       { PCI_VDEVICE(INTEL, 0x3b23), board_ahci }, /* PCH AHCI */
+       { PCI_VDEVICE(INTEL, 0x3b24), board_ahci }, /* PCH RAID */
+       { PCI_VDEVICE(INTEL, 0x3b25), board_ahci }, /* PCH RAID */
+-      { PCI_VDEVICE(INTEL, 0x3b29), board_ahci }, /* PCH M AHCI */
++      { PCI_VDEVICE(INTEL, 0x3b29), board_ahci_mobile }, /* PCH M AHCI */
+       { PCI_VDEVICE(INTEL, 0x3b2b), board_ahci }, /* PCH RAID */
+-      { PCI_VDEVICE(INTEL, 0x3b2c), board_ahci }, /* PCH M RAID */
++      { PCI_VDEVICE(INTEL, 0x3b2c), board_ahci_mobile }, /* PCH M RAID */
+       { PCI_VDEVICE(INTEL, 0x3b2f), board_ahci }, /* PCH AHCI */
+       { PCI_VDEVICE(INTEL, 0x19b0), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19b1), board_ahci }, /* DNV AHCI */
+@@ -285,9 +293,9 @@ static const struct pci_device_id ahci_p
+       { PCI_VDEVICE(INTEL, 0x19cE), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19cF), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x1c02), board_ahci }, /* CPT AHCI */
+-      { PCI_VDEVICE(INTEL, 0x1c03), board_ahci }, /* CPT M AHCI */
++      { PCI_VDEVICE(INTEL, 0x1c03), board_ahci_mobile }, /* CPT M AHCI */
+       { PCI_VDEVICE(INTEL, 0x1c04), board_ahci }, /* CPT RAID */
+-      { PCI_VDEVICE(INTEL, 0x1c05), board_ahci }, /* CPT M RAID */
++      { PCI_VDEVICE(INTEL, 0x1c05), board_ahci_mobile }, /* CPT M RAID */
+       { PCI_VDEVICE(INTEL, 0x1c06), board_ahci }, /* CPT RAID */
+       { PCI_VDEVICE(INTEL, 0x1c07), board_ahci }, /* CPT RAID */
+       { PCI_VDEVICE(INTEL, 0x1d02), board_ahci }, /* PBG AHCI */
+@@ -296,28 +304,28 @@ static const struct pci_device_id ahci_p
+       { PCI_VDEVICE(INTEL, 0x2826), board_ahci }, /* PBG RAID */
+       { PCI_VDEVICE(INTEL, 0x2323), board_ahci }, /* DH89xxCC AHCI */
+       { PCI_VDEVICE(INTEL, 0x1e02), board_ahci }, /* Panther Point AHCI */
+-      { PCI_VDEVICE(INTEL, 0x1e03), board_ahci }, /* Panther Point M AHCI */
++      { PCI_VDEVICE(INTEL, 0x1e03), board_ahci_mobile }, /* Panther M AHCI */
+       { PCI_VDEVICE(INTEL, 0x1e04), board_ahci }, /* Panther Point RAID */
+       { PCI_VDEVICE(INTEL, 0x1e05), board_ahci }, /* Panther Point RAID */
+       { PCI_VDEVICE(INTEL, 0x1e06), board_ahci }, /* Panther Point RAID */
+-      { PCI_VDEVICE(INTEL, 0x1e07), board_ahci }, /* Panther Point M RAID */
++      { PCI_VDEVICE(INTEL, 0x1e07), board_ahci_mobile }, /* Panther M RAID */
+       { PCI_VDEVICE(INTEL, 0x1e0e), board_ahci }, /* Panther Point RAID */
+       { PCI_VDEVICE(INTEL, 0x8c02), board_ahci }, /* Lynx Point AHCI */
+-      { PCI_VDEVICE(INTEL, 0x8c03), board_ahci }, /* Lynx Point M AHCI */
++      { PCI_VDEVICE(INTEL, 0x8c03), board_ahci_mobile }, /* Lynx M AHCI */
+       { PCI_VDEVICE(INTEL, 0x8c04), board_ahci }, /* Lynx Point RAID */
+-      { PCI_VDEVICE(INTEL, 0x8c05), board_ahci }, /* Lynx Point M RAID */
++      { PCI_VDEVICE(INTEL, 0x8c05), board_ahci_mobile }, /* Lynx M RAID */
+       { PCI_VDEVICE(INTEL, 0x8c06), board_ahci }, /* Lynx Point RAID */
+-      { PCI_VDEVICE(INTEL, 0x8c07), board_ahci }, /* Lynx Point M RAID */
++      { PCI_VDEVICE(INTEL, 0x8c07), board_ahci_mobile }, /* Lynx M RAID */
+       { PCI_VDEVICE(INTEL, 0x8c0e), board_ahci }, /* Lynx Point RAID */
+-      { PCI_VDEVICE(INTEL, 0x8c0f), board_ahci }, /* Lynx Point M RAID */
+-      { PCI_VDEVICE(INTEL, 0x9c02), board_ahci }, /* Lynx Point-LP AHCI */
+-      { PCI_VDEVICE(INTEL, 0x9c03), board_ahci }, /* Lynx Point-LP AHCI */
+-      { PCI_VDEVICE(INTEL, 0x9c04), board_ahci }, /* Lynx Point-LP RAID */
+-      { PCI_VDEVICE(INTEL, 0x9c05), board_ahci }, /* Lynx Point-LP RAID */
+-      { PCI_VDEVICE(INTEL, 0x9c06), board_ahci }, /* Lynx Point-LP RAID */
+-      { PCI_VDEVICE(INTEL, 0x9c07), board_ahci }, /* Lynx Point-LP RAID */
+-      { PCI_VDEVICE(INTEL, 0x9c0e), board_ahci }, /* Lynx Point-LP RAID */
+-      { PCI_VDEVICE(INTEL, 0x9c0f), board_ahci }, /* Lynx Point-LP RAID */
++      { PCI_VDEVICE(INTEL, 0x8c0f), board_ahci_mobile }, /* Lynx M RAID */
++      { PCI_VDEVICE(INTEL, 0x9c02), board_ahci_mobile }, /* Lynx LP AHCI */
++      { PCI_VDEVICE(INTEL, 0x9c03), board_ahci_mobile }, /* Lynx LP AHCI */
++      { PCI_VDEVICE(INTEL, 0x9c04), board_ahci_mobile }, /* Lynx LP RAID */
++      { PCI_VDEVICE(INTEL, 0x9c05), board_ahci_mobile }, /* Lynx LP RAID */
++      { PCI_VDEVICE(INTEL, 0x9c06), board_ahci_mobile }, /* Lynx LP RAID */
++      { PCI_VDEVICE(INTEL, 0x9c07), board_ahci_mobile }, /* Lynx LP RAID */
++      { PCI_VDEVICE(INTEL, 0x9c0e), board_ahci_mobile }, /* Lynx LP RAID */
++      { PCI_VDEVICE(INTEL, 0x9c0f), board_ahci_mobile }, /* Lynx LP RAID */
+       { PCI_VDEVICE(INTEL, 0x1f22), board_ahci }, /* Avoton AHCI */
+       { PCI_VDEVICE(INTEL, 0x1f23), board_ahci }, /* Avoton AHCI */
+       { PCI_VDEVICE(INTEL, 0x1f24), board_ahci }, /* Avoton RAID */
+@@ -345,26 +353,26 @@ static const struct pci_device_id ahci_p
+       { PCI_VDEVICE(INTEL, 0x8d66), board_ahci }, /* Wellsburg RAID */
+       { PCI_VDEVICE(INTEL, 0x8d6e), board_ahci }, /* Wellsburg RAID */
+       { PCI_VDEVICE(INTEL, 0x23a3), board_ahci }, /* Coleto Creek AHCI */
+-      { PCI_VDEVICE(INTEL, 0x9c83), board_ahci }, /* Wildcat Point-LP AHCI */
+-      { PCI_VDEVICE(INTEL, 0x9c85), board_ahci }, /* Wildcat Point-LP RAID */
+-      { PCI_VDEVICE(INTEL, 0x9c87), board_ahci }, /* Wildcat Point-LP RAID */
+-      { PCI_VDEVICE(INTEL, 0x9c8f), board_ahci }, /* Wildcat Point-LP RAID */
++      { PCI_VDEVICE(INTEL, 0x9c83), board_ahci_mobile }, /* Wildcat LP AHCI */
++      { PCI_VDEVICE(INTEL, 0x9c85), board_ahci_mobile }, /* Wildcat LP RAID */
++      { PCI_VDEVICE(INTEL, 0x9c87), board_ahci_mobile }, /* Wildcat LP RAID */
++      { PCI_VDEVICE(INTEL, 0x9c8f), board_ahci_mobile }, /* Wildcat LP RAID */
+       { PCI_VDEVICE(INTEL, 0x8c82), board_ahci }, /* 9 Series AHCI */
+-      { PCI_VDEVICE(INTEL, 0x8c83), board_ahci }, /* 9 Series M AHCI */
++      { PCI_VDEVICE(INTEL, 0x8c83), board_ahci_mobile }, /* 9 Series M AHCI */
+       { PCI_VDEVICE(INTEL, 0x8c84), board_ahci }, /* 9 Series RAID */
+-      { PCI_VDEVICE(INTEL, 0x8c85), board_ahci }, /* 9 Series M RAID */
++      { PCI_VDEVICE(INTEL, 0x8c85), board_ahci_mobile }, /* 9 Series M RAID */
+       { PCI_VDEVICE(INTEL, 0x8c86), board_ahci }, /* 9 Series RAID */
+-      { PCI_VDEVICE(INTEL, 0x8c87), board_ahci }, /* 9 Series M RAID */
++      { PCI_VDEVICE(INTEL, 0x8c87), board_ahci_mobile }, /* 9 Series M RAID */
+       { PCI_VDEVICE(INTEL, 0x8c8e), board_ahci }, /* 9 Series RAID */
+-      { PCI_VDEVICE(INTEL, 0x8c8f), board_ahci }, /* 9 Series M RAID */
+-      { PCI_VDEVICE(INTEL, 0x9d03), board_ahci }, /* Sunrise Point-LP AHCI */
+-      { PCI_VDEVICE(INTEL, 0x9d05), board_ahci }, /* Sunrise Point-LP RAID */
+-      { PCI_VDEVICE(INTEL, 0x9d07), board_ahci }, /* Sunrise Point-LP RAID */
++      { PCI_VDEVICE(INTEL, 0x8c8f), board_ahci_mobile }, /* 9 Series M RAID */
++      { PCI_VDEVICE(INTEL, 0x9d03), board_ahci_mobile }, /* Sunrise LP AHCI */
++      { PCI_VDEVICE(INTEL, 0x9d05), board_ahci_mobile }, /* Sunrise LP RAID */
++      { PCI_VDEVICE(INTEL, 0x9d07), board_ahci_mobile }, /* Sunrise LP RAID */
+       { PCI_VDEVICE(INTEL, 0xa102), board_ahci }, /* Sunrise Point-H AHCI */
+-      { PCI_VDEVICE(INTEL, 0xa103), board_ahci }, /* Sunrise Point-H M AHCI */
++      { PCI_VDEVICE(INTEL, 0xa103), board_ahci_mobile }, /* Sunrise M AHCI */
+       { PCI_VDEVICE(INTEL, 0xa105), board_ahci }, /* Sunrise Point-H RAID */
+       { PCI_VDEVICE(INTEL, 0xa106), board_ahci }, /* Sunrise Point-H RAID */
+-      { PCI_VDEVICE(INTEL, 0xa107), board_ahci }, /* Sunrise Point-H M RAID */
++      { PCI_VDEVICE(INTEL, 0xa107), board_ahci_mobile }, /* Sunrise M RAID */
+       { PCI_VDEVICE(INTEL, 0xa10f), board_ahci }, /* Sunrise Point-H RAID */
+       { PCI_VDEVICE(INTEL, 0x2822), board_ahci }, /* Lewisburg RAID*/
+       { PCI_VDEVICE(INTEL, 0x2823), board_ahci }, /* Lewisburg AHCI*/
+@@ -382,10 +390,10 @@ static const struct pci_device_id ahci_p
+       { PCI_VDEVICE(INTEL, 0xa20e), board_ahci }, /* Lewisburg RAID*/
+       { PCI_VDEVICE(INTEL, 0xa252), board_ahci }, /* Lewisburg RAID*/
+       { PCI_VDEVICE(INTEL, 0xa256), board_ahci }, /* Lewisburg RAID*/
+-      { PCI_VDEVICE(INTEL, 0x0f22), board_ahci }, /* Bay Trail AHCI */
+-      { PCI_VDEVICE(INTEL, 0x0f23), board_ahci }, /* Bay Trail AHCI */
+-      { PCI_VDEVICE(INTEL, 0x22a3), board_ahci }, /* Cherry Trail AHCI */
+-      { PCI_VDEVICE(INTEL, 0x5ae3), board_ahci }, /* Apollo Lake AHCI */
++      { PCI_VDEVICE(INTEL, 0x0f22), board_ahci_mobile }, /* Bay Trail AHCI */
++      { PCI_VDEVICE(INTEL, 0x0f23), board_ahci_mobile }, /* Bay Trail AHCI */
++      { PCI_VDEVICE(INTEL, 0x22a3), board_ahci_mobile }, /* Cherry Tr. AHCI */
++      { PCI_VDEVICE(INTEL, 0x5ae3), board_ahci_mobile }, /* ApolloLake AHCI */
+       /* JMicron 360/1/3/5/6, match class to avoid IDE function */
+       { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
+@@ -587,6 +595,9 @@ static int marvell_enable = 1;
+ module_param(marvell_enable, int, 0644);
+ MODULE_PARM_DESC(marvell_enable, "Marvell SATA via AHCI (1 = enabled)");
++static int mobile_lpm_policy = CONFIG_SATA_MOBILE_LPM_POLICY;
++module_param(mobile_lpm_policy, int, 0644);
++MODULE_PARM_DESC(mobile_lpm_policy, "Default LPM policy for mobile chipsets");
+ static void ahci_pci_save_initial_config(struct pci_dev *pdev,
+                                        struct ahci_host_priv *hpriv)
+@@ -1630,6 +1641,10 @@ static int ahci_init_one(struct pci_dev
+               if (ap->flags & ATA_FLAG_EM)
+                       ap->em_message_type = hpriv->em_msg_type;
++              if ((hpriv->flags & AHCI_HFLAG_IS_MOBILE) &&
++                  mobile_lpm_policy >= ATA_LPM_UNKNOWN &&
++                  mobile_lpm_policy <= ATA_LPM_MIN_POWER)
++                      ap->target_lpm_policy = mobile_lpm_policy;
+               /* disabled/not-implemented port */
+               if (!(hpriv->port_map & (1 << i)))
+--- a/drivers/ata/ahci.h
++++ b/drivers/ata/ahci.h
+@@ -242,6 +242,9 @@ enum {
+       AHCI_HFLAG_NO_FBS               = (1 << 18), /* no FBS */
+       AHCI_HFLAG_EDGE_IRQ             = (1 << 19), /* HOST_IRQ_STAT behaves as
+                                                       Edge Triggered */
++      AHCI_HFLAG_IS_MOBILE            = (1 << 25), /* mobile chipset, use
++                                                      SATA_MOBILE_LPM_POLICY
++                                                      as default lpm_policy */
+       /* ap->flags bits */
diff --git a/queue-4.4/ahci-annotate-pci-ids-for-mobile-intel-chipsets-as-such.patch b/queue-4.4/ahci-annotate-pci-ids-for-mobile-intel-chipsets-as-such.patch
new file mode 100644 (file)
index 0000000..7b3a99e
--- /dev/null
@@ -0,0 +1,108 @@
+From ca1b4974bd237f2373b0e980b11957aac3499b56 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Wed, 6 Dec 2017 16:41:08 +0100
+Subject: ahci: Annotate PCI ids for mobile Intel chipsets as such
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+commit ca1b4974bd237f2373b0e980b11957aac3499b56 upstream.
+
+Intel uses different SATA PCI ids for the Desktop and Mobile SKUs of their
+chipsets. For older models the comment describing which chipset the PCI id
+is for, aksi indicates when we're dealing with a mobile SKU. Extend the
+comments for recent chipsets to also indicate mobile SKUs.
+
+The information this commit adds comes from Intel's chipset datasheets.
+
+This commit is a preparation patch for allowing a different default
+sata link powermanagement policy for mobile chipsets.
+
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: Tejun Heo <tj@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/ata/ahci.c |   32 ++++++++++++++++----------------
+ 1 file changed, 16 insertions(+), 16 deletions(-)
+
+--- a/drivers/ata/ahci.c
++++ b/drivers/ata/ahci.c
+@@ -260,9 +260,9 @@ static const struct pci_device_id ahci_p
+       { PCI_VDEVICE(INTEL, 0x3b23), board_ahci }, /* PCH AHCI */
+       { PCI_VDEVICE(INTEL, 0x3b24), board_ahci }, /* PCH RAID */
+       { PCI_VDEVICE(INTEL, 0x3b25), board_ahci }, /* PCH RAID */
+-      { PCI_VDEVICE(INTEL, 0x3b29), board_ahci }, /* PCH AHCI */
++      { PCI_VDEVICE(INTEL, 0x3b29), board_ahci }, /* PCH M AHCI */
+       { PCI_VDEVICE(INTEL, 0x3b2b), board_ahci }, /* PCH RAID */
+-      { PCI_VDEVICE(INTEL, 0x3b2c), board_ahci }, /* PCH RAID */
++      { PCI_VDEVICE(INTEL, 0x3b2c), board_ahci }, /* PCH M RAID */
+       { PCI_VDEVICE(INTEL, 0x3b2f), board_ahci }, /* PCH AHCI */
+       { PCI_VDEVICE(INTEL, 0x19b0), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19b1), board_ahci }, /* DNV AHCI */
+@@ -285,9 +285,9 @@ static const struct pci_device_id ahci_p
+       { PCI_VDEVICE(INTEL, 0x19cE), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19cF), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x1c02), board_ahci }, /* CPT AHCI */
+-      { PCI_VDEVICE(INTEL, 0x1c03), board_ahci }, /* CPT AHCI */
++      { PCI_VDEVICE(INTEL, 0x1c03), board_ahci }, /* CPT M AHCI */
+       { PCI_VDEVICE(INTEL, 0x1c04), board_ahci }, /* CPT RAID */
+-      { PCI_VDEVICE(INTEL, 0x1c05), board_ahci }, /* CPT RAID */
++      { PCI_VDEVICE(INTEL, 0x1c05), board_ahci }, /* CPT M RAID */
+       { PCI_VDEVICE(INTEL, 0x1c06), board_ahci }, /* CPT RAID */
+       { PCI_VDEVICE(INTEL, 0x1c07), board_ahci }, /* CPT RAID */
+       { PCI_VDEVICE(INTEL, 0x1d02), board_ahci }, /* PBG AHCI */
+@@ -296,20 +296,20 @@ static const struct pci_device_id ahci_p
+       { PCI_VDEVICE(INTEL, 0x2826), board_ahci }, /* PBG RAID */
+       { PCI_VDEVICE(INTEL, 0x2323), board_ahci }, /* DH89xxCC AHCI */
+       { PCI_VDEVICE(INTEL, 0x1e02), board_ahci }, /* Panther Point AHCI */
+-      { PCI_VDEVICE(INTEL, 0x1e03), board_ahci }, /* Panther Point AHCI */
++      { PCI_VDEVICE(INTEL, 0x1e03), board_ahci }, /* Panther Point M AHCI */
+       { PCI_VDEVICE(INTEL, 0x1e04), board_ahci }, /* Panther Point RAID */
+       { PCI_VDEVICE(INTEL, 0x1e05), board_ahci }, /* Panther Point RAID */
+       { PCI_VDEVICE(INTEL, 0x1e06), board_ahci }, /* Panther Point RAID */
+-      { PCI_VDEVICE(INTEL, 0x1e07), board_ahci }, /* Panther Point RAID */
++      { PCI_VDEVICE(INTEL, 0x1e07), board_ahci }, /* Panther Point M RAID */
+       { PCI_VDEVICE(INTEL, 0x1e0e), board_ahci }, /* Panther Point RAID */
+       { PCI_VDEVICE(INTEL, 0x8c02), board_ahci }, /* Lynx Point AHCI */
+-      { PCI_VDEVICE(INTEL, 0x8c03), board_ahci }, /* Lynx Point AHCI */
++      { PCI_VDEVICE(INTEL, 0x8c03), board_ahci }, /* Lynx Point M AHCI */
+       { PCI_VDEVICE(INTEL, 0x8c04), board_ahci }, /* Lynx Point RAID */
+-      { PCI_VDEVICE(INTEL, 0x8c05), board_ahci }, /* Lynx Point RAID */
++      { PCI_VDEVICE(INTEL, 0x8c05), board_ahci }, /* Lynx Point M RAID */
+       { PCI_VDEVICE(INTEL, 0x8c06), board_ahci }, /* Lynx Point RAID */
+-      { PCI_VDEVICE(INTEL, 0x8c07), board_ahci }, /* Lynx Point RAID */
++      { PCI_VDEVICE(INTEL, 0x8c07), board_ahci }, /* Lynx Point M RAID */
+       { PCI_VDEVICE(INTEL, 0x8c0e), board_ahci }, /* Lynx Point RAID */
+-      { PCI_VDEVICE(INTEL, 0x8c0f), board_ahci }, /* Lynx Point RAID */
++      { PCI_VDEVICE(INTEL, 0x8c0f), board_ahci }, /* Lynx Point M RAID */
+       { PCI_VDEVICE(INTEL, 0x9c02), board_ahci }, /* Lynx Point-LP AHCI */
+       { PCI_VDEVICE(INTEL, 0x9c03), board_ahci }, /* Lynx Point-LP AHCI */
+       { PCI_VDEVICE(INTEL, 0x9c04), board_ahci }, /* Lynx Point-LP RAID */
+@@ -350,21 +350,21 @@ static const struct pci_device_id ahci_p
+       { PCI_VDEVICE(INTEL, 0x9c87), board_ahci }, /* Wildcat Point-LP RAID */
+       { PCI_VDEVICE(INTEL, 0x9c8f), board_ahci }, /* Wildcat Point-LP RAID */
+       { PCI_VDEVICE(INTEL, 0x8c82), board_ahci }, /* 9 Series AHCI */
+-      { PCI_VDEVICE(INTEL, 0x8c83), board_ahci }, /* 9 Series AHCI */
++      { PCI_VDEVICE(INTEL, 0x8c83), board_ahci }, /* 9 Series M AHCI */
+       { PCI_VDEVICE(INTEL, 0x8c84), board_ahci }, /* 9 Series RAID */
+-      { PCI_VDEVICE(INTEL, 0x8c85), board_ahci }, /* 9 Series RAID */
++      { PCI_VDEVICE(INTEL, 0x8c85), board_ahci }, /* 9 Series M RAID */
+       { PCI_VDEVICE(INTEL, 0x8c86), board_ahci }, /* 9 Series RAID */
+-      { PCI_VDEVICE(INTEL, 0x8c87), board_ahci }, /* 9 Series RAID */
++      { PCI_VDEVICE(INTEL, 0x8c87), board_ahci }, /* 9 Series M RAID */
+       { PCI_VDEVICE(INTEL, 0x8c8e), board_ahci }, /* 9 Series RAID */
+-      { PCI_VDEVICE(INTEL, 0x8c8f), board_ahci }, /* 9 Series RAID */
++      { PCI_VDEVICE(INTEL, 0x8c8f), board_ahci }, /* 9 Series M RAID */
+       { PCI_VDEVICE(INTEL, 0x9d03), board_ahci }, /* Sunrise Point-LP AHCI */
+       { PCI_VDEVICE(INTEL, 0x9d05), board_ahci }, /* Sunrise Point-LP RAID */
+       { PCI_VDEVICE(INTEL, 0x9d07), board_ahci }, /* Sunrise Point-LP RAID */
+       { PCI_VDEVICE(INTEL, 0xa102), board_ahci }, /* Sunrise Point-H AHCI */
+-      { PCI_VDEVICE(INTEL, 0xa103), board_ahci }, /* Sunrise Point-H AHCI */
++      { PCI_VDEVICE(INTEL, 0xa103), board_ahci }, /* Sunrise Point-H M AHCI */
+       { PCI_VDEVICE(INTEL, 0xa105), board_ahci }, /* Sunrise Point-H RAID */
+       { PCI_VDEVICE(INTEL, 0xa106), board_ahci }, /* Sunrise Point-H RAID */
+-      { PCI_VDEVICE(INTEL, 0xa107), board_ahci }, /* Sunrise Point-H RAID */
++      { PCI_VDEVICE(INTEL, 0xa107), board_ahci }, /* Sunrise Point-H M RAID */
+       { PCI_VDEVICE(INTEL, 0xa10f), board_ahci }, /* Sunrise Point-H RAID */
+       { PCI_VDEVICE(INTEL, 0x2822), board_ahci }, /* Lewisburg RAID*/
+       { PCI_VDEVICE(INTEL, 0x2823), board_ahci }, /* Lewisburg AHCI*/
diff --git a/queue-4.4/kernfs-fix-regression-in-kernfs_fop_write-caused-by-wrong-type.patch b/queue-4.4/kernfs-fix-regression-in-kernfs_fop_write-caused-by-wrong-type.patch
new file mode 100644 (file)
index 0000000..b3a1ec5
--- /dev/null
@@ -0,0 +1,43 @@
+From ba87977a49913129962af8ac35b0e13e0fa4382d Mon Sep 17 00:00:00 2001
+From: Ivan Vecera <ivecera@redhat.com>
+Date: Fri, 19 Jan 2018 09:18:54 +0100
+Subject: kernfs: fix regression in kernfs_fop_write caused by wrong type
+
+From: Ivan Vecera <ivecera@redhat.com>
+
+commit ba87977a49913129962af8ac35b0e13e0fa4382d upstream.
+
+Commit b7ce40cff0b9 ("kernfs: cache atomic_write_len in
+kernfs_open_file") changes type of local variable 'len' from ssize_t
+to size_t. This change caused that the *ppos value is updated also
+when the previous write callback failed.
+
+Mentioned snippet:
+...
+len = ops->write(...); <- return value can be negative
+...
+if (len > 0)           <- true here in this case
+        *ppos += len;
+...
+
+Fixes: b7ce40cff0b9 ("kernfs: cache atomic_write_len in kernfs_open_file")
+Acked-by: Tejun Heo <tj@kernel.org>
+Signed-off-by: Ivan Vecera <ivecera@redhat.com>
+Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/kernfs/file.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/fs/kernfs/file.c
++++ b/fs/kernfs/file.c
+@@ -272,7 +272,7 @@ static ssize_t kernfs_fop_write(struct f
+ {
+       struct kernfs_open_file *of = kernfs_of(file);
+       const struct kernfs_ops *ops;
+-      size_t len;
++      ssize_t len;
+       char *buf;
+       if (of->atomic_write_len) {
diff --git a/queue-4.4/mtd-cfi-convert-inline-functions-to-macros.patch b/queue-4.4/mtd-cfi-convert-inline-functions-to-macros.patch
new file mode 100644 (file)
index 0000000..f4ac5b3
--- /dev/null
@@ -0,0 +1,185 @@
+From 9e343e87d2c4c707ef8fae2844864d4dde3a2d13 Mon Sep 17 00:00:00 2001
+From: Arnd Bergmann <arnd@arndb.de>
+Date: Wed, 11 Oct 2017 15:54:10 +0200
+Subject: mtd: cfi: convert inline functions to macros
+
+From: Arnd Bergmann <arnd@arndb.de>
+
+commit 9e343e87d2c4c707ef8fae2844864d4dde3a2d13 upstream.
+
+The map_word_() functions, dating back to linux-2.6.8, try to perform
+bitwise operations on a 'map_word' structure. This may have worked
+with compilers that were current then (gcc-3.4 or earlier), but end
+up being rather inefficient on any version I could try now (gcc-4.4 or
+higher). Specifically we hit a problem analyzed in gcc PR81715 where we
+fail to reuse the stack space for local variables.
+
+This can be seen immediately in the stack consumption for
+cfi_staa_erase_varsize() and other functions that (with CONFIG_KASAN)
+can be up to 2200 bytes. Changing the inline functions into macros brings
+this down to 1280 bytes.  Without KASAN, the same problem exists, but
+the stack consumption is lower to start with, my patch shrinks it from
+920 to 496 bytes on with arm-linux-gnueabi-gcc-5.4, and saves around
+1KB in .text size for cfi_cmdset_0020.c, as it avoids copying map_word
+structures for each call to one of these helpers.
+
+With the latest gcc-8 snapshot, the problem is fixed in upstream gcc,
+but nobody uses that yet, so we should still work around it in mainline
+kernels and probably backport the workaround to stable kernels as well.
+We had a couple of other functions that suffered from the same gcc bug,
+and all of those had a simpler workaround involving dummy variables
+in the inline function. Unfortunately that did not work here, the
+macro hack was the best I could come up with.
+
+It would also be helpful to have someone to a little performance testing
+on the patch, to see how much it helps in terms of CPU utilitzation.
+
+Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Acked-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ include/linux/mtd/map.h |  130 ++++++++++++++++++++++--------------------------
+ 1 file changed, 61 insertions(+), 69 deletions(-)
+
+--- a/include/linux/mtd/map.h
++++ b/include/linux/mtd/map.h
+@@ -265,75 +265,67 @@ void map_destroy(struct mtd_info *mtd);
+ #define INVALIDATE_CACHED_RANGE(map, from, size) \
+       do { if (map->inval_cache) map->inval_cache(map, from, size); } while (0)
+-
+-static inline int map_word_equal(struct map_info *map, map_word val1, map_word val2)
+-{
+-      int i;
+-
+-      for (i = 0; i < map_words(map); i++) {
+-              if (val1.x[i] != val2.x[i])
+-                      return 0;
+-      }
+-
+-      return 1;
+-}
+-
+-static inline map_word map_word_and(struct map_info *map, map_word val1, map_word val2)
+-{
+-      map_word r;
+-      int i;
+-
+-      for (i = 0; i < map_words(map); i++)
+-              r.x[i] = val1.x[i] & val2.x[i];
+-
+-      return r;
+-}
+-
+-static inline map_word map_word_clr(struct map_info *map, map_word val1, map_word val2)
+-{
+-      map_word r;
+-      int i;
+-
+-      for (i = 0; i < map_words(map); i++)
+-              r.x[i] = val1.x[i] & ~val2.x[i];
+-
+-      return r;
+-}
+-
+-static inline map_word map_word_or(struct map_info *map, map_word val1, map_word val2)
+-{
+-      map_word r;
+-      int i;
+-
+-      for (i = 0; i < map_words(map); i++)
+-              r.x[i] = val1.x[i] | val2.x[i];
+-
+-      return r;
+-}
+-
+-static inline int map_word_andequal(struct map_info *map, map_word val1, map_word val2, map_word val3)
+-{
+-      int i;
+-
+-      for (i = 0; i < map_words(map); i++) {
+-              if ((val1.x[i] & val2.x[i]) != val3.x[i])
+-                      return 0;
+-      }
+-
+-      return 1;
+-}
+-
+-static inline int map_word_bitsset(struct map_info *map, map_word val1, map_word val2)
+-{
+-      int i;
+-
+-      for (i = 0; i < map_words(map); i++) {
+-              if (val1.x[i] & val2.x[i])
+-                      return 1;
+-      }
+-
+-      return 0;
+-}
++#define map_word_equal(map, val1, val2)                                       \
++({                                                                    \
++      int i, ret = 1;                                                 \
++      for (i = 0; i < map_words(map); i++)                            \
++              if ((val1).x[i] != (val2).x[i]) {                       \
++                      ret = 0;                                        \
++                      break;                                          \
++              }                                                       \
++      ret;                                                            \
++})
++
++#define map_word_and(map, val1, val2)                                 \
++({                                                                    \
++      map_word r;                                                     \
++      int i;                                                          \
++      for (i = 0; i < map_words(map); i++)                            \
++              r.x[i] = (val1).x[i] & (val2).x[i];                     \
++      r;                                                              \
++})
++
++#define map_word_clr(map, val1, val2)                                 \
++({                                                                    \
++      map_word r;                                                     \
++      int i;                                                          \
++      for (i = 0; i < map_words(map); i++)                            \
++              r.x[i] = (val1).x[i] & ~(val2).x[i];                    \
++      r;                                                              \
++})
++
++#define map_word_or(map, val1, val2)                                  \
++({                                                                    \
++      map_word r;                                                     \
++      int i;                                                          \
++      for (i = 0; i < map_words(map); i++)                            \
++              r.x[i] = (val1).x[i] | (val2).x[i];                     \
++      r;                                                              \
++})
++
++#define map_word_andequal(map, val1, val2, val3)                      \
++({                                                                    \
++      int i, ret = 1;                                                 \
++      for (i = 0; i < map_words(map); i++) {                          \
++              if (((val1).x[i] & (val2).x[i]) != (val2).x[i]) {       \
++                      ret = 0;                                        \
++                      break;                                          \
++              }                                                       \
++      }                                                               \
++      ret;                                                            \
++})
++
++#define map_word_bitsset(map, val1, val2)                             \
++({                                                                    \
++      int i, ret = 0;                                                 \
++      for (i = 0; i < map_words(map); i++) {                          \
++              if ((val1).x[i] & (val2).x[i]) {                        \
++                      ret = 1;                                        \
++                      break;                                          \
++              }                                                       \
++      }                                                               \
++      ret;                                                            \
++})
+ static inline map_word map_word_load(struct map_info *map, const void *ptr)
+ {
diff --git a/queue-4.4/mtd-nand-brcmnand-disable-prefetch-by-default.patch b/queue-4.4/mtd-nand-brcmnand-disable-prefetch-by-default.patch
new file mode 100644 (file)
index 0000000..fb82201
--- /dev/null
@@ -0,0 +1,45 @@
+From f953f0f89663c39f08f4baaa8a4a881401b65654 Mon Sep 17 00:00:00 2001
+From: Kamal Dasu <kdasu.kdev@gmail.com>
+Date: Mon, 8 Jan 2018 15:36:48 -0500
+Subject: mtd: nand: brcmnand: Disable prefetch by default
+
+From: Kamal Dasu <kdasu.kdev@gmail.com>
+
+commit f953f0f89663c39f08f4baaa8a4a881401b65654 upstream.
+
+Brcm nand controller prefetch feature needs to be disabled
+by default. Enabling affects performance on random reads as
+well as dma reads.
+
+Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
+Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller")
+Acked-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/mtd/nand/brcmnand/brcmnand.c |   13 +++----------
+ 1 file changed, 3 insertions(+), 10 deletions(-)
+
+--- a/drivers/mtd/nand/brcmnand/brcmnand.c
++++ b/drivers/mtd/nand/brcmnand/brcmnand.c
+@@ -1922,16 +1922,9 @@ static int brcmnand_setup_dev(struct brc
+       tmp &= ~ACC_CONTROL_PARTIAL_PAGE;
+       tmp &= ~ACC_CONTROL_RD_ERASED;
+       tmp &= ~ACC_CONTROL_FAST_PGM_RDIN;
+-      if (ctrl->features & BRCMNAND_HAS_PREFETCH) {
+-              /*
+-               * FIXME: Flash DMA + prefetch may see spurious erased-page ECC
+-               * errors
+-               */
+-              if (has_flash_dma(ctrl))
+-                      tmp &= ~ACC_CONTROL_PREFETCH;
+-              else
+-                      tmp |= ACC_CONTROL_PREFETCH;
+-      }
++      if (ctrl->features & BRCMNAND_HAS_PREFETCH)
++              tmp &= ~ACC_CONTROL_PREFETCH;
++
+       nand_writereg(ctrl, offs, tmp);
+       return 0;
diff --git a/queue-4.4/mtd-nand-fix-nand_do_read_oob-return-value.patch b/queue-4.4/mtd-nand-fix-nand_do_read_oob-return-value.patch
new file mode 100644 (file)
index 0000000..b1e8b8b
--- /dev/null
@@ -0,0 +1,59 @@
+From 87e89ce8d0d14f573c068c61bec2117751fb5103 Mon Sep 17 00:00:00 2001
+From: Miquel Raynal <miquel.raynal@free-electrons.com>
+Date: Fri, 12 Jan 2018 10:13:36 +0100
+Subject: mtd: nand: Fix nand_do_read_oob() return value
+
+From: Miquel Raynal <miquel.raynal@free-electrons.com>
+
+commit 87e89ce8d0d14f573c068c61bec2117751fb5103 upstream.
+
+Starting from commit 041e4575f034 ("mtd: nand: handle ECC errors in
+OOB"), nand_do_read_oob() (from the NAND core) did return 0 or a
+negative error, and the MTD layer expected it.
+
+However, the trend for the NAND layer is now to return an error or a
+positive number of bitflips. Deciding which status to return to the user
+belongs to the MTD layer.
+
+Commit e47f68587b82 ("mtd: check for max_bitflips in mtd_read_oob()")
+brought this logic to the mtd_read_oob() function while the return value
+coming from nand_do_read_oob() (called by the ->_read_oob() hook) was
+left unchanged.
+
+Fixes: e47f68587b82 ("mtd: check for max_bitflips in mtd_read_oob()")
+Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
+Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/mtd/nand/nand_base.c |    5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+--- a/drivers/mtd/nand/nand_base.c
++++ b/drivers/mtd/nand/nand_base.c
+@@ -2023,6 +2023,7 @@ static int nand_write_oob_syndrome(struc
+ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
+                           struct mtd_oob_ops *ops)
+ {
++      unsigned int max_bitflips = 0;
+       int page, realpage, chipnr;
+       struct nand_chip *chip = mtd->priv;
+       struct mtd_ecc_stats stats;
+@@ -2083,6 +2084,8 @@ static int nand_do_read_oob(struct mtd_i
+                               nand_wait_ready(mtd);
+               }
++              max_bitflips = max_t(unsigned int, max_bitflips, ret);
++
+               readlen -= len;
+               if (!readlen)
+                       break;
+@@ -2108,7 +2111,7 @@ static int nand_do_read_oob(struct mtd_i
+       if (mtd->ecc_stats.failed - stats.failed)
+               return -EBADMSG;
+-      return  mtd->ecc_stats.corrected - stats.corrected ? -EUCLEAN : 0;
++      return max_bitflips;
+ }
+ /**
diff --git a/queue-4.4/mtd-nand-sunxi-fix-ecc-strength-choice.patch b/queue-4.4/mtd-nand-sunxi-fix-ecc-strength-choice.patch
new file mode 100644 (file)
index 0000000..12ee2a0
--- /dev/null
@@ -0,0 +1,47 @@
+From f4c6cd1a7f2275d5bc0e494b21fff26f8dde80f0 Mon Sep 17 00:00:00 2001
+From: Miquel Raynal <miquel.raynal@free-electrons.com>
+Date: Wed, 24 Jan 2018 23:49:31 +0100
+Subject: mtd: nand: sunxi: Fix ECC strength choice
+
+From: Miquel Raynal <miquel.raynal@free-electrons.com>
+
+commit f4c6cd1a7f2275d5bc0e494b21fff26f8dde80f0 upstream.
+
+When the requested ECC strength does not exactly match the strengths
+supported by the ECC engine, the driver is selecting the closest
+strength meeting the 'selected_strength > requested_strength'
+constraint. Fix the fact that, in this particular case, ecc->strength
+value was not updated to match the 'selected_strength'.
+
+For instance, one can encounter this issue when no ECC requirement is
+filled in the device tree while the NAND chip minimum requirement is not
+a strength/step_size combo natively supported by the ECC engine.
+
+Fixes: 1fef62c1423b ("mtd: nand: add sunxi NAND flash controller support")
+Suggested-by: Boris Brezillon <boris.brezillon@free-electrons.com>
+Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
+Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/mtd/nand/sunxi_nand.c |    8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+--- a/drivers/mtd/nand/sunxi_nand.c
++++ b/drivers/mtd/nand/sunxi_nand.c
+@@ -1046,8 +1046,14 @@ static int sunxi_nand_hw_common_ecc_ctrl
+       /* Add ECC info retrieval from DT */
+       for (i = 0; i < ARRAY_SIZE(strengths); i++) {
+-              if (ecc->strength <= strengths[i])
++              if (ecc->strength <= strengths[i]) {
++                      /*
++                       * Update ecc->strength value with the actual strength
++                       * that will be used by the ECC engine.
++                       */
++                      ecc->strength = strengths[i];
+                       break;
++              }
+       }
+       if (i >= ARRAY_SIZE(strengths)) {
diff --git a/queue-4.4/nfs-add-a-cond_resched-to-nfs_commit_release_pages.patch b/queue-4.4/nfs-add-a-cond_resched-to-nfs_commit_release_pages.patch
new file mode 100644 (file)
index 0000000..06bebdd
--- /dev/null
@@ -0,0 +1,32 @@
+From 7f1bda447c9bd48b415acedba6b830f61591601f Mon Sep 17 00:00:00 2001
+From: Trond Myklebust <trond.myklebust@primarydata.com>
+Date: Mon, 18 Dec 2017 14:39:13 -0500
+Subject: NFS: Add a cond_resched() to nfs_commit_release_pages()
+
+From: Trond Myklebust <trond.myklebust@primarydata.com>
+
+commit 7f1bda447c9bd48b415acedba6b830f61591601f upstream.
+
+The commit list can get very large, and so we need a cond_resched()
+in nfs_commit_release_pages() in order to ensure we don't hog the CPU
+for excessive periods of time.
+
+Reported-by: Mike Galbraith <efault@gmx.de>
+Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/nfs/write.c |    2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/fs/nfs/write.c
++++ b/fs/nfs/write.c
+@@ -1746,6 +1746,8 @@ static void nfs_commit_release_pages(str
+               set_bit(NFS_CONTEXT_RESEND_WRITES, &req->wb_context->flags);
+       next:
+               nfs_unlock_and_release_request(req);
++              /* Latency breaker */
++              cond_resched();
+       }
+       nfss = NFS_SERVER(data->inode);
+       if (atomic_long_read(&nfss->writeback) < NFS_CONGESTION_OFF_THRESH)
diff --git a/queue-4.4/nfs-commit-direct-writes-even-if-they-fail-partially.patch b/queue-4.4/nfs-commit-direct-writes-even-if-they-fail-partially.patch
new file mode 100644 (file)
index 0000000..b1ebf28
--- /dev/null
@@ -0,0 +1,40 @@
+From 1b8d97b0a837beaf48a8449955b52c650a7114b4 Mon Sep 17 00:00:00 2001
+From: "J. Bruce Fields" <bfields@redhat.com>
+Date: Tue, 16 Jan 2018 10:08:00 -0500
+Subject: NFS: commit direct writes even if they fail partially
+
+From: J. Bruce Fields <bfields@redhat.com>
+
+commit 1b8d97b0a837beaf48a8449955b52c650a7114b4 upstream.
+
+If some of the WRITE calls making up an O_DIRECT write syscall fail,
+we neglect to commit, even if some of the WRITEs succeed.
+
+We also depend on the commit code to free the reference count on the
+nfs_page taken in the "if (request_commit)" case at the end of
+nfs_direct_write_completion().  The problem was originally noticed
+because ENOSPC's encountered partway through a write would result in a
+closed file being sillyrenamed when it should have been unlinked.
+
+Signed-off-by: J. Bruce Fields <bfields@redhat.com>
+Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/nfs/direct.c |    4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+--- a/fs/nfs/direct.c
++++ b/fs/nfs/direct.c
+@@ -787,10 +787,8 @@ static void nfs_direct_write_completion(
+       spin_lock(&dreq->lock);
+-      if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) {
+-              dreq->flags = 0;
++      if (test_bit(NFS_IOHDR_ERROR, &hdr->flags))
+               dreq->error = hdr->error;
+-      }
+       if (dreq->error == 0) {
+               nfs_direct_good_bytes(dreq, hdr);
+               if (nfs_write_need_commit(hdr)) {
diff --git a/queue-4.4/nfs-pnfs-fix-nfs_direct_req-ref-leak-when-i-o-falls-back-to-the-mds.patch b/queue-4.4/nfs-pnfs-fix-nfs_direct_req-ref-leak-when-i-o-falls-back-to-the-mds.patch
new file mode 100644 (file)
index 0000000..60b9936
--- /dev/null
@@ -0,0 +1,62 @@
+From ba4a76f703ab7eb72941fdaac848502073d6e9ee Mon Sep 17 00:00:00 2001
+From: Scott Mayhew <smayhew@redhat.com>
+Date: Fri, 15 Dec 2017 16:12:32 -0500
+Subject: nfs/pnfs: fix nfs_direct_req ref leak when i/o falls back to the mds
+
+From: Scott Mayhew <smayhew@redhat.com>
+
+commit ba4a76f703ab7eb72941fdaac848502073d6e9ee upstream.
+
+Currently when falling back to doing I/O through the MDS (via
+pnfs_{read|write}_through_mds), the client frees the nfs_pgio_header
+without releasing the reference taken on the dreq
+via pnfs_generic_pg_{read|write}pages -> nfs_pgheader_init ->
+nfs_direct_pgio_init.  It then takes another reference on the dreq via
+nfs_generic_pg_pgios -> nfs_pgheader_init -> nfs_direct_pgio_init and
+as a result the requester will become stuck in inode_dio_wait.  Once
+that happens, other processes accessing the inode will become stuck as
+well.
+
+Ensure that pnfs_read_through_mds() and pnfs_write_through_mds() clean
+up correctly by calling hdr->completion_ops->completion() instead of
+calling hdr->release() directly.
+
+This can be reproduced (sometimes) by performing "storage failover
+takeover" commands on NetApp filer while doing direct I/O from a client.
+
+This can also be reproduced using SystemTap to simulate a failure while
+doing direct I/O from a client (from Dave Wysochanski
+<dwysocha@redhat.com>):
+
+stap -v -g -e 'probe module("nfs_layout_nfsv41_files").function("nfs4_fl_prepare_ds").return { $return=NULL; exit(); }'
+
+Suggested-by: Trond Myklebust <trond.myklebust@primarydata.com>
+Signed-off-by: Scott Mayhew <smayhew@redhat.com>
+Fixes: 1ca018d28d ("pNFS: Fix a memory leak when attempted pnfs fails")
+Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/nfs/pnfs.c |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/fs/nfs/pnfs.c
++++ b/fs/nfs/pnfs.c
+@@ -1943,7 +1943,7 @@ pnfs_write_through_mds(struct nfs_pageio
+               nfs_pageio_reset_write_mds(desc);
+               mirror->pg_recoalesce = 1;
+       }
+-      hdr->release(hdr);
++      hdr->completion_ops->completion(hdr);
+ }
+ static enum pnfs_try_status
+@@ -2058,7 +2058,7 @@ pnfs_read_through_mds(struct nfs_pageio_
+               nfs_pageio_reset_read_mds(desc);
+               mirror->pg_recoalesce = 1;
+       }
+-      hdr->release(hdr);
++      hdr->completion_ops->completion(hdr);
+ }
+ /*
diff --git a/queue-4.4/nfs-reject-request-for-id_legacy-key-without-auxdata.patch b/queue-4.4/nfs-reject-request-for-id_legacy-key-without-auxdata.patch
new file mode 100644 (file)
index 0000000..87fa961
--- /dev/null
@@ -0,0 +1,53 @@
+From 49686cbbb3ebafe42e63868222f269d8053ead00 Mon Sep 17 00:00:00 2001
+From: Eric Biggers <ebiggers@google.com>
+Date: Fri, 19 Jan 2018 15:15:34 -0800
+Subject: NFS: reject request for id_legacy key without auxdata
+
+From: Eric Biggers <ebiggers@google.com>
+
+commit 49686cbbb3ebafe42e63868222f269d8053ead00 upstream.
+
+nfs_idmap_legacy_upcall() is supposed to be called with 'aux' pointing
+to a 'struct idmap', via the call to request_key_with_auxdata() in
+nfs_idmap_request_key().
+
+However it can also be reached via the request_key() system call in
+which case 'aux' will be NULL, causing a NULL pointer dereference in
+nfs_idmap_prepare_pipe_upcall(), assuming that the key description is
+valid enough to get that far.
+
+Fix this by making nfs_idmap_legacy_upcall() negate the key if no
+auxdata is provided.
+
+As usual, this bug was found by syzkaller.  A simple reproducer using
+the command-line keyctl program is:
+
+    keyctl request2 id_legacy uid:0 '' @s
+
+Fixes: 57e62324e469 ("NFS: Store the legacy idmapper result in the keyring")
+Reported-by: syzbot+5dfdbcf7b3eb5912abbb@syzkaller.appspotmail.com
+Signed-off-by: Eric Biggers <ebiggers@google.com>
+Signed-off-by: Trond Myklebust <trondmy@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/nfs/nfs4idmap.c |    6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+--- a/fs/nfs/nfs4idmap.c
++++ b/fs/nfs/nfs4idmap.c
+@@ -567,9 +567,13 @@ static int nfs_idmap_legacy_upcall(struc
+       struct idmap_msg *im;
+       struct idmap *idmap = (struct idmap *)aux;
+       struct key *key = cons->key;
+-      int ret = -ENOMEM;
++      int ret = -ENOKEY;
++
++      if (!aux)
++              goto out1;
+       /* msg and im are freed in idmap_pipe_destroy_msg */
++      ret = -ENOMEM;
+       data = kzalloc(sizeof(*data), GFP_KERNEL);
+       if (!data)
+               goto out1;
index 5a0fef8184e8c11688e17da82d7768bd44291ed2..49ab469e13fab8bb6b98de7f621d05b546dcd705 100644 (file)
@@ -51,3 +51,17 @@ sched-rt-up-the-root-domain-ref-count-when-passing-it-around-via-ipis.patch
 dccp-cve-2017-8824-use-after-free-in-dccp-code.patch
 media-dvb-usb-v2-lmedm04-improve-logic-checking-of-warm-start.patch
 media-dvb-usb-v2-lmedm04-move-ts2020-attach-to-dm04_lme2510_tuner.patch
+mtd-cfi-convert-inline-functions-to-macros.patch
+mtd-nand-brcmnand-disable-prefetch-by-default.patch
+mtd-nand-fix-nand_do_read_oob-return-value.patch
+mtd-nand-sunxi-fix-ecc-strength-choice.patch
+ubi-block-fix-locking-for-idr_alloc-idr_remove.patch
+nfs-pnfs-fix-nfs_direct_req-ref-leak-when-i-o-falls-back-to-the-mds.patch
+nfs-add-a-cond_resched-to-nfs_commit_release_pages.patch
+nfs-commit-direct-writes-even-if-they-fail-partially.patch
+nfs-reject-request-for-id_legacy-key-without-auxdata.patch
+kernfs-fix-regression-in-kernfs_fop_write-caused-by-wrong-type.patch
+ahci-annotate-pci-ids-for-mobile-intel-chipsets-as-such.patch
+ahci-add-pci-ids-for-intel-bay-trail-cherry-trail-and-apollo-lake-ahci.patch
+ahci-allow-setting-a-default-lpm-policy-for-mobile-chipsets.patch
+ahci-add-intel-cannon-lake-pch-h-pci-id.patch
diff --git a/queue-4.4/ubi-block-fix-locking-for-idr_alloc-idr_remove.patch b/queue-4.4/ubi-block-fix-locking-for-idr_alloc-idr_remove.patch
new file mode 100644 (file)
index 0000000..6f421b3
--- /dev/null
@@ -0,0 +1,188 @@
+From 7f29ae9f977bcdc3654e68bc36d170223c52fd48 Mon Sep 17 00:00:00 2001
+From: Bradley Bolen <bradleybolen@gmail.com>
+Date: Thu, 18 Jan 2018 08:55:20 -0500
+Subject: ubi: block: Fix locking for idr_alloc/idr_remove
+
+From: Bradley Bolen <bradleybolen@gmail.com>
+
+commit 7f29ae9f977bcdc3654e68bc36d170223c52fd48 upstream.
+
+This fixes a race with idr_alloc where gd->first_minor can be set to the
+same value for two simultaneous calls to ubiblock_create.  Each instance
+calls device_add_disk with the same first_minor.  device_add_disk calls
+bdi_register_owner which generates several warnings.
+
+WARNING: CPU: 1 PID: 179 at kernel-source/fs/sysfs/dir.c:31
+sysfs_warn_dup+0x68/0x88
+sysfs: cannot create duplicate filename '/devices/virtual/bdi/252:2'
+
+WARNING: CPU: 1 PID: 179 at kernel-source/lib/kobject.c:240
+kobject_add_internal+0x1ec/0x2f8
+kobject_add_internal failed for 252:2 with -EEXIST, don't try to
+register things with the same name in the same directory
+
+WARNING: CPU: 1 PID: 179 at kernel-source/fs/sysfs/dir.c:31
+sysfs_warn_dup+0x68/0x88
+sysfs: cannot create duplicate filename '/dev/block/252:2'
+
+However, device_add_disk does not error out when bdi_register_owner
+returns an error.  Control continues until reaching blk_register_queue.
+It then BUGs.
+
+kernel BUG at kernel-source/fs/sysfs/group.c:113!
+[<c01e26cc>] (internal_create_group) from [<c01e2950>]
+(sysfs_create_group+0x20/0x24)
+[<c01e2950>] (sysfs_create_group) from [<c00e3d38>]
+(blk_trace_init_sysfs+0x18/0x20)
+[<c00e3d38>] (blk_trace_init_sysfs) from [<c02bdfbc>]
+(blk_register_queue+0xd8/0x154)
+[<c02bdfbc>] (blk_register_queue) from [<c02cec84>]
+(device_add_disk+0x194/0x44c)
+[<c02cec84>] (device_add_disk) from [<c0436ec8>]
+(ubiblock_create+0x284/0x2e0)
+[<c0436ec8>] (ubiblock_create) from [<c0427bb8>]
+(vol_cdev_ioctl+0x450/0x554)
+[<c0427bb8>] (vol_cdev_ioctl) from [<c0189110>] (vfs_ioctl+0x30/0x44)
+[<c0189110>] (vfs_ioctl) from [<c01892e0>] (do_vfs_ioctl+0xa0/0x790)
+[<c01892e0>] (do_vfs_ioctl) from [<c0189a14>] (SyS_ioctl+0x44/0x68)
+[<c0189a14>] (SyS_ioctl) from [<c0010640>] (ret_fast_syscall+0x0/0x34)
+
+Locking idr_alloc/idr_remove removes the race and keeps gd->first_minor
+unique.
+
+Fixes: 2bf50d42f3a4 ("UBI: block: Dynamically allocate minor numbers")
+Signed-off-by: Bradley Bolen <bradleybolen@gmail.com>
+Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/mtd/ubi/block.c |   42 ++++++++++++++++++++++++++----------------
+ 1 file changed, 26 insertions(+), 16 deletions(-)
+
+--- a/drivers/mtd/ubi/block.c
++++ b/drivers/mtd/ubi/block.c
+@@ -99,6 +99,8 @@ struct ubiblock {
+ /* Linked list of all ubiblock instances */
+ static LIST_HEAD(ubiblock_devices);
++static DEFINE_IDR(ubiblock_minor_idr);
++/* Protects ubiblock_devices and ubiblock_minor_idr */
+ static DEFINE_MUTEX(devices_mutex);
+ static int ubiblock_major;
+@@ -354,8 +356,6 @@ static struct blk_mq_ops ubiblock_mq_ops
+       .map_queue      = blk_mq_map_queue,
+ };
+-static DEFINE_IDR(ubiblock_minor_idr);
+-
+ int ubiblock_create(struct ubi_volume_info *vi)
+ {
+       struct ubiblock *dev;
+@@ -368,14 +368,15 @@ int ubiblock_create(struct ubi_volume_in
+       /* Check that the volume isn't already handled */
+       mutex_lock(&devices_mutex);
+       if (find_dev_nolock(vi->ubi_num, vi->vol_id)) {
+-              mutex_unlock(&devices_mutex);
+-              return -EEXIST;
++              ret = -EEXIST;
++              goto out_unlock;
+       }
+-      mutex_unlock(&devices_mutex);
+       dev = kzalloc(sizeof(struct ubiblock), GFP_KERNEL);
+-      if (!dev)
+-              return -ENOMEM;
++      if (!dev) {
++              ret = -ENOMEM;
++              goto out_unlock;
++      }
+       mutex_init(&dev->dev_mutex);
+@@ -440,14 +441,13 @@ int ubiblock_create(struct ubi_volume_in
+               goto out_free_queue;
+       }
+-      mutex_lock(&devices_mutex);
+       list_add_tail(&dev->list, &ubiblock_devices);
+-      mutex_unlock(&devices_mutex);
+       /* Must be the last step: anyone can call file ops from now on */
+       add_disk(dev->gd);
+       dev_info(disk_to_dev(dev->gd), "created from ubi%d:%d(%s)",
+                dev->ubi_num, dev->vol_id, vi->name);
++      mutex_unlock(&devices_mutex);
+       return 0;
+ out_free_queue:
+@@ -460,6 +460,8 @@ out_put_disk:
+       put_disk(dev->gd);
+ out_free_dev:
+       kfree(dev);
++out_unlock:
++      mutex_unlock(&devices_mutex);
+       return ret;
+ }
+@@ -481,30 +483,36 @@ static void ubiblock_cleanup(struct ubib
+ int ubiblock_remove(struct ubi_volume_info *vi)
+ {
+       struct ubiblock *dev;
++      int ret;
+       mutex_lock(&devices_mutex);
+       dev = find_dev_nolock(vi->ubi_num, vi->vol_id);
+       if (!dev) {
+-              mutex_unlock(&devices_mutex);
+-              return -ENODEV;
++              ret = -ENODEV;
++              goto out_unlock;
+       }
+       /* Found a device, let's lock it so we can check if it's busy */
+       mutex_lock(&dev->dev_mutex);
+       if (dev->refcnt > 0) {
+-              mutex_unlock(&dev->dev_mutex);
+-              mutex_unlock(&devices_mutex);
+-              return -EBUSY;
++              ret = -EBUSY;
++              goto out_unlock_dev;
+       }
+       /* Remove from device list */
+       list_del(&dev->list);
+-      mutex_unlock(&devices_mutex);
+-
+       ubiblock_cleanup(dev);
+       mutex_unlock(&dev->dev_mutex);
++      mutex_unlock(&devices_mutex);
++
+       kfree(dev);
+       return 0;
++
++out_unlock_dev:
++      mutex_unlock(&dev->dev_mutex);
++out_unlock:
++      mutex_unlock(&devices_mutex);
++      return ret;
+ }
+ static int ubiblock_resize(struct ubi_volume_info *vi)
+@@ -633,6 +641,7 @@ static void ubiblock_remove_all(void)
+       struct ubiblock *next;
+       struct ubiblock *dev;
++      mutex_lock(&devices_mutex);
+       list_for_each_entry_safe(dev, next, &ubiblock_devices, list) {
+               /* The module is being forcefully removed */
+               WARN_ON(dev->desc);
+@@ -641,6 +650,7 @@ static void ubiblock_remove_all(void)
+               ubiblock_cleanup(dev);
+               kfree(dev);
+       }
++      mutex_unlock(&devices_mutex);
+ }
+ int __init ubiblock_init(void)