All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v9] mmc: Export host capabilities to debugfs.
@ 2018-03-12  4:31 ` Harish Jenny K N
  0 siblings, 0 replies; 15+ messages in thread
From: Harish Jenny K N @ 2018-03-12  4:31 UTC (permalink / raw)
  To: ulf.hansson, linus.walleij, adrian.hunter, shawn.lin,
	avri.altman, andriy.shevchenko
  Cc: linux-mmc, linux-kernel, harish_kandiga, Vladimir_Zapolskiy

This patch exports the host capabilities to debugfs

This idea of sharing host capabilities over debugfs
came up from Abbas Raza <Abbas_Raza@mentor.com>
Earlier discussions:
https://lkml.org/lkml/2018/3/5/357
https://www.spinics.net/lists/linux-mmc/msg48219.html

Signed-off-by: Harish Jenny K N <harish_kandiga@mentor.com>
---

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..e19305a 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)"
+};
+
+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, (const unsigned long *)&caps, BITS_PER_LONG)
+		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, (const unsigned long *)&caps2, BITS_PER_LONG)
+		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", S_IRUSR, 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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v9] mmc: Export host capabilities to debugfs.
@ 2018-03-12  4:31 ` Harish Jenny K N
  0 siblings, 0 replies; 15+ messages in thread
From: Harish Jenny K N @ 2018-03-12  4:31 UTC (permalink / raw)
  To: ulf.hansson, linus.walleij, adrian.hunter, shawn.lin,
	avri.altman, andriy.shevchenko
  Cc: linux-mmc, linux-kernel, harish_kandiga, Vladimir_Zapolskiy

This patch exports the host capabilities to debugfs

This idea of sharing host capabilities over debugfs
came up from Abbas Raza <Abbas_Raza@mentor.com>
Earlier discussions:
https://lkml.org/lkml/2018/3/5/357
https://www.spinics.net/lists/linux-mmc/msg48219.html

Signed-off-by: Harish Jenny K N <harish_kandiga@mentor.com>
---

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..e19305a 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)"
+};
+
+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, (const unsigned long *)&caps, BITS_PER_LONG)
+		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, (const unsigned long *)&caps2, BITS_PER_LONG)
+		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", S_IRUSR, 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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH v9] mmc: Export host capabilities to debugfs.
  2018-03-12  4:31 ` Harish Jenny K N
  (?)
@ 2018-03-12 10:07 ` Andy Shevchenko
  2018-03-12 10:27     ` Harish Jenny K N
  2018-03-12 10:45   ` Avri Altman
  -1 siblings, 2 replies; 15+ messages in thread
From: Andy Shevchenko @ 2018-03-12 10:07 UTC (permalink / raw)
  To: Harish Jenny K N, ulf.hansson, linus.walleij, adrian.hunter,
	shawn.lin, avri.altman
  Cc: linux-mmc, linux-kernel, Vladimir_Zapolskiy

On Mon, 2018-03-12 at 10:01 +0530, 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 <Abbas_Raza@mentor.com>
> Earlier discussions:
> https://lkml.org/lkml/2018/3/5/357
> https://www.spinics.net/lists/linux-mmc/msg48219.html
> 

Address below minors and, FWIW, take mine

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> +	for_each_set_bit(bit, (const unsigned long *)&caps,
> BITS_PER_LONG)

> +	for_each_set_bit(bit, (const unsigned long *)&caps2,
> BITS_PER_LONG)

