From patchwork Thu Apr 25 09:04:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 162831 Delivered-To: patches@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1671678jan; Thu, 25 Apr 2019 02:04:31 -0700 (PDT) X-Received: by 2002:a2e:80c8:: with SMTP id r8mr2521608ljg.112.1556183071052; Thu, 25 Apr 2019 02:04:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556183071; cv=none; d=google.com; s=arc-20160816; b=jlG2KGLJtRi1ILguZBC2drfI3Y76Ni1vqlWKreAuSa8NKctp3M52S28v+4aLPvMrxc 4cmjD7ikQtcwdEHiN7jFL2/GaFgue1e4H+rzbhdVEi2IF7u+h3LsOwMnI89PzoOekFSA qsqbKWZ/Q4wtZGknCao1E+y6Nn7GXFtb6eDfGGXvDxPhxi8y6nCoaV/Xz2cluyCToAwP mZcBgDZo9YPTBu4ylhCtxEA8HilNczR6DjQz2K6L+2jL1xRtmEnJgj5p12YJaBRRRW5p q1Nm8hXORvrMLLnPKNnM2dz6yy0dPVn++yEqtj39/ukAROW8bTphFL6TGGkl5d69kDKp Ej8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+54V2h/XgAc13rlQ/SlFnygRmRch2uFRJkG3WKQRigw=; b=jkwjnCQhTBqkZl/f4IcMhAfYhNmcQ4vLlvfrivrNeTEjSJGy3kM7nGVip3qm0XuYoL vwWm/AwhexNGobtM05LNgRwNpjGN3mv9b0SCroqu0fZ3wVaH7gSzN+MRPuPuQGh6PyCD +iFqJM90uZ1UsmorHp1MSAOg469DEnrINk4K/MIBq6QIvluzo9QjPrldorVEs4drtxrA OgkbWy7yL3c0zDeCTqaus/BDtiuHTNyI+c/3ntiIB41xh8IpyVmBTdJMLzjPRix6SV6e aKVP2G3Mb2AH+qKWw64KTM5RDoeaq4ZMR+krWqqcZL5xIUEZbmTysQ95df1wCR762b1V wd8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KQmk7AwU; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id d20sor11074993lji.12.2019.04.25.02.04.30 for (Google Transport Security); Thu, 25 Apr 2019 02:04:31 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KQmk7AwU; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+54V2h/XgAc13rlQ/SlFnygRmRch2uFRJkG3WKQRigw=; b=KQmk7AwUQoPW2mhxbS6TbUc3r7+PGjbj3/fAGNr0k/M5E/bxs6vjesb1EMTfE7qahu mjo053Qcdz2MYbIjtNyE7tk3CSwVWY4AmlrbjMN2XtSANsD7HX0Y7TKnR6+OsbtFse5O sXUna4rQr9RO0G+sqR3DobsE8n83OOOlNyW5KXVh7DjHRh3P8pUEFJTfACqAyKBwI7TX yktVEhPgbp3tH5ruHg2A3odsJAf2+82PNfNTMHdnf/kcNOBJVo1U7s3bMp8koLCvLKHk 2U+oyKLdPNs9YiCni7hh9xZrSXDJCI96Ma0iVYbbGcQUyP6JBLg4WTbWJOAdQkbS322B mX/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+54V2h/XgAc13rlQ/SlFnygRmRch2uFRJkG3WKQRigw=; b=VM0wLtfjxiaWjTcNcU+8Y+CGNroQsXj6S4SkOh0fNX3iEVvYJkwO5np/Z+a8Ao+27Q lhsGGiLRfVK1olSK18A6/AB0ZqLPkkPkGou3hiPyA160wMX+RrCCmPJ6Esd1SdO4Pctt SgKa4+v+UIGrSPdmMtfDUFN99aihvtQztQpQnVzv9tezBzc8v09v1dIyNW93ckO0AQHy UW5N1UW6O02VUNyxOCVdpUHVp6FewRxNwxIgkM6+xz617cjCLBSq9UhtIHf8GC789LMY 1wB5Hpdwcb7NywHh4cO7WpqeMTFLn97etI50vlIXp13/kE8BAAE0YOOajLJZZ1sFZnrI bBrw== X-Gm-Message-State: APjAAAXPRYdKvdPw2AosQjNnmDol88ON5GkTiETM+WX6BRXHSr61qCkw wgomYpZHb+e/3JlFkU2kvcJTRnrb X-Google-Smtp-Source: APXvYqwTUexwmpqjGqL8ndwTScbQ3jA2Gi9wk4uhiTaDz25Zi5/AQ81/TdtnywrUEXCFKwJaXlLlVg== X-Received: by 2002:a2e:9e04:: with SMTP id e4mr9087891ljk.74.1556183070284; Thu, 25 Apr 2019 02:04:30 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id v26sm4517353lja.60.2019.04.25.02.04.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Apr 2019 02:04:29 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Daniel Lezcano , "Raju P . L . S . S . S . N" , Stephen Boyd , Tony Lindgren , Kevin Hilman , Lina Iyer , Rajendra Nayak , Viresh Kumar , Niklas Cassel , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Rob Herring Subject: [PATCH 1/4] PM / Domains: Use the base device for driver_deferred_probe_check_state() Date: Thu, 25 Apr 2019 11:04:10 +0200 Message-Id: <20190425090413.10700-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190425090413.10700-1-ulf.hansson@linaro.org> References: <20190425090413.10700-1-ulf.hansson@linaro.org> When genpd fails to attach a device to one of its multiple PM domains, we end up calling driver_deferred_probe_check_state() for the recently allocated virtual device. This is wrong, as it's the base device that is being probed. Fix this, by passing along the base device to __genpd_dev_pm_attach() and use that instead. Fixes: e01afc325025 ("PM / Domains: Stop deferring probe at the end of initcall") Cc: Rob Herring Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) -- 2.17.1 Acked-by: Viresh Kumar diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 8362dfe187f5..8aca1c9b4406 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2405,8 +2405,8 @@ static void genpd_dev_pm_sync(struct device *dev) genpd_queue_power_off_work(pd); } -static int __genpd_dev_pm_attach(struct device *dev, unsigned int index, - bool power_on) +static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, + unsigned int index, bool power_on) { struct of_phandle_args pd_args; struct generic_pm_domain *pd; @@ -2424,7 +2424,7 @@ static int __genpd_dev_pm_attach(struct device *dev, unsigned int index, mutex_unlock(&gpd_list_lock); dev_dbg(dev, "%s() failed to find PM domain: %ld\n", __func__, PTR_ERR(pd)); - return driver_deferred_probe_check_state(dev); + return driver_deferred_probe_check_state(base_dev); } dev_dbg(dev, "adding to PM domain %s\n", pd->name); @@ -2480,7 +2480,7 @@ int genpd_dev_pm_attach(struct device *dev) "#power-domain-cells") != 1) return 0; - return __genpd_dev_pm_attach(dev, 0, true); + return __genpd_dev_pm_attach(dev, dev, 0, true); } EXPORT_SYMBOL_GPL(genpd_dev_pm_attach); @@ -2533,7 +2533,7 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev, } /* Try to attach the device to the PM domain at the specified index. */ - ret = __genpd_dev_pm_attach(virt_dev, index, false); + ret = __genpd_dev_pm_attach(virt_dev, dev, index, false); if (ret < 1) { device_unregister(virt_dev); return ret ? ERR_PTR(ret) : NULL; From patchwork Thu Apr 25 09:04:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 162832 Delivered-To: patches@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1671699jan; Thu, 25 Apr 2019 02:04:32 -0700 (PDT) X-Received: by 2002:a05:6512:20d:: with SMTP id a13mr10369799lfo.42.1556183072536; Thu, 25 Apr 2019 02:04:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556183072; cv=none; d=google.com; s=arc-20160816; b=zv6iLf6CTTYXxv8fRht8aXA7U9+so9AezKa5JbbVh+2yZC6doT/JFKqnj5S5E51e0R n0ALxUBY0TDVpBDWJ+23LWZmORcf0hXdmcNeF4GPKfhfpMLkUbiJSMNdZ0yJo2vF1S4m psrQDqhRG21WiFsPmFCeNBb/Rx0zWrea25GEs1GX0oaqxOxzBmGXCOnKtWKuvli3c2IB xM8Xq6v9WHefyUF+GwqEPEr5DWLnuzTxNqUadv9427LeCLNBSI+E3cZ4nWIPRFga9/MK rjE9R+LssV/1Ey6p5NtaGoIO7TZ/gFqyH1tYL7BsIDR6nHONvPRpI2QRrk/V7rjCg9q2 QFsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wzmNVY0MlNQoNKUiuFMitPMY1YZ/UR3X4yK7u+qVxVk=; b=THjDEbg32vxwpJN8/QpPuVtLDW9g+qpzFgWMz4GzVoxmwD/en3rLEsMQdWOS5ttEEr B4ElNe/PZA9v18C3ozLHgBkKZyGNPVXu4a9w+3LKABkTxfJXBcTQFOHPhoqshrCf2xmR esnzOXQ5Osw6cOzQ/UoUyY+Rnjj11tvoixKydifMwDtDkh+jJIXL6KFSkLwCRB8jBm+S V/XcJndLL79H4/tDbit7ovtink8zuix6oB54Hg25+z8W6jyKPo0xdAdDCFK+D/kupw9a 32Oi5IXBoK7ksavw9XlqZjhgEVc6rW5ofJvhsLcYEGQdSsSo6zHWsvYvsRxuaRpHiPM5 wOkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A2KTRy+U; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id j28sor5883508lfk.0.2019.04.25.02.04.32 for (Google Transport Security); Thu, 25 Apr 2019 02:04:32 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A2KTRy+U; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wzmNVY0MlNQoNKUiuFMitPMY1YZ/UR3X4yK7u+qVxVk=; b=A2KTRy+UTjfFd6veJikGx+mAUNWRwrabYPXJSq0/v4iJK3R2oiqxGAkZNOydnxTg9w tw1lnJBBGtW5bXKza56jkpnosPgGqY0VRU7lYp+Gm7PWF0gkJ3s//k5r+seLl9U3FOp7 W4n3veKjXDH+OwuSS8DNc41UC42eOdfT2EoWJA39ky+yMOe1atsVWy+yT6Nx5fC3ZcbM RZNY7K2SSnY8kzITh0pniHbFQvxp5wYL6xcds5xDhQtAol+LWvaRW3RNcx2lIkpNdY6K IwWLXk+4yIBe4yKQmqGbrYq962cxUxnYSUNbkoGY9kOcyMPqnlUTVQwCSQkPDF6+KYYf c2Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wzmNVY0MlNQoNKUiuFMitPMY1YZ/UR3X4yK7u+qVxVk=; b=tVIvcElEvvqyG5vAMswVSon+ovDi4gXbZbVzTLnOQD1reUSh1HIrcmEzoE08pkRpvq 6lfbsiXrlfgueJlz9bdV6As3ujl1EXdXS9VjChX0AXhKxbP4jrfS3nRmzUzOBHDfYrfQ tfZYKJp0JENvzRjc/BknnoJNQG1OMMGSHHAbkmNEixKU0X0L36wOYlrMNCcnGJ/8DQYw jmeIkJUS2nQXwHrP3Wx/dw+7PBBLzsEgn+LOwFZnvAhMadFl0hqAsOhPp5SvHjYM5dX9 DvDgcxywTXEkOxWtmLqm+gA0sq95epKd7etVTl638mJJiSF3XteEirGOszCRiYzrPPhC sTtw== X-Gm-Message-State: APjAAAV3OiEgYzNGCEZgcBMHCxbmbHALv8Wkh2fEo1JdgmvzJ+cIy1bL wrvyTVLJ6gQzd5Pb9AUxobZQr+KR X-Google-Smtp-Source: APXvYqxOExGs7TchsFt3Iosql2c44CBBoUo1AKafGwYXzlB0y9Oui8WYRfkMv0ESWoUQPAPCVag72A== X-Received: by 2002:a19:f50e:: with SMTP id j14mr19043514lfb.11.1556183072109; Thu, 25 Apr 2019 02:04:32 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id v26sm4517353lja.60.2019.04.25.02.04.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Apr 2019 02:04:31 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Daniel Lezcano , "Raju P . L . S . S . S . N" , Stephen Boyd , Tony Lindgren , Kevin Hilman , Lina Iyer , Rajendra Nayak , Viresh Kumar , Niklas Cassel , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/4] PM / Domains: Drop unused in-parameter to some genpd functions Date: Thu, 25 Apr 2019 11:04:11 +0200 Message-Id: <20190425090413.10700-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190425090413.10700-1-ulf.hansson@linaro.org> References: <20190425090413.10700-1-ulf.hansson@linaro.org> Both genpd_alloc_dev_data() and genpd_add_device(), whom are internal genpd functions, allows a struct gpd_timing_data *td to be passed as an in-parameter. However, as NULL is always passed, let's just drop the in-parameter altogether. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) -- 2.17.1 Acked-by: Viresh Kumar diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 8aca1c9b4406..93298b7db408 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1396,8 +1396,7 @@ EXPORT_SYMBOL_GPL(pm_genpd_syscore_poweron); #endif /* CONFIG_PM_SLEEP */ -static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev, - struct gpd_timing_data *td) +static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev) { struct generic_pm_domain_data *gpd_data; int ret; @@ -1412,9 +1411,6 @@ static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev, goto err_put; } - if (td) - gpd_data->td = *td; - gpd_data->base.dev = dev; gpd_data->td.constraint_changed = true; gpd_data->td.effective_constraint_ns = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT_NS; @@ -1504,8 +1500,7 @@ static void genpd_clear_cpumask(struct generic_pm_domain *genpd, genpd_update_cpumask(genpd, dev, false); } -static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, - struct gpd_timing_data *td) +static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev) { struct generic_pm_domain_data *gpd_data; int ret; @@ -1515,7 +1510,7 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(dev)) return -EINVAL; - gpd_data = genpd_alloc_dev_data(dev, td); + gpd_data = genpd_alloc_dev_data(dev); if (IS_ERR(gpd_data)) return PTR_ERR(gpd_data); @@ -1553,7 +1548,7 @@ int pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev) int ret; mutex_lock(&gpd_list_lock); - ret = genpd_add_device(genpd, dev, NULL); + ret = genpd_add_device(genpd, dev); mutex_unlock(&gpd_list_lock); return ret; @@ -2259,7 +2254,7 @@ int of_genpd_add_device(struct of_phandle_args *genpdspec, struct device *dev) goto out; } - ret = genpd_add_device(genpd, dev, NULL); + ret = genpd_add_device(genpd, dev); out: mutex_unlock(&gpd_list_lock); @@ -2429,7 +2424,7 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, dev_dbg(dev, "adding to PM domain %s\n", pd->name); - ret = genpd_add_device(pd, dev, NULL); + ret = genpd_add_device(pd, dev); mutex_unlock(&gpd_list_lock); if (ret < 0) { From patchwork Thu Apr 25 09:04:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 162833 Delivered-To: patches@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1671745jan; Thu, 25 Apr 2019 02:04:34 -0700 (PDT) X-Received: by 2002:a2e:7e0f:: with SMTP id z15mr20311182ljc.122.1556183074020; Thu, 25 Apr 2019 02:04:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556183074; cv=none; d=google.com; s=arc-20160816; b=di8eL0aC39OtFPoag1Co0lV7Pk2aoge6kIQA90eKA7zGk2ARsquobdBWuHjIaoaiKN WVzXVOdBaX554fHJ/sX9Lk/WuzvX9cUl66gojfIB3e6Et81dRNnZRMh0izmqx6llVtnI F8ZvaBlau3chq6AwaflGJCKileliqgMtyMEpRHojUJQWmiupYDJ6z2DAp3PxupSwZfg+ T+Ge8i4woa+WYLs4nI6vuJsWsO6I6ZOnF19u+P+KTioAj7a0behx0glp76nWxHe1T1pJ bv+c1is4D2fM+P3MiQDDaXEdgQmSF6ADglx9rxP46Mx7AQzG2smaIaCmAnRQPqFhaoWJ 8EMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ljpH5vhDYU6UY/Q2jNUSgYZIZdDGjQoptAffM3+XQlk=; b=QuMovMx2TkNWzh+7SpYIpshnaN7hW8RQ4Y1Ar0bJ/hPen8n+WiVYZJsmRyZcXwZNQz dD5acOVibOPZNSTPl/SXOzl0pG+L5iGmebizSl8r3z7f0/qnEWy6tY+gUKDWxM1Kc1lc cnHZ2wDwfDAv4A1+DQ47s1IdteScGjqA18b6ZG9tDjf8aHR/y+Uka5NFAmuqW9tjxo2e C+hHyP8AdLyveoD1/2hM+qGLIjzl4xBSXzzEmNa76xzsRMnfBpvpFBjts7ljQQxihcAU gk/aH6pPMgo6KtJO9nP9gKgv0C7JaTIHzD/e/AexbeS+/THKWEsrsWZry+Efo4bllrXB CllA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BAmUdz0A; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id u25sor11050992ljj.11.2019.04.25.02.04.33 for (Google Transport Security); Thu, 25 Apr 2019 02:04:34 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BAmUdz0A; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ljpH5vhDYU6UY/Q2jNUSgYZIZdDGjQoptAffM3+XQlk=; b=BAmUdz0A6ucFtMa3FlMjlvWEkgHz+I/RgilH744my9IIg2l5Ut2yeVd499EqUNrr6R uV/4d0GC3qYyx6hCiI49R6RLU0kg/2hLato1gnweW5VdtAIm8JM2e0zrpFNRcFPidZnd h3/qVFeDrsxuCRCGoaPPavPlZpDY7b7UMRlMdiXQXYk9Zrw73S1i5lRTrrtbIRHkdGwb ewlfzjEnDEjEXq7oGTSkAonepLVdiQ/Hizm1tR0DDbGj44fhARuiSq0PIR7rFyEgI7JK klfi2i29i5xjhTfk+vEM6yAgeYBd690fWdvNX9Ybvab1BGCzhknbbmqCaB1iggqbLqWV FjvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ljpH5vhDYU6UY/Q2jNUSgYZIZdDGjQoptAffM3+XQlk=; b=gZK+0tcOsfDuae59WPqYq6DLcDblMjyDkf+MkbM2IBLfiDchbhcZnSNn1raGkJ0hra KbDx29guRR21qE+s+qVvB5VmVLcTt6yhj72Zp6Osuv7h1kG3tkSQfywNNcGrZ33EX2vX uIrR4GUxm4zRDjyIAwWBQ6ltzRCH/qcx1etno7Yo9PM/LukBrzlf3q6D1ePZOk16cBvx 3iRduUVo3ZLe9rBY4hnWV0XGlftixGjCGv8RP20rUrdA9AntzF+Z8my4ZRKU1tv21JQb 7akV+ZD2e1w8/ONQVgtabUdKxRQxwLk4dhpnjzlEUUXeZdLw10o1ytijJACfBsO/foFV SbFA== X-Gm-Message-State: APjAAAVaDQALEV23yzGpuKrs0U3U0EoOjRwz/ewCnRvM7FSJCLVt5cu1 GI0q8dx3n7zRhvnRRYiaMYWZP3Xm X-Google-Smtp-Source: APXvYqwUgctYNY2PsII4FPHfAlMMLwytUkPcselJGfHLwIChpuih8ndC76NbC/2TMSVHxD4zsiSlAg== X-Received: by 2002:a2e:9a0f:: with SMTP id o15mr10280206lji.130.1556183073597; Thu, 25 Apr 2019 02:04:33 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id v26sm4517353lja.60.2019.04.25.02.04.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Apr 2019 02:04:32 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Daniel Lezcano , "Raju P . L . S . S . S . N" , Stephen Boyd , Tony Lindgren , Kevin Hilman , Lina Iyer , Rajendra Nayak , Viresh Kumar , Niklas Cassel , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/4] PM / Domains: Search for the CPU device outside the genpd lock Date: Thu, 25 Apr 2019 11:04:12 +0200 Message-Id: <20190425090413.10700-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190425090413.10700-1-ulf.hansson@linaro.org> References: <20190425090413.10700-1-ulf.hansson@linaro.org> While attaching/detaching a device to a PM domain (genpd) that has the GENPD_FLAG_CPU_DOMAIN set, genpd iterates the cpu_possible_mask to check whether the device corresponds to a CPU. This iteration is done while holding the genpd's lock, which is unnecessary. Let's avoid the locking, by restructuring the corresponding code a bit. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 52 +++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 25 deletions(-) -- 2.17.1 Acked-by: Viresh Kumar diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 93298b7db408..da1c99178943 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1450,8 +1450,8 @@ static void genpd_free_dev_data(struct device *dev, dev_pm_put_subsys_data(dev); } -static void __genpd_update_cpumask(struct generic_pm_domain *genpd, - int cpu, bool set, unsigned int depth) +static void genpd_update_cpumask(struct generic_pm_domain *genpd, + int cpu, bool set, unsigned int depth) { struct gpd_link *link; @@ -1462,7 +1462,7 @@ static void __genpd_update_cpumask(struct generic_pm_domain *genpd, struct generic_pm_domain *master = link->master; genpd_lock_nested(master, depth + 1); - __genpd_update_cpumask(master, cpu, set, depth + 1); + genpd_update_cpumask(master, cpu, set, depth + 1); genpd_unlock(master); } @@ -1472,38 +1472,37 @@ static void __genpd_update_cpumask(struct generic_pm_domain *genpd, cpumask_clear_cpu(cpu, genpd->cpus); } -static void genpd_update_cpumask(struct generic_pm_domain *genpd, - struct device *dev, bool set) +static void genpd_set_cpumask(struct generic_pm_domain *genpd, int cpu) +{ + if (cpu >= 0) + genpd_update_cpumask(genpd, cpu, true, 0); +} + +static void genpd_clear_cpumask(struct generic_pm_domain *genpd, int cpu) +{ + if (cpu >= 0) + genpd_update_cpumask(genpd, cpu, false, 0); +} + +static int genpd_get_cpu(struct generic_pm_domain *genpd, struct device *dev) { int cpu; if (!genpd_is_cpu_domain(genpd)) - return; + return -1; for_each_possible_cpu(cpu) { - if (get_cpu_device(cpu) == dev) { - __genpd_update_cpumask(genpd, cpu, set, 0); - return; - } + if (get_cpu_device(cpu) == dev) + return cpu; } -} -static void genpd_set_cpumask(struct generic_pm_domain *genpd, - struct device *dev) -{ - genpd_update_cpumask(genpd, dev, true); -} - -static void genpd_clear_cpumask(struct generic_pm_domain *genpd, - struct device *dev) -{ - genpd_update_cpumask(genpd, dev, false); + return -1; } static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev) { struct generic_pm_domain_data *gpd_data; - int ret; + int ret, cpu; dev_dbg(dev, "%s()\n", __func__); @@ -1514,13 +1513,15 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev) if (IS_ERR(gpd_data)) return PTR_ERR(gpd_data); + cpu = genpd_get_cpu(genpd, dev); + ret = genpd->attach_dev ? genpd->attach_dev(genpd, dev) : 0; if (ret) goto out; genpd_lock(genpd); - genpd_set_cpumask(genpd, dev); + genpd_set_cpumask(genpd, cpu); dev_pm_domain_set(dev, &genpd->domain); genpd->device_count++; @@ -1560,13 +1561,14 @@ static int genpd_remove_device(struct generic_pm_domain *genpd, { struct generic_pm_domain_data *gpd_data; struct pm_domain_data *pdd; - int ret = 0; + int cpu, ret = 0; dev_dbg(dev, "%s()\n", __func__); pdd = dev->power.subsys_data->domain_data; gpd_data = to_gpd_data(pdd); dev_pm_qos_remove_notifier(dev, &gpd_data->nb); + cpu = genpd_get_cpu(genpd, dev); genpd_lock(genpd); @@ -1578,7 +1580,7 @@ static int genpd_remove_device(struct generic_pm_domain *genpd, genpd->device_count--; genpd->max_off_time_changed = true; - genpd_clear_cpumask(genpd, dev); + genpd_clear_cpumask(genpd, cpu); dev_pm_domain_set(dev, NULL); list_del_init(&pdd->list_node); From patchwork Thu Apr 25 09:04:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 162834 Delivered-To: patches@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1671785jan; Thu, 25 Apr 2019 02:04:35 -0700 (PDT) X-Received: by 2002:a2e:9348:: with SMTP id m8mr1511804ljh.23.1556183075523; Thu, 25 Apr 2019 02:04:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556183075; cv=none; d=google.com; s=arc-20160816; b=sWf08vcvZxxjIeepp7DkyNlU0TjIX3+pJHE3cCrwMCmB8T0MnxtrkrKB8RZISMoKuC kzmzUeRRxWwHu6uv6KSvAjdk8wU4ZGvETGh/69Jsx3K8/Lo48UWAC/O4mSOMbdnMGUHm ESSBxwzSv8nodZ/MXP5Ak2WSPlPnm3LNTrzWWZwzzRBEhyko2p6us218Bc7+NWp8kgLF wFJGjwPfZF69LF0Ez2RUNGeEoTfRXNBSY8SNldsvB8P1K8Ftb+hQN9w/GtppV4+XckZ1 wkUYd1Fv0H9gt5bGWUEpZH7Uq8Dol2POTVJTp0+n0dyC5zJOd8FyOro4ZrJU4rL0Hfth Xo2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+vO/H92ltJAN7Sc2E9gRf3gzSgRQawDyXMnQqUjpfmc=; b=aebBhdYYppeRdFy1uSpHW29w43K70WQVP0JwrWDaKm+39YfHJuKBzC1+vOrbz1oisM E8tF/oNqzCFie6uFSU/+cBdF/QVgp9K6oZHZvjQTcCtL9rp7xpHFLhT9VgWgy9hNoY9r IdONbGj33gKj/SW+qUa3MI7cYMgun3xe7x8X+z6cDxyUG22X9TSjFfOMcNPyT8MXhcdP 0WN1Nxjpr0kuLeYVzcNP1tHG3Ixp2vOjKmk4njW05rhTyKYRh1PFkxpPCLy8UaEpyAlm 2OUbDai7hgJ90o8AQqXMLJ1Rx9rDIdm8I8qthfKRYo2i6Mi/IrxJH+3xmjQIMtHXLVbO tndw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yC5dRReB; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 15sor4571771lfb.21.2019.04.25.02.04.35 for (Google Transport Security); Thu, 25 Apr 2019 02:04:35 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yC5dRReB; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+vO/H92ltJAN7Sc2E9gRf3gzSgRQawDyXMnQqUjpfmc=; b=yC5dRReBJJI91/9zHctiDbBK59FaHXwQvaYJBTJebSGUCyuzX/iD6Buf3sCzCASEqs NmeLl71rKWz3ChLuH3k8bRaYGUa9bkODHy531ZOa+0dPu6nMNXfg6d/fMpKJT1VJf0SS igBn8+5X2lfYrp6Y3N2KYQklvlU/tpTdiCLvl78TcSITlhpLRvJ0WVshNKmVCovDJsBY r3K73wXOzmWETpoYQVNMLcSKBlpxpmQ31bh9p14BxZnG0PHtdHILwcx4IjLygixHEQU8 XcFxD9itxPzWX8dF3ZUDS1TuceFbeyme+Mg1cA37EQog0ybfvN9XnIbN3mjxxh7t25wf +Mfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+vO/H92ltJAN7Sc2E9gRf3gzSgRQawDyXMnQqUjpfmc=; b=nKS9Y4P+unzfx7cDG4TVjGvofdNs5/K94jOaEk0zP+EzNVQETDay2vtcQ7CGbw3FhZ iMdgH9FQrur9ZqoHB5MIh6xmMQs2lsqju07Dm9HPVE+vOVaVjP+kFl5oKwv45RHxy2r+ KYD3fPl4d1GMnQeIb7jFLNqNrZD7i8X5TBzfdHOhzhPohFUuZTyX49JODmG8J0e/gH0z 28m2Fxqo65KcrOl0Rns5D5kiY/uOwkvlhAhhtcBf/UwGyFSuaXZlAorrrm9bNoEkhbBn Bfa6bOSxTz9dTUCe9VlbIIljHfxdiKc4jLXHFaLZB1jucEZctPR5/+ohKDjmX4EuJtxq 7MMQ== X-Gm-Message-State: APjAAAVfTwljb8NqSnG/hKNAXw9ffuUTC6T71tuCfHLk6V2JqfCV0+VV F0gLCetxwNi6bNOyJ/kYIVXC4WU/ X-Google-Smtp-Source: APXvYqzk3cC5yBbK4/5Bi8xvesd2ymcePZ07SfwUeHdRpIavXWYij45EEO0csvL4Ao/ccnoOMwwZSA== X-Received: by 2002:ac2:5088:: with SMTP id f8mr21568780lfm.107.1556183075155; Thu, 25 Apr 2019 02:04:35 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id v26sm4517353lja.60.2019.04.25.02.04.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Apr 2019 02:04:34 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Daniel Lezcano , "Raju P . L . S . S . S . N" , Stephen Boyd , Tony Lindgren , Kevin Hilman , Lina Iyer , Rajendra Nayak , Viresh Kumar , Niklas Cassel , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 4/4] PM / Domains: Allow to attach a CPU via genpd_dev_pm_attach_by_id|name() Date: Thu, 25 Apr 2019 11:04:13 +0200 Message-Id: <20190425090413.10700-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190425090413.10700-1-ulf.hansson@linaro.org> References: <20190425090413.10700-1-ulf.hansson@linaro.org> Attaching a device via genpd_dev_pm_attach_by_id|name() makes genpd to allocate a virtual device that it attaches instead. This leads to a problem in case the base device belongs to a CPU. More precisely, it means genpd_get_cpu() compares against the virtual device, thus it fails to find a matching CPU device. Address this limitation, by passing the base device to genpd_get_cpu() rather than the virtual device. Moreover, to deal with detach correctly from genpd_remove_device(), let's store the CPU number in the struct generic_pm_domain_data, as to be able to clear the corresponding bit in the cpumask for the genpd. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 20 ++++++++++---------- include/linux/pm_domain.h | 1 + 2 files changed, 11 insertions(+), 10 deletions(-) -- 2.17.1 Acked-by: Viresh Kumar diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index da1c99178943..3d899e8abd58 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1499,10 +1499,11 @@ static int genpd_get_cpu(struct generic_pm_domain *genpd, struct device *dev) return -1; } -static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev) +static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, + struct device *base_dev) { struct generic_pm_domain_data *gpd_data; - int ret, cpu; + int ret; dev_dbg(dev, "%s()\n", __func__); @@ -1513,7 +1514,7 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev) if (IS_ERR(gpd_data)) return PTR_ERR(gpd_data); - cpu = genpd_get_cpu(genpd, dev); + gpd_data->cpu = genpd_get_cpu(genpd, base_dev); ret = genpd->attach_dev ? genpd->attach_dev(genpd, dev) : 0; if (ret) @@ -1521,7 +1522,7 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev) genpd_lock(genpd); - genpd_set_cpumask(genpd, cpu); + genpd_set_cpumask(genpd, gpd_data->cpu); dev_pm_domain_set(dev, &genpd->domain); genpd->device_count++; @@ -1549,7 +1550,7 @@ int pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev) int ret; mutex_lock(&gpd_list_lock); - ret = genpd_add_device(genpd, dev); + ret = genpd_add_device(genpd, dev, dev); mutex_unlock(&gpd_list_lock); return ret; @@ -1561,14 +1562,13 @@ static int genpd_remove_device(struct generic_pm_domain *genpd, { struct generic_pm_domain_data *gpd_data; struct pm_domain_data *pdd; - int cpu, ret = 0; + int ret = 0; dev_dbg(dev, "%s()\n", __func__); pdd = dev->power.subsys_data->domain_data; gpd_data = to_gpd_data(pdd); dev_pm_qos_remove_notifier(dev, &gpd_data->nb); - cpu = genpd_get_cpu(genpd, dev); genpd_lock(genpd); @@ -1580,7 +1580,7 @@ static int genpd_remove_device(struct generic_pm_domain *genpd, genpd->device_count--; genpd->max_off_time_changed = true; - genpd_clear_cpumask(genpd, cpu); + genpd_clear_cpumask(genpd, gpd_data->cpu); dev_pm_domain_set(dev, NULL); list_del_init(&pdd->list_node); @@ -2256,7 +2256,7 @@ int of_genpd_add_device(struct of_phandle_args *genpdspec, struct device *dev) goto out; } - ret = genpd_add_device(genpd, dev); + ret = genpd_add_device(genpd, dev, dev); out: mutex_unlock(&gpd_list_lock); @@ -2426,7 +2426,7 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, dev_dbg(dev, "adding to PM domain %s\n", pd->name); - ret = genpd_add_device(pd, dev); + ret = genpd_add_device(pd, dev, base_dev); mutex_unlock(&gpd_list_lock); if (ret < 0) { diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index bc82e74560ee..0e8e356bed6a 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -175,6 +175,7 @@ struct generic_pm_domain_data { struct pm_domain_data base; struct gpd_timing_data td; struct notifier_block nb; + int cpu; unsigned int performance_state; void *data; };