Message ID | 20240223-b4-bus-v1-2-2803c3ac4673@outlook.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-77743-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp368239dyb; Thu, 22 Feb 2024 19:52:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXNAjg5QG8nqZh5icmadzARauRsoG8E7w5sD3UX2WyLxgrtB2qE0QRoYuzP7kFNRcEDK1smnzh9NfnK0ggVmGMuS9updA== X-Google-Smtp-Source: AGHT+IGpQQnzB8a+6fOnG8uFbpNoKQLFzfI5dhtRmTCuoBw7nf3wafPFn1X2LGIBSzBBSIo0k26/ X-Received: by 2002:a05:620a:12ed:b0:787:a766:6eb4 with SMTP id f13-20020a05620a12ed00b00787a7666eb4mr909733qkl.62.1708660375581; Thu, 22 Feb 2024 19:52:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708660375; cv=pass; d=google.com; s=arc-20160816; b=Mb/qaYA4j6SKw0mT8wf5Ul0fk5oVxlErogbULysy7VHRadbFxVFLcceX77UdX0N2Fy 6et+l26kscs1rFK370c/oFNXiDh/DQlETfYWVR2EMiRXszquNiInRrWr0xzz2c0Zjs5O +ysevX0x7vwGlobfZeq5/YTSJZz5LYhhCk6SIXPwMzEw9SwRSOUsP8xeaalD0RrYjo8o V5glfBYq7H/TmdKr58ywP1tA0vMqllDMBu+Cnk3iJNohhKEeiuIUue/joq6QD6EsrE57 umHLKF020OoLT7Rml2sKDHtv/fvPMD9AF7dI4zhiuEDBnUBoPIldy+GI7gegTxReuMHi EB1w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:date:from:dkim-signature; bh=2+kui3rF8OVERqBfrbtrESqaK9kTj65yv1h19o2Kbbs=; fh=v9eDaXLBM4EIWvXGxm7HVV0FdJjPOnBmQsTyxhEFunc=; b=uiZoIuvux2vWGlrlWAAnfRPoKHKNpdDSVTD/Stx6VDRc5zGdhN9OqrM8NyFz7Di4St gm16s7Q/k9BoAa1+aSlWInNCEX+MR5ac5ezNH6QU0BJalPxyrpBDOxjHcHCNFSp6SCOj 7Z5E5HBDL3e5Fus4+HfwoVNHrMVZrPAvqOAN2WRuFWYhFKjgppQARdqGTAZbnFgtMuqT J1qdE/DPjhhU0SWP3zJ+W24AO0tk4G9EznUqfs8vNWDR/Pgdxlzk4pLqJShm95j+WeIu 4Lz6xlermrrsOgmgZiW7EQUQvzABg+WKdm01QHz23vZbkKvpHEcFZBJp6I4nNelekwM/ Hsrg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jqc+9AuQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-77743-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77743-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j26-20020a37ef1a000000b007873a515f5fsi14298630qkk.47.2024.02.22.19.52.55 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 19:52:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77743-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jqc+9AuQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-77743-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77743-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5DBFC1C24EB6 for <ouuuleilei@gmail.com>; Fri, 23 Feb 2024 03:52:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A353F12B8C; Fri, 23 Feb 2024 03:49:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jqc+9AuQ" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B256111B5; Fri, 23 Feb 2024 03:49:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708660191; cv=none; b=m6Gv8wP1R1wnrf/Hairuiv60/0tUenJA1UDIXvOnqSEqDhTIvbqVebzRUg1kDrXnvZDdnNB/EZlUrwxaNl6FukPD3ScDesGDEdiEjyd7Us4X1B8YrsDGGlcFVKhakaJJlH8k18wiRuBzL//jPpqT+r6Wgi2hr/yxohmc6bnI7Y8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708660191; c=relaxed/simple; bh=TWYzt4cWE702k5VOaGpWj9p2plXpYzNDkLilGGhbLfg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TTEH5YVBXzjxuVjcHy3WRjyT0Ug6AD5o325xNoz27jt2aRl/YMhK8Dwa9ibEdp2G3dpinLtV93km3ITK7vaPauxxGJKEnK6hdFmwdGEt+TwfMXQGfJyXu7rwXHDog7Iv0YZt9abVoKUdoihLmNaqMSB8w1oDlQ93YgcqPCbhZqM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jqc+9AuQ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 9B710C433A6; Fri, 23 Feb 2024 03:49:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708660190; bh=TWYzt4cWE702k5VOaGpWj9p2plXpYzNDkLilGGhbLfg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=jqc+9AuQt9R+RFyxDbEXLasVKrOHbloI3R9NUuBgLCLw7/qNkRGQx0FDzweBtoO72 h8brlCRB+MH8L+ZcTFyn5hme99s75Bi4yFwxKyGPpJ4Dj0L/tBbkaugzGVP/g4LT7D Bh5xkGwUVOqQrB4h7m3JUjxin/esA1qWVU0H3qXtdTAchnGWLRNcKiHzENybnHXQa0 a3vZczf0lGAJUw+60ovLSDoKFZS0KmDHZikCSuPGWL2NTUE3fDZkmzHKr/+i9DMuNP UYKuuqo0AXBvrepPVMMFUkCKqGgtXhxXOx2NvUUexnBYpwTMlAtAwGKrbCzHQcBGdR URzHf17w2vt4w== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E373C54798; Fri, 23 Feb 2024 03:49:50 +0000 (UTC) From: Yang Xiwen via B4 Relay <devnull+forbidden405.outlook.com@kernel.org> Date: Fri, 23 Feb 2024 11:49:47 +0800 Subject: [PATCH 2/2] drivers: bus: simple-pm-bus: Get and deassert resets exclusively Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240223-b4-bus-v1-2-2803c3ac4673@outlook.com> References: <20240223-b4-bus-v1-0-2803c3ac4673@outlook.com> In-Reply-To: <20240223-b4-bus-v1-0-2803c3ac4673@outlook.com> To: Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, Geert Uytterhoeven <geert+renesas@glider.be>, Philipp Zabel <p.zabel@pengutronix.de> Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Yang Xiwen <forbidden405@outlook.com> X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1708660187; l=1979; i=forbidden405@outlook.com; s=20230724; h=from:subject:message-id; bh=JWFA4aEPe9UmKX/cnL2dAlkZhpNjtIvdqZ32qXjuGyM=; b=qcHy1AJ2U0hzEwKWQHgC3iK0+xqjk8WbWl2uq7fhr6LqaRXcHt0ct/VyrmF1YNi9UhZRUXtJi 6PhcXTFCv+eBZKsu7+gUxThU6jlKAvTTFu0oUsKCCNpUvnj66v+mIiW X-Developer-Key: i=forbidden405@outlook.com; a=ed25519; pk=qOD5jhp891/Xzc+H/PZ8LWVSWE3O/XCQnAg+5vdU2IU= X-Endpoint-Received: by B4 Relay for forbidden405@outlook.com/20230724 with auth_id=67 X-Original-From: Yang Xiwen <forbidden405@outlook.com> Reply-To: <forbidden405@outlook.com> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791660262054468015 X-GMAIL-MSGID: 1791660262054468015 |
Series |
simple-pm-bus: deassert resets if possible
|
|
Commit Message
Yang Xiwen via B4 Relay
Feb. 23, 2024, 3:49 a.m. UTC
From: Yang Xiwen <forbidden405@outlook.com> Simple Power-Managed bus controller may need functional reset(s) to be deasserted before child devices connected to the bus can be accessed. Get the reset(s) as an array and assert/deassert the reset(s) when the bus is being power managed. One example is that HiSilicon USB2 INNO PHY test bus needs to deassert the reset to the bus before accessing its registers. Signed-off-by: Yang Xiwen <forbidden405@outlook.com> --- drivers/bus/simple-pm-bus.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
Comments
Hi Yang, On Fri, Feb 23, 2024 at 4:49 AM Yang Xiwen via B4 Relay <devnull+forbidden405.outlook.com@kernel.org> wrote: > From: Yang Xiwen <forbidden405@outlook.com> > > Simple Power-Managed bus controller may need functional reset(s) > to be deasserted before child devices connected to the bus can be > accessed. Get the reset(s) as an array and assert/deassert the > reset(s) when the bus is being power managed. > > One example is that HiSilicon USB2 INNO PHY test bus needs to deassert > the reset to the bus before accessing its registers. > > Signed-off-by: Yang Xiwen <forbidden405@outlook.com> Thanks for your patch! > --- a/drivers/bus/simple-pm-bus.c > +++ b/drivers/bus/simple-pm-bus.c > @@ -62,6 +64,10 @@ static int simple_pm_bus_probe(struct platform_device *pdev) > if (bus->num_clks < 0) > return dev_err_probe(&pdev->dev, bus->num_clks, "failed to get clocks\n"); > > + bus->rsts = devm_reset_control_array_get(dev, false, true); Please use the devm_reset_control_array_get_optional_exclusive() wrapper. > + if (IS_ERR(bus->rsts)) > + return dev_err_probe(&pdev->dev, PTR_ERR(bus->rsts), "failed to get resets\n"); > + > dev_set_drvdata(&pdev->dev, bus); > > dev_dbg(&pdev->dev, "%s\n", __func__); The rest LGTM, so Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Gr{oetje,eeting}s, Geert
Hi Yang, kernel test robot noticed the following build errors: [auto build test ERROR on 8d3dea210042f54b952b481838c1e7dfc4ec751d] url: https://github.com/intel-lab-lkp/linux/commits/Yang-Xiwen-via-B4-Relay/dt-bindings-simple-pm-bus-Add-optional-resets/20240223-115400 base: 8d3dea210042f54b952b481838c1e7dfc4ec751d patch link: https://lore.kernel.org/r/20240223-b4-bus-v1-2-2803c3ac4673%40outlook.com patch subject: [PATCH 2/2] drivers: bus: simple-pm-bus: Get and deassert resets exclusively config: arm-allnoconfig (https://download.01.org/0day-ci/archive/20240224/202402240646.IirqjDw8-lkp@intel.com/config) compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project edd4aee4dd9b5b98b2576a6f783e4086173d902a) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240224/202402240646.IirqjDw8-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202402240646.IirqjDw8-lkp@intel.com/ All errors (new ones prefixed by >>): >> drivers/bus/simple-pm-bus.c:67:43: error: passing 'const struct device *' to parameter of type 'struct device *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] 67 | bus->rsts = devm_reset_control_array_get(dev, false, true); | ^~~ include/linux/reset.h:192:45: note: passing argument to parameter 'dev' here 192 | devm_reset_control_array_get(struct device *dev, bool shared, bool optional) | ^ 1 error generated. vim +67 drivers/bus/simple-pm-bus.c 26 27 static int simple_pm_bus_probe(struct platform_device *pdev) 28 { 29 const struct device *dev = &pdev->dev; 30 const struct of_dev_auxdata *lookup = dev_get_platdata(dev); 31 struct device_node *np = dev->of_node; 32 const struct of_device_id *match; 33 struct simple_pm_bus *bus; 34 35 /* 36 * Allow user to use driver_override to bind this driver to a 37 * transparent bus device which has a different compatible string 38 * that's not listed in simple_pm_bus_of_match. We don't want to do any 39 * of the simple-pm-bus tasks for these devices, so return early. 40 */ 41 if (pdev->driver_override) 42 return 0; 43 44 match = of_match_device(dev->driver->of_match_table, dev); 45 /* 46 * These are transparent bus devices (not simple-pm-bus matches) that 47 * have their child nodes populated automatically. So, don't need to 48 * do anything more. We only match with the device if this driver is 49 * the most specific match because we don't want to incorrectly bind to 50 * a device that has a more specific driver. 51 */ 52 if (match && match->data) { 53 if (of_property_match_string(np, "compatible", match->compatible) == 0) 54 return 0; 55 else 56 return -ENODEV; 57 } 58 59 bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL); 60 if (!bus) 61 return -ENOMEM; 62 63 bus->num_clks = devm_clk_bulk_get_all(&pdev->dev, &bus->clks); 64 if (bus->num_clks < 0) 65 return dev_err_probe(&pdev->dev, bus->num_clks, "failed to get clocks\n"); 66 > 67 bus->rsts = devm_reset_control_array_get(dev, false, true); 68 if (IS_ERR(bus->rsts)) 69 return dev_err_probe(&pdev->dev, PTR_ERR(bus->rsts), "failed to get resets\n"); 70 71 dev_set_drvdata(&pdev->dev, bus); 72 73 dev_dbg(&pdev->dev, "%s\n", __func__); 74 75 pm_runtime_enable(&pdev->dev); 76 77 if (np) 78 of_platform_populate(np, NULL, lookup, &pdev->dev); 79 80 return 0; 81 } 82
Hi Yang, kernel test robot noticed the following build warnings: [auto build test WARNING on 8d3dea210042f54b952b481838c1e7dfc4ec751d] url: https://github.com/intel-lab-lkp/linux/commits/Yang-Xiwen-via-B4-Relay/dt-bindings-simple-pm-bus-Add-optional-resets/20240223-115400 base: 8d3dea210042f54b952b481838c1e7dfc4ec751d patch link: https://lore.kernel.org/r/20240223-b4-bus-v1-2-2803c3ac4673%40outlook.com patch subject: [PATCH 2/2] drivers: bus: simple-pm-bus: Get and deassert resets exclusively config: openrisc-allnoconfig (https://download.01.org/0day-ci/archive/20240224/202402240650.1O7vtd48-lkp@intel.com/config) compiler: or1k-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240224/202402240650.1O7vtd48-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202402240650.1O7vtd48-lkp@intel.com/ All warnings (new ones prefixed by >>): drivers/bus/simple-pm-bus.c: In function 'simple_pm_bus_probe': >> drivers/bus/simple-pm-bus.c:67:50: warning: passing argument 1 of 'devm_reset_control_array_get' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 67 | bus->rsts = devm_reset_control_array_get(dev, false, true); | ^~~ In file included from drivers/bus/simple-pm-bus.c:19: include/linux/reset.h:192:45: note: expected 'struct device *' but argument is of type 'const struct device *' 192 | devm_reset_control_array_get(struct device *dev, bool shared, bool optional) | ~~~~~~~~~~~~~~~^~~ vim +67 drivers/bus/simple-pm-bus.c 26 27 static int simple_pm_bus_probe(struct platform_device *pdev) 28 { 29 const struct device *dev = &pdev->dev; 30 const struct of_dev_auxdata *lookup = dev_get_platdata(dev); 31 struct device_node *np = dev->of_node; 32 const struct of_device_id *match; 33 struct simple_pm_bus *bus; 34 35 /* 36 * Allow user to use driver_override to bind this driver to a 37 * transparent bus device which has a different compatible string 38 * that's not listed in simple_pm_bus_of_match. We don't want to do any 39 * of the simple-pm-bus tasks for these devices, so return early. 40 */ 41 if (pdev->driver_override) 42 return 0; 43 44 match = of_match_device(dev->driver->of_match_table, dev); 45 /* 46 * These are transparent bus devices (not simple-pm-bus matches) that 47 * have their child nodes populated automatically. So, don't need to 48 * do anything more. We only match with the device if this driver is 49 * the most specific match because we don't want to incorrectly bind to 50 * a device that has a more specific driver. 51 */ 52 if (match && match->data) { 53 if (of_property_match_string(np, "compatible", match->compatible) == 0) 54 return 0; 55 else 56 return -ENODEV; 57 } 58 59 bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL); 60 if (!bus) 61 return -ENOMEM; 62 63 bus->num_clks = devm_clk_bulk_get_all(&pdev->dev, &bus->clks); 64 if (bus->num_clks < 0) 65 return dev_err_probe(&pdev->dev, bus->num_clks, "failed to get clocks\n"); 66 > 67 bus->rsts = devm_reset_control_array_get(dev, false, true); 68 if (IS_ERR(bus->rsts)) 69 return dev_err_probe(&pdev->dev, PTR_ERR(bus->rsts), "failed to get resets\n"); 70 71 dev_set_drvdata(&pdev->dev, bus); 72 73 dev_dbg(&pdev->dev, "%s\n", __func__); 74 75 pm_runtime_enable(&pdev->dev); 76 77 if (np) 78 of_platform_populate(np, NULL, lookup, &pdev->dev); 79 80 return 0; 81 } 82
Hi Yang, kernel test robot noticed the following build warnings: [auto build test WARNING on 8d3dea210042f54b952b481838c1e7dfc4ec751d] url: https://github.com/intel-lab-lkp/linux/commits/Yang-Xiwen-via-B4-Relay/dt-bindings-simple-pm-bus-Add-optional-resets/20240223-115400 base: 8d3dea210042f54b952b481838c1e7dfc4ec751d patch link: https://lore.kernel.org/r/20240223-b4-bus-v1-2-2803c3ac4673%40outlook.com patch subject: [PATCH 2/2] drivers: bus: simple-pm-bus: Get and deassert resets exclusively config: i386-randconfig-061-20240223 (https://download.01.org/0day-ci/archive/20240224/202402240740.rPfLNrGO-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240224/202402240740.rPfLNrGO-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202402240740.rPfLNrGO-lkp@intel.com/ sparse warnings: (new ones prefixed by >>) >> drivers/bus/simple-pm-bus.c:67:50: sparse: sparse: incorrect type in argument 1 (different modifiers) @@ expected struct device *dev @@ got struct device const *dev @@ drivers/bus/simple-pm-bus.c:67:50: sparse: expected struct device *dev drivers/bus/simple-pm-bus.c:67:50: sparse: got struct device const *dev vim +67 drivers/bus/simple-pm-bus.c 26 27 static int simple_pm_bus_probe(struct platform_device *pdev) 28 { 29 const struct device *dev = &pdev->dev; 30 const struct of_dev_auxdata *lookup = dev_get_platdata(dev); 31 struct device_node *np = dev->of_node; 32 const struct of_device_id *match; 33 struct simple_pm_bus *bus; 34 35 /* 36 * Allow user to use driver_override to bind this driver to a 37 * transparent bus device which has a different compatible string 38 * that's not listed in simple_pm_bus_of_match. We don't want to do any 39 * of the simple-pm-bus tasks for these devices, so return early. 40 */ 41 if (pdev->driver_override) 42 return 0; 43 44 match = of_match_device(dev->driver->of_match_table, dev); 45 /* 46 * These are transparent bus devices (not simple-pm-bus matches) that 47 * have their child nodes populated automatically. So, don't need to 48 * do anything more. We only match with the device if this driver is 49 * the most specific match because we don't want to incorrectly bind to 50 * a device that has a more specific driver. 51 */ 52 if (match && match->data) { 53 if (of_property_match_string(np, "compatible", match->compatible) == 0) 54 return 0; 55 else 56 return -ENODEV; 57 } 58 59 bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL); 60 if (!bus) 61 return -ENOMEM; 62 63 bus->num_clks = devm_clk_bulk_get_all(&pdev->dev, &bus->clks); 64 if (bus->num_clks < 0) 65 return dev_err_probe(&pdev->dev, bus->num_clks, "failed to get clocks\n"); 66 > 67 bus->rsts = devm_reset_control_array_get(dev, false, true); 68 if (IS_ERR(bus->rsts)) 69 return dev_err_probe(&pdev->dev, PTR_ERR(bus->rsts), "failed to get resets\n"); 70 71 dev_set_drvdata(&pdev->dev, bus); 72 73 dev_dbg(&pdev->dev, "%s\n", __func__); 74 75 pm_runtime_enable(&pdev->dev); 76 77 if (np) 78 of_platform_populate(np, NULL, lookup, &pdev->dev); 79 80 return 0; 81 } 82
On 2/24/2024 7:32 AM, kernel test robot wrote: > Hi Yang, > > kernel test robot noticed the following build warnings: > > [auto build test WARNING on 8d3dea210042f54b952b481838c1e7dfc4ec751d] > > url: https://github.com/intel-lab-lkp/linux/commits/Yang-Xiwen-via-B4-Relay/dt-bindings-simple-pm-bus-Add-optional-resets/20240223-115400 > base: 8d3dea210042f54b952b481838c1e7dfc4ec751d > patch link: https://lore.kernel.org/r/20240223-b4-bus-v1-2-2803c3ac4673%40outlook.com > patch subject: [PATCH 2/2] drivers: bus: simple-pm-bus: Get and deassert resets exclusively > config: i386-randconfig-061-20240223 (https://download.01.org/0day-ci/archive/20240224/202402240740.rPfLNrGO-lkp@intel.com/config) > compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240224/202402240740.rPfLNrGO-lkp@intel.com/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot <lkp@intel.com> > | Closes: https://lore.kernel.org/oe-kbuild-all/202402240740.rPfLNrGO-lkp@intel.com/ > > sparse warnings: (new ones prefixed by >>) >>> drivers/bus/simple-pm-bus.c:67:50: sparse: sparse: incorrect type in argument 1 (different modifiers) @@ expected struct device *dev @@ got struct device const *dev @@ > drivers/bus/simple-pm-bus.c:67:50: sparse: expected struct device *dev > drivers/bus/simple-pm-bus.c:67:50: sparse: got struct device const *dev > > vim +67 drivers/bus/simple-pm-bus.c > > 26 > 27 static int simple_pm_bus_probe(struct platform_device *pdev) > 28 { > 29 const struct device *dev = &pdev->dev; > 30 const struct of_dev_auxdata *lookup = dev_get_platdata(dev); > 31 struct device_node *np = dev->of_node; > 32 const struct of_device_id *match; > 33 struct simple_pm_bus *bus; > 34 > 35 /* > 36 * Allow user to use driver_override to bind this driver to a > 37 * transparent bus device which has a different compatible string > 38 * that's not listed in simple_pm_bus_of_match. We don't want to do any > 39 * of the simple-pm-bus tasks for these devices, so return early. > 40 */ > 41 if (pdev->driver_override) > 42 return 0; > 43 > 44 match = of_match_device(dev->driver->of_match_table, dev); > 45 /* > 46 * These are transparent bus devices (not simple-pm-bus matches) that > 47 * have their child nodes populated automatically. So, don't need to > 48 * do anything more. We only match with the device if this driver is > 49 * the most specific match because we don't want to incorrectly bind to > 50 * a device that has a more specific driver. > 51 */ > 52 if (match && match->data) { > 53 if (of_property_match_string(np, "compatible", match->compatible) == 0) > 54 return 0; > 55 else > 56 return -ENODEV; > 57 } > 58 > 59 bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL); > 60 if (!bus) > 61 return -ENOMEM; > 62 > 63 bus->num_clks = devm_clk_bulk_get_all(&pdev->dev, &bus->clks); > 64 if (bus->num_clks < 0) > 65 return dev_err_probe(&pdev->dev, bus->num_clks, "failed to get clocks\n"); > 66 > > 67 bus->rsts = devm_reset_control_array_get(dev, false, true); Fixed in v2 before reporting. > 68 if (IS_ERR(bus->rsts)) > 69 return dev_err_probe(&pdev->dev, PTR_ERR(bus->rsts), "failed to get resets\n"); > 70 > 71 dev_set_drvdata(&pdev->dev, bus); > 72 > 73 dev_dbg(&pdev->dev, "%s\n", __func__); > 74 > 75 pm_runtime_enable(&pdev->dev); > 76 > 77 if (np) > 78 of_platform_populate(np, NULL, lookup, &pdev->dev); > 79 > 80 return 0; > 81 } > 82 >
diff --git a/drivers/bus/simple-pm-bus.c b/drivers/bus/simple-pm-bus.c index 50870c827889..d84dbd61c02b 100644 --- a/drivers/bus/simple-pm-bus.c +++ b/drivers/bus/simple-pm-bus.c @@ -16,9 +16,11 @@ #include <linux/of_platform.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> +#include <linux/reset.h> struct simple_pm_bus { struct clk_bulk_data *clks; + struct reset_control *rsts; int num_clks; }; @@ -62,6 +64,10 @@ static int simple_pm_bus_probe(struct platform_device *pdev) if (bus->num_clks < 0) return dev_err_probe(&pdev->dev, bus->num_clks, "failed to get clocks\n"); + bus->rsts = devm_reset_control_array_get(dev, false, true); + if (IS_ERR(bus->rsts)) + return dev_err_probe(&pdev->dev, PTR_ERR(bus->rsts), "failed to get resets\n"); + dev_set_drvdata(&pdev->dev, bus); dev_dbg(&pdev->dev, "%s\n", __func__); @@ -92,7 +98,7 @@ static int simple_pm_bus_runtime_suspend(struct device *dev) clk_bulk_disable_unprepare(bus->num_clks, bus->clks); - return 0; + return reset_control_assert(bus->rsts); } static int simple_pm_bus_runtime_resume(struct device *dev) @@ -106,6 +112,12 @@ static int simple_pm_bus_runtime_resume(struct device *dev) return ret; } + ret = reset_control_deassert(bus->rsts); + if (ret) { + dev_err(dev, "failed to deassert resets: %d\n", ret); + return ret; + } + return 0; }