Explicit casting is not needed anymore in both cases.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v9] mmc: Export host capabilities to debugfs.
  2018-03-12 10:07 ` Andy Shevchenko
@ 2018-03-12 10:27     ` Harish Jenny K N
  2018-03-12 10:45   ` Avri Altman
  1 sibling, 0 replies; 15+ messages in thread
From: Harish Jenny K N @ 2018-03-12 10:27 UTC (permalink / raw)
  To: Andy Shevchenko, ulf.hansson, linus.walleij, adrian.hunter,
	shawn.lin, avri.altman
  Cc: linux-mmc, linux-kernel, Vladimir_Zapolskiy



On Monday 12 March 2018 03:37 PM, Andy Shevchenko wrote:
> On Mon, 2018-03-12 at 10:01 +0530, 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 <Abbas_Raza@mentor.com>
>> Earlier discussions:
>> https://lkml.org/lkml/2018/3/5/357
>> https://www.spinics.net/lists/linux-mmc/msg48219.html
>>
> Address below minors and, FWIW, take mine
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Thanks.

>
>> +	for_each_set_bit(bit, (const unsigned long *)&caps,
>> BITS_PER_LONG)
>> +	for_each_set_bit(bit, (const unsigned long *)&caps2,
>> BITS_PER_LONG)
> Explicit casting is not needed anymore in both cases.
>

I will address these.
Before sending new patch , I would like to inform that I have been sending this patch with the following checkpatch warning, just to keep it same as other usages of debugfs_create_file in the drivers/mmc/core/debugfs.c file.

WARNING:SYMBOLIC_PERMS: Symbolic permissions 'S_IRUSR' are not preferred. Consider using octal permissions '0400'.

Do I need to address this or keep it same as S_IRUSR ?

Thanks,
Harish Jenny K N

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v9] mmc: Export host capabilities to debugfs.
@ 2018-03-12 10:27     ` Harish Jenny K N
  0 siblings, 0 replies; 15+ messages in thread
From: Harish Jenny K N @ 2018-03-12 10:27 UTC (permalink / raw)
  To: Andy Shevchenko, ulf.hansson, linus.walleij, adrian.hunter,
	shawn.lin, avri.altman
  Cc: linux-mmc, linux-kernel, Vladimir_Zapolskiy



On Monday 12 March 2018 03:37 PM, Andy Shevchenko wrote:
> On Mon, 2018-03-12 at 10:01 +0530, 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 <Abbas_Raza@mentor.com>
>> Earlier discussions:
>> https://lkml.org/lkml/2018/3/5/357
>> https://www.spinics.net/lists/linux-mmc/msg48219.html
>>
> Address below minors and, FWIW, take mine
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Thanks.

>
>> +	for_each_set_bit(bit, (const unsigned long *)&caps,
>> BITS_PER_LONG)
>> +	for_each_set_bit(bit, (const unsigned long *)&caps2,
>> BITS_PER_LONG)
> Explicit casting is not needed anymore in both cases.
>

I will address these.
Before sending new patch , I would like to inform that I have been sending this patch with the following checkpatch warning, just to keep it same as other usages of debugfs_create_file in the drivers/mmc/core/debugfs.c file.

WARNING:SYMBOLIC_PERMS: Symbolic permissions 'S_IRUSR' are not preferred. Consider using octal permissions '0400'.

Do I need to address this or keep it same as S_IRUSR ?

Thanks,
Harish Jenny K N

^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: [PATCH v9] mmc: Export host capabilities to debugfs.
  2018-03-12 10:07 ` Andy Shevchenko
  2018-03-12 10:27     ` Harish Jenny K N
@ 2018-03-12 10:45   ` Avri Altman
  2018-03-12 11:16     ` Harish Jenny K N
  1 sibling, 1 reply; 15+ messages in thread
From: Avri Altman @ 2018-03-12 10:45 UTC (permalink / raw)
  To: Andy Shevchenko, Harish Jenny K N, ulf.hansson, linus.walleij,
	adrian.hunter, shawn.lin
  Cc: linux-mmc, linux-kernel, Vladimir_Zapolskiy



> -----Original Message-----
> From: Andy Shevchenko [mailto:andriy.shevchenko@linux.intel.com]
> Sent: Monday, March 12, 2018 12:08 PM
> To: Harish Jenny K N <harish_kandiga@mentor.com>; ulf.hansson@linaro.org;
> linus.walleij@linaro.org; adrian.hunter@intel.com; shawn.lin@rock-
> chips.com; Avri Altman <Avri.Altman@wdc.com>
> Cc: linux-mmc@vger.kernel.org; linux-kernel@vger.kernel.org;
> Vladimir_Zapolskiy@mentor.com
> Subject: Re: [PATCH v9] mmc: Export host capabilities to debugfs.
> 
> On Mon, 2018-03-12 at 10:01 +0530, 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 <Abbas_Raza@mentor.com> Earlier discussions:
> > https://lkml.org/lkml/2018/3/5/357
> > https://www.spinics.net/lists/linux-mmc/msg48219.html
> >
> 
> Address below minors and, FWIW, take mine
> 
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> > +	for_each_set_bit(bit, (const unsigned long *)&caps,
> > BITS_PER_LONG)
> 
> > +	for_each_set_bit(bit, (const unsigned long *)&caps2,
> > BITS_PER_LONG)
> 
> Explicit casting is not needed anymore in both cases.
Also maybe use sizeof(mmc_host_capabilities) instead of BITS_PER_LONG?


