From patchwork Tue Sep 1 08:27:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 248839 Delivered-To: patches@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp4017769ilg; Tue, 1 Sep 2020 01:27:17 -0700 (PDT) X-Received: by 2002:a2e:865a:: with SMTP id i26mr7271ljj.246.1598948837572; Tue, 01 Sep 2020 01:27:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598948837; cv=none; d=google.com; s=arc-20160816; b=06gnReGDzbPX2ANWQd+zhP6D6uZ38Av4f25qGSjmXACSDfh/8L2xQVhHqr/yFcLc+y ktK51iO6E2hR9liZvyM8C0fnWX3XULsLSnjTPkvDeZkvkhCMG2B3xmx3D1SdpJ3DxVXL 3h2w9anV+stlP3EHuH/o1qeLXMUZ3bF8mwC+ffWDMv8Y6LuW5zJylK0TKVQh6c7Zw5Wl Rq9o7TZ3c3LlecrFEMBh0+/5Vikb5iCdjgE4yJ/RlgXmx/tauCcjG9EbX+QgPIcKwdy1 zsVa+pDquIJV81nQDMudMXNPtywuD+KKA01xt09UljVOwILNC0Vr9wpQ93MMszGrNXpj C9mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=+5tYnQUX16Q+heMCNRPh41Y4CeDI+HHRPCn/NIvgA2k=; b=Mu0M4yoqOxmkgjMicLEmgMcW7Jc1MHDQZn9saEg0gOVvSDKuqvf8wdeKB/oFE89BpI oZTIiSO65p9ja4P5FqmLMdyNTlHrdY8q2mZemJFm6uffXi3ndwnu3OtF9o3pKtQj5F9A aX7N0UpenmWGssyumKUdLo3mvaBaq7jwgqek84hXYwqE/F2p70+VyqF+Jbrbf/fFgZcF YITSxUcdaxty9DdnZ8BbrzbPGjezmBbwH/dAOofLi3t7cWVhzN1YqkHrhjgE2vts75Ys VKvN+Qc0MWeqGsKfjWqTEY26PuWJZxBqm3B34de0mGPEP7XITnyKB9xp0NAq7t4qnRRq I0/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yxjSKuPU; 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 h10sor217822ljj.56.2020.09.01.01.27.17 for (Google Transport Security); Tue, 01 Sep 2020 01:27:17 -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=yxjSKuPU; 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 :mime-version:content-transfer-encoding; bh=+5tYnQUX16Q+heMCNRPh41Y4CeDI+HHRPCn/NIvgA2k=; b=yxjSKuPUj5jB/wd3E8BkAdEXpcwx+QYNlsPC+DlHOjFfNJIeYoAl+TOYLt71CG5nws 4wfPK6ihZGANEYge9CnzaRZHhIfU85mFZAjm5NIeQHIeTcT8xhHssr37u5c82vV3Xg6e xkaIuaf0XNj5qVPUGpCAxh1r2VKsdBceZ1rao2PrnuhOMMKML5sA/N/PePhhSTZeZpiC DvQ9ojYsgfYnm3yMYakbKCVddVBeIPTRRwTGlN6Oh7ThjJdgVYpmaZi1RKDRomNJUHSf cTUn/ZKpPJV1SIQhRuxZSJkuVw2eNdB3EoSbTyhnzkNnWaC1aYkicnw01akLplRv1s5o 85RQ== 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:mime-version:content-transfer-encoding; bh=+5tYnQUX16Q+heMCNRPh41Y4CeDI+HHRPCn/NIvgA2k=; b=AlmzlxIm+BDdAnO7u7xemu4jW9SxU0eUaqq3TYK3AEY7bSTnX5Uf0rebKYQEDgfuMf y7Bco0NQZC9qiCqquYNo7Yn+RWqEPQkSDvAeb5vBvLk2OhN0TzJm/GS/uAooKjWoqwvz bfFjFYZt7kbb6aQENGcynU/8EyIQRXv2na9aA+xXf6a6dMlKG2i+WaB+PjUrnTTv+xPZ e9mBxAtHsDj5QUOOTqVoqHl2QwuO2iB5cRsMYxvmuIwTb/LShFE+Y8R00/bSATxUG8lH 7su/2+vBhQ4zGgJXVFSqVZ3qqsXptUn5G2l7q1ZhS+WJxsKNsXPTOaloh/1ay4HArCZO sKyQ== X-Gm-Message-State: AOAM5337tNAZ4lgAtV4qTgT4YgCSuLYPvlNQGbXNFH6ucp3iv2q19in1 iQGvNzzYdCOxBJGqCstKhif4sVzI X-Google-Smtp-Source: ABdhPJzBA4RJyll+BAH3x5aIMti9jSrmCxrccc4R3hcNImFw9LL9oQ7gvcPr4tUtek3iqAyzWjLKIw== X-Received: by 2002:a2e:900e:: with SMTP id h14mr438675ljg.103.1598948837167; Tue, 01 Sep 2020 01:27:17 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-98-128-180-79.NA.cust.bahnhof.se. [98.128.180.79]) by smtp.gmail.com with ESMTPSA id c5sm111252lfb.24.2020.09.01.01.27.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 01:27:16 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Lina Iyer , Lukasz Luba , Vincent Guittot , Stephen Boyd , Bjorn Andersson , Benjamin Gaignard , Ulf Hansson , linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/2] PM / Domains: Enable locking for syscore devices for IRQ safe genpds Date: Tue, 1 Sep 2020 10:27:06 +0200 Message-Id: <20200901082707.106860-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200901082707.106860-1-ulf.hansson@linaro.org> References: <20200901082707.106860-1-ulf.hansson@linaro.org> MIME-Version: 1.0 The genpd lock is currently not being used, while suspending/resuming syscore devices through genpd. This because we need to avoid using a mutex when running in the syscore phase. However, the locking can be useful under special circumstances (as shown in subsequent changes) and for a genpd having the flag GENPD_FLAG_IRQ_SAFE set. Therefore, let's make use of the lock when it's possible. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) -- 2.25.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 2cb5e04cf86c..55d99a36bf6b 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1342,18 +1342,27 @@ static void genpd_complete(struct device *dev) static void genpd_syscore_switch(struct device *dev, bool suspend) { struct generic_pm_domain *genpd; + bool use_lock; genpd = dev_to_genpd_safe(dev); if (!genpd) return; + use_lock = genpd_is_irq_safe(genpd); + + if (use_lock) + genpd_lock(genpd); + if (suspend) { genpd->suspended_count++; - genpd_sync_power_off(genpd, false, 0); + genpd_sync_power_off(genpd, use_lock, 0); } else { - genpd_sync_power_on(genpd, false, 0); + genpd_sync_power_on(genpd, use_lock, 0); genpd->suspended_count--; } + + if (use_lock) + genpd_unlock(genpd); } void pm_genpd_syscore_poweroff(struct device *dev)