From: Greg Kroah-Hartman Date: Mon, 6 Jan 2020 15:52:30 +0000 (+0100) Subject: 4.14-stable patches X-Git-Tag: v4.14.163~40 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7dba97a1f793108be9b06be87a9b5a9bf9dd8ebb;p=thirdparty%2Fkernel%2Fstable-queue.git 4.14-stable patches added patches: ata-ahci_brcm-fix-ahci-resources-management.patch ata-libahci_platform-export-again-ahci_platform_-en-dis-able_phys.patch gpiolib-fix-up-emulated-open-drain-outputs.patch tracing-fix-lock-inversion-in-trace_event_enable_tgid_record.patch tracing-have-the-histogram-compare-functions-convert-to-u64-first.patch --- diff --git a/queue-4.14/ata-ahci_brcm-fix-ahci-resources-management.patch b/queue-4.14/ata-ahci_brcm-fix-ahci-resources-management.patch new file mode 100644 index 00000000000..1362bb6ec43 --- /dev/null +++ b/queue-4.14/ata-ahci_brcm-fix-ahci-resources-management.patch @@ -0,0 +1,224 @@ +From c0cdf2ac4b5bf3e5ef2451ea29fb4104278cdabc Mon Sep 17 00:00:00 2001 +From: Florian Fainelli +Date: Tue, 10 Dec 2019 10:53:45 -0800 +Subject: ata: ahci_brcm: Fix AHCI resources management + +From: Florian Fainelli + +commit c0cdf2ac4b5bf3e5ef2451ea29fb4104278cdabc upstream. + +The AHCI resources management within ahci_brcm.c is a little +convoluted, largely because it historically had a dedicated clock that +was managed within this file in the downstream tree. Once brough +upstream though, the clock was left to be managed by libahci_platform.c +which is entirely appropriate. + +This patch series ensures that the AHCI resources are fetched and +enabled before any register access is done, thus avoiding bus errors on +platforms which clock gate the controller by default. + +As a result we need to re-arrange the suspend() and resume() functions +in order to avoid accessing registers after the clocks have been turned +off respectively before the clocks have been turned on. Finally, we can +refactor brcm_ahci_get_portmask() in order to fetch the number of ports +from hpriv->mmio which is now accessible without jumping through hoops +like we used to do. + +The commit pointed in the Fixes tag is both old and new enough not to +require major headaches for backporting of this patch. + +Fixes: eba68f829794 ("ata: ahci_brcmstb: rename to support across Broadcom SoC's") +Cc: stable@vger.kernel.org +Reviewed-by: Hans de Goede +Signed-off-by: Florian Fainelli +Signed-off-by: Jens Axboe +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/ata/ahci_brcm.c | 105 ++++++++++++++++++++++++++++++++++-------------- + 1 file changed, 76 insertions(+), 29 deletions(-) + +--- a/drivers/ata/ahci_brcm.c ++++ b/drivers/ata/ahci_brcm.c +@@ -221,19 +221,12 @@ static void brcm_sata_phys_disable(struc + brcm_sata_phy_disable(priv, i); + } + +-static u32 brcm_ahci_get_portmask(struct platform_device *pdev, ++static u32 brcm_ahci_get_portmask(struct ahci_host_priv *hpriv, + struct brcm_ahci_priv *priv) + { +- void __iomem *ahci; +- struct resource *res; + u32 impl; + +- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ahci"); +- ahci = devm_ioremap_resource(&pdev->dev, res); +- if (IS_ERR(ahci)) +- return 0; +- +- impl = readl(ahci + HOST_PORTS_IMPL); ++ impl = readl(hpriv->mmio + HOST_PORTS_IMPL); + + if (fls(impl) > SATA_TOP_MAX_PHYS) + dev_warn(priv->dev, "warning: more ports than PHYs (%#x)\n", +@@ -241,9 +234,6 @@ static u32 brcm_ahci_get_portmask(struct + else if (!impl) + dev_info(priv->dev, "no ports found\n"); + +- devm_iounmap(&pdev->dev, ahci); +- devm_release_mem_region(&pdev->dev, res->start, resource_size(res)); +- + return impl; + } + +@@ -270,11 +260,10 @@ static int brcm_ahci_suspend(struct devi + struct ata_host *host = dev_get_drvdata(dev); + struct ahci_host_priv *hpriv = host->private_data; + struct brcm_ahci_priv *priv = hpriv->plat_data; +- int ret; + +- ret = ahci_platform_suspend(dev); + brcm_sata_phys_disable(priv); +- return ret; ++ ++ return ahci_platform_suspend(dev); + } + + static int brcm_ahci_resume(struct device *dev) +@@ -282,11 +271,44 @@ static int brcm_ahci_resume(struct devic + struct ata_host *host = dev_get_drvdata(dev); + struct ahci_host_priv *hpriv = host->private_data; + struct brcm_ahci_priv *priv = hpriv->plat_data; ++ int ret; ++ ++ /* Make sure clocks are turned on before re-configuration */ ++ ret = ahci_platform_enable_clks(hpriv); ++ if (ret) ++ return ret; + + brcm_sata_init(priv); + brcm_sata_phys_enable(priv); + brcm_sata_alpm_init(hpriv); +- return ahci_platform_resume(dev); ++ ++ /* Since we had to enable clocks earlier on, we cannot use ++ * ahci_platform_resume() as-is since a second call to ++ * ahci_platform_enable_resources() would bump up the resources ++ * (regulators, clocks, PHYs) count artificially so we copy the part ++ * after ahci_platform_enable_resources(). ++ */ ++ ret = ahci_platform_enable_phys(hpriv); ++ if (ret) ++ goto out_disable_phys; ++ ++ ret = ahci_platform_resume_host(dev); ++ if (ret) ++ goto out_disable_platform_phys; ++ ++ /* We resumed so update PM runtime state */ ++ pm_runtime_disable(dev); ++ pm_runtime_set_active(dev); ++ pm_runtime_enable(dev); ++ ++ return 0; ++ ++out_disable_platform_phys: ++ ahci_platform_disable_phys(hpriv); ++out_disable_phys: ++ brcm_sata_phys_disable(priv); ++ ahci_platform_disable_clks(hpriv); ++ return ret; + } + #endif + +@@ -333,38 +355,63 @@ static int brcm_ahci_probe(struct platfo + priv->quirks |= BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE; + } + ++ hpriv = ahci_platform_get_resources(pdev); ++ if (IS_ERR(hpriv)) { ++ ret = PTR_ERR(hpriv); ++ goto out_reset; ++ } ++ ++ ret = ahci_platform_enable_clks(hpriv); ++ if (ret) ++ goto out_reset; ++ ++ /* Must be first so as to configure endianness including that ++ * of the standard AHCI register space. ++ */ + brcm_sata_init(priv); + +- priv->port_mask = brcm_ahci_get_portmask(pdev, priv); +- if (!priv->port_mask) +- return -ENODEV; ++ /* Initializes priv->port_mask which is used below */ ++ priv->port_mask = brcm_ahci_get_portmask(hpriv, priv); ++ if (!priv->port_mask) { ++ ret = -ENODEV; ++ goto out_disable_clks; ++ } + ++ /* Must be done before ahci_platform_enable_phys() */ + brcm_sata_phys_enable(priv); + +- hpriv = ahci_platform_get_resources(pdev); +- if (IS_ERR(hpriv)) +- return PTR_ERR(hpriv); + hpriv->plat_data = priv; + hpriv->flags = AHCI_HFLAG_WAKE_BEFORE_STOP; + + brcm_sata_alpm_init(hpriv); + +- ret = ahci_platform_enable_resources(hpriv); +- if (ret) +- return ret; +- + if (priv->quirks & BRCM_AHCI_QUIRK_NO_NCQ) + hpriv->flags |= AHCI_HFLAG_NO_NCQ; + hpriv->flags |= AHCI_HFLAG_NO_WRITE_TO_RO; + ++ ret = ahci_platform_enable_phys(hpriv); ++ if (ret) ++ goto out_disable_phys; ++ + ret = ahci_platform_init_host(pdev, hpriv, &ahci_brcm_port_info, + &ahci_platform_sht); + if (ret) +- return ret; ++ goto out_disable_platform_phys; + + dev_info(dev, "Broadcom AHCI SATA3 registered\n"); + + return 0; ++ ++out_disable_platform_phys: ++ ahci_platform_disable_phys(hpriv); ++out_disable_phys: ++ brcm_sata_phys_disable(priv); ++out_disable_clks: ++ ahci_platform_disable_clks(hpriv); ++out_reset: ++ if (!IS_ERR_OR_NULL(priv->rcdev)) ++ reset_control_assert(priv->rcdev); ++ return ret; + } + + static int brcm_ahci_remove(struct platform_device *pdev) +@@ -374,12 +421,12 @@ static int brcm_ahci_remove(struct platf + struct brcm_ahci_priv *priv = hpriv->plat_data; + int ret; + ++ brcm_sata_phys_disable(priv); ++ + ret = ata_platform_remove_one(pdev); + if (ret) + return ret; + +- brcm_sata_phys_disable(priv); +- + return 0; + } + diff --git a/queue-4.14/ata-libahci_platform-export-again-ahci_platform_-en-dis-able_phys.patch b/queue-4.14/ata-libahci_platform-export-again-ahci_platform_-en-dis-able_phys.patch new file mode 100644 index 00000000000..a4714aa2839 --- /dev/null +++ b/queue-4.14/ata-libahci_platform-export-again-ahci_platform_-en-dis-able_phys.patch @@ -0,0 +1,76 @@ +From 84b032dbfdf1c139cd2b864e43959510646975f8 Mon Sep 17 00:00:00 2001 +From: Florian Fainelli +Date: Tue, 10 Dec 2019 10:53:44 -0800 +Subject: ata: libahci_platform: Export again ahci_platform_able_phys() + +From: Florian Fainelli + +commit 84b032dbfdf1c139cd2b864e43959510646975f8 upstream. + +This reverts commit 6bb86fefa086faba7b60bb452300b76a47cde1a5 +("libahci_platform: Staticize ahci_platform_able_phys()") we are +going to need ahci_platform_{enable,disable}_phys() in a subsequent +commit for ahci_brcm.c in order to properly control the PHY +initialization order. + +Also make sure the function prototypes are declared in +include/linux/ahci_platform.h as a result. + +Cc: stable@vger.kernel.org +Reviewed-by: Hans de Goede +Signed-off-by: Florian Fainelli +Signed-off-by: Jens Axboe +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/ata/libahci_platform.c | 6 ++++-- + include/linux/ahci_platform.h | 2 ++ + 2 files changed, 6 insertions(+), 2 deletions(-) + +--- a/drivers/ata/libahci_platform.c ++++ b/drivers/ata/libahci_platform.c +@@ -46,7 +46,7 @@ EXPORT_SYMBOL_GPL(ahci_platform_ops); + * RETURNS: + * 0 on success otherwise a negative error code + */ +-static int ahci_platform_enable_phys(struct ahci_host_priv *hpriv) ++int ahci_platform_enable_phys(struct ahci_host_priv *hpriv) + { + int rc, i; + +@@ -71,6 +71,7 @@ disable_phys: + } + return rc; + } ++EXPORT_SYMBOL_GPL(ahci_platform_enable_phys); + + /** + * ahci_platform_disable_phys - Disable PHYs +@@ -78,7 +79,7 @@ disable_phys: + * + * This function disables all PHYs found in hpriv->phys. + */ +-static void ahci_platform_disable_phys(struct ahci_host_priv *hpriv) ++void ahci_platform_disable_phys(struct ahci_host_priv *hpriv) + { + int i; + +@@ -87,6 +88,7 @@ static void ahci_platform_disable_phys(s + phy_exit(hpriv->phys[i]); + } + } ++EXPORT_SYMBOL_GPL(ahci_platform_disable_phys); + + /** + * ahci_platform_enable_clks - Enable platform clocks +--- a/include/linux/ahci_platform.h ++++ b/include/linux/ahci_platform.h +@@ -23,6 +23,8 @@ struct ahci_host_priv; + struct platform_device; + struct scsi_host_template; + ++int ahci_platform_enable_phys(struct ahci_host_priv *hpriv); ++void ahci_platform_disable_phys(struct ahci_host_priv *hpriv); + int ahci_platform_enable_clks(struct ahci_host_priv *hpriv); + void ahci_platform_disable_clks(struct ahci_host_priv *hpriv); + int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv); diff --git a/queue-4.14/gpiolib-fix-up-emulated-open-drain-outputs.patch b/queue-4.14/gpiolib-fix-up-emulated-open-drain-outputs.patch new file mode 100644 index 00000000000..07993cc8b28 --- /dev/null +++ b/queue-4.14/gpiolib-fix-up-emulated-open-drain-outputs.patch @@ -0,0 +1,44 @@ +From 256efaea1fdc4e38970489197409a26125ee0aaa Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Sat, 7 Dec 2019 16:20:18 +0000 +Subject: gpiolib: fix up emulated open drain outputs + +From: Russell King + +commit 256efaea1fdc4e38970489197409a26125ee0aaa upstream. + +gpiolib has a corner case with open drain outputs that are emulated. +When such outputs are outputting a logic 1, emulation will set the +hardware to input mode, which will cause gpiod_get_direction() to +report that it is in input mode. This is different from the behaviour +with a true open-drain output. + +Unify the semantics here. + +Cc: +Suggested-by: Linus Walleij +Signed-off-by: Russell King +Signed-off-by: Bartosz Golaszewski +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/gpio/gpiolib.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +--- a/drivers/gpio/gpiolib.c ++++ b/drivers/gpio/gpiolib.c +@@ -206,6 +206,14 @@ int gpiod_get_direction(struct gpio_desc + chip = gpiod_to_chip(desc); + offset = gpio_chip_hwgpio(desc); + ++ /* ++ * Open drain emulation using input mode may incorrectly report ++ * input here, fix that up. ++ */ ++ if (test_bit(FLAG_OPEN_DRAIN, &desc->flags) && ++ test_bit(FLAG_IS_OUT, &desc->flags)) ++ return 0; ++ + if (!chip->get_direction) + return status; + diff --git a/queue-4.14/series b/queue-4.14/series index b7402b5e7a8..27bb203e08f 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -33,3 +33,8 @@ locks-print-unsigned-ino-in-proc-locks.patch dmaengine-fix-access-to-uninitialized-dma_slave_caps.patch compat_ioctl-block-handle-persistent-reservations.patch compat_ioctl-block-handle-blkreportzone-blkresetzone.patch +ata-libahci_platform-export-again-ahci_platform_-en-dis-able_phys.patch +ata-ahci_brcm-fix-ahci-resources-management.patch +gpiolib-fix-up-emulated-open-drain-outputs.patch +tracing-fix-lock-inversion-in-trace_event_enable_tgid_record.patch +tracing-have-the-histogram-compare-functions-convert-to-u64-first.patch diff --git a/queue-4.14/tracing-fix-lock-inversion-in-trace_event_enable_tgid_record.patch b/queue-4.14/tracing-fix-lock-inversion-in-trace_event_enable_tgid_record.patch new file mode 100644 index 00000000000..65274d59337 --- /dev/null +++ b/queue-4.14/tracing-fix-lock-inversion-in-trace_event_enable_tgid_record.patch @@ -0,0 +1,117 @@ +From 3a53acf1d9bea11b57c1f6205e3fe73f9d8a3688 Mon Sep 17 00:00:00 2001 +From: Prateek Sood +Date: Tue, 10 Dec 2019 09:15:16 +0000 +Subject: tracing: Fix lock inversion in trace_event_enable_tgid_record() + +From: Prateek Sood + +commit 3a53acf1d9bea11b57c1f6205e3fe73f9d8a3688 upstream. + + Task T2 Task T3 +trace_options_core_write() subsystem_open() + + mutex_lock(trace_types_lock) mutex_lock(event_mutex) + + set_tracer_flag() + + trace_event_enable_tgid_record() mutex_lock(trace_types_lock) + + mutex_lock(event_mutex) + +This gives a circular dependency deadlock between trace_types_lock and +event_mutex. To fix this invert the usage of trace_types_lock and +event_mutex in trace_options_core_write(). This keeps the sequence of +lock usage consistent. + +Link: http://lkml.kernel.org/r/0101016eef175e38-8ca71caf-a4eb-480d-a1e6-6f0bbc015495-000000@us-west-2.amazonses.com + +Cc: stable@vger.kernel.org +Fixes: d914ba37d7145 ("tracing: Add support for recording tgid of tasks") +Signed-off-by: Prateek Sood +Signed-off-by: Steven Rostedt (VMware) +Signed-off-by: Greg Kroah-Hartman + +--- + kernel/trace/trace.c | 8 ++++++++ + kernel/trace/trace_events.c | 8 ++++---- + 2 files changed, 12 insertions(+), 4 deletions(-) + +--- a/kernel/trace/trace.c ++++ b/kernel/trace/trace.c +@@ -4368,6 +4368,10 @@ int trace_keep_overwrite(struct tracer * + + int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled) + { ++ if ((mask == TRACE_ITER_RECORD_TGID) || ++ (mask == TRACE_ITER_RECORD_CMD)) ++ lockdep_assert_held(&event_mutex); ++ + /* do nothing if flag is already set */ + if (!!(tr->trace_flags & mask) == !!enabled) + return 0; +@@ -4433,6 +4437,7 @@ static int trace_set_options(struct trac + cmp += 2; + } + ++ mutex_lock(&event_mutex); + mutex_lock(&trace_types_lock); + + for (i = 0; trace_options[i]; i++) { +@@ -4447,6 +4452,7 @@ static int trace_set_options(struct trac + ret = set_tracer_option(tr, cmp, neg); + + mutex_unlock(&trace_types_lock); ++ mutex_unlock(&event_mutex); + + /* + * If the first trailing whitespace is replaced with '\0' by strstrip, +@@ -7373,9 +7379,11 @@ trace_options_core_write(struct file *fi + if (val != 0 && val != 1) + return -EINVAL; + ++ mutex_lock(&event_mutex); + mutex_lock(&trace_types_lock); + ret = set_tracer_flag(tr, 1 << index, val); + mutex_unlock(&trace_types_lock); ++ mutex_unlock(&event_mutex); + + if (ret < 0) + return ret; +--- a/kernel/trace/trace_events.c ++++ b/kernel/trace/trace_events.c +@@ -326,7 +326,8 @@ void trace_event_enable_cmd_record(bool + struct trace_event_file *file; + struct trace_array *tr; + +- mutex_lock(&event_mutex); ++ lockdep_assert_held(&event_mutex); ++ + do_for_each_event_file(tr, file) { + + if (!(file->flags & EVENT_FILE_FL_ENABLED)) +@@ -340,7 +341,6 @@ void trace_event_enable_cmd_record(bool + clear_bit(EVENT_FILE_FL_RECORDED_CMD_BIT, &file->flags); + } + } while_for_each_event_file(); +- mutex_unlock(&event_mutex); + } + + void trace_event_enable_tgid_record(bool enable) +@@ -348,7 +348,8 @@ void trace_event_enable_tgid_record(bool + struct trace_event_file *file; + struct trace_array *tr; + +- mutex_lock(&event_mutex); ++ lockdep_assert_held(&event_mutex); ++ + do_for_each_event_file(tr, file) { + if (!(file->flags & EVENT_FILE_FL_ENABLED)) + continue; +@@ -362,7 +363,6 @@ void trace_event_enable_tgid_record(bool + &file->flags); + } + } while_for_each_event_file(); +- mutex_unlock(&event_mutex); + } + + static int __ftrace_event_enable_disable(struct trace_event_file *file, diff --git a/queue-4.14/tracing-have-the-histogram-compare-functions-convert-to-u64-first.patch b/queue-4.14/tracing-have-the-histogram-compare-functions-convert-to-u64-first.patch new file mode 100644 index 00000000000..9112c249ae0 --- /dev/null +++ b/queue-4.14/tracing-have-the-histogram-compare-functions-convert-to-u64-first.patch @@ -0,0 +1,45 @@ +From 106f41f5a302cb1f36c7543fae6a05de12e96fa4 Mon Sep 17 00:00:00 2001 +From: "Steven Rostedt (VMware)" +Date: Wed, 11 Dec 2019 15:44:22 -0500 +Subject: tracing: Have the histogram compare functions convert to u64 first + +From: Steven Rostedt (VMware) + +commit 106f41f5a302cb1f36c7543fae6a05de12e96fa4 upstream. + +The compare functions of the histogram code would be specific for the size +of the value being compared (byte, short, int, long long). It would +reference the value from the array via the type of the compare, but the +value was stored in a 64 bit number. This is fine for little endian +machines, but for big endian machines, it would end up comparing zeros or +all ones (depending on the sign) for anything but 64 bit numbers. + +To fix this, first derference the value as a u64 then convert it to the type +being compared. + +Link: http://lkml.kernel.org/r/20191211103557.7bed6928@gandalf.local.home + +Cc: stable@vger.kernel.org +Fixes: 08d43a5fa063e ("tracing: Add lock-free tracing_map") +Acked-by: Tom Zanussi +Reported-by: Sven Schnelle +Signed-off-by: Steven Rostedt (VMware) +Signed-off-by: Greg Kroah-Hartman + +--- + kernel/trace/tracing_map.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/kernel/trace/tracing_map.c ++++ b/kernel/trace/tracing_map.c +@@ -90,8 +90,8 @@ static int tracing_map_cmp_atomic64(void + #define DEFINE_TRACING_MAP_CMP_FN(type) \ + static int tracing_map_cmp_##type(void *val_a, void *val_b) \ + { \ +- type a = *(type *)val_a; \ +- type b = *(type *)val_b; \ ++ type a = (type)(*(u64 *)val_a); \ ++ type b = (type)(*(u64 *)val_b); \ + \ + return (a > b) ? 1 : ((a < b) ? -1 : 0); \ + }