> 
> --
> Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Intel Finland Oy

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v9] mmc: Export host capabilities to debugfs.
  2018-03-12 10:45   ` Avri Altman
@ 2018-03-12 11:16     ` Harish Jenny K N
  2018-03-12 11:32       ` Avri Altman
  0 siblings, 1 reply; 15+ messages in thread
From: Harish Jenny K N @ 2018-03-12 11:16 UTC (permalink / raw)
  To: Avri Altman, Andy Shevchenko, ulf.hansson, linus.walleij,
	adrian.hunter, shawn.lin
  Cc: linux-mmc, linux-kernel, Vladimir_Zapolskiy



On Monday 12 March 2018 04:15 PM, Avri Altman wrote:
>
>> -----Original Message-----
>> From: Andy Shevchenko [mailto:andriy.shevchenko@linux.intel.com]
>> Sent: Monday, March 12, 2018 12:08 PM
>> To: Harish Jenny K N <harish_kandiga@mentor.com>; ulf.hansson@linaro.org;
>> linus.walleij@linaro.org; adrian.hunter@intel.com; shawn.lin@rock-
>> chips.com; Avri Altman <Avri.Altman@wdc.com>
>> Cc: linux-mmc@vger.kernel.org; linux-kernel@vger.kernel.org;
>> Vladimir_Zapolskiy@mentor.com
>> Subject: Re: [PATCH v9] mmc: Export host capabilities to debugfs.
>>
>> On Mon, 2018-03-12 at 10:01 +0530, 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 <Abbas_Raza@mentor.com> Earlier discussions:
>>> https://lkml.org/lkml/2018/3/5/357
>>> https://www.spinics.net/lists/linux-mmc/msg48219.html
>>>
>> Address below minors and, FWIW, take mine
>>
>> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>>
>>> +	for_each_set_bit(bit, (const unsigned long *)&caps,
>>> BITS_PER_LONG)
>>> +	for_each_set_bit(bit, (const unsigned long *)&caps2,
>>> BITS_PER_LONG)
>> Explicit casting is not needed anymore in both cases.
> Also maybe use sizeof(mmc_host_capabilities) instead of BITS_PER_LONG?

You mean sizeof(caps) and not sizeof(mmc_host_capabilities) . Right ?


Thanks,
Harish Jenny K N

^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: [PATCH v9] mmc: Export host capabilities to debugfs.
  2018-03-12 11:16     ` Harish Jenny K N
@ 2018-03-12 11:32       ` Avri Altman
  2018-03-12 12:30         ` Harish Jenny K N
  0 siblings, 1 reply; 15+ messages in thread
From: Avri Altman @ 2018-03-12 11:32 UTC (permalink / raw)
  To: Harish Jenny K N, Andy Shevchenko, ulf.hansson, linus.walleij,
	adrian.hunter, shawn.lin
  Cc: linux-mmc, linux-kernel, Vladimir_Zapolskiy



