From patchwork Thu May 23 19:05:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 165052 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp2607263ili; Thu, 23 May 2019 12:15:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3Nwq74AVJcx/EtnayHLizN6l2cT3lliJYY6JvAjpA5gThZaQe77bA1+MY1jx8sWJ08gs1 X-Received: by 2002:a17:90a:22d0:: with SMTP id s74mr3388412pjc.3.1558638952756; Thu, 23 May 2019 12:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558638952; cv=none; d=google.com; s=arc-20160816; b=UUoYPt3de6NhYPWcq8EmXTsMJhqWJ7097zOdg33A4Ga70HF6zVP8kHRVuVRgFF1euL jM+31xLQLWn0FhCc6qfEe+TgYX8mqtkiLM6Nm64XKd+1onLqopPCqMkHBDVZx0NnOadB bf6zB6RoK1Rv5+w3MNyL48q7Kci2cgOFj2HeE+xl2vczFSUvBjB2bYnqRiYzfySzMQsh x4VS5WpR6ZVCfO8pozJxfzNvd0QkV+gy1qOhlE8JSYbO2I/MGabFHxWf1wmCkmTuxmtf Kz2z7xCQzL+FuIw0Lx5f80udIrpGH6KNCoVgVeybpl5kXimQQ5URHh6WmIfcBbuPSfUa 9xGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KEVtfQ2jsJB44mlpJnX7tOxN1Z5OXLllYNaE7aqT4pU=; b=1I9NgwJU9bqak6r7DSifGq9/JVaviFus6sPKMjt9FUzt2Bbh838QkNn3HbtdjcmSY5 To80LW2qyPdUwDs1WLFZzilOBew8lyQOpdR429Lr/bvjdt6jXBSsP5qFwsDo2udXpFlP MHj4nRkgiJh5xVppGoGTcTiaMSm8JSVphrxv86S6yrFOA+xBA1irKWuC/Ay8sablJyZW CXh7eVbKlMhCduB90gf+B3bXdi6ngRHyCH4deRgCbqpVR9JvWLl2+dWK3WWF1KAN8p4K jzHRiDDtC1rsobBXEYZD3pv+TSA/gxwWRcYAW9uMtWtZiUBdiBmmMUMCuDr1qB0Lfu2m K7ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cAnmXq3r; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 101si619454plb.31.2019.05.23.12.15.52; Thu, 23 May 2019 12:15:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cAnmXq3r; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388623AbfEWTPv (ORCPT + 30 others); Thu, 23 May 2019 15:15:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:50270 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389066AbfEWTPq (ORCPT ); Thu, 23 May 2019 15:15:46 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D590C2133D; Thu, 23 May 2019 19:15:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558638946; bh=HiFtAIKrl+Yj/b7btEiQx9X+/cf8POcNBsL9C668gKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cAnmXq3rNl4GYGEnZ89oWrttUELBRqd1Nt00SVPEKLswghcE3lgtUMPEP22RzW8ko dx/qv4xcvn67z+1u1Rk/8cr5ANrizYCxKKsLzE34c1RZ/sIh9e+s1Pl9Mia1zdfLCZ HgyIMX6UXbkpVLWe8XwyK7w5dhrZBNCl+98IyXz8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhong Kaihua , John Stultz , Zhangfei Gao , Dong Zhang , Leo Yan , Stephen Boyd Subject: [PATCH 4.19 039/114] clk: hi3660: Mark clk_gate_ufs_subsys as critical Date: Thu, 23 May 2019 21:05:38 +0200 Message-Id: <20190523181735.310111138@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190523181731.372074275@linuxfoundation.org> References: <20190523181731.372074275@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leo Yan commit 9f77a60669d13ed4ddfa6cd7374c9d88da378ffa upstream. clk_gate_ufs_subsys is a system bus clock, turning off it will introduce lockup issue during system suspend flow. Let's mark clk_gate_ufs_subsys as critical clock, thus keeps it on during system suspend and resume. Fixes: d374e6fd5088 ("clk: hisilicon: Add clock driver for hi3660 SoC") Cc: stable@vger.kernel.org Cc: Zhong Kaihua Cc: John Stultz Cc: Zhangfei Gao Suggested-by: Dong Zhang Signed-off-by: Leo Yan Signed-off-by: Stephen Boyd Signed-off-by: Greg Kroah-Hartman --- drivers/clk/hisilicon/clk-hi3660.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/clk/hisilicon/clk-hi3660.c +++ b/drivers/clk/hisilicon/clk-hi3660.c @@ -163,8 +163,12 @@ static const struct hisi_gate_clock hi36 "clk_isp_snclk_mux", CLK_SET_RATE_PARENT, 0x50, 17, 0, }, { HI3660_CLK_GATE_ISP_SNCLK2, "clk_gate_isp_snclk2", "clk_isp_snclk_mux", CLK_SET_RATE_PARENT, 0x50, 18, 0, }, + /* + * clk_gate_ufs_subsys is a system bus clock, mark it as critical + * clock and keep it on for system suspend and resume. + */ { HI3660_CLK_GATE_UFS_SUBSYS, "clk_gate_ufs_subsys", "clk_div_sysbus", - CLK_SET_RATE_PARENT, 0x50, 21, 0, }, + CLK_SET_RATE_PARENT | CLK_IS_CRITICAL, 0x50, 21, 0, }, { HI3660_PCLK_GATE_DSI0, "pclk_gate_dsi0", "clk_div_cfgbus", CLK_SET_RATE_PARENT, 0x50, 28, 0, }, { HI3660_PCLK_GATE_DSI1, "pclk_gate_dsi1", "clk_div_cfgbus", From patchwork Thu May 23 19:06:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 165054 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp2611480ili; Thu, 23 May 2019 12:19:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxruX71Z88xHsg8MkMuo8naDwyPd5ooznlWySR4bNA//J6Wd85mP2MGy7HZSMqqWcjiAMSo X-Received: by 2002:a17:90a:a790:: with SMTP id f16mr3599575pjq.27.1558639172620; Thu, 23 May 2019 12:19:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558639172; cv=none; d=google.com; s=arc-20160816; b=NqpvmUL5dkszXer6PeF4O8MwCF75iU6KCjsnaSU5x8ujKWD0X3QQXeyCVg8OnbsUJ2 imv10Q9ZI1Ezvrs20pJ3t6hHFDn8HbgB4gTm93mUi695gHDjJpl4GcQwh2GyOttk8MT8 xyVpNw9sr4jBrbJg3Om8SZaTQdYgxCffyEDeI8/YwzlJXKDiIdqV/YN1fj1SxsMjkzA8 R8LsLg9Mogg4onWdnKZpyZajgRhxhvXwbfY9DhF7AJIrWA2NHzsx1DyX/bzlizDPIjjx KHAeNoWWp++lVsPv8mVVyIdCpPVnBDANOlNF0YinDSrYnPXeb048veeW20IEXMOHchM/ n/Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=prWGkba+ocs8Na2N7TpUbHu775tD4AHdAm/gHrCWo60=; b=Gfql8yq3KqWjyNQAOP4SNgBHIcfRJ96J5WNK1U2d/awlxmQOzk44JukV2FjPWa3VdW eIoDjr6pxwl/hYdFIPfUSR98E6e3Rh6nJW6QSLMXShmwqtboXQ2PBv3k78yOHWSAuhuP wSgdUGWN0Zz9nt+F7OX1f9dIl8GoyjxEQQYAeTo3b0GKKfM0HuOjrkTGvRXAfoz53M0b C6rKK6iAVg9RwItt4ZKH8zcH1J9T47cA9NBT4BYv8hIz/bsWAIoHrQP2Vq7Itfdjm+zz b1nTk9/Y07Bgyqo25DLCqGTcLzwQusJsJj4VJGaiRh92fvA1pZG3s3wL9yL+/it+SKgd EXjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WXBI8s2Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l33si1776893pje.1.2019.05.23.12.19.32; Thu, 23 May 2019 12:19:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WXBI8s2Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389833AbfEWTTa (ORCPT + 30 others); Thu, 23 May 2019 15:19:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:55378 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388839AbfEWTTZ (ORCPT ); Thu, 23 May 2019 15:19:25 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B0FBF21871; Thu, 23 May 2019 19:19:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558639164; bh=ah9NYwZD5QyR//kljXWMaBM3bNbH/UdGmfzGGRv4JgI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WXBI8s2Q9+8sGuAGlAQsZURrtnCuU26zblU9qbvZaMhEiVkXEtClzeBOZVM/beYiI KOff1QpIERMaEN8YA2uyy3AC3/Gokw9mYVqd76v+gFO0fGRjqDvpDHx3/Lk9ZxomFQ 9W2ZH/3J8lGe+kyI3svnDZHFZrYIA20ZwvFT01BU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiang Chen , John Garry , Robin Murphy Subject: [PATCH 4.19 110/114] driver core: Postpone DMA tear-down until after devres release for probe failure Date: Thu, 23 May 2019 21:06:49 +0200 Message-Id: <20190523181740.751743027@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190523181731.372074275@linuxfoundation.org> References: <20190523181731.372074275@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: John Garry commit 0b777eee88d712256ba8232a9429edb17c4f9ceb upstream. In commit 376991db4b64 ("driver core: Postpone DMA tear-down until after devres release"), we changed the ordering of tearing down the device DMA ops and releasing all the device's resources; this was because the DMA ops should be maintained until we release the device's managed DMA memories. However, we have seen another crash on an arm64 system when a device driver probe fails: hisi_sas_v3_hw 0000:74:02.0: Adding to iommu group 2 scsi host1: hisi_sas_v3_hw BUG: Bad page state in process swapper/0 pfn:313f5 page:ffff7e0000c4fd40 count:1 mapcount:0 mapping:0000000000000000 index:0x0 flags: 0xfffe00000001000(reserved) raw: 0fffe00000001000 ffff7e0000c4fd48 ffff7e0000c4fd48 0000000000000000 raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000 page dumped because: PAGE_FLAGS_CHECK_AT_FREE flag(s) set bad because of flags: 0x1000(reserved) Modules linked in: CPU: 49 PID: 1 Comm: swapper/0 Not tainted 5.1.0-rc1-43081-g22d97fd-dirty #1433 Hardware name: Huawei D06/D06, BIOS Hisilicon D06 UEFI RC0 - V1.12.01 01/29/2019 Call trace: dump_backtrace+0x0/0x118 show_stack+0x14/0x1c dump_stack+0xa4/0xc8 bad_page+0xe4/0x13c free_pages_check_bad+0x4c/0xc0 __free_pages_ok+0x30c/0x340 __free_pages+0x30/0x44 __dma_direct_free_pages+0x30/0x38 dma_direct_free+0x24/0x38 dma_free_attrs+0x9c/0xd8 dmam_release+0x20/0x28 release_nodes+0x17c/0x220 devres_release_all+0x34/0x54 really_probe+0xc4/0x2c8 driver_probe_device+0x58/0xfc device_driver_attach+0x68/0x70 __driver_attach+0x94/0xdc bus_for_each_dev+0x5c/0xb4 driver_attach+0x20/0x28 bus_add_driver+0x14c/0x200 driver_register+0x6c/0x124 __pci_register_driver+0x48/0x50 sas_v3_pci_driver_init+0x20/0x28 do_one_initcall+0x40/0x25c kernel_init_freeable+0x2b8/0x3c0 kernel_init+0x10/0x100 ret_from_fork+0x10/0x18 Disabling lock debugging due to kernel taint BUG: Bad page state in process swapper/0 pfn:313f6 page:ffff7e0000c4fd80 count:1 mapcount:0 mapping:0000000000000000 index:0x0 [ 89.322983] flags: 0xfffe00000001000(reserved) raw: 0fffe00000001000 ffff7e0000c4fd88 ffff7e0000c4fd88 0000000000000000 raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000 The crash occurs for the same reason. In this case, on the really_probe() failure path, we are still clearing the DMA ops prior to releasing the device's managed memories. This patch fixes this issue by reordering the DMA ops teardown and the call to devres_release_all() on the failure path. Reported-by: Xiang Chen Tested-by: Xiang Chen Signed-off-by: John Garry Reviewed-by: Robin Murphy [jpg: backport to 4.19.x and earlier] Signed-off-by: John Garry Signed-off-by: Greg Kroah-Hartman --- drivers/base/dd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -482,7 +482,7 @@ re_probe: ret = dma_configure(dev); if (ret) - goto dma_failed; + goto probe_failed; if (driver_sysfs_add(dev)) { printk(KERN_ERR "%s: driver_sysfs_add(%s) failed\n", @@ -537,14 +537,13 @@ re_probe: goto done; probe_failed: - dma_deconfigure(dev); -dma_failed: if (dev->bus) blocking_notifier_call_chain(&dev->bus->p->bus_notifier, BUS_NOTIFY_DRIVER_NOT_BOUND, dev); pinctrl_bind_failed: device_links_no_driver(dev); devres_release_all(dev); + dma_deconfigure(dev); driver_sysfs_remove(dev); dev->driver = NULL; dev_set_drvdata(dev, NULL);