From patchwork Wed Jan 10 03:47:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 10153883 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 564C7602D8 for ; Wed, 10 Jan 2018 03:49:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42E43274D1 for ; Wed, 10 Jan 2018 03:49:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36F0327853; Wed, 10 Jan 2018 03:49:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 964FF274D1 for ; Wed, 10 Jan 2018 03:49:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=uCwQHZ3QYq2JvJf1Ko+SMw18cny6nEQ8KSkrmC1l3lY=; b=fUW2zwA3wQVNkGKvXh3B8JjNI9 Llk1UOa1kRCkUFtFqt/GMeSvxRT+83X3hJDcYWMw4aaKgc4YquFJHu3sF9NXDXwNqKn1DTphSePzF 1ob999rJ2oH59AdIyyEZDB9x1LnMMe1WaUhnAbfrvnynhyEwWbDedvn6GUHXWWagPK4Ined+ZpBM6 +WMjEA5437EiBP3A8fzKoswAcay70A8z9wkUwRVf7w3rHpu2Mgn4rkNSzJY6zOIdlc1DAb1xqq+F1 Zxc+CECPzfO9agi3VpQm68+O/UYUbdbhEn7OS44BY7BjZkhLlcSjGcbDoCi2CYauEzB6IC8MLLUpd ZW+muwzQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eZ7OT-0003r3-Qx; Wed, 10 Jan 2018 03:49:37 +0000 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZ7ND-0002CZ-72 for linux-arm-kernel@lists.infradead.org; Wed, 10 Jan 2018 03:48:30 +0000 Received: by mail-pg0-x243.google.com with SMTP id j4so9818046pgp.1 for ; Tue, 09 Jan 2018 19:48: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=c3PeOr6UYwegIAxqel7kamm4xbJThWTBjJAt8Kw3j+UNGMjM8rWPsu44KBRm6yMht0 MKtEmRrXa2Gce7vjsojz7gIhG4nouZfhHgQJ6OR+ULMeUrXsd/IcAjbjgFhcejzlV5xG TBrK506py5yyXrnc/yy4D+POjIjIXsdaLggGI= 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=gZZ8RxazvChUusC1oe+xHGNUkI+uEjA9fp8YDIfs8I2V0Dl9V2paOId3IxWRUbiKh1 uM0shTbWwnFeZHsCdn7DdvPxTDcLOLeJQFO3m4YzRrzWTn02kby9jYerJE8FqoTyMbNQ fSzHYiP7JFXF5dia165UhJG7FX9PyOReXiMG1Nqgq23X+lSbp+PaUiwcTMCAI3ST9Eu5 mybYV7bF87L4LbkawGmJi6wrJAtLB36ARLmq0IN0U38+R8ePO5M7AEwOhwhFpcGbbZTM iR5N9yVZSZHcoU1/m8rxoEucdt/hcWxJzl4hMAt6USe80L+VpvP48qgYndwTAFM7ULHe smCA== X-Gm-Message-State: AKGB3mJwaJmM0ZaLTefsg4sL4rz9Zw+N+8yqttGe42Q2KyhOgZY6cGRQ /7iqtUpYI68Wl4DVBLfNW2I4KA== X-Google-Smtp-Source: ACJfBotxSTNldGlkHxKZ5suSIx3bEzFZCGbzUzZdVAGXfk0o1W1JY1YlPEyivVX0fa23yKuZDJ2uXA== X-Received: by 10.98.11.130 with SMTP id 2mr8985618pfl.190.1515556091296; Tue, 09 Jan 2018 19:48:11 -0800 (PST) Received: from localhost ([122.172.19.39]) by smtp.gmail.com with ESMTPSA id t80sm9194955pgb.88.2018.01.09.19.48.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jan 2018 19:48:10 -0800 (PST) From: Viresh Kumar To: Greg Kroah-Hartman Subject: [PATCH V6 07/13] boot_constraint: Add debugfs support Date: Wed, 10 Jan 2018 09:17:36 +0530 Message-Id: X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180109_194819_881062_3794D1C3 X-CRM114-Status: GOOD ( 16.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nm@ti.com, Rajendra Nayak , Viresh Kumar , s.hauer@pengutronix.de, Stephen Boyd , linux-kernel@vger.kernel.org, xuwei5@hisilicon.com, robdclark@gmail.com, robh+dt@kernel.org, fabio.estevam@nxp.com, Vincent Guittot , shawnguo@kernel.org, linux-arm-kernel@lists.infradead.org, l.stach@pengutronix.de MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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);