> -----Original Message-----
> From: Harish Jenny K N [mailto:harish_kandiga@mentor.com]
> Sent: Monday, March 12, 2018 1:17 PM
> To: Avri Altman <Avri.Altman@wdc.com>; Andy Shevchenko
> <andriy.shevchenko@linux.intel.com>; ulf.hansson@linaro.org;
> linus.walleij@linaro.org; adrian.hunter@intel.com; shawn.lin@rock-chips.com
> Cc: linux-mmc@vger.kernel.org; linux-kernel@vger.kernel.org;
> Vladimir_Zapolskiy@mentor.com
> Subject: Re: [PATCH v9] mmc: Export host capabilities to debugfs.
> 
> 
> 
> On Monday 12 March 2018 04:15 PM, Avri Altman wrote:
> >
> >> -----Original Message-----
> >> From: Andy Shevchenko [mailto:andriy.shevchenko@linux.intel.com]
> >> Sent: Monday, March 12, 2018 12:08 PM
> >> To: Harish Jenny K N <harish_kandiga@mentor.com>;
> >> ulf.hansson@linaro.org; linus.walleij@linaro.org;
> >> adrian.hunter@intel.com; shawn.lin@rock- chips.com; Avri Altman
> >> <Avri.Altman@wdc.com>
> >> Cc: linux-mmc@vger.kernel.org; linux-kernel@vger.kernel.org;
> >> Vladimir_Zapolskiy@mentor.com
> >> Subject: Re: [PATCH v9] mmc: Export host capabilities to debugfs.
> >>
> >> On Mon, 2018-03-12 at 10:01 +0530, 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 <Abbas_Raza@mentor.com> Earlier discussions:
> >>> https://lkml.org/lkml/2018/3/5/357
> >>> https://www.spinics.net/lists/linux-mmc/msg48219.html
> >>>
> >> Address below minors and, FWIW, take mine
> >>
> >> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> >>
> >>> +	for_each_set_bit(bit, (const unsigned long *)&caps,
> >>> BITS_PER_LONG)
> >>> +	for_each_set_bit(bit, (const unsigned long *)&caps2,
> >>> BITS_PER_LONG)
> >> Explicit casting is not needed anymore in both cases.
> > Also maybe use sizeof(mmc_host_capabilities) instead of BITS_PER_LONG?
> 
> You mean sizeof(caps) and not sizeof(mmc_host_capabilities) . Right ?
meant ARRAY_SIZE(mmc_host_capabilities)

Thanks,
Avri

> 
> 
> Thanks,
> Harish Jenny K N

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v9] mmc: Export host capabilities to debugfs.
  2018-03-12 11:32       ` Avri Altman
@ 2018-03-12 12:30         ` Harish Jenny K N
  2018-03-12 13:03           ` Andy Shevchenko
  0 siblings, 1 reply; 15+ messages in thread
From: Harish Jenny K N @ 2018-03-12 12:30 UTC (permalink / raw)
  To: Avri Altman, Andy Shevchenko, ulf.hansson, linus.walleij,
	adrian.hunter, shawn.lin
  Cc: linux-mmc, linux-kernel, Vladimir_Zapolskiy



On Monday 12 March 2018 05:02 PM, Avri Altman wrote:
>
>> -----Original Message-----
>> From: Harish Jenny K N [mailto:harish_kandiga@mentor.com]
>> Sent: Monday, March 12, 2018 1:17 PM
>> To: Avri Altman <Avri.Altman@wdc.com>; Andy Shevchenko
>> <andriy.shevchenko@linux.intel.com>; ulf.hansson@linaro.org;
>> linus.walleij@linaro.org; adrian.hunter@intel.com; shawn.lin@rock-chips.com
>> Cc: linux-mmc@vger.kernel.org; linux-kernel@vger.kernel.org;
>> Vladimir_Zapolskiy@mentor.com
>> Subject: Re: [PATCH v9] mmc: Export host capabilities to debugfs.
>>
>>
>>
>> On Monday 12 March 2018 04:15 PM, Avri Altman wrote:
>>>> -----Original Message-----
>>>> From: Andy Shevchenko [mailto:andriy.shevchenko@linux.intel.com]
>>>> Sent: Monday, March 12, 2018 12:08 PM
>>>> To: Harish Jenny K N <harish_kandiga@mentor.com>;
>>>> ulf.hansson@linaro.org; linus.walleij@linaro.org;
>>>> adrian.hunter@intel.com; shawn.lin@rock- chips.com; Avri Altman
>>>> <Avri.Altman@wdc.com>
>>>> Cc: linux-mmc@vger.kernel.org; linux-kernel@vger.kernel.org;
>>>> Vladimir_Zapolskiy@mentor.com
>>>> Subject: Re: [PATCH v9] mmc: Export host capabilities to debugfs.
>>>>
>>>> On Mon, 2018-03-12 at 10:01 +0530, 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 <Abbas_Raza@mentor.com> Earlier discussions:
>>>>> https://lkml.org/lkml/2018/3/5/357
>>>>> https://www.spinics.net/lists/linux-mmc/msg48219.html
>>>>>
>>>> Address below minors and, FWIW, take mine
>>>>
>>>> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>>>>
>>>>> +	for_each_set_bit(bit, (const unsigned long *)&caps,
>>>>> BITS_PER_LONG)
>>>>> +	for_each_set_bit(bit, (const unsigned long *)&caps2,
>>>>> BITS_PER_LONG)
>>>> Explicit casting is not needed anymore in both cases.
>>> Also maybe use sizeof(mmc_host_capabilities) instead of BITS_PER_LONG?
>> You mean sizeof(caps) and not sizeof(mmc_host_capabilities) . Right ?
> meant ARRAY_SIZE(mmc_host_capabilities)
>
> Thanks,
> Avri
>

ARRAY_SIZE(mmc_host_capabilities) will be 32 and this will be my old change for which I got a comment from Andy Shevchenko asking me to replace u32 with unsigned long.

This is the old comment:

>> +    int size = sizeof(u32) * BITS_PER_BYTE;
> This is redundant. Use BITS_PER_LONG (why's that, see below) in the
for_each_set_bit().

>> +    for_each_set_bit(bit, (const unsigned long *)&caps, size)
>> +    for_each_set_bit(bit, (const unsigned long *)&caps2, size)
> These are UB cases.
> Fix is simple, replace u32 by unsigned long in (1) above.

Note: Without typecasting &caps to(const unsigned long *) will give compilation error in this case.


Thanks,
Harish Jenny K N

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v9] mmc: Export host capabilities to debugfs.
  2018-03-12 12:30         ` Harish Jenny K N
