From patchwork Wed Jun 28 10:26:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 106511 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp838748qge; Wed, 28 Jun 2017 03:27:59 -0700 (PDT) X-Received: by 10.99.49.20 with SMTP id x20mr9677498pgx.181.1498645679147; Wed, 28 Jun 2017 03:27:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498645679; cv=none; d=google.com; s=arc-20160816; b=Z2cLhyBpkM6B6k2cQrjBo6hrY3O9xw596hlvVRQnb3Erz3cuZCAaMsFTueX13fhKMU p1ywyLZGYowej3DMavqqkbnxeLzqWYDNKJxaqSB1vwBuBVsjvdKfAKio5yHxuZDpUiS3 Y5q8Op8FuusxImhK/G+vLxppClRG/VSTDQmRBO2z2kpDXLFBzeEESpDYQFnPHj7nfA/w yZN2EtEM7mj320/3MTtXXDQjuojmmDdruSBivwFy+jXJJFh+IFjAOL+ZnjN+RXFL4aN7 nuzyCc9uemApvYSdBXQ9DAqVJLEYY7qtvhbDSJhP2XTUeYWWk9osnFwj62kD7e4KZL2u y11A== 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=yjcbfsMFbC4geogg52o+6IZ35JP03uzSX+gBJl1Lzv8=; b=UrQ4AYwJG7Klg2IOBaQSbBO6Zk59r0uslg73g40IYAUuedsvih4xftr1wmM/dmhMO2 bLaRjSsU3u5cpIZ9jZJHAHMsCCZk0LR+ExD09rZZrgRDfxzr5SKYIND0CTaRXyZsgmeT NXU63PeFUVe0R+qBIoLQRJpt+jk4kzlLUInx2SYLL/lXh+Gq3qJrVsvb1Nsf/V1sh6x7 04Pwgc8ex7IpjkGsVYOrcjYiA6zDJOka/G2yIjdOc9eq5nUtswjd8UvQ/hTUu6wFM0IZ lowEvPtOH2JeGcKZaEbs8B/k3C+Ll1wR+J+R3JxXvacaPBQ7RlErnB9SlJgYnYYoS18p k+sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=QcpuXOtx; 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 d2si1185325pge.232.2017.06.28.03.27.58; Wed, 28 Jun 2017 03:27:59 -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=QcpuXOtx; 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 S1751989AbdF1K1t (ORCPT + 25 others); Wed, 28 Jun 2017 06:27:49 -0400 Received: from mail-pg0-f43.google.com ([74.125.83.43]:33081 "EHLO mail-pg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751817AbdF1K1W (ORCPT ); Wed, 28 Jun 2017 06:27:22 -0400 Received: by mail-pg0-f43.google.com with SMTP id f127so29836053pgc.0 for ; Wed, 28 Jun 2017 03:27:22 -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=yjcbfsMFbC4geogg52o+6IZ35JP03uzSX+gBJl1Lzv8=; b=QcpuXOtxQur9DhbFnJQ+Y6o5AReNFl/jXAXq+bFH4d5FH3jOvZJsibJ4C25E6s0+Ce nbFle6gr6Oi5anofZCgxEtxPwNyNvA1fzjEMXT5cWl4Ir+7eOv89iskoPNQC6UpBtqQN cPHa4meCXq+P8ZzDF1bxfy7t6Gt3XEuBk3vrU= 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=yjcbfsMFbC4geogg52o+6IZ35JP03uzSX+gBJl1Lzv8=; b=CowBs590ikVCjUgMXjx21VHA+qjUh8l3jFblWhub99zKYiZaKmImPpIutSNT/SOKIL MsyQPEpl/q+dO9RpmZxLm6erLKSr+Uoe7W4Tu6GnMjwA11jWb4cCIsqXt2t6L/3Oj29f 7k/cZ7w1+zV6huI0I7l4n3I1FqzHwD8Jg8vKwvSPcNxECQmTnfgjCR/Rk3XY/0HPf+UL rX0dHe24zXlK72ZZeBoO/oC8eZIXFgpvK3VO/LR3186W/f8UhW7764yyP9xhc1jEdL3S nagZuxXu6XUv/3aNzQXh0/iSf0O+vSyCxbseMJKcOTImpoOvhZ/qsNx4AAyEOgBWtV32 AjIA== X-Gm-Message-State: AKS2vOwYQfgSf3aP6WrVh9nc5Nq7CWnlkQYqFTWDNe5YcX0tDJidcWXT KwI32S2jX0PkiMWH X-Received: by 10.99.131.193 with SMTP id h184mr9960929pge.80.1498645641015; Wed, 28 Jun 2017 03:27:21 -0700 (PDT) Received: from localhost ([122.171.238.149]) by smtp.gmail.com with ESMTPSA id d1sm4081951pfj.51.2017.06.28.03.27.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jun 2017 03:27:20 -0700 (PDT) From: Viresh Kumar To: Greg Kroah-Hartman Cc: Viresh Kumar , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Rafael Wysocki , Vincent Guittot , Stephen Boyd , Mark Brown , Shiraz Hashim , Rob Herring , rnayak@codeaurora.org Subject: [RFC 4/5] drivers: boot_constraint: Add debugfs support Date: Wed, 28 Jun 2017 15:56:37 +0530 Message-Id: <58dbcc2e397fc679af814a9752efa1829885d7f3.1498642745.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: supply-vmmc /sys/kernel/debug/boot_constraints/f723d000.dwmmc0/supply-vmmc: enable u_volt_max u_volt_min Signed-off-by: Viresh Kumar --- drivers/base/boot_constraint.c | 83 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) -- 2.13.0.71.gd7076ec9c9cb diff --git a/drivers/base/boot_constraint.c b/drivers/base/boot_constraint.c index ab766d60191a..ff1c63b34458 100644 --- a/drivers/base/boot_constraint.c +++ b/drivers/base/boot_constraint.c @@ -10,6 +10,7 @@ #define pr_fmt(fmt) "Boot Constraints: " fmt #include +#include #include #include #include @@ -22,6 +23,7 @@ struct constraint { struct constraint_dev *cdev; struct list_head node; enum boot_constraint_type type; + struct dentry *dentry; int (*add)(struct constraint *constraint, void *data); void (*remove)(struct constraint *constraint); @@ -32,6 +34,7 @@ struct constraint_dev { struct device *dev; struct list_head node; struct list_head constraints; + struct dentry *dentry; }; #define for_each_constraint(_constraint, _temp, _cdev) \ @@ -57,6 +60,71 @@ 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); +} + +static 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 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); +} + +static void constraint_remove_debugfs(struct constraint *constraint) +{ + debugfs_remove_recursive(constraint->dentry); +} + +static int __init constraint_debugfs_init(void) +{ + if (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) @@ -84,12 +152,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); } @@ -285,6 +355,18 @@ static 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_ulong("u_volt_min", 0444, constraint->dentry, + &csupply->supply.u_volt_min); + + debugfs_create_ulong("u_volt_max", 0444, constraint->dentry, + &csupply->supply.u_volt_max); + + debugfs_create_bool("enable", 0444, constraint->dentry, + &csupply->supply.enable); + return 0; remove_voltage: @@ -314,6 +396,7 @@ static void constraint_supply_remove(struct constraint *constraint) dev_err(dev, "regulator_set_voltage failed (%d)\n", ret); regulator_put(csupply->reg); + constraint_remove_debugfs(constraint); kfree_const(csupply->supply.name); kfree(csupply); }