From patchwork Sun Oct 29 13:48:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 117414 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1528393qgn; Sun, 29 Oct 2017 06:50:47 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TZiFxFME+9Ln6yaFm4fjs/nmG5H2Uq1yyMAqJNVznawhqX+9kiGJno1WyFPO3Cn3btXHK3 X-Received: by 10.84.215.9 with SMTP id k9mr4797469pli.284.1509285047872; Sun, 29 Oct 2017 06:50:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509285047; cv=none; d=google.com; s=arc-20160816; b=FDCDNOiTpU9u/AYcTO1lyvq8VJeC8fAfUwxO2bSyXqbOFbRkb+quj9Hw9rWXh2GbLH 6Q+IomDBO+SOG74pKBi9cRdN6dKgjDgjHaSDeEy+/Hnr5dvagthd7g1te/U3aEQhXrkG gLOPkehA0+3qid7JHem7IeOCvnsLgcGisPa+4GlpD4Vc6dwxk62uh8y8bUHyzeeARxfW +g+gb4L7PwWDpy9maejNOGLD/noAfmAXa9wQuI55PWITiAfBzquN1kjIKxBfXPPL1Dff GN4i3TDFq+8pVPAR8FkjPCrChXgpnkBnTfzwNTqiiqXhuGEHmB21BxWJhdGpebAouEPh pPMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=AUapgh7rcEIeG7tzA1pr/dDTN70gc45QREU9J7qYkYs=; b=YuxDPrKSI2M56O5rE7I/tHJoJNSjzLpFGahg4mYnb8VVVT+4V8xMsJWqBe5RTjoC/4 W5EO2TqUc347MEjF2kFFaG3neKYY5WaFYepUX4ojaGxeYhknQIvmx/fc4vUlTKgUgexn 64LVaiRi3f4pXGvom3NLEVe1XavpCJA5ZzLt2CuF6bta4NqL0pm0u6difyMv0/TjqQbc fR+FAEnJjmo3F7s1YKJ3OHLpatikgdQOuoKCXvuFuiW+KWRk2Ei35HG9YY4sGg+OewUo 4t1LBLSv7DOgh5xtf99+I/VzPdwe1tGQzjy7vN/sNuUivssCuIJ6kSsCsfU5CHs7AYHK D9Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LvrjYJmT; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j71si7942812pgc.290.2017.10.29.06.50.47; Sun, 29 Oct 2017 06:50:47 -0700 (PDT) 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=@linaro.org header.s=google header.b=LvrjYJmT; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751978AbdJ2Nup (ORCPT + 27 others); Sun, 29 Oct 2017 09:50:45 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:53016 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751744AbdJ2Nt3 (ORCPT ); Sun, 29 Oct 2017 09:49:29 -0400 Received: by mail-pf0-f193.google.com with SMTP id e64so8655481pfk.9 for ; Sun, 29 Oct 2017 06:49:29 -0700 (PDT) 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 :in-reply-to:references; bh=AUapgh7rcEIeG7tzA1pr/dDTN70gc45QREU9J7qYkYs=; b=LvrjYJmTN4gfrbpXJogAJlKIBZ2Gs3YF72K6fhQ/HlUJAxJYb6MGRwn0Wf3RlcqRv4 /NKZPRb9B+dWH8jSkTmSjNUDvUQ9xrLeT0WtRSFGYgBUeG0HhJBK/NCoSJkw0O9VZQdV 9qSaImRxfBpwpWTlmN8GeFR06/g72kHpp8sns= 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:in-reply-to:references; bh=AUapgh7rcEIeG7tzA1pr/dDTN70gc45QREU9J7qYkYs=; b=LkmTLZ8qzpMkDoXtmu4l8EGuwISATmcZCfAKa9lySoYhp1Cb6O4LT3JZj2V2bshZ6+ ZRqVaaj/IR27fAgt5IBBJMqeiwJNFGKyIakUmmxAp7NQN+WgcQB1qskPCtG8CzpsjdvJ SaWzft+pYYMjr47PpOQGqNDMpATJ9KHRpZqWQYvZrvseBq+neg6PPnOQ2/Dh282M7eCw ga5ZECt6CALnUWfDbtmohhCc50RqRGEwrt7cV5iDOnSaBkT1FhkuITyIXge/wX8OYavs jnApeS1ExeYq5gQD0HyPi4DBD0xgkYy2uSivVG6twWe0I3bcG5RHnOBvAp3QAc0z4hyi VfPA== X-Gm-Message-State: AMCzsaUx/EDrrO3eIQkoX/28JrS+YUR5Ls+kubESS3ko3s82D7U5ui3l BSLmiNqZG/Nj/ikQ0xFsW8+oFw== X-Received: by 10.99.160.71 with SMTP id u7mr5233932pgn.22.1509284969033; Sun, 29 Oct 2017 06:49:29 -0700 (PDT) Received: from localhost ([122.167.161.211]) by smtp.gmail.com with ESMTPSA id e6sm25752363pfg.42.2017.10.29.06.49.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Oct 2017 06:49:28 -0700 (PDT) From: Viresh Kumar To: Greg Kroah-Hartman Cc: Viresh Kumar , Vincent Guittot , Stephen Boyd , Rajendra Nayak , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robdclark@gmail.com, s.hauer@pengutronix.de, l.stach@pengutronix.de, shawnguo@kernel.org, fabio.estevam@nxp.com, nm@ti.com, xuwei5@hisilicon.com, robh+dt@kernel.org Subject: [PATCH V4 07/12] boot_constraint: Add debugfs support Date: Sun, 29 Oct 2017 19:18:55 +0530 Message-Id: X-Mailer: git-send-email 2.15.0.rc1.236.g92ea95045093 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds debugfs support for boot constraints. This is how it looks for a "vmmc-supply" constraint for the MMC device. $ ls -R /sys/kernel/debug/boot_constraints/ /sys/kernel/debug/boot_constraints/: f723d000.dwmmc0 /sys/kernel/debug/boot_constraints/f723d000.dwmmc0: clk-ciu pm-domain supply-vmmc supply-vmmcaux /sys/kernel/debug/boot_constraints/f723d000.dwmmc0/clk-ciu: /sys/kernel/debug/boot_constraints/f723d000.dwmmc0/pm-domain: /sys/kernel/debug/boot_constraints/f723d000.dwmmc0/supply-vmmc: u_volt_max u_volt_min /sys/kernel/debug/boot_constraints/f723d000.dwmmc0/supply-vmmcaux: u_volt_max u_volt_min Tested-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/boot_constraints/clk.c | 3 ++ drivers/boot_constraints/core.c | 60 +++++++++++++++++++++++++++++++++++++++ drivers/boot_constraints/core.h | 6 ++++ drivers/boot_constraints/pm.c | 11 +++++-- drivers/boot_constraints/supply.c | 9 ++++++ 5 files changed, 87 insertions(+), 2 deletions(-) -- 2.15.0.rc1.236.g92ea95045093 diff --git a/drivers/boot_constraints/clk.c b/drivers/boot_constraints/clk.c index b5b1d63c3e76..91b7b538ef32 100644 --- a/drivers/boot_constraints/clk.c +++ b/drivers/boot_constraints/clk.c @@ -49,6 +49,8 @@ int constraint_clk_add(struct constraint *constraint, void *data) cclk->clk_info.name = kstrdup_const(clk_info->name, GFP_KERNEL); constraint->private = cclk; + constraint_add_debugfs(constraint, clk_info->name); + return 0; put_clk: @@ -63,6 +65,7 @@ void constraint_clk_remove(struct constraint *constraint) { struct constraint_clk *cclk = constraint->private; + constraint_remove_debugfs(constraint); kfree_const(cclk->clk_info.name); clk_disable_unprepare(cclk->clk); clk_put(cclk->clk); diff --git a/drivers/boot_constraints/core.c b/drivers/boot_constraints/core.c index f4d3520ddb04..707ffac690fc 100644 --- a/drivers/boot_constraints/core.c +++ b/drivers/boot_constraints/core.c @@ -24,6 +24,64 @@ static LIST_HEAD(constraint_devices); static DEFINE_MUTEX(constraint_devices_mutex); +/* Debugfs */ + +static struct dentry *rootdir; + +static void constraint_device_add_debugfs(struct constraint_dev *cdev) +{ + struct device *dev = cdev->dev; + + cdev->dentry = debugfs_create_dir(dev_name(dev), rootdir); +} + +static void constraint_device_remove_debugfs(struct constraint_dev *cdev) +{ + debugfs_remove_recursive(cdev->dentry); +} + +void constraint_add_debugfs(struct constraint *constraint, const char *suffix) +{ + struct device *dev = constraint->cdev->dev; + const char *prefix; + char name[NAME_MAX]; + + switch (constraint->type) { + case DEV_BOOT_CONSTRAINT_CLK: + prefix = "clk"; + break; + case DEV_BOOT_CONSTRAINT_PM: + prefix = "pm"; + break; + case DEV_BOOT_CONSTRAINT_SUPPLY: + prefix = "supply"; + break; + default: + dev_err(dev, "%s: Constraint type (%d) not supported\n", + __func__, constraint->type); + return; + } + + snprintf(name, NAME_MAX, "%s-%s", prefix, suffix); + + constraint->dentry = debugfs_create_dir(name, constraint->cdev->dentry); +} + +void constraint_remove_debugfs(struct constraint *constraint) +{ + debugfs_remove_recursive(constraint->dentry); +} + +static int __init constraint_debugfs_init(void) +{ + /* Create /sys/kernel/debug/opp directory */ + rootdir = debugfs_create_dir("boot_constraints", NULL); + + return 0; +} +core_initcall(constraint_debugfs_init); + + /* Boot constraints core */ static struct constraint_dev *constraint_device_find(struct device *dev) @@ -51,12 +109,14 @@ static struct constraint_dev *constraint_device_allocate(struct device *dev) INIT_LIST_HEAD(&cdev->constraints); list_add(&cdev->node, &constraint_devices); + constraint_device_add_debugfs(cdev); return cdev; } static void constraint_device_free(struct constraint_dev *cdev) { + constraint_device_remove_debugfs(cdev); list_del(&cdev->node); kfree(cdev); } diff --git a/drivers/boot_constraints/core.h b/drivers/boot_constraints/core.h index a051c3d7c8ab..ee84e237c66a 100644 --- a/drivers/boot_constraints/core.h +++ b/drivers/boot_constraints/core.h @@ -8,6 +8,7 @@ #define _CORE_H #include +#include #include #include @@ -15,6 +16,7 @@ struct constraint_dev { struct device *dev; struct list_head node; struct list_head constraints; + struct dentry *dentry; }; struct constraint { @@ -23,12 +25,16 @@ struct constraint { enum dev_boot_constraint_type type; void (*free_resources)(void *data); void *free_resources_data; + struct dentry *dentry; int (*add)(struct constraint *constraint, void *data); void (*remove)(struct constraint *constraint); void *private; }; +void constraint_add_debugfs(struct constraint *constraint, const char *suffix); +void constraint_remove_debugfs(struct constraint *constraint); + /* Forward declarations of constraint specific callbacks */ int constraint_clk_add(struct constraint *constraint, void *data); void constraint_clk_remove(struct constraint *constraint); diff --git a/drivers/boot_constraints/pm.c b/drivers/boot_constraints/pm.c index edba5eca5093..d74b776cdced 100644 --- a/drivers/boot_constraints/pm.c +++ b/drivers/boot_constraints/pm.c @@ -14,11 +14,18 @@ int constraint_pm_add(struct constraint *constraint, void *data) { struct device *dev = constraint->cdev->dev; + int ret; - return dev_pm_domain_attach(dev, true); + ret = dev_pm_domain_attach(dev, true); + if (ret) + return ret; + + constraint_add_debugfs(constraint, "domain"); + + return 0; } void constraint_pm_remove(struct constraint *constraint) { - /* Nothing to do for now */ + constraint_remove_debugfs(constraint); } diff --git a/drivers/boot_constraints/supply.c b/drivers/boot_constraints/supply.c index 30f816dbf12c..3d658410a082 100644 --- a/drivers/boot_constraints/supply.c +++ b/drivers/boot_constraints/supply.c @@ -60,6 +60,14 @@ int constraint_supply_add(struct constraint *constraint, void *data) csupply->supply.name = kstrdup_const(supply->name, GFP_KERNEL); constraint->private = csupply; + constraint_add_debugfs(constraint, supply->name); + + debugfs_create_u32("u_volt_min", 0444, constraint->dentry, + &csupply->supply.u_volt_min); + + debugfs_create_u32("u_volt_max", 0444, constraint->dentry, + &csupply->supply.u_volt_max); + return 0; remove_voltage: @@ -80,6 +88,7 @@ void constraint_supply_remove(struct constraint *constraint) struct device *dev = constraint->cdev->dev; int ret; + constraint_remove_debugfs(constraint); kfree_const(supply->name); ret = regulator_disable(csupply->reg);