@ 2018-03-12 13:03           ` Andy Shevchenko
  2018-03-12 13:34             ` Harish Jenny K N
  0 siblings, 1 reply; 15+ messages in thread
From: Andy Shevchenko @ 2018-03-12 13:03 UTC (permalink / raw)
  To: Harish Jenny K N, Avri Altman, ulf.hansson, linus.walleij,
	adrian.hunter, shawn.lin
  Cc: linux-mmc, linux-kernel, Vladimir_Zapolskiy

On Mon, 2018-03-12 at 18:00 +0530, Harish Jenny K N wrote:


> > > > > > +	for_each_set_bit(bit, (const unsigned long *)&caps,
> > > > > > BITS_PER_LONG)
> > > > > > +	for_each_set_bit(bit, (const unsigned long
> > > > > > *)&caps2,
> > > > > > BITS_PER_LONG)
> > > > > 
> > > > > Explicit casting is not needed anymore in both cases.
> > > > 
> > > > Also maybe use sizeof(mmc_host_capabilities) instead of
> > > > BITS_PER_LONG?
> > > 
> > > You mean sizeof(caps) and not sizeof(mmc_host_capabilities) .
> > > Right ?
> > 
> > meant ARRAY_SIZE(mmc_host_capabilities)

> ARRAY_SIZE(mmc_host_capabilities) will be 32 and this will be my old
> change for which I got a comment from Andy Shevchenko asking me to
> replace u32 with unsigned long.
> 
> This is the old comment:
> 
> > > +    int size = sizeof(u32) * BITS_PER_BYTE;
> > 
> > This is redundant. Use BITS_PER_LONG (why's that, see below) in the

There is nothing about ARRAY_SIZE().
ARRAY_SIZE() will work quite good as well.

> for_each_set_bit().
> 
> > > +    for_each_set_bit(bit, (const unsigned long *)&caps, size)
> > > +    for_each_set_bit(bit, (const unsigned long *)&caps2, size)
> > 
> > These are UB cases.
> > Fix is simple, replace u32 by unsigned long in (1) above.
> 
> Note: Without typecasting &caps to(const unsigned long *) will give
> compilation error in this case.

What kind of?

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v9] mmc: Export host capabilities to debugfs.
  2018-03-12 13:03           ` Andy Shevchenko
@ 2018-03-12 13:34             ` Harish Jenny K N
  2018-03-12 14:07               ` Harish Jenny K N
  2018-03-12 14:22               ` Andy Shevchenko
  0 siblings, 2 replies; 15+ messages in thread
From: Harish Jenny K N @ 2018-03-12 13:34 UTC (permalink / raw)
  To: Andy Shevchenko, Avri Altman, ulf.hansson, linus.walleij,
	adrian.hunter, shawn.lin
  Cc: linux-mmc, linux-kernel, Vladimir_Zapolskiy



On Monday 12 March 2018 06:33 PM, Andy Shevchenko wrote:
> On Mon, 2018-03-12 at 18:00 +0530, Harish Jenny K N wrote:
>
>
>>>>>>> +	for_each_set_bit(bit, (const unsigned long *)&caps,
>>>>>>> BITS_PER_LONG)
>>>>>>> +	for_each_set_bit(bit, (const unsigned long
>>>>>>> *)&caps2,
>>>>>>> BITS_PER_LONG)
>>>>>> Explicit casting is not needed anymore in both cases.
>>>>> Also maybe use sizeof(mmc_host_capabilities) instead of
>>>>> BITS_PER_LONG?
>>>> You mean sizeof(caps) and not sizeof(mmc_host_capabilities) .
>>>> Right ?
>>> meant ARRAY_SIZE(mmc_host_capabilities)
>> ARRAY_SIZE(mmc_host_capabilities) will be 32 and this will be my old
>> change for which I got a comment from Andy Shevchenko asking me to
>> replace u32 with unsigned long.
>>
>> This is the old comment:
>>
>>>> +    int size = sizeof(u32) * BITS_PER_BYTE;
>>> This is redundant. Use BITS_PER_LONG (why's that, see below) in the
> There is nothing about ARRAY_SIZE().
> ARRAY_SIZE() will work quite good as well.

Yes. Definitely it works. I was only mentioning about changing u32 to unsigned long for caps and passing BITS_PER_LONG  as size in for_each_set_bit.
>
>> for_each_set_bit().
>>
>>>> +    for_each_set_bit(bit, (const unsigned long *)&caps, size)
>>>> +    for_each_set_bit(bit, (const unsigned long *)&caps2, size)
>>> These are UB cases.
>>> Fix is simple, replace u32 by unsigned long in (1) above.
>> Note: Without typecasting &caps to(const unsigned long *) will give
>> compilation error in this case.
> What kind of?
>

Sorry for I was not clear that the compilation error is for the following case
> u32 caps = host->caps;
> for_each_set_bit(bit, &caps, ARRAY_SIZE(mmc_host_capabilities))


example: compilation for arm gives this error for the following lines:

drivers/mmc/core/debugfs.c: In function 'mmc_caps_show':
./include/linux/bitops.h:41:30: error: passing argument 1 of '_find_first_bit_le' from incompatible pointer type [-Werror=incompatible-pointer-types]
  for ((bit) = find_first_bit((addr), (size));  \
                              ^
./arch/arm/include/asm/bitops.h:202:50: note: in definition of macro 'find_first_bit'
 #define find_first_bit(p,sz)  _find_first_bit_le(p,sz)
                                                  ^
drivers/mmc/core/debugfs.c:318:2: note: in expansion of macro 'for_each_set_bit'
  for_each_set_bit(bit, &caps, ARRAY_SIZE(mmc_host_capabilities))
  ^
./arch/arm/include/asm/bitops.h:165:12: note: expected 'const long unsigned int *' but argument is of type 'u32 * {aka unsigned int *}'
 extern int _find_first_bit_le(const unsigned long *p, unsigned size);
            ^





Thanks,
Harish Jenny K N

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v9] mmc: Export host capabilities to debugfs.
  2018-03-12 13:34             ` Harish Jenny K N
@ 2018-03-12 14:07               ` Harish Jenny K N
  2018-03-12 14:20                 ` Andy Shevchenko
  2018-03-12 14:22               ` Andy Shevchenko
  1 sibling, 1 reply; 15+ messages in thread
From: Harish Jenny K N @ 2018-03-12 14:07 UTC (permalink / raw)
  To: Andy Shevchenko, Avri Altman, ulf.hansson, linus.walleij,
	adrian.hunter, shawn.lin
  Cc: linux-mmc, linux-kernel, Vladimir_Zapolskiy



On Monday 12 March 2018 07:04 PM, Harish Jenny K N wrote:
>
> On Monday 12 March 2018 06:33 PM, Andy Shevchenko wrote:
>> On Mon, 2018-03-12 at 18:00 +0530, Harish Jenny K N wrote:
>>
>>
>>>>>>>> +	for_each_set_bit(bit, (const unsigned long *)&caps,
>>>>>>>> BITS_PER_LONG)
>>>>>>>> +	for_each_set_bit(bit, (const unsigned long
>>>>>>>> *)&caps2,
>>>>>>>> BITS_PER_LONG)
>>>>>>> Explicit casting is not needed anymore in both cases.
>>>>>> Also maybe use sizeof(mmc_host_capabilities) instead of
>>>>>> BITS_PER_LONG?
>>>>> You mean sizeof(caps) and not sizeof(mmc_host_capabilities) .
>>>>> Right ?
>>>> meant ARRAY_SIZE(mmc_host_capabilities)
>>> ARRAY_SIZE(mmc_host_capabilities) will be 32 and this will be my old
>>> change for which I got a comment from Andy Shevchenko asking me to
>>> replace u32 with unsigned long.
>>>
>>> This is the old comment:
>>>
>>>>> +    int size = sizeof(u32) * BITS_PER_BYTE;
>>>> This is redundant. Use BITS_PER_LONG (why's that, see below) in the
>> There is nothing about ARRAY_SIZE().
>> ARRAY_SIZE() will work quite good as well.
> Yes. Definitely it works. I was only mentioning about changing u32 to unsigned long for caps and passing BITS_PER_LONG  as size in for_each_set_bit.
>


Just to make it clear, I will use ARRAY_SIZE(mmc_host_capabilities) as argument in the next version of the patch.

Can anyone please respond to my previous request?

> Before sending new patch , I would like to inform that I have been sending this patch with the following checkpatch warning, just to keep it same as other usages of debugfs_create_file in the drivers/mmc/core/debugfs.c file.

> WARNING:SYMBOLIC_PERMS: Symbolic permissions 'S_IRUSR' are not preferred. Consider using octal permissions '0400'.

> Do I need to address this or keep it same as S_IRUSR ?



Thanks,
Harish Jenny K N

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v9] mmc: Export host capabilities to debugfs.
  2018-03-12 14:07               ` Harish Jenny K N
@ 2018-03-12 14:20                 ` Andy Shevchenko
  0 siblings, 0 replies; 15+ messages in thread
From: Andy Shevchenko @ 2018-03-12 14:20 UTC (permalink / raw)
  To: Harish Jenny K N, Avri Altman, ulf.hansson, linus.walleij,
	adrian.hunter, shawn.lin
  Cc: linux-mmc, linux-kernel, Vladimir_Zapolskiy

On Mon, 2018-03-12 at 19:37 +0530, Harish Jenny K N wrote:


> Can anyone please respond to my previous request?
> 
> > Before sending new patch , I would like to inform that I have been
> > sending this patch with the following checkpatch warning, just to
> > keep it same as other usages of debugfs_create_file in the
> > drivers/mmc/core/debugfs.c file.
> > WARNING:SYMBOLIC_PERMS: Symbolic permissions 'S_IRUSR' are not
> > preferred. Consider using octal permissions '0400'.
> > Do I need to address this or keep it same as S_IRUSR ?

Please, do.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v9] mmc: Export host capabilities to debugfs.
  2018-03-12 13:34             ` Harish Jenny K N
  2018-03-12 14:07               ` Harish Jenny K N
