From patchwork Thu Dec 14 15:33:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 121976 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6960320qgn; Thu, 14 Dec 2017 07:34:20 -0800 (PST) X-Google-Smtp-Source: ACJfBotaWP/GurTV8CyP0O7jRULlGdlNJfHv+lHxFsY/zGdfIrN0poT8DCi8AOJDymIqTjXS2MFf X-Received: by 10.101.68.129 with SMTP id l1mr8805654pgq.53.1513265660497; Thu, 14 Dec 2017 07:34:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513265660; cv=none; d=google.com; s=arc-20160816; b=crgsKUm3SeLkNipvAZVFd3tL6hXhQryr5FzE6WYyrDZoec9CiWDwgCTk/gPIilJmDz 3zRN4q4EwchS+7F9ltYvWH9gFJLU31mpXeMCj1NqiqRok/vSJLMYyOXOX/U4NcCGQqdr rBxoi/NhdYnYYA24MZd1OBw5znSl83nz2SkF6CIx3JBFvCsUZF388WpEawjIv9HbUMi7 74kAbe27/E++CVBnFh5qD4/RaUEi8V/L3L0jEYF37GjWGhTxBTxcSLUwbbphOqxmM86R IoWbsk4c4ZvBvV+sqrVUO+D1LqnLOHP9hd/KRkQpexaGl+cSOipFQQz1QDVmhlL3ZjuA QViw== 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=Y9LAhMI7yhCkqOWCqeEdKg7pECc3enz78Dn0k4Sy7n4=; b=D3stH0odsHHGC18YRy+WeMh26gxuvy5BlUr0vFPQrUuQZtIlG5PjHz+caI4BXNF4fO FNPBe1gxa2CAZZ+T+xpIp/8oTc/PlYm3653jTZXVCV6orBZrv0v0hLSkxsCQMUxOsVaR s8s3xgXeaSAiepcrCVOrmhStXRfBTv1lIp1PVFk8dH6jsPNBdBw9UpZdT1kda40C22T9 ixgHBzlaMTCgyofPb/0ESevjMpaPaXhkyfiVprVM/2jOtiRKDpXZSw6VI/eugA/RdHAU Uf6IJ1IBQkvC2YJg8vIPkNnj0riyw/3v4YX8/4/72GmCzB3IPYouUwq+a5iXcsj4o+UQ +SCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ONj6Qgwc; 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 m5si3312916pli.463.2017.12.14.07.34.20; Thu, 14 Dec 2017 07:34:20 -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=@linaro.org header.s=google header.b=ONj6Qgwc; 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 S1753484AbdLNPeQ (ORCPT + 19 others); Thu, 14 Dec 2017 10:34:16 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:37900 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753264AbdLNPeL (ORCPT ); Thu, 14 Dec 2017 10:34:11 -0500 Received: by mail-pf0-f196.google.com with SMTP id u25so3849279pfg.5 for ; Thu, 14 Dec 2017 07:34:11 -0800 (PST) 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=Y9LAhMI7yhCkqOWCqeEdKg7pECc3enz78Dn0k4Sy7n4=; b=ONj6QgwcwfOdoMBspKIyMoxw08QoDury4saq2+lCujRDwLtt+dq+R/6/zxMIeZHWUr rqp84geIiSaljK2AFHIOxCUHRwVaexv9e4Jgd9tLJGcwN+qizlR+MGk2CXsd/YKn/H7u IM9Bf8Vlt8vT/ADd43ijaOrYPqJxsjM4bb+qI= 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=Y9LAhMI7yhCkqOWCqeEdKg7pECc3enz78Dn0k4Sy7n4=; b=EFtn3NUlyx9U5TANUY82hh137EiyGuD++RfkqDgkhjGANulGRzZgnOwXqr9p8YXj2q x0qlZp5dl9NPemoqZfrVdranXe0NNigVt2xsVqF7AEnG/mZ6BsefPpPVPnHwiwCg4ryx zlq/yyusIrj67rtTYCl0VSDFJqOtSPApmp4aB0W7jsCGUk8sbtAswe51XIHqcHhRx5VB bXCOO8MwQimU54baMWRVNqhqElTH6dh5H4csLz73npE7DEkE/wcrLMVe4bpfsXFTymPs kMvOrBcV7afHyKOyrrAhLq8zu2TCQlfIqxg20VnVPjed5MOye8ktkPelMICwHFdwpxcM 4H9w== X-Gm-Message-State: AKGB3mLPQlQhA3erBoIQSkch+YEvAXyfAc1c0HRpibGMPq45J/t5ybVT N2XdDnnSIJHJhBBnLiSqsZp02w== X-Received: by 10.98.159.135 with SMTP id v7mr9929784pfk.162.1513265650931; Thu, 14 Dec 2017 07:34:10 -0800 (PST) Received: from localhost ([122.172.99.7]) by smtp.gmail.com with ESMTPSA id r5sm7615942pgq.25.2017.12.14.07.34.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Dec 2017 07:34:10 -0800 (PST) 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 V5 07/13] boot_constraint: Add debugfs support Date: Thu, 14 Dec 2017 21:03:14 +0530 Message-Id: X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 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_constraint/clk.c | 3 ++ drivers/boot_constraint/core.c | 59 ++++++++++++++++++++++++++++++++++++++++ drivers/boot_constraint/core.h | 6 ++++ drivers/boot_constraint/pm.c | 11 ++++++-- drivers/boot_constraint/supply.c | 9 ++++++ 5 files changed, 86 insertions(+), 2 deletions(-) -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/boot_constraint/clk.c b/drivers/boot_constraint/clk.c index db22acff43e6..ebc871c29a83 100644 --- a/drivers/boot_constraint/clk.c +++ b/drivers/boot_constraint/clk.c @@ -46,6 +46,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: @@ -60,6 +62,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_constraint/core.c b/drivers/boot_constraint/core.c index b36c02aa50c5..0350c5057ee5 100644 --- a/drivers/boot_constraint/core.c +++ b/drivers/boot_constraint/core.c @@ -21,6 +21,63 @@ 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) +{ + 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) @@ -48,12 +105,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_constraint/core.h b/drivers/boot_constraint/core.h index c5b27617b4ae..9dd481d38b99 100644 --- a/drivers/boot_constraint/core.h +++ b/drivers/boot_constraint/core.h @@ -7,6 +7,7 @@ #define _CORE_H #include +#include #include #include @@ -14,6 +15,7 @@ struct constraint_dev { struct device *dev; struct list_head node; struct list_head constraints; + struct dentry *dentry; }; struct constraint { @@ -22,12 +24,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_constraint/pm.c b/drivers/boot_constraint/pm.c index 4950ec6b248b..584d3d46ef65 100644 --- a/drivers/boot_constraint/pm.c +++ b/drivers/boot_constraint/pm.c @@ -11,11 +11,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_constraint/supply.c b/drivers/boot_constraint/supply.c index 916e5d6848d5..28fda60a0711 100644 --- a/drivers/boot_constraint/supply.c +++ b/drivers/boot_constraint/supply.c @@ -57,6 +57,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: @@ -77,6 +85,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);