Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp1115229img; Tue, 26 Feb 2019 14:35:17 -0800 (PST) X-Google-Smtp-Source: AHgI3IbdlymXCJu7g1SAlHAo0sGhz30ujx6LLMnDgWKrvMNz1Aa7VjqIgXI5Moeuh/O+L6etkR6y X-Received: by 2002:a17:902:4225:: with SMTP id g34mr29012930pld.152.1551220517173; Tue, 26 Feb 2019 14:35:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551220517; cv=none; d=google.com; s=arc-20160816; b=mm7ASSkd77G3UdDxpsWc2q3b2yHTA78rOzdBjbcaLWtwUCubmUACswiRKVzKV7CWZD Br6HqyRIhVMPM+aaT2KL9kEJlfodj6onOjGBDw+dbozK+T9TPkoE8gG3FT5t/dVXHHYW EqwNgQbj1XHChcQFoov1SqOvhwvGASCw79CNkrfIFKrno6Vhf+ub1BJJEYjmMppFa/hU vghIpgXdC0964vaU5/6BnVkmmhzwyCS/09xUaHIhOiYxvGDOkvuyBq/K4ya/BOd/fHTa WSE5YnWK2c/rFzTjiWhOvOMHL8Mi2oddQZ89lHNlNLIzCJPv8nJ1pekYm23nk0bGod0h SbCg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8RDMXjPeVOwU+w9Zd7DxFU8lrQYErNcEKlD2wL0W1co=; b=yhT0eJdQnJvX5280cnYBPAYZqVc8SWopD6xcuqyVHcSMURbcSItJvRSgUdEx1hvHtv jPh+LmJJe79Jk00dFHStmCqDytoqPn91boD1C0JSMoGEfoqPkjN/njhTilhYZJOPmTFW GxJX5eTT69i0A2YSpvZMnj9wMZqunZtZ90H6bpv3V4/hds9ooC+byrdoQ6I/SJodsZXp sQAHvP1vLbzdYHyjU6xJn3HlyWLx3OGII6zkiZKUnyaPrf+kmZJQIOuT7Xu3POvO5C9b f+JVWHk0J0vbL5RubTDC8OzoZjiZ9Ca2ZFPY3fNdBOIzwZLAOJGn1QgvZk8FbpByhPY2 751Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jI+lGYBg; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y72si13010280pgd.398.2019.02.26.14.35.01; Tue, 26 Feb 2019 14:35:17 -0800 (PST) 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=jI+lGYBg; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729340AbfBZWee (ORCPT + 99 others); Tue, 26 Feb 2019 17:34:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:48246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729187AbfBZWed (ORCPT ); Tue, 26 Feb 2019 17:34:33 -0500 Received: from mail.kernel.org (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 54BB5218A1; Tue, 26 Feb 2019 22:34:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551220471; bh=EhSwc8YZXpNLa457hu+6PsYYq1FYt0pMKcWYUIlYCSE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jI+lGYBgVD+nUUzZMkqIsZXvF/TmO56M6kLugzmh06R6b5le6QM2oabRAunMnkJKh zGZ0+tP/ZumBp3raKeqZtnC9V0mGt3a9r6/2/0CwGjGmPcJphER2R2YE3xVXzZvAqf 2tQjuZnEwxjM4BvMI5zxxiepgAHsp2LDUWG1w+KE= From: Stephen Boyd To: Michael Turquette , Stephen Boyd Cc: Miquel Raynal , linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Jerome Brunet , Russell King , Jeffrey Hugo , Chen-Yu Tsai Subject: [PATCH v2 2/8] clk: core: clarify the check for runtime PM Date: Tue, 26 Feb 2019 14:34:23 -0800 Message-Id: <20190226223429.193873-3-sboyd@kernel.org> X-Mailer: git-send-email 2.21.0.rc2.261.ga7da99ff1b-goog In-Reply-To: <20190226223429.193873-1-sboyd@kernel.org> References: <20190226223429.193873-1-sboyd@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miquel Raynal Currently, the core->dev entry is populated only if runtime PM is enabled. Doing so prevents accessing the device structure in any case. Keep the same logic but instead of using the presence of core->dev as the only condition, also check the status of pm_runtime_enabled(). Then, we can set the core->dev pointer at any time as long as a device structure is available. This change will help supporting device links in the clock subsystem. Signed-off-by: Miquel Raynal Cc: Jerome Brunet Cc: Russell King Cc: Michael Turquette Cc: Jeffrey Hugo Cc: Chen-Yu Tsai [sboyd@kernel.org: Change to a boolean flag] Signed-off-by: Stephen Boyd --- drivers/clk/clk.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index fef937ea44f4..d46e8b9b9c9f 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -57,6 +57,7 @@ struct clk_core { struct clk_core *new_child; unsigned long flags; bool orphan; + bool rpm_enabled; unsigned int enable_count; unsigned int prepare_count; unsigned int protect_count; @@ -92,9 +93,9 @@ struct clk { /*** runtime pm ***/ static int clk_pm_runtime_get(struct clk_core *core) { - int ret = 0; + int ret; - if (!core->dev) + if (!core->rpm_enabled) return 0; ret = pm_runtime_get_sync(core->dev); @@ -103,7 +104,7 @@ static int clk_pm_runtime_get(struct clk_core *core) static void clk_pm_runtime_put(struct clk_core *core) { - if (!core->dev) + if (!core->rpm_enabled) return; pm_runtime_put_sync(core->dev); @@ -223,7 +224,7 @@ static bool clk_core_is_enabled(struct clk_core *core) * taking enable spinlock, but the below check is needed if one tries * to call it from other places. */ - if (core->dev) { + if (core->rpm_enabled) { pm_runtime_get_noresume(core->dev); if (!pm_runtime_active(core->dev)) { ret = false; @@ -233,7 +234,7 @@ static bool clk_core_is_enabled(struct clk_core *core) ret = core->ops->is_enabled(core->hw); done: - if (core->dev) + if (core->rpm_enabled) pm_runtime_put(core->dev); return ret; @@ -3341,7 +3342,8 @@ struct clk *clk_register(struct device *dev, struct clk_hw *hw) core->ops = hw->init->ops; if (dev && pm_runtime_enabled(dev)) - core->dev = dev; + core->rpm_enabled = true; + core->dev = dev; if (dev && dev->driver) core->owner = dev->driver->owner; core->hw = hw; -- Sent by a computer through tubes