@ 2018-03-12 14:22               ` Andy Shevchenko
  2018-03-12 14:27                 ` Andy Shevchenko
  1 sibling, 1 reply; 15+ messages in thread
From: Andy Shevchenko @ 2018-03-12 14:22 UTC (permalink / raw)
  To: Harish Jenny K N, Avri Altman, ulf.hansson, linus.walleij,
	adrian.hunter, shawn.lin
  Cc: linux-mmc, linux-kernel, Vladimir_Zapolskiy

On Mon, 2018-03-12 at 19:04 +0530, Harish Jenny K N wrote:
> 
> On Monday 12 March 2018 06:33 PM, Andy Shevchenko wrote:
> > On Mon, 2018-03-12 at 18:00 +0530, Harish Jenny K N wrote:

> > > > > > > > +	for_each_set_bit(bit, (const unsigned long
> > > > > > > > *)&caps,
> > > > > > > > BITS_PER_LONG)
> > > > > > > > +	for_each_set_bit(bit, (const unsigned long
> > > > > > > > *)&caps2,
> > > > > > > > BITS_PER_LONG)
> > > > > > > 
> > > > > > > Explicit casting is not needed anymore in both cases.

> Sorry for I was not clear that the compilation error is for the
> following case
> > u32 caps = host->caps;
> > for_each_set_bit(bit, &caps, ARRAY_SIZE(mmc_host_capabilities))
> 
> 
> example: compilation for arm gives this error for the following lines:
> 
> drivers/mmc/core/debugfs.c: In function 'mmc_caps_show':
> ./include/linux/bitops.h:41:30: error: passing argument 1 of
> '_find_first_bit_le' from incompatible pointer type [-
> Werror=incompatible-pointer-types]
>   for ((bit) = find_first_bit((addr), (size));  \
>                               ^
> ./arch/arm/include/asm/bitops.h:202:50: note: in definition of macro
> 'find_first_bit'
>  #define find_first_bit(p,sz)  _find_first_bit_le(p,sz)
>                                                   ^
> drivers/mmc/core/debugfs.c:318:2: note: in expansion of macro
> 'for_each_set_bit'
>   for_each_set_bit(bit, &caps, ARRAY_SIZE(mmc_host_capabilities))
>   ^
> ./arch/arm/include/asm/bitops.h:165:12: note: expected 'const long
> unsigned int *' but argument is of type 'u32 * {aka unsigned int *}'
>  extern int _find_first_bit_le(const unsigned long *p, unsigned size);
>             ^

Are you sure you have caps defined as unsigned long?

Check your code, the explicit casting should gone. Otherwise you are
doing something wrong.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v9] mmc: Export host capabilities to debugfs.
  2018-03-12 14:22               ` Andy Shevchenko
@ 2018-03-12 14:27                 ` Andy Shevchenko
  0 siblings, 0 replies; 15+ messages in thread
