Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1781005lqg; Mon, 4 Mar 2024 03:47:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVg+uZpz1vOaUGnnCk1OQwX0ppIpmFQ6E3Ede4Tk3AQ8ouY26LeEJBVCO3DTS9LKkYjNaUPTF5XTWPqv5Aj+y7X4X9kZjE/ZdybEk/qwQ== X-Google-Smtp-Source: AGHT+IHgjXe/j84OJ+1IMTEd1EOSF0OA4Y3WY/S36Qptf09ZUj2Bup/IJDBEYap7rl5B57ech6+B X-Received: by 2002:a05:6830:1e8a:b0:6e4:98fe:b530 with SMTP id n10-20020a0568301e8a00b006e498feb530mr8911742otr.31.1709552823538; Mon, 04 Mar 2024 03:47:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709552823; cv=pass; d=google.com; s=arc-20160816; b=WYm5iED2hOtPT7bMNmLt+s4aoQRiW1pgu9xsLSPocpr5pYa28WfUYnL8+xapzG7VQj 693uguwGwyIgTLQ7+bOcTS9PMy+zw1iv2NLbQhD2SEVJNVnCfGr3b+ixqRHq8FOC/mpY igJrQpDaCwrBgSMCWvPR1v4g4+AEpk29a+zL33BwhZHYH3eXv4OVF5YmMYCzjxHGf9kQ gJXg8Oa9HEAzwa1HOVmIuYvVWREGtWyCWyxEqdI5NEyA8NGtNCSbgbhPiOdWQOXwSZdV bSQE/5fFlMD0Q/UuVlRn/JPDvVWkjW3UcTCFMBKUiGCgwCJvqO1Ql6TSuTdXwtloR8uT FFuw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=6JEGHtbqyJwPzknb9cutu3F9GTXF2cnTcxkajaqQGKU=; fh=yLhSRvT3/AGzgV3wmdgUk8SZvhCz29TUhUmV5afUFDA=; b=yoL43Ly9noYccFEfqVMtg9nrvAvVj3Rmk0JOrDw99NANDMFdU4eI7PhY7JBiu0WyC/ ZP220TnLUIg0irGNVVOycD65va6DBzKtVY8d/wcrX5RWUxjph8FNZTL/r6BdnOIRW1c4 mruJ9gbimZHtq4o6l7NJie059S4AksG2nyqn+1qmCa7DSBxy/tGYASZcD15VWbcByYWO GweW/dul+vwhSWImJxv+hScv77a5ymscFUZ7xh3hBvYXx8SMXE/brfo1FABv87Kzb7v8 Du0N72YN3ue7+a4ih8JaED/TqJn3CuhDXPCEHvNPkj9jZQPw6muXAS2Ri71HX9t8I/Yp Iapg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DvdcOhRh; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-90527-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90527-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id bw29-20020a056a02049d00b005dc1c316cf5si8881056pgb.357.2024.03.04.03.47.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 03:47:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90527-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DvdcOhRh; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-90527-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90527-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2F073284F0B for ; Mon, 4 Mar 2024 11:47:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 24D5B3B2B6; Mon, 4 Mar 2024 11:46:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DvdcOhRh" Received: from mail-oo1-f54.google.com (mail-oo1-f54.google.com [209.85.161.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98B212BCFF; Mon, 4 Mar 2024 11:46:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709552810; cv=none; b=uX4X3LWbdwPsoGpPLbFPxLdRFq+nGlEt9VKicaSIGOJlwgMkqdII5+18rlqAXPEyIIxRDKitDoDX5sM8KnDtqhEpbyiW9D/6x2Kr7MHKOiYFtKAJyFXO4/wW1IV1+8KsFj9EWeDlKvPK7uGROnPeKHGSZidU9mx+rm070VlwSPo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709552810; c=relaxed/simple; bh=MREf+q+trSbCOEQo2zmMzNcMz+h6WiYld+brhD1xTWI=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=vAwaLAzDFboMP/bVJFK9zywBFqXy1AIds7Fm2YeGVoUrEQdCLkU8eWgGadbQDQJ0JCVVCnNvVc7kn/x66Ipn9U6s3bdjbzYXtYK+aSeZSjR7A7FLyvT8jOtxJWddXCXipOaVpyXqVCdbcH1Zsx+WtZ2YIbsqGPYQV7hurDvKiaI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DvdcOhRh; arc=none smtp.client-ip=209.85.161.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oo1-f54.google.com with SMTP id 006d021491bc7-5a0a19c9bb7so3538188eaf.3; Mon, 04 Mar 2024 03:46:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709552808; x=1710157608; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=6JEGHtbqyJwPzknb9cutu3F9GTXF2cnTcxkajaqQGKU=; b=DvdcOhRhKJyzGkG7Xb+992GJpuMqhdDK05IQXQlF3RDOmeun1SMzVBtpt8kqypkoyR 5+JSoS0LXJ+EJJhxTa4FOGIRA3bwp2TDgRTtdwn5TM0LELJJseas43sRlLsKxAhwVaKT v+Hi5kqyLRPj0iTqtFuNjta5vU/X1IgpPlBa+AYMW3Kd/OA8eCLBr/IkUM8hVGLD8YRm Ii0Bx8wTHySCJcPoEPgBJnyhL9gFcNOXRjEJzNfLbuvGof4dFnRdyYu+keqP29PYUhey GgaxbzGK1dularqYVkhBM4ixCMQTA4MKiRsdJfx1ZoO8HMv83eFHT6JyCqwVo9w7C/SF JShA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709552808; x=1710157608; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6JEGHtbqyJwPzknb9cutu3F9GTXF2cnTcxkajaqQGKU=; b=kg0IeYDFci5KRr4K63TTWp3sELHuJCguH5li7mJrv7K4Rd+InU8xWj45Ny6apR1kJW 9eQ41V9MFM3u6z3Zqd8v+J3Gr0j7o4yjU9JqYj6QeSRn4146XefFfMVSSgH+biCxFr5U ix3BWG5dPShZmGxgr9KVr6NW2gwJYVzKHWBdeD6SvKumivyLvMIlLMhAxM0Sw6vJr43o vELmL1MbUW2DV9Heqg9XLOfvaxcGM+KYGJBQEDl52Gs40mSY5AgBYQbV8JpkmiNxp03N w8xE6uc5fbo+d8opwgeB9uQt0SZlRti5fDqRbVBv+DR2E4ZszO+ma/24+SpTFdaUdq6X VpaQ== X-Forwarded-Encrypted: i=1; AJvYcCWOywENJYacw6n6vNS4N8GMG0rypYriOC6pWoT8vIYSpkNrog27t1ocGAYz4Qs47JHxQberi3caS07NGFuKaMXQ8RHvH+9ErTd1nPHLz8K5MJ6XWNMvyNrc1ccicQKbuMdzX3MbSvpUBk+K30HyblX5wIIOyekYWM/ryIQhQKmGYRBWOoxUL9TZKlA= X-Gm-Message-State: AOJu0YyBFHIiJDuoJCam9w8bY7DSOkiBJv/TxyqlIT17q+/qA+CkibJE qlHG3Kap2k7WUiRbSBlR+c5kpheyvsHZ+6bE3ehqTJWllJ57WyIuDq2KGiGPQ5DgPQsihpCpz1V KHVvAHswhiv36hGFSk5aRYFwa24w= X-Received: by 2002:a05:6820:2281:b0:5a1:841:c2a6 with SMTP id ck1-20020a056820228100b005a10841c2a6mr7832749oob.3.1709552807779; Mon, 04 Mar 2024 03:46:47 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240301193831.3346-1-linux.amoon@gmail.com> <20240301193831.3346-4-linux.amoon@gmail.com> <52158bf6-16fe-4ce2-b9b6-bbc6550a6e14@wanadoo.fr> In-Reply-To: From: Anand Moon Date: Mon, 4 Mar 2024 17:16:35 +0530 Message-ID: Subject: Re: [PATCH v1 3/4] usb: dwc3: exynos: Use devm_regulator_bulk_get_enable() helper function To: Christophe JAILLET Cc: Thinh Nguyen , Greg Kroah-Hartman , Krzysztof Kozlowski , Alim Akhtar , linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Christophe, On Sun, 3 Mar 2024 at 00:07, Christophe JAILLET wrote: > > Le 02/03/2024 =C3=A0 17:48, Anand Moon a =C3=A9crit : > > Hi Christophe, > > > > On Sat, 2 Mar 2024 at 21:20, Christophe JAILLET > > wrote: > >> > >> Le 01/03/2024 =C3=A0 20:38, Anand Moon a =C3=A9crit : > >>> Use devm_regulator_bulk_get_enable() instead of open coded > >>> 'devm_regulator_get(), regulator_enable(), regulator_disable(). > >>> > >>> Signed-off-by: Anand Moon > >>> --- > >>> drivers/usb/dwc3/dwc3-exynos.c | 49 +++---------------------------= ---- > >>> 1 file changed, 4 insertions(+), 45 deletions(-) > >>> > >>> diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-e= xynos.c > >>> index 5d365ca51771..7c77f3c69825 100644 > >>> --- a/drivers/usb/dwc3/dwc3-exynos.c > >>> +++ b/drivers/usb/dwc3/dwc3-exynos.c > >>> @@ -32,9 +32,6 @@ struct dwc3_exynos { > >>> struct clk *clks[DWC3_EXYNOS_MAX_CLOCKS]; > >>> int num_clks; > >>> int suspend_clk_idx; > >>> - > >>> - struct regulator *vdd33; > >>> - struct regulator *vdd10; > >>> }; > >>> > >>> static int dwc3_exynos_probe(struct platform_device *pdev) > >>> @@ -44,6 +41,7 @@ static int dwc3_exynos_probe(struct platform_device= *pdev) > >>> struct device_node *node =3D dev->of_node; > >>> const struct dwc3_exynos_driverdata *driver_data; > >>> int i, ret; > >>> + static const char * const regulators[] =3D { "vdd33", "vdd10" }= ; > >>> > >>> exynos =3D devm_kzalloc(dev, sizeof(*exynos), GFP_KERNEL); > >>> if (!exynos) > >>> @@ -78,27 +76,9 @@ static int dwc3_exynos_probe(struct platform_devic= e *pdev) > >>> if (exynos->suspend_clk_idx >=3D 0) > >>> clk_prepare_enable(exynos->clks[exynos->suspend_clk_id= x]); > >>> > >>> - exynos->vdd33 =3D devm_regulator_get(dev, "vdd33"); > >>> - if (IS_ERR(exynos->vdd33)) { > >>> - ret =3D PTR_ERR(exynos->vdd33); > >>> - goto vdd33_err; > >>> - } > >>> - ret =3D regulator_enable(exynos->vdd33); > >>> - if (ret) { > >>> - dev_err(dev, "Failed to enable VDD33 supply\n"); > >>> - goto vdd33_err; > >>> - } > >>> - > >>> - exynos->vdd10 =3D devm_regulator_get(dev, "vdd10"); > >>> - if (IS_ERR(exynos->vdd10)) { > >>> - ret =3D PTR_ERR(exynos->vdd10); > >>> - goto vdd10_err; > >>> - } > >>> - ret =3D regulator_enable(exynos->vdd10); > >>> - if (ret) { > >>> - dev_err(dev, "Failed to enable VDD10 supply\n"); > >>> - goto vdd10_err; > >>> - } > >>> + ret =3D devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulato= rs), regulators); > >>> + if (ret) > >>> + return dev_err_probe(dev, ret, "Failed to enable regula= tors\n"); > >>> > >>> if (node) { > >>> ret =3D of_platform_populate(node, NULL, NULL, dev); > >>> @@ -115,10 +95,6 @@ static int dwc3_exynos_probe(struct platform_devi= ce *pdev) > >>> return 0; > >>> > >>> populate_err: > >>> - regulator_disable(exynos->vdd10); > >>> -vdd10_err: > >>> - regulator_disable(exynos->vdd33); > >>> -vdd33_err: > >>> for (i =3D exynos->num_clks - 1; i >=3D 0; i--) > >>> clk_disable_unprepare(exynos->clks[i]); > >>> > >>> @@ -140,9 +116,6 @@ static void dwc3_exynos_remove(struct platform_de= vice *pdev) > >>> > >>> if (exynos->suspend_clk_idx >=3D 0) > >>> clk_disable_unprepare(exynos->clks[exynos->suspend_clk= _idx]); > >>> - > >>> - regulator_disable(exynos->vdd33); > >>> - regulator_disable(exynos->vdd10); > >>> } > >>> > >>> static const struct dwc3_exynos_driverdata exynos5250_drvdata =3D = { > >>> @@ -196,9 +169,6 @@ static int dwc3_exynos_suspend(struct device *dev= ) > >>> for (i =3D exynos->num_clks - 1; i >=3D 0; i--) > >>> clk_disable_unprepare(exynos->clks[i]); > >>> > >>> - regulator_disable(exynos->vdd33); > >>> - regulator_disable(exynos->vdd10); > >> > >> Hi, > >> > >> Same here, I don't think that removing regulator_[en|dis]able from the > >> suspend and resume function is correct. > >> > >> The goal is to stop some hardware when the system is suspended, in ord= er > >> to save some power. > > Ok, > >> > >> Why did you removed it? > > > > As per the description of the function devm_regulator_bulk_get_enable > > > > * This helper function allows drivers to get several regulator > > * consumers in one operation with management, the regulators will > > * automatically be freed when the device is unbound. If any of the > > * regulators cannot be acquired then any regulators that were > > * allocated will be freed before returning to the caller. > > The code in suspend/resume is not about freeing some resources. It is > about enabling/disabling some hardware to save some power. > > Think to the probe/remove functions as the software in the kernel that > knows how to handle some hardawre, and the suspend/resume as the on/off > button to power-on and off the electrical chips. > > When the system is suspended, the software is still around. But some > hardware can be set in a low consumption mode to save some power. > > IMHO, part of the code you removed changed this behaviour and increase > the power consumption when the system is suspended. > You are correct, I have changed the regulator API from devm_regulator_get_enable to devm_regulator_bulk_get_enable which changes this behavior. I will fix it in the next version. > CJ Thanks -Anand