From patchwork Fri Feb 23 10:23:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 10237355 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 685C0602DC for ; Fri, 23 Feb 2018 10:34:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F708294FE for ; Fri, 23 Feb 2018 10:34:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 440EB29503; Fri, 23 Feb 2018 10:34:03 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 7DFD6294FE for ; Fri, 23 Feb 2018 10:34:02 +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=lnF/llH1v0mfTIYOWUic7a9en11RZ3mR1OYJL2lrVgs=; b=EZ3imZyRkXbeD/SL6k+7h07aAE asWJoPyGnZtLXHCjHOp6u0nZnv8Bn+vSiIe2Ard4uSbP0KHF6OTIHWXkoVvXklAMy9rJUKK/qx+sU asEq091niPVZcQOHYU9m5Y9QSI2zQ7P+gtS3DHUScel62zcsv0IkW4Sx8qoxmeaVJzlYUY013gaH6 9Jco7dNfPfmMrXgIeKzqZMHrsqEEztw+0860QJ1k3nMq5B9o9DnYW7ya7mEuOrVJoAK2ghSVxkbe+ KaJfuJxOgn6rkJVPVvly4N01yKlm5BY7tWTDvQZ9B62/SGq3uVNSTxWs94tOPTne96RKriR+Muo4G LsNyW0oQ==; 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 1epAfn-0004xh-Es; Fri, 23 Feb 2018 10:33:51 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1epAd6-0003Ib-1i for linux-arm-kernel@bombadil.infradead.org; Fri, 23 Feb 2018 10:31:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Tyw/mrJdFFjfo1YJuoZPOmEuLTwlV0np1KAhDQwf3+8=; b=pfy9Oz25PfWVrPf9zMEoOlmOi Id2AQRknb+GG0rHXIkNv6kJ6jABk3Sg4gJzLh0EpnV7X2X17ZnI5LLMOYu0Dwhkr65NPKo5MAHKNN leYn0f1C0X36Q+x1NOO0oYiiJeyrZcMjYhBUjR3vYXhercbGDfQ9btMaDTCF0KEybDh3QESGcc4fB uyXDnSUhxImRrSBnIhyaZITKnyyL9e71LiS5nW0pUAZZbYVolFTfGSN+cmDY3zHXx4caTIj+QCEt/ ZACEEA8kjkVp9aZnRv9z2oF5Ezryr7VSRUFXL8z+VwH0v9P7bQJIVbxgDz0gRNHnnK/QyW7ldI49x B+KU6HLQw==; Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1epAWp-00060V-2z for linux-arm-kernel@lists.infradead.org; Fri, 23 Feb 2018 10:24:36 +0000 Received: by mail-pl0-x243.google.com with SMTP id d4so4664767pll.5 for ; Fri, 23 Feb 2018 02:24:24 -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=Tyw/mrJdFFjfo1YJuoZPOmEuLTwlV0np1KAhDQwf3+8=; b=LKeAzf8zPPJ7F1dgz9YajaImgKkBeGcob/kC3HnHdqWZMCp+FPq8G9gpsLG+5WFVj7 kYvhEVJ3bK5WzfwrspLhlotYNjzzcUMXYllY3nmmwBNq/Z8R1ZYy/uP+E63PvIzYwk+T nLM/GQleTWJAdO8TCZm4r6MiTwDRPMzwxfgw0= 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=Tyw/mrJdFFjfo1YJuoZPOmEuLTwlV0np1KAhDQwf3+8=; b=OZfWBKE/o+t35V9UXyrTPitqiIudb3vsW4XAFvnST2GqOrTG1mElvE9odTh6BguYXy egOypq+fdmzqRhzF2t/YNoE1zZQhKvk4Cieiis1ng2IPSREPmie8uCc0NaG76NEhODWQ pfLNauHKVaqInO2R7hfa9mObgEhl/iYGFieHW9amNAqZj3YDaU54c6Xvzzg6U23GUT65 0m2oA93kjrGgyC8nqIW3mJBPXu7DXesuFlzcD5xnGbHWxFyD8dxoXUmfEuOOzYkVkMRV rIlnE+TdN23yd8ZM30lxohdPEUu3L36NagqeSbngV8eG3tPKB+y/VdjB8jib2ftGONhT b+gA== X-Gm-Message-State: APf1xPCt9Ekv+QGIQFzV7d5XDE44ZSpW+tchH5dohl1Ay0wmflMZqkyu /OVk1LAPo9NqBizsCR/2LO6LQA== X-Google-Smtp-Source: AH8x227OsK6g3K2arfxyMStbmWMLFFQ74gMKFENa0B01nOwnzLkwAiYBY9DLSBYu+SUbLuTpKArPKA== X-Received: by 2002:a17:902:3124:: with SMTP id w33-v6mr1252362plb.356.1519381463462; Fri, 23 Feb 2018 02:24:23 -0800 (PST) Received: from localhost ([122.167.232.138]) by smtp.gmail.com with ESMTPSA id g16sm4632893pfd.23.2018.02.23.02.24.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 02:24:22 -0800 (PST) From: Viresh Kumar To: Greg Kroah-Hartman Subject: [PATCH V7 07/13] boot_constraint: Add debugfs support Date: Fri, 23 Feb 2018 15:53:46 +0530 Message-Id: <745f7dea835174ff837af39a2ae6e9f2b8b94cc0.1519380923.git.viresh.kumar@linaro.org> 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-20180223_102435_115493_DA0742A9 X-CRM114-Status: GOOD ( 20.67 ) 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 , Stephen Boyd , Viresh Kumar , s.hauer@pengutronix.de, linux-kernel@vger.kernel.org, xuwei5@hisilicon.com, olof@lixom.net, 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/bootconstraint/clk.c | 3 +++ drivers/bootconstraint/core.c | 59 +++++++++++++++++++++++++++++++++++++++++ drivers/bootconstraint/core.h | 6 +++++ drivers/bootconstraint/pm.c | 11 ++++++-- drivers/bootconstraint/supply.c | 9 +++++++ 5 files changed, 86 insertions(+), 2 deletions(-) diff --git a/drivers/bootconstraint/clk.c b/drivers/bootconstraint/clk.c index 90262fe9057c..1ee8ab1978a5 100644 --- a/drivers/bootconstraint/clk.c +++ b/drivers/bootconstraint/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/bootconstraint/core.c b/drivers/bootconstraint/core.c index a6148b625b48..5a6984276139 100644 --- a/drivers/bootconstraint/core.c +++ b/drivers/bootconstraint/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/bootconstraint/core.h b/drivers/bootconstraint/core.h index 35ea984d74f0..3084baaee127 100644 --- a/drivers/bootconstraint/core.h +++ b/drivers/bootconstraint/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/bootconstraint/pm.c b/drivers/bootconstraint/pm.c index f52bff240dd5..65810d9485bc 100644 --- a/drivers/bootconstraint/pm.c +++ b/drivers/bootconstraint/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/bootconstraint/supply.c b/drivers/bootconstraint/supply.c index 352ded92d057..8965db534be6 100644 --- a/drivers/bootconstraint/supply.c +++ b/drivers/bootconstraint/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);