From: Andy Shevchenko @ 2018-03-12 14:27 UTC (permalink / raw)
  To: Harish Jenny K N, Avri Altman, ulf.hansson, linus.walleij,
	adrian.hunter, shawn.lin
  Cc: linux-mmc, linux-kernel, Vladimir_Zapolskiy

On Mon, 2018-03-12 at 16:22 +0200, Andy Shevchenko wrote:
> On Mon, 2018-03-12 at 19:04 +0530, Harish Jenny K N wrote:
> > 
> > On Monday 12 March 2018 06:33 PM, Andy Shevchenko wrote:
> > > On Mon, 2018-03-12 at 18:00 +0530, Harish Jenny K N wrote:
> > > > > > > > > +	for_each_set_bit(bit, (const unsigned long
> > > > > > > > > *)&caps,
> > > > > > > > > BITS_PER_LONG)
> > > > > > > > > +	for_each_set_bit(bit, (const unsigned long
> > > > > > > > > *)&caps2,
> > > > > > > > > BITS_PER_LONG)
> > > > > > > > 
> > > > > > > > Explicit casting is not needed anymore in both cases.
> > Sorry for I was not clear that the compilation error is for the
> > following case

> > > u32 caps = host->caps;

This is wrong! I told you that and you seems changed at least in v9.
What are you doing locally?

> > > for_each_set_bit(bit, &caps, ARRAY_SIZE(mmc_host_capabilities))
> > 

> Are you sure you have caps defined as unsigned long?
> 
> Check your code, the explicit casting should gone. Otherwise you are
> doing something wrong.

See above.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2018-03-12 14:27 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-12  4:31 [PATCH v9] mmc: Export host capabilities to debugfs Harish Jenny K N
2018-03-12  4:31 ` Harish Jenny K N
2018-03-12 10:07 ` Andy Shevchenko
2018-03-12 10:27   ` Harish Jenny K N
2018-03-12 10:27     ` Harish Jenny K N
2018-03-12 10:45   ` Avri Altman
2018-03-12 11:16     ` Harish Jenny K N
2018-03-12 11:32       ` Avri Altman
2018-03-12 12:30         ` Harish Jenny K N
2018-03-12 13:03           ` Andy Shevchenko
2018-03-12 13:34             ` Harish Jenny K N
2018-03-12 14:07               ` Harish Jenny K N
2018-03-12 14:20                 ` Andy Shevchenko
2018-03-12 14:22               ` Andy Shevchenko
2018-03-12 14:27                 ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.