Received: by 10.213.65.68 with SMTP id h4csp1558285imn; Thu, 15 Mar 2018 03:14:07 -0700 (PDT) X-Google-Smtp-Source: AG47ELvA/Br3xfQ47rcxqt+ewLQ7CbFrIIm7NHS1zOlR7CiiqcmaPBhehNQ2tKq0naxam2ERqaBP X-Received: by 2002:a17:902:43a4:: with SMTP id j33-v6mr7376033pld.247.1521108847643; Thu, 15 Mar 2018 03:14:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521108847; cv=none; d=google.com; s=arc-20160816; b=pzx54bw3yelDQVUxl1t4nh6cUaHgmlNky2pO0PusAJLJgRJx71hHvK2I/8pCAY5mZU 2OyCAZ01O3KhEP/LFWbGcojMQI/Hn+7XOKdz1U3N2jdH/fTca6CGnIyiwtWBpd8NZDGh GUzSfVFKsiUPFsQj4FrNpCUpM4ffqeAF6PGgNVyt+7oH6LAkOr4Vwqrf2zUruLude1tM uz6MYIzoOSBQTktMQDLjqYWA4N8Y5USC/IrBl353SqO/fw8K+9brtbA8215X1kX9jr8H 1F6Kw/0xvsJG7Z5sZKR6QSMbx6E0yh0+Sw+eTNHziH/yoirS/enoq2Z9HiFiUDfaYfWz slMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=1cPyVt27x5Mvl6clEhewhPbNsndzpLgoj8bwZvdEjd0=; b=izECYFA8KDBlgeERlcNZMpAIZBOAsj0QR/ME8qrFf5ka6iTJedXEsTARkzDG2OII4A l7WZ9uMhZCaoMlsYfXbyWpfsITc0rptioXYthsSZZkaTD39NoWs7TuO549ryVQR7bUk4 eaXpvywZ9W0ZOILZRk9FKlDQAm8KzmLOusmvyCno3Fn/uMwKMc49PHm94GvZ917W7Ap4 utxBHVHlJhXhOlPsX7/763A8Me/zwwmi6OTos0d9ZpDtE02wDZ9XvUOmS57j0wjP+sQC YeMpNpFx3VtP+q8KOHv9i7CMn0jqyfUF9jFy47p2+OfyQ0XyVGAJ6HImQXmGW1nyiM4P AMdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kt6+paBq; 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 q6-v6si99533plk.234.2018.03.15.03.13.53; Thu, 15 Mar 2018 03:14:07 -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.s=google header.b=kt6+paBq; 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 S1751618AbeCOKM6 (ORCPT + 99 others); Thu, 15 Mar 2018 06:12:58 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:40659 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750745AbeCOKMz (ORCPT ); Thu, 15 Mar 2018 06:12:55 -0400 Received: by mail-it0-f65.google.com with SMTP id e64-v6so8454301ita.5 for ; Thu, 15 Mar 2018 03:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=1cPyVt27x5Mvl6clEhewhPbNsndzpLgoj8bwZvdEjd0=; b=kt6+paBqMpuLFQj07iYPHzTU7xbSM38bMjVHFxC5bpmlKWWoeXanuzBFV7vhtdVBZJ NURl3AQiH3UhUGLpIuWaB2OpmJsuXWG131bxS6zgHudHqdVXZ575ycs9KwIIzX/eutvV O0cC463pEowzWH+xZCv6X6hVuoLGoBNq+Q/pk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=1cPyVt27x5Mvl6clEhewhPbNsndzpLgoj8bwZvdEjd0=; b=SYuwtuPadCePG27GWf9+rg560RmbgVJT5jlfCdF5ldP+p0zeEYnNaDaT3W8epedVN9 b7jqe4J4+6MH2Pxy4PlIQn5TFrL9PFC/P9i25DJGFqHKLNYFj1dA1wDnDAIj0Iq+ZvgJ tRAr483PVepM3HtKKpce3yI5lNAjTn0aj0QzwJ1yDUcLFLgKDqoa2+cBbrNFHR35xBEj aOxZ4P0O8xVeA2YmUqtFbuMU6PZFUFcLrs5NviSVCur/o6hpIfvEt+ai1c8347ltuNmC nvuTqxHkPxVKZ0LSONKtzYFjqEP4u3hdaNwnWdFy9fgS1rOlNoX1DqXGIdEYcDs5TJCw X/ZA== X-Gm-Message-State: AElRT7GAI4uTDuQXjTZaYBZjeDL4lexEwUNcZ+pa+EQ7lHO5o8GCmUKG 8ZIwZsEAmwzgrQJbEULrCoc1OR0G/7VUqbEFh8fC7Q== X-Received: by 10.36.31.18 with SMTP id d18mr5307669itd.55.1521108774394; Thu, 15 Mar 2018 03:12:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.2.101.23 with HTTP; Thu, 15 Mar 2018 03:12:54 -0700 (PDT) In-Reply-To: <1520917812-20047-1-git-send-email-harish_kandiga@mentor.com> References: <1520917812-20047-1-git-send-email-harish_kandiga@mentor.com> From: Ulf Hansson Date: Thu, 15 Mar 2018 11:12:54 +0100 Message-ID: Subject: Re: [PATCH v10] mmc: Export host capabilities to debugfs. To: Harish Jenny K N Cc: Linus Walleij , Adrian Hunter , Shawn Lin , avri.altman@wdc.com, Andy Shevchenko , "linux-mmc@vger.kernel.org" , Linux Kernel Mailing List , Vladimir Zapolskiy Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13 March 2018 at 06:10, Harish Jenny K N wrote: > This patch exports the host capabilities to debugfs > > This idea of sharing host capabilities over debugfs > came up from Abbas Raza > Earlier discussions: > https://lkml.org/lkml/2018/3/5/357 > https://www.spinics.net/lists/linux-mmc/msg48219.html > > Reviewed-by: Andy Shevchenko > Signed-off-by: Harish Jenny K N > --- > > Changes in v10: > - minor review comment addressed. > - Added "Reviewed-by" line > > Changes in v9 > - More code cleanup as suggested by Andy Shevchenko. > > Changes in v8 > - Changes to use for_each_set_bit as suggested by Andy Shevchenko. > > Changes in v7 > - Moved additional capabilities also to caps file as mentioned by Ulf Hansson > - compacting the code with macros > > Changes in v6: > - Used DEFINE_SHOW_ATTRIBUTE > > Changes in v5: > - Added parser logic in kernel by using debugfs_create_file for caps and caps2 instead of debugfs_create_x32 > - Changed Author > > Changes in v4: > - Moved the creation of nodes to mmc_add_host_debugfs > - Exported caps2 > - Renamed host_caps to caps > > Changes in v3: > - Removed typecasting of &host->caps to (u32 *) > > Changes in v2: > - Changed Author > > drivers/mmc/core/debugfs.c | 107 +++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 107 insertions(+) > > diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c > index c51e0c0..826d361 100644 > --- a/drivers/mmc/core/debugfs.c > +++ b/drivers/mmc/core/debugfs.c > @@ -225,6 +225,110 @@ static int mmc_clock_opt_set(void *data, u64 val) > DEFINE_SIMPLE_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set, > "%llu\n"); > > +/* > + * mmc_host_capabilities - MMC host capabilities > + * > + * This must be in sync with caps definitions in the mmc/host.h > + */ > +static const char * const mmc_host_capabilities[] = { > + "4-bit transfers allowed", > + "Supports MMC high-speed timing", > + "Supports SD high-speed timing", > + "Can signal pending SDIO IRQs", > + "Talks only SPI protocols", > + "Needs polling for card-detection", > + "8 bit transfers allowed", > + "Suspends (e)MMC/SD at idle", > + "Nonremovable", > + "Waits while card is busy", > + "Allows erase/trim commands", > + "Supports DDR mode at 3.3V", > + "Supports DDR mode at 1.8V", > + "Supports DDR mode at 1.2V", > + "Can power off after boot", > + "CMD14/CMD19 bus width ok", > + "Supports UHS SDR12 mode", > + "Supports UHS SDR25 mode", > + "Supports UHS SDR50 mode", > + "Supports UHS SDR104 mode", > + "Supports UHS DDR50 mode", > + "Unknown (bit 21)", > + "Unknown (bit 22)", > + "Supports Driver Type A", > + "Supports Driver Type C", > + "Supports Driver Type D", > + "Unknown (bit 26)", > + "RW reqs can be completed within mmc_request_done()", > + "Supports Enable card detect wake", > + "Can send commands during data transfer", > + "CMD23 supported", > + "Supports Hardware reset" > +}; > + > +/* > + * mmc_host_capabilities2 - MMC host additional capabilities > + * > + * This must be in sync with caps2 definitions in the mmc/host.h > + */ > +static const char * const mmc_host_capabilities2[] = { > + "No access to Boot partition", > + "Unknown (bit 1)", > + "Can do full power cycle", > + "Unknown (bit 3)", > + "Unknown (bit 4)", > + "Supports HS200 1.8V SDR", > + "Supports HS200 1.2V SDR", > + "Unknown (bit 7)", > + "Unknown (bit 8)", > + "Unknown (bit 9)", > + "Card-detect signal active high", > + "Write-protect signal active high", > + "Unknown (bit 12)", > + "Unknown (bit 13)", > + "Can do complete power cycle of the card", > + "Supports HS400 1.8V", > + "Support HS400 1.2V", > + "SDIO IRQ - Nothread", > + "No physical write protect pin, assume always read-write", > + "Do not send SDIO commands during initialization", > + "Supports enhanced strobe", > + "Do not send SD commands during initialization", > + "Do not send (e)MMC commands during initialization", > + "Has eMMC command queue engine", > + "CQE can issue a direct command", > + "Unknown (bit 25)", > + "Unknown (bit 26)", > + "Unknown (bit 27)", > + "Unknown (bit 28)", > + "Unknown (bit 29)", > + "Unknown (bit 30)", > + "Unknown (bit 31)" > +}; Honestly, I don't like this, but maybe other people do, then I am fine with this approach. If were to decide, I would just rather print the caps field in a hexadecimal bit form and leave the translation to the user. > + > +static int mmc_caps_show(struct seq_file *s, void *unused) > +{ > + struct mmc_host *host = s->private; > + unsigned long caps = host->caps; > + unsigned long caps2 = host->caps2; > + int bit; > + > + seq_puts(s, "MMC Host capabilities are:\n"); > + seq_puts(s, "=============================================\n"); > + > + for_each_set_bit(bit, &caps, ARRAY_SIZE(mmc_host_capabilities)) > + seq_printf(s, "%s\n", mmc_host_capabilities[bit]); > + > + seq_puts(s, "=============================================\n"); > + seq_puts(s, "MMC Host additional capabilities are:\n"); > + seq_puts(s, "=============================================\n"); > + > + for_each_set_bit(bit, &caps2, ARRAY_SIZE(mmc_host_capabilities2)) > + seq_printf(s, "%s\n", mmc_host_capabilities2[bit]); > + > + return 0; > +} > +DEFINE_SHOW_ATTRIBUTE(mmc_caps); > + > void mmc_add_host_debugfs(struct mmc_host *host) > { > struct dentry *root; > @@ -243,6 +347,9 @@ void mmc_add_host_debugfs(struct mmc_host *host) > if (!debugfs_create_file("ios", S_IRUSR, root, host, &mmc_ios_fops)) > goto err_node; > > + if (!debugfs_create_file("caps", 0400, root, host, &mmc_caps_fops)) > + goto err_node; > + > if (!debugfs_create_file("clock", S_IRUSR | S_IWUSR, root, host, > &mmc_clock_fops)) > goto err_node; > -- > 1.9.1 > Kind regards Uffe