From: Greg Kroah-Hartman Date: Mon, 18 Feb 2019 13:34:44 +0000 (+0100) Subject: 4.9-stable patches X-Git-Tag: v3.18.135~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=511513014d1b352f1be358d1846239d9eb109ede;p=thirdparty%2Fkernel%2Fstable-queue.git 4.9-stable patches added patches: mm-stop-leaking-pagetables.patch pinctrl-msm-fix-gpio-hog-related-boot-issues.patch --- diff --git a/queue-4.9/mm-stop-leaking-pagetables.patch b/queue-4.9/mm-stop-leaking-pagetables.patch new file mode 100644 index 00000000000..4c347a58e48 --- /dev/null +++ b/queue-4.9/mm-stop-leaking-pagetables.patch @@ -0,0 +1,82 @@ +From b0b9b3df27d100a975b4e8818f35382b64a5e35c Mon Sep 17 00:00:00 2001 +From: Hugh Dickins +Date: Sat, 7 Jan 2017 15:37:31 -0800 +Subject: mm: stop leaking PageTables + +From: Hugh Dickins + +commit b0b9b3df27d100a975b4e8818f35382b64a5e35c upstream. + +4.10-rc loadtest (even on x86, and even without THPCache) fails with +"fork: Cannot allocate memory" or some such; and /proc/meminfo shows +PageTables growing. + +Commit 953c66c2b22a ("mm: THP page cache support for ppc64") that got +merged in rc1 removed the freeing of an unused preallocated pagetable +after do_fault_around() has called map_pages(). + +This is usually a good optimization, so that the followup doesn't have +to reallocate one; but it's not sufficient to shift the freeing into +alloc_set_pte(), since there are failure cases (most commonly +VM_FAULT_RETRY) which never reach finish_fault(). + +Check and free it at the outer level in do_fault(), then we don't need +to worry in alloc_set_pte(), and can restore that to how it was (I +cannot find any reason to pte_free() under lock as it was doing). + +And fix a separate pagetable leak, or crash, introduced by the same +change, that could only show up on some ppc64: why does do_set_pmd()'s +failure case attempt to withdraw a pagetable when it never deposited +one, at the same time overwriting (so leaking) the vmf->prealloc_pte? +Residue of an earlier implementation, perhaps? Delete it. + +Fixes: 953c66c2b22a ("mm: THP page cache support for ppc64") +Cc: Aneesh Kumar K.V +Cc: Kirill A. Shutemov +Cc: Michael Ellerman +Cc: Benjamin Herrenschmidt +Cc: Michael Neuling +Cc: Paul Mackerras +Cc: Balbir Singh +Cc: Andrew Morton +Signed-off-by: Hugh Dickins +Signed-off-by: Linus Torvalds +Signed-off-by: Minchan Kim +Signed-off-by: Greg Kroah-Hartman +--- + mm/memory.c | 21 +++++++++++++++------ + 1 file changed, 15 insertions(+), 6 deletions(-) + +--- a/mm/memory.c ++++ b/mm/memory.c +@@ -3329,15 +3329,24 @@ static int do_fault(struct fault_env *fe + { + struct vm_area_struct *vma = fe->vma; + pgoff_t pgoff = linear_page_index(vma, fe->address); ++ int ret; + + /* The VMA was not fully populated on mmap() or missing VM_DONTEXPAND */ + if (!vma->vm_ops->fault) +- return VM_FAULT_SIGBUS; +- if (!(fe->flags & FAULT_FLAG_WRITE)) +- return do_read_fault(fe, pgoff); +- if (!(vma->vm_flags & VM_SHARED)) +- return do_cow_fault(fe, pgoff); +- return do_shared_fault(fe, pgoff); ++ ret = VM_FAULT_SIGBUS; ++ else if (!(fe->flags & FAULT_FLAG_WRITE)) ++ ret = do_read_fault(fe, pgoff); ++ else if (!(vma->vm_flags & VM_SHARED)) ++ ret = do_cow_fault(fe, pgoff); ++ else ++ ret = do_shared_fault(fe, pgoff); ++ ++ /* preallocated pagetable is unused: free it */ ++ if (fe->prealloc_pte) { ++ pte_free(vma->vm_mm, fe->prealloc_pte); ++ fe->prealloc_pte = 0; ++ } ++ return ret; + } + + static int numa_migrate_prep(struct page *page, struct vm_area_struct *vma, diff --git a/queue-4.9/pinctrl-msm-fix-gpio-hog-related-boot-issues.patch b/queue-4.9/pinctrl-msm-fix-gpio-hog-related-boot-issues.patch new file mode 100644 index 00000000000..bc6ea2081e0 --- /dev/null +++ b/queue-4.9/pinctrl-msm-fix-gpio-hog-related-boot-issues.patch @@ -0,0 +1,101 @@ +From a86caa9ba5d70696ceb35d1d39caa20d8b641387 Mon Sep 17 00:00:00 2001 +From: Christian Lamparter +Date: Mon, 21 May 2018 22:57:37 +0200 +Subject: pinctrl: msm: fix gpio-hog related boot issues + +From: Christian Lamparter + +commit a86caa9ba5d70696ceb35d1d39caa20d8b641387 upstream. + +Sven Eckelmann reported an issue with the current IPQ4019 pinctrl. +Setting up any gpio-hog in the device-tree for his device would +"kill the bootup completely": + +| [ 0.477838] msm_serial 78af000.serial: could not find pctldev for node /soc/pinctrl@1000000/serial_pinmux, deferring probe +| [ 0.499828] spi_qup 78b5000.spi: could not find pctldev for node /soc/pinctrl@1000000/spi_0_pinmux, deferring probe +| [ 1.298883] requesting hog GPIO enable USB2 power (chip 1000000.pinctrl, offset 58) failed, -517 +| [ 1.299609] gpiochip_add_data: GPIOs 0..99 (1000000.pinctrl) failed to register +| [ 1.308589] ipq4019-pinctrl 1000000.pinctrl: Failed register gpiochip +| [ 1.316586] msm_serial 78af000.serial: could not find pctldev for node /soc/pinctrl@1000000/serial_pinmux, deferring probe +| [ 1.322415] spi_qup 78b5000.spi: could not find pctldev for node /soc/pinctrl@1000000/spi_0_pinmux, deferri + +This was also verified on a RT-AC58U (IPQ4018) which would +no longer boot, if a gpio-hog was specified. (Tried forcing +the USB LED PIN (GPIO0) to high.). + +The problem is that Pinctrl+GPIO registration is currently +peformed in the following order in pinctrl-msm.c: + 1. pinctrl_register() + 2. gpiochip_add() + 3. gpiochip_add_pin_range() + +The actual error code -517 == -EPROBE_DEFER is coming from +pinctrl_get_device_gpio_range(), which is called through: + gpiochip_add + of_gpiochip_add + of_gpiochip_scan_gpios + gpiod_hog + gpiochip_request_own_desc + __gpiod_request + chip->request + gpiochip_generic_request + pinctrl_gpio_request + pinctrl_get_device_gpio_range + +pinctrl_get_device_gpio_range() is unable to find any valid +pin ranges, since nothing has been added to the pinctrldev_list yet. +so the range can't be found, and the operation fails with -EPROBE_DEFER. + +This patch fixes the issue by adding the "gpio-ranges" property to +the pinctrl device node of all upstream Qcom SoC. The pin ranges are +then added by the gpio core. + +In order to remain compatible with older, existing DTs (and ACPI) +a check for the "gpio-ranges" property has been added to +msm_gpio_init(). This prevents the driver of adding the same entry +to the pinctrldev_list twice. + +Reported-by: Sven Eckelmann +Tested-by: Sven Eckelmann [ipq4019] +Reviewed-by: Bjorn Andersson +Signed-off-by: Christian Lamparter +Signed-off-by: Linus Walleij +Signed-off-by: Amit Pundir +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/pinctrl/qcom/pinctrl-msm.c | 23 ++++++++++++++++++----- + 1 file changed, 18 insertions(+), 5 deletions(-) + +--- a/drivers/pinctrl/qcom/pinctrl-msm.c ++++ b/drivers/pinctrl/qcom/pinctrl-msm.c +@@ -803,11 +803,24 @@ static int msm_gpio_init(struct msm_pinc + return ret; + } + +- ret = gpiochip_add_pin_range(&pctrl->chip, dev_name(pctrl->dev), 0, 0, chip->ngpio); +- if (ret) { +- dev_err(pctrl->dev, "Failed to add pin range\n"); +- gpiochip_remove(&pctrl->chip); +- return ret; ++ /* ++ * For DeviceTree-supported systems, the gpio core checks the ++ * pinctrl's device node for the "gpio-ranges" property. ++ * If it is present, it takes care of adding the pin ranges ++ * for the driver. In this case the driver can skip ahead. ++ * ++ * In order to remain compatible with older, existing DeviceTree ++ * files which don't set the "gpio-ranges" property or systems that ++ * utilize ACPI the driver has to call gpiochip_add_pin_range(). ++ */ ++ if (!of_property_read_bool(pctrl->dev->of_node, "gpio-ranges")) { ++ ret = gpiochip_add_pin_range(&pctrl->chip, ++ dev_name(pctrl->dev), 0, 0, chip->ngpio); ++ if (ret) { ++ dev_err(pctrl->dev, "Failed to add pin range\n"); ++ gpiochip_remove(&pctrl->chip); ++ return ret; ++ } + } + + ret = gpiochip_irqchip_add(chip, diff --git a/queue-4.9/series b/queue-4.9/series index b27cabbac97..124d1f8ee0e 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -54,3 +54,5 @@ ch9200-use-skb_cow_head-to-deal-with-cloned-skbs.patch kaweth-use-skb_cow_head-to-deal-with-cloned-skbs.patch usb-dwc2-remove-unnecessary-kfree.patch netfilter-nf_tables-fix-mismatch-in-big-endian-system.patch +pinctrl-msm-fix-gpio-hog-related-boot-issues.patch +mm-stop-leaking-pagetables.patch