From patchwork Tue Aug 1 09:23:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 109122 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp1267194qge; Tue, 1 Aug 2017 02:29:11 -0700 (PDT) X-Received: by 10.84.241.71 with SMTP id u7mr20432369plm.196.1501579751291; Tue, 01 Aug 2017 02:29:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501579751; cv=none; d=google.com; s=arc-20160816; b=tLMiX3X19UWPju4MIkRf3nWhI4llH/Kq7QEWvvaScHX5NftIxRkHk0Xpmbls355jgH mNx1TZvBJA5BFfA8goP+mQchmdN5b8qyIipnkQmFX+mNMSZ60NYvFGE+00tR7wCjU1B4 OAMcm0ApUWs7GZOUlaI7COzm/DJLX+GZT6f3tWezRisqcRp/rBj9c5/FgkZwrQ37uXWA a8m128b+bSugGvNMHa9wiia7oFvVr2kS/taiPzJj38zET1FTG1HxhxBzD4tiodfVGU/x vKPyTXhhn/gpIPHEonaNaF2+q5Xlj6uphFNPMLFpvfhTvMH5vEKo1LOIax4GPV0/0IKv kfqg== 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=6md5ryAp8WswVU2AZXWaVyYJxaC31qCON4ECwcj98no=; b=AWIxW0n0Jy6uZ40DznvCDdt/k5fYbM0ubphOXhHUuwkHqab7tW7iYVPmYIqqXp4j8P sZzw9h7W21Nvik2nDuClaXhjDkW09UItdJHK3GuhO5va+UJEJKyt0Nct2jUY1gNOYiLR H8ImsWhn/Wdax0StRLnCzwzsHZ5Fm5ybpmUt4jbEvzlq9SCCJibw1FLIa+IvTCwVBCS+ uHnEnJ89eIM7N8nqC5YhcOg7hgPruMLBJKYF5lU6Jq7sGySaAHvrbV7QTjD+GqV0RPh+ aHuAUCJLGD2yRr5amsOLw9Mzyexd6NWQz6oRtmELPXsClPMibSptWGyiKNkPXSFW/J45 naFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=UoFE4NjJ; 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 s132si17915082pgs.645.2017.08.01.02.29.10; Tue, 01 Aug 2017 02:29:11 -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.b=UoFE4NjJ; 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 S1751883AbdHAJ3J (ORCPT + 26 others); Tue, 1 Aug 2017 05:29:09 -0400 Received: from mail-pg0-f43.google.com ([74.125.83.43]:34375 "EHLO mail-pg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751834AbdHAJ3H (ORCPT ); Tue, 1 Aug 2017 05:29:07 -0400 Received: by mail-pg0-f43.google.com with SMTP id u185so5716471pgb.1 for ; Tue, 01 Aug 2017 02:29:07 -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=6md5ryAp8WswVU2AZXWaVyYJxaC31qCON4ECwcj98no=; b=UoFE4NjJd+YYv1AztZBRzVRMQQR+g2Hv0llc0sqLmfYh1cmqhU/h+dz5u5C3g0G1Ju RFtMr6qXzsTfhZ9egOWpODVoEzD+uH0DII5lcXbQKKgQERXpY4BOjjWGIa83CuhSRgV5 Qtd0XT2HHgBWkoIRkeQ7aG88/0olBLiaO4T6I= 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=6md5ryAp8WswVU2AZXWaVyYJxaC31qCON4ECwcj98no=; b=qkmEg3NwLTGvpSx2gxJf47NEHienp9Bql4Zu5tgCfZ5d/PYdHovUIcuT9+4l2WrO+4 2wVZQEE/VyrEmSPJVk3hqGMNoin1VNCd1llfRsRdQ1b6z1kR34DqzpAoNXvAiDHdlGcq LjwxGXXWCAoFzt1RHjHbQ11CQ6TDj9NGsVWdybus0uZoNKYzI6moa1buQfNEpe3PWvL7 rbQcntZHG9cUVupamGfeySWJblkAQ/ZdRk3pu2PU2HGnBBMCucNqzoNxPwPprwJu65Iz tTerbnj2PADnfxXM0dx5PPvGOSKtMvYComn65wn6Jl3GXrAlcsVcGNpDJ5ncEjfgJQd1 lZYg== X-Gm-Message-State: AIVw110zv4PZXSYwR6X/gsNLePttOCLiZKm5f7VpAbQQxztcIRNXzqRf 7YOWoc6BtrPK2YdH X-Received: by 10.84.179.165 with SMTP id b34mr20655560plc.455.1501579746772; Tue, 01 Aug 2017 02:29:06 -0700 (PDT) Received: from localhost ([122.172.27.66]) by smtp.gmail.com with ESMTPSA id z12sm55395702pgs.88.2017.08.01.02.29.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Aug 2017 02:29:06 -0700 (PDT) From: Viresh Kumar To: Greg Kroah-Hartman Cc: Viresh Kumar , Vincent Guittot , Mark Brown , Stephen Boyd , Rajendra Nayak , Shiraz Hashim , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robdclark@gmail.com Subject: [PATCH V3 6/8] drivers: boot_constraint: Add debugfs support Date: Tue, 1 Aug 2017 14:53:47 +0530 Message-Id: <7a42cfb49a580a07c2045207fe7f1a3cb2096ce3.1501578037.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.13.0.71.gd7076ec9c9cb 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/base/boot_constraints/clk.c | 4 ++ drivers/base/boot_constraints/core.c | 72 ++++++++++++++++++++++++++++++++++ drivers/base/boot_constraints/core.h | 6 +++ drivers/base/boot_constraints/pm.c | 12 +++++- drivers/base/boot_constraints/supply.c | 10 +++++ 5 files changed, 102 insertions(+), 2 deletions(-) -- 2.13.0.71.gd7076ec9c9cb diff --git a/drivers/base/boot_constraints/clk.c b/drivers/base/boot_constraints/clk.c index b5b1d63c3e76..bdbfcbc2944d 100644 --- a/drivers/base/boot_constraints/clk.c +++ b/drivers/base/boot_constraints/clk.c @@ -49,6 +49,9 @@ int constraint_clk_add(struct constraint *constraint, void *data) cclk->clk_info.name = kstrdup_const(clk_info->name, GFP_KERNEL); constraint->private = cclk; + /* Debugfs */ + constraint_add_debugfs(constraint, clk_info->name); + return 0; put_clk: @@ -63,6 +66,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/base/boot_constraints/core.c b/drivers/base/boot_constraints/core.c index 06267f0c88d4..c0e3a85ff85a 100644 --- a/drivers/base/boot_constraints/core.c +++ b/drivers/base/boot_constraints/core.c @@ -35,6 +35,76 @@ static int __init constraints_disable(char *str) } early_param("boot_constraints_disable", constraints_disable); +/* 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); + if (!cdev->dentry) + dev_err(dev, "Failed to create constraint dev debugfs dir\n"); +} + +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); + if (!constraint->dentry) + dev_err(dev, "Failed to create constraint (%s) debugfs dir\n", + name); +} + +void constraint_remove_debugfs(struct constraint *constraint) +{ + debugfs_remove_recursive(constraint->dentry); +} + +static int __init constraint_debugfs_init(void) +{ + if (boot_constraints_disabled) + return -ENODEV; + + /* Create /sys/kernel/debug/opp directory */ + rootdir = debugfs_create_dir("boot_constraints", NULL); + if (!rootdir) { + pr_err("Failed to create root directory\n"); + return -ENOMEM; + } + + return 0; +} +core_initcall(constraint_debugfs_init); + + /* Boot constraints core */ static struct constraint_dev *constraint_device_find(struct device *dev) @@ -62,12 +132,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/base/boot_constraints/core.h b/drivers/base/boot_constraints/core.h index a051c3d7c8ab..ee84e237c66a 100644 --- a/drivers/base/boot_constraints/core.h +++ b/drivers/base/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/base/boot_constraints/pm.c b/drivers/base/boot_constraints/pm.c index edba5eca5093..95910d0dc457 100644 --- a/drivers/base/boot_constraints/pm.c +++ b/drivers/base/boot_constraints/pm.c @@ -14,11 +14,19 @@ 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; + + /* Debugfs */ + 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/base/boot_constraints/supply.c b/drivers/base/boot_constraints/supply.c index 30f816dbf12c..b206f500b2bc 100644 --- a/drivers/base/boot_constraints/supply.c +++ b/drivers/base/boot_constraints/supply.c @@ -60,6 +60,15 @@ int constraint_supply_add(struct constraint *constraint, void *data) csupply->supply.name = kstrdup_const(supply->name, GFP_KERNEL); constraint->private = csupply; + /* Debugfs */ + 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 +89,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);