Re: [PATCH] wlcore/wl18xx: Add invert-irq OF property for physically inverted IRQ
On 12/06/19 8:36 PM, Eugeniu Rosca wrote: > Hi Marc, > > Thanks for your comment. > > On Wed, Jun 12, 2019 at 11:17:10AM +0100, Marc Zyngier wrote: >> Eugeniu Rosca wrote: >>> On Tue, Jun 11, 2019 at 10:00:41AM +0100, Marc Zyngier wrote: > [..] >>>> We already have plenty of that in the tree, the canonical example >>>> probably being drivers/irqchip/irq-mtk-sysirq.c. It should be pretty >>>> easy to turn this driver into something more generic. >>> I don't think drivers/irqchip/irq-mtk-sysirq.c can serve the >>> use-case/purpose of this patch. The MTK driver seems to be dealing with >>> the polarity inversion of on-SoC interrupts which are routed to GiC, >>> whereas in this patch we are talking about an off-chip interrupt >>> wired to R-Car GPIO controller. >> And how different is that? The location of the interrupt source is >> pretty irrelevant here. > The main difference which I sense is that a driver like irq-mtk-sysirq > mostly (if not exclusively) deals with internal kernel implementation > detail (tuned via DT) whilst adding an inverter for GPIO IRQs raises > a whole bunch of new questions (e.g. how to arbitrate between > kernel-space and user-space IRQ polarity configuration?). > >> The point is that there is already a general >> scheme to deal with these "signal altering widgets", and that we >> should try to reuse at least the concept, if not the code. > Since Harish Jenny K N might be working on a new driver doing GPIO IRQ > inversion, I have CC-ed him as well to avoid any overlapping work. Sorry I am not completely aware of the background discussion. But here is the link to my proposal for new consumer driver to provide a new virtual gpio controller to configure the polarity of the gpio pins used by the userspace. https://www.spinics.net/lists/linux-gpio/msg39681.html > >>> It looks to me that the nice DTS sketch shared by Linus Walleij in [5] >>> might come closer to the concept proposed by Geert? FWIW, the >>> infrastructure/implementation to make this possible is still not >>> ready. >> Which looks like what I'm suggesting. > Then we are on the same page. Thanks. > >> M. >> >> -- >> Jazz is not dead, it just smells funny.
Re: [PATCH v10] mmc: Export host capabilities to debugfs.
On Friday 16 March 2018 01:27 PM, Ulf Hansson wrote: > On 16 March 2018 at 05:20, Harish Jenny K N wrote: >> >> On Thursday 15 March 2018 05:59 PM, Ulf Hansson wrote: >>> On 15 March 2018 at 11:26, Andy Shevchenko >>> wrote: >>>> On Thu, 2018-03-15 at 11:12 +0100, Ulf Hansson wrote: >>>>> On 13 March 2018 at 06:10, Harish Jenny K N >>>>> wrote: >>>>>> >>>>> 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. >>>> A compromise would be to print both: >>>> >>>> 0x\n >>>> Description of each enabled field, one per line >>>> >>>> >>>> Another format would be: >>>> >>>> Bit XX: Description of a field >>> If we were to print the description, there is no point in printing the >>> bits in hex. Or is it? >> Yes. I also do not see the use of printing hex value if we are printing the >> description. >> >>> As I said, if you and other folkz thinks this is valuable, then I am >>> fine as well. Just saying, it's not my preferred option. >>> >>> >> >> I just want to inform that the idea of printing the description came after >> discussion in https://www.spinics.net/lists/linux-mmc/msg48246.html, where >> it was decided adding utility in mmc-utils was not going to work ( reason: >> We may very well be changing the bit offsets for the caps and caps2 in the >> mmc kernel header, keeping a copy of them is not a good idea. It's just a >> matter of *when* it will break). > I recall. However, I didn't realize all these strings were going to be > needed. :-) > >> On Thu, 2018-03-15 at 11:12 +0100, Ulf Hansson wrote: >>> If were to decide, I would just rather print the caps field in a >>> hexadecimal bit form and leave the translation to the user. >> I think translation becomes difficult for the above reason and hence I would >> prefer printing the description. > Okay. > >> Note: Printing values in Hex was the original idea and it is also available >> in https://www.spinics.net/lists/linux-mmc/msg48213.html just in case if it >> is required. > Yeah, so maybe I should apply that one, then we can take it from there!? Fine with both the approach. Please consider this. Thanks, Harish Jenny K N
Re: [PATCH v10] mmc: Export host capabilities to debugfs.
On Thursday 15 March 2018 05:59 PM, Ulf Hansson wrote: > On 15 March 2018 at 11:26, Andy Shevchenko > wrote: >> On Thu, 2018-03-15 at 11:12 +0100, Ulf Hansson wrote: >>> On 13 March 2018 at 06:10, Harish Jenny K N >>> wrote: >>>> >>> 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. >> A compromise would be to print both: >> >> 0x\n >> Description of each enabled field, one per line >> >> >> Another format would be: >> >> Bit XX: Description of a field > If we were to print the description, there is no point in printing the > bits in hex. Or is it? Yes. I also do not see the use of printing hex value if we are printing the description. > > As I said, if you and other folkz thinks this is valuable, then I am > fine as well. Just saying, it's not my preferred option. > > I just want to inform that the idea of printing the description came after discussion in https://www.spinics.net/lists/linux-mmc/msg48246.html, where it was decided adding utility in mmc-utils was not going to work ( reason: We may very well be changing the bit offsets for the caps and caps2 in the mmc kernel header, keeping a copy of them is not a good idea. It's just a matter of *when* it will break). On Thu, 2018-03-15 at 11:12 +0100, Ulf Hansson wrote: > If were to decide, I would just rather print the caps field in a hexadecimal > bit form and leave the translation to the user. I think translation becomes difficult for the above reason and hence I would prefer printing the description. Note: Printing values in Hex was the original idea and it is also available in https://www.spinics.net/lists/linux-mmc/msg48213.html just in case if it is required. Thanks & Regards, Harish Jenny K N
[PATCH v10] mmc: Export host capabilities to debugfs.
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)" +}; + +static int mmc_caps_show(struct seq_file *s, void *unused) +{ + struct mmc_host *host
Re: [PATCH v9] mmc: Export host capabilities to debugfs.
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
Re: [PATCH v9] mmc: Export host capabilities to debugfs.
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
Re: [PATCH v9] mmc: Export host capabilities to debugfs.
On Monday 12 March 2018 05:02 PM, Avri Altman wrote: > >> -Original Message- >> From: Harish Jenny K N [mailto:harish_kand...@mentor.com] >> Sent: Monday, March 12, 2018 1:17 PM >> To: Avri Altman ; Andy Shevchenko >> ; ulf.hans...@linaro.org; >> linus.wall...@linaro.org; adrian.hun...@intel.com; shawn@rock-chips.com >> Cc: linux-...@vger.kernel.org; linux-kernel@vger.kernel.org; >> vladimir_zapols...@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.shevche...@linux.intel.com] >>>> Sent: Monday, March 12, 2018 12:08 PM >>>> To: Harish Jenny K N ; >>>> ulf.hans...@linaro.org; linus.wall...@linaro.org; >>>> adrian.hun...@intel.com; shawn.lin@rock- chips.com; Avri Altman >>>> >>>> Cc: linux-...@vger.kernel.org; linux-kernel@vger.kernel.org; >>>> vladimir_zapols...@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 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 >>>> >>>>> + 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
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.shevche...@linux.intel.com] >> Sent: Monday, March 12, 2018 12:08 PM >> To: Harish Jenny K N ; ulf.hans...@linaro.org; >> linus.wall...@linaro.org; adrian.hun...@intel.com; shawn.lin@rock- >> chips.com; Avri Altman >> Cc: linux-...@vger.kernel.org; linux-kernel@vger.kernel.org; >> vladimir_zapols...@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 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 >> >>> + 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
Re: [PATCH v9] mmc: Export host capabilities to debugfs.
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 >> 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 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
Re: [PATCH] mmc: card: Don't show eMMC RPMB and BOOT areas in /proc/partitions
On Saturday 10 March 2018 05:29 PM, Linus Walleij wrote: > > But this patch doesn't hide the partition from userspace does it? > > They will still appear in /dev/mmcblk0boot1 etc. > > Just not reported as "real" partitions in /proc/partitions. > > Or do I misunderstand it? > > You are correct. This patch does not hide partition from userspace. They will still appear in /dev/. But not reported as "real" partitions in /proc/partiotions. Thanks, Harish Jenny K N
[PATCH v9] mmc: Export host capabilities to debugfs.
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 Signed-off-by: Harish Jenny K N --- 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->cap
[PATCH v8] mmc: Export host capabilities to debugfs.
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 Signed-off-by: Harish Jenny K N --- 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 | 111 + 1 file changed, 111 insertions(+) diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index c51e0c0..a16846b 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -225,6 +225,114 @@ 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"); +static int mmc_caps_show(struct seq_file *s, void *unused) +{ + static const char * const mmc_host_capabilities[] = { + "4-bit transfers allowed",/* MMC_CAP_4_BIT_DATA (1 << 0) */ + /* MMC_CAP_MMC_HIGHSPEED (1 << 1)*/ + "Supports MMC high-speed timing", + /* MMC_CAP_SD_HIGHSPEED (1 << 2)*/ + "Supports SD high-speed timing", + "Can signal pending SDIO IRQs",/* MMC_CAP_SDIO_IRQ (1 << 3) */ + "Talks only SPI protocols",/* MMC_CAP_SPI (1 << 4) */ + /* MMC_CAP_NEEDS_POLL (1 << 5)*/ + "Needs polling for card-detection", + "8 bit transfers allowed",/* MMC_CAP_8_BIT_DATA (1 << 6) */ + "Suspends (e)MMC/SD at idle",/*MMC_CAP_AGGRESSIVE_PM (1 << 7)*/ + "Nonremovable",/* MMC_CAP_NONREMOVABLE (1 << 8) */ + "Waits while card is busy",/*MMC_CAP_WAIT_WHILE_BUSY (1 << 9)*/ + "Allows erase/trim commands",/* MMC_CAP_ERASE (1 << 10) */ + "Supports DDR mode at 3.3V",/* MMC_CAP_3_3V_DDR (1 << 11) */ + "Supports DDR mode at 1.8V",/* MMC_CAP_1_8V_DDR (1 << 12) */ + "Supports DDR mode at 1.2V",/* MMC_CAP_1_2V_DDR (1 << 13) */ + "Can power off after boot",/*MMC_CAP_POWER_OFF_CARD (1 << 14)*/ + "CMD14/CMD19 bus width ok",/*MMC_CAP_BUS_WIDTH_TEST (1 << 15)*/ + "Supports UHS SDR12 mode",/* MMC_CAP_UHS_SDR12 (1 << 16) */ + "Supports UHS SDR25 mode",/* MMC_CAP_UHS_SDR25 (1 << 17) */ + "Supports UHS SDR50 mode",/* MMC_CAP_UHS_SDR50 (1 << 18) */ + "Supports UHS SDR104 mode",/* MMC_CAP_UHS_SDR104 (1 << 19) */ + "Supports UHS DDR50 mode",/* MMC_CAP_UHS_DDR50 (1 << 20) */ + "",/* (1 << 21) is free for reuse*/ + "",/* (1 << 22) */ + "Supports Driver Type A",/* MMC_CAP_DRIVER_TYPE_A (1 << 23) */ + "Supports Driver Type C",/* MMC_CAP_DRIVER_TYPE_C (1 << 24) */ + "Supports Driver Type D",/* MMC_CAP_DRIVER_TYPE_D (1 << 25) */ + "",/* (1 << 26) */ + /* MMC_CAP_DONE_COMPLETE (1 << 27) */ + "RW reqs can be completed within mmc_request_done()", + "Supports Enable card detect wake",/*MMC_CAP_CD_WAKE (1 << 28)*/ + /* MMC_CAP_CMD_DURING_TFR (1 << 29) */ + "Can send commands during data transfer", + "CMD23 supported",/* MMC_CAP_CMD23 (1 << 30) */ + "Supports Hardware reset"/* MMC_CAP_HW_RESET(1 << 31) */ + }; + + static const char * const mmc_host_capabilities2[] = { + /* MMC_CAP2_BOOTPART_NOACC (1 << 0) */ + "No access to Boot partition", + "",/* (1 << 1) */ + "Can do full power cycle",/* MMC_CAP2_FULL_PWR_CYCLE (1 << 2) */ + "",/* (1 << 3) */ + "",/* (1 << 4) */ + "Supports HS200 1.8V SDR",/*
[PATCH v7] mmc: Export host capabilities to debugfs.
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 Signed-off-by: Harish Jenny K N --- 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 | 114 + 1 file changed, 114 insertions(+) diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index c51e0c0..f2fbeae 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -225,6 +225,117 @@ 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"); +static int mmc_caps_show(struct seq_file *s, void *unused) +{ +#define YN(bit) ((caps & bit) ? "Yes" : "No") +#define YN2(bit) ((caps2 & bit) ? "Yes" : "No") + struct mmc_host *host = s->private; + u32 caps = host->caps; + u32 caps2 = host->caps2; + + seq_puts(s, "\nMMC Host capabilities are:\n"); + seq_puts(s, "=\n"); + seq_printf(s, "Can the host do 4 bit transfers :\t%s\n", + YN(MMC_CAP_4_BIT_DATA)); + seq_printf(s, "Can do MMC high-speed timing :\t%s\n", + YN(MMC_CAP_MMC_HIGHSPEED)); + seq_printf(s, "Can do SD high-speed timing :\t%s\n", + YN(MMC_CAP_SD_HIGHSPEED)); + seq_printf(s, "Can signal pending SDIO IRQs :\t%s\n", + YN(MMC_CAP_SDIO_IRQ)); + seq_printf(s, "Talks only SPI protocols :\t%s\n", + YN(MMC_CAP_SPI)); + seq_printf(s, "Needs polling for card-detection :\t%s\n", + YN(MMC_CAP_NEEDS_POLL)); + seq_printf(s, "Can the host do 8 bit transfers :\t%s\n", + YN(MMC_CAP_8_BIT_DATA)); + seq_printf(s, "Suspend (e)MMC/SD at idle :\t%s\n", + YN(MMC_CAP_AGGRESSIVE_PM)); + seq_printf(s, "Nonremovable e.g. eMMC :\t%s\n", + YN(MMC_CAP_NONREMOVABLE)); + seq_printf(s, "Waits while card is busy :\t%s\n", + YN(MMC_CAP_WAIT_WHILE_BUSY)); + seq_printf(s, "Allow erase/trim commands :\t%s\n", + YN(MMC_CAP_ERASE)); + seq_printf(s, "Can support DDR mode at 3.3V :\t%s\n", + YN(MMC_CAP_3_3V_DDR)); + seq_printf(s, "Can support DDR mode at 1.8V :\t%s\n", + YN(MMC_CAP_1_8V_DDR)); + seq_printf(s, "Can support DDR mode at 1.2V :\t%s\n", + YN(MMC_CAP_1_2V_DDR)); + seq_printf(s, "Can power off after boot :\t%s\n", + YN(MMC_CAP_POWER_OFF_CARD)); + seq_printf(s, "CMD14/CMD19 bus width ok :\t%s\n", + YN(MMC_CAP_BUS_WIDTH_TEST)); + seq_printf(s, "Host supports UHS SDR12 mode :\t%s\n", + YN(MMC_CAP_UHS_SDR12)); + seq_printf(s, "Host supports UHS SDR25 mode :\t%s\n", + YN(MMC_CAP_UHS_SDR25)); + seq_printf(s, "Host supports UHS SDR50 mode :\t%s\n", + YN(MMC_CAP_UHS_SDR50)); + seq_printf(s, "Host supports UHS SDR104 mode :\t%s\n", + YN(MMC_CAP_UHS_SDR104)); + seq_printf(s, "Host supports UHS DDR50 mode :\t%s\n", + YN(MMC_CAP_UHS_DDR50)); + seq_printf(s, "Host supports Driver Type A :\t%s\n", + YN(MMC_CAP_DRIVER_TYPE_A)); + seq_printf(s, "Host supports Driver Type C :\t%s\n", + YN(MMC_CAP_DRIVER_TYPE_C)); + seq_printf(s, "Host supports Driver Type D :\t%s\n", + YN(MMC_CAP_DRIVER_TYPE_D)); + seq_printf(s, "RW reqs can be completed within mmc_request_done() :\t%s\n", + YN(MMC_CAP_DONE_COMPLETE)); + seq_printf(s, "Enable card detect wake :\t%s\n", + YN(MMC_CAP_CD_WAKE)); + seq_printf(s, "Commands during data transfer :\t%s\n", + YN(MMC_CAP_CMD_DURING_TFR)); + seq_printf(s, "CMD23 supported. :\t%s\n", + YN(MMC_CAP_CMD23)); +
Re: [PATCH v6] mmc: Export host capabilities to debugfs.
On Wednesday 07 March 2018 12:10 PM, Avri Altman wrote: > >> -Original Message- >> From: Harish Jenny K N [mailto:harish_kand...@mentor.com] >> Sent: Wednesday, March 07, 2018 7:38 AM >> To: ulf.hans...@linaro.org; linus.wall...@linaro.org; >> adrian.hun...@intel.com; shawn@rock-chips.com; Avri Altman >> ; andriy.shevche...@linux.intel.com >> Cc: linux-...@vger.kernel.org; linux-kernel@vger.kernel.org; >> harish_kand...@mentor.com; vladimir_zapols...@mentor.com >> Subject: [PATCH v6] mmc: Export host capabilities to debugfs. >> >> 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 >> >> Signed-off-by: Harish Jenny K N >> --- >> >> >> +static int mmc_caps_show(struct seq_file *s, void *unused) { >> +struct mmc_host *host = s->private; >> +u32 caps = host->caps; >> + >> +seq_puts(s, "\nMMC Host capabilities are:\n"); >> +seq_puts(s, >> "=\n"); >> +seq_printf(s, "Can the host do 4 bit transfers :\t%s\n", >> + ((caps & MMC_CAP_4_BIT_DATA) ? "Yes" : "No")); > Maybe use a more compact form, and just call a macro with the applicable > (stringified) bit? Something like this ? #define YN(bit) ((caps & bit) ? "Yes" : "No") and then call seq_printf(s, "Can the host do 4 bit transfers :\t%s\n", YN(MMC_CAP_4_BIT_DATA)); Thanks, Harish Jenny K N
[PATCH v6] mmc: Export host capabilities to debugfs.
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 Signed-off-by: Harish Jenny K N --- 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 | 120 + 1 file changed, 120 insertions(+) diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index c51e0c0..136bdf7 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -225,6 +225,120 @@ 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"); +static int mmc_caps_show(struct seq_file *s, void *unused) +{ + struct mmc_host *host = s->private; + u32 caps = host->caps; + + seq_puts(s, "\nMMC Host capabilities are:\n"); + seq_puts(s, "=\n"); + seq_printf(s, "Can the host do 4 bit transfers :\t%s\n", + ((caps & MMC_CAP_4_BIT_DATA) ? "Yes" : "No")); + seq_printf(s, "Can do MMC high-speed timing :\t%s\n", + ((caps & MMC_CAP_MMC_HIGHSPEED) ? "Yes" : "No")); + seq_printf(s, "Can do SD high-speed timing :\t%s\n", + ((caps & MMC_CAP_SD_HIGHSPEED) ? "Yes" : "No")); + seq_printf(s, "Can signal pending SDIO IRQs :\t%s\n", + ((caps & MMC_CAP_SDIO_IRQ) ? "Yes" : "No")); + seq_printf(s, "Talks only SPI protocols :\t%s\n", + ((caps & MMC_CAP_SPI) ? "Yes" : "No")); + seq_printf(s, "Needs polling for card-detection :\t%s\n", + ((caps & MMC_CAP_NEEDS_POLL) ? "Yes" : "No")); + seq_printf(s, "Can the host do 8 bit transfers :\t%s\n", + ((caps & MMC_CAP_8_BIT_DATA) ? "Yes" : "No")); + seq_printf(s, "Suspend (e)MMC/SD at idle :\t%s\n", + ((caps & MMC_CAP_AGGRESSIVE_PM) ? "Yes" : "No")); + seq_printf(s, "Nonremovable e.g. eMMC :\t%s\n", + ((caps & MMC_CAP_NONREMOVABLE) ? "Yes" : "No")); + seq_printf(s, "Waits while card is busy :\t%s\n", + ((caps & MMC_CAP_WAIT_WHILE_BUSY) ? "Yes" : "No")); + seq_printf(s, "Allow erase/trim commands :\t%s\n", + ((caps & MMC_CAP_ERASE) ? "Yes" : "No")); + seq_printf(s, "Can support DDR mode at 3.3V :\t%s\n", + ((caps & MMC_CAP_3_3V_DDR) ? "Yes" : "No")); + seq_printf(s, "Can support DDR mode at 1.8V :\t%s\n", + ((caps & MMC_CAP_1_8V_DDR) ? "Yes" : "No")); + seq_printf(s, "Can support DDR mode at 1.2V :\t%s\n", + ((caps & MMC_CAP_1_2V_DDR) ? "Yes" : "No")); + seq_printf(s, "Can power off after boot :\t%s\n", + ((caps & MMC_CAP_POWER_OFF_CARD) ? "Yes" : "No")); + seq_printf(s, "CMD14/CMD19 bus width ok :\t%s\n", + ((caps & MMC_CAP_BUS_WIDTH_TEST) ? "Yes" : "No")); + seq_printf(s, "Host supports UHS SDR12 mode :\t%s\n", + ((caps & MMC_CAP_UHS_SDR12) ? "Yes" : "No")); + seq_printf(s, "Host supports UHS SDR25 mode :\t%s\n", + ((caps & MMC_CAP_UHS_SDR25) ? "Yes" : "No")); + seq_printf(s, "Host supports UHS SDR50 mode :\t%s\n", + ((caps & MMC_CAP_UHS_SDR50) ? "Yes" : "No")); + seq_printf(s, "Host supports UHS SDR104 mode :\t%s\n", + ((caps & MMC_CAP_UHS_SDR104) ? "Yes" : "No")); + seq_printf(s, "Host supports UHS DDR50 mode :\t%s\n", + ((caps & MMC_CAP_UHS_DDR50) ? "Yes" : "No")); + seq_printf(s, "Host supports Driver Type A :\t%s\n", + ((caps & MMC_CAP_DRIVER_TYPE_A) ? "Yes" : "No")); +
[PATCH v2] mmc: Export card RCA register to sysfs.
This patch exports RCA register to sysfs which will help in reading the disk identification information. Reviewed-by: Shawn Lin Signed-off-by: Harish Jenny K N --- Changes in v2: - Used 0x%04x to display 16 bit register drivers/mmc/core/mmc.c | 2 ++ drivers/mmc/core/sd.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 208a762..6f8ebd6 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -792,6 +792,7 @@ static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width) MMC_DEV_ATTR(raw_rpmb_size_mult, "%#x\n", card->ext_csd.raw_rpmb_size_mult); MMC_DEV_ATTR(rel_sectors, "%#x\n", card->ext_csd.rel_sectors); MMC_DEV_ATTR(ocr, "0x%08x\n", card->ocr); +MMC_DEV_ATTR(rca, "0x%04x\n", card->rca); MMC_DEV_ATTR(cmdq_en, "%d\n", card->ext_csd.cmdq_en); static ssize_t mmc_fwrev_show(struct device *dev, @@ -848,6 +849,7 @@ static ssize_t mmc_dsr_show(struct device *dev, &dev_attr_raw_rpmb_size_mult.attr, &dev_attr_rel_sectors.attr, &dev_attr_ocr.attr, + &dev_attr_rca.attr, &dev_attr_dsr.attr, &dev_attr_cmdq_en.attr, NULL, diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 62b84dd..2ecd098 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -676,6 +676,7 @@ static int mmc_sd_init_uhs_card(struct mmc_card *card) MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid); MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial); MMC_DEV_ATTR(ocr, "0x%08x\n", card->ocr); +MMC_DEV_ATTR(rca, "0x%04x\n", card->rca); static ssize_t mmc_dsr_show(struct device *dev, @@ -709,6 +710,7 @@ static ssize_t mmc_dsr_show(struct device *dev, &dev_attr_oemid.attr, &dev_attr_serial.attr, &dev_attr_ocr.attr, + &dev_attr_rca.attr, &dev_attr_dsr.attr, NULL, }; -- 1.9.1
[PATCH v5] mmc: Export host capabilities to debugfs.
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 Signed-off-by: Harish Jenny K N --- 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 | 142 + 1 file changed, 142 insertions(+) diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index c51e0c0..6990859 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -225,6 +225,142 @@ 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"); +static int mmc_caps_show(struct seq_file *s, void *unused) +{ + struct mmc_host *host = s->private; + u32 caps = host->caps; + + seq_puts(s, "\nMMC Host capabilities are:\n"); + seq_puts(s, "=\n"); + seq_printf(s, "Can the host do 4 bit transfers :\t%s\n", + ((caps & MMC_CAP_4_BIT_DATA) ? "Yes" : "No")); + seq_printf(s, "Can do MMC high-speed timing :\t%s\n", + ((caps & MMC_CAP_MMC_HIGHSPEED) ? "Yes" : "No")); + seq_printf(s, "Can do SD high-speed timing :\t%s\n", + ((caps & MMC_CAP_SD_HIGHSPEED) ? "Yes" : "No")); + seq_printf(s, "Can signal pending SDIO IRQs :\t%s\n", + ((caps & MMC_CAP_SDIO_IRQ) ? "Yes" : "No")); + seq_printf(s, "Talks only SPI protocols :\t%s\n", + ((caps & MMC_CAP_SPI) ? "Yes" : "No")); + seq_printf(s, "Needs polling for card-detection :\t%s\n", + ((caps & MMC_CAP_NEEDS_POLL) ? "Yes" : "No")); + seq_printf(s, "Can the host do 8 bit transfers :\t%s\n", + ((caps & MMC_CAP_8_BIT_DATA) ? "Yes" : "No")); + seq_printf(s, "Suspend (e)MMC/SD at idle :\t%s\n", + ((caps & MMC_CAP_AGGRESSIVE_PM) ? "Yes" : "No")); + seq_printf(s, "Nonremovable e.g. eMMC :\t%s\n", + ((caps & MMC_CAP_NONREMOVABLE) ? "Yes" : "No")); + seq_printf(s, "Waits while card is busy :\t%s\n", + ((caps & MMC_CAP_WAIT_WHILE_BUSY) ? "Yes" : "No")); + seq_printf(s, "Allow erase/trim commands :\t%s\n", + ((caps & MMC_CAP_ERASE) ? "Yes" : "No")); + seq_printf(s, "Can support DDR mode at 3.3V :\t%s\n", + ((caps & MMC_CAP_3_3V_DDR) ? "Yes" : "No")); + seq_printf(s, "Can support DDR mode at 1.8V :\t%s\n", + ((caps & MMC_CAP_1_8V_DDR) ? "Yes" : "No")); + seq_printf(s, "Can support DDR mode at 1.2V :\t%s\n", + ((caps & MMC_CAP_1_2V_DDR) ? "Yes" : "No")); + seq_printf(s, "Can power off after boot :\t%s\n", + ((caps & MMC_CAP_POWER_OFF_CARD) ? "Yes" : "No")); + seq_printf(s, "CMD14/CMD19 bus width ok :\t%s\n", + ((caps & MMC_CAP_BUS_WIDTH_TEST) ? "Yes" : "No")); + seq_printf(s, "Host supports UHS SDR12 mode :\t%s\n", + ((caps & MMC_CAP_UHS_SDR12) ? "Yes" : "No")); + seq_printf(s, "Host supports UHS SDR25 mode :\t%s\n", + ((caps & MMC_CAP_UHS_SDR25) ? "Yes" : "No")); + seq_printf(s, "Host supports UHS SDR50 mode :\t%s\n", + ((caps & MMC_CAP_UHS_SDR50) ? "Yes" : "No")); + seq_printf(s, "Host supports UHS SDR104 mode :\t%s\n", + ((caps & MMC_CAP_UHS_SDR104) ? "Yes" : "No")); + seq_printf(s, "Host supports UHS DDR50 mode :\t%s\n", + ((caps & MMC_CAP_UHS_DDR50) ? "Yes" : "No")); + seq_printf(s, "Host supports Driver Type A :\t%s\n", + ((caps & MMC_CAP_DRIVER_TYPE_A) ? "Yes" : "No")); + seq_printf(s, "Host
Re: [PATCH] mmc: Export card RCA register to sysfs.
On Tuesday 27 February 2018 05:26 PM, Harish Jenny K N wrote: > This patch exports RCA register to sysfs which will help in > reading the disk identification information. > > Signed-off-by: Harish Jenny K N > --- > drivers/mmc/core/mmc.c | 2 ++ > drivers/mmc/core/sd.c | 2 ++ > 2 files changed, 4 insertions(+) > > diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c > index 208a762..d45a244 100644 > --- a/drivers/mmc/core/mmc.c > +++ b/drivers/mmc/core/mmc.c > @@ -792,6 +792,7 @@ static int mmc_compare_ext_csds(struct mmc_card *card, > unsigned bus_width) > MMC_DEV_ATTR(raw_rpmb_size_mult, "%#x\n", card->ext_csd.raw_rpmb_size_mult); > MMC_DEV_ATTR(rel_sectors, "%#x\n", card->ext_csd.rel_sectors); > MMC_DEV_ATTR(ocr, "0x%08x\n", card->ocr); > +MMC_DEV_ATTR(rca, "0x%x\n", card->rca); > MMC_DEV_ATTR(cmdq_en, "%d\n", card->ext_csd.cmdq_en); > > static ssize_t mmc_fwrev_show(struct device *dev, > @@ -848,6 +849,7 @@ static ssize_t mmc_dsr_show(struct device *dev, > &dev_attr_raw_rpmb_size_mult.attr, > &dev_attr_rel_sectors.attr, > &dev_attr_ocr.attr, > + &dev_attr_rca.attr, > &dev_attr_dsr.attr, > &dev_attr_cmdq_en.attr, > NULL, > diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c > index 62b84dd..17d9005 100644 > --- a/drivers/mmc/core/sd.c > +++ b/drivers/mmc/core/sd.c > @@ -676,6 +676,7 @@ static int mmc_sd_init_uhs_card(struct mmc_card *card) > MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid); > MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial); > MMC_DEV_ATTR(ocr, "0x%08x\n", card->ocr); > +MMC_DEV_ATTR(rca, "0x%x\n", card->rca); > > > static ssize_t mmc_dsr_show(struct device *dev, > @@ -709,6 +710,7 @@ static ssize_t mmc_dsr_show(struct device *dev, > &dev_attr_oemid.attr, > &dev_attr_serial.attr, > &dev_attr_ocr.attr, > + &dev_attr_rca.attr, > &dev_attr_dsr.attr, > NULL, > }; > -- > 1.9.1 > Any comments/inputs on this ? Thanks, Harish Jenny K N
Re: [PATCH] mmc: card: Don't show eMMC RPMB and BOOT areas in /proc/partitions
On Friday 02 March 2018 06:23 PM, Linus Walleij wrote: > On Tue, Feb 27, 2018 at 12:33 PM, Harish Jenny K N > wrote: > >> From: Andrew Gabbasov >> >> Since RPMB area is accessible via special ioctl only and boot areas >> are unlikely to contain any partitions, exclude them all from listing >> in /proc/partitions. This will hide them from various user-level >> software (e.g. fdisk), thus avoiding unnecessary access attempts. >> >> Signed-off-by: Andrew Gabbasov >> Signed-off-by: Harish Jenny K N > Makes sense to me, at least it makes the problem smaller not bigger. > Reviewed-by: Linus Walleij Any other comments/inputs on this ? Thanks, Harish Jenny K N
Re: [PATCH v3] mmc: Export host capabilities to debugfs.
On Monday 05 March 2018 05:43 PM, Ulf Hansson wrote: > On 5 March 2018 at 10:28, Harish Jenny K N wrote: >> From: Abbas Raza >> >> This patch exports the host capabilities to debugfs >> >> Signed-off-by: Abbas Raza >> Signed-off-by: Andrew Gabbasov >> Signed-off-by: Harish Jenny K N >> --- >> >> Changes in v3: >> - Removed typecasting of &host->caps to (u32 *) >> >> Changes in v2: >> - Changed Author >> >> drivers/mmc/core/debugfs.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c >> index c51e0c0..570c9e4 100644 >> --- a/drivers/mmc/core/debugfs.c >> +++ b/drivers/mmc/core/debugfs.c >> @@ -289,6 +289,9 @@ void mmc_add_card_debugfs(struct mmc_card *card) >> >> card->debugfs_root = root; >> >> + if (!debugfs_create_x32("host_caps", S_IRUSR, root, &host->caps)) >> + goto err; >> + > This isn't the correct place to created the node(s). Please move this > to mmc_add_host_debugfs(). > > Moreover, I suggest you export both caps and caps2 in the same change, > there is no need to have two changes for that - and finally name the > nodes to "caps" and "caps2". Addressed your review findings in v4 patch. Thanks, Harish Jenny K N
[PATCH v4] mmc: Export host capabilities to debugfs.
From: Abbas Raza This patch exports the host capabilities to debugfs Signed-off-by: Abbas Raza Signed-off-by: Andrew Gabbasov [Harish: Added caps2, moved creation to mmc_add_host_debugfs] Signed-off-by: Harish Jenny K N --- 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 | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index c51e0c0..d2275c5 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -243,6 +243,12 @@ 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_x32("caps", S_IRUSR, root, &host->caps)) + goto err_node; + + if (!debugfs_create_x32("caps2", S_IRUSR, root, &host->caps2)) + goto err_node; + if (!debugfs_create_file("clock", S_IRUSR | S_IWUSR, root, host, &mmc_clock_fops)) goto err_node; -- 1.9.1
[PATCH] mmc: Export host capabilities to debugfs.
From: Abbas Raza This patch exports the host capabilities to debugfs Signed-off-by: Abbas Raza Signed-off-by: Andrew Gabbasov [Harish: Added caps2, moved creation to mmc_add_host_debugfs] Signed-off-by: Harish Jenny K N --- 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 | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index c51e0c0..d2275c5 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -243,6 +243,12 @@ 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_x32("caps", S_IRUSR, root, &host->caps)) + goto err_node; + + if (!debugfs_create_x32("caps2", S_IRUSR, root, &host->caps2)) + goto err_node; + if (!debugfs_create_file("clock", S_IRUSR | S_IWUSR, root, host, &mmc_clock_fops)) goto err_node; -- 1.9.1
[PATCH v3] mmc: Export host capabilities to debugfs.
From: Abbas Raza This patch exports the host capabilities to debugfs Signed-off-by: Abbas Raza Signed-off-by: Andrew Gabbasov Signed-off-by: Harish Jenny K N --- Changes in v3: - Removed typecasting of &host->caps to (u32 *) Changes in v2: - Changed Author drivers/mmc/core/debugfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index c51e0c0..570c9e4 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -289,6 +289,9 @@ void mmc_add_card_debugfs(struct mmc_card *card) card->debugfs_root = root; + if (!debugfs_create_x32("host_caps", S_IRUSR, root, &host->caps)) + goto err; + if (!debugfs_create_x32("state", S_IRUSR, root, &card->state)) goto err; -- 1.9.1
Re: [PATCH v2] mmc: Export host capabilities to debugfs.
On Monday 05 March 2018 01:21 PM, Shawn Lin wrote: > On 2018/3/5 12:24, Harish Jenny K N wrote: >> From: Abbas Raza >> >> This patch exports the host capabilities to debugfs >> >> Signed-off-by: Abbas Raza >> Signed-off-by: Andrew Gabbasov >> Signed-off-by: Harish Jenny K N >> --- >> >> Changes in v2: >> - Changed Author >> >> drivers/mmc/core/debugfs.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c >> index c51e0c0..fa2df7f 100644 >> --- a/drivers/mmc/core/debugfs.c >> +++ b/drivers/mmc/core/debugfs.c >> @@ -289,6 +289,9 @@ void mmc_add_card_debugfs(struct mmc_card *card) >> card->debugfs_root = root; >> + if (!debugfs_create_x32("host_caps", S_IRUSR, root, (u32 >> *)&host->caps)) > > Perhaps you don't need cast, and '&host->caps' should be fine? Yes. I will send updated patch. > And you don't need to export host->caps2? I will send this is as a separate patch, as this also requires changes in mmc-utils sample application to parse the value. Thanks, Harish Jenny K N
[PATCH v2] mmc: Export host capabilities to debugfs.
From: Abbas Raza This patch exports the host capabilities to debugfs Signed-off-by: Abbas Raza Signed-off-by: Andrew Gabbasov Signed-off-by: Harish Jenny K N --- Changes in v2: - Changed Author drivers/mmc/core/debugfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index c51e0c0..fa2df7f 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -289,6 +289,9 @@ void mmc_add_card_debugfs(struct mmc_card *card) card->debugfs_root = root; + if (!debugfs_create_x32("host_caps", S_IRUSR, root, (u32 *)&host->caps)) + goto err; + if (!debugfs_create_x32("state", S_IRUSR, root, &card->state)) goto err; -- 1.9.1
Re: [PATCH] mmc: Export host capabilities to debugfs.
On Saturday 03 March 2018 10:02 PM, Vladimir Zapolskiy wrote: > Hi Harish, > > On 03/01/2018 03:17 PM, Harish Jenny K N wrote: >> This patch exports the host capabilities to debugfs >> >> Signed-off-by: Andrew Gabbasov >> Signed-off-by: Harish Jenny K N >> --- > would you mind to restore the authorship to Abbas Raza and send v2? Sure. Abbas had left Mentor and this was being done as part of new project. Still, I will resend the patch by changing the Author. Thanks, Harish
Re: [PATCH] mmc: Export host capabilities to debugfs.
On Thursday 01 March 2018 07:54 PM, Linus Walleij wrote: > On Thu, Mar 1, 2018 at 2:17 PM, Harish Jenny K N > wrote: > > Thanks for your patch! > >> This patch exports the host capabilities to debugfs >> >> Signed-off-by: Andrew Gabbasov >> Signed-off-by: Harish Jenny K N > Is there a corresponding patch to the mmc utils to make use > of the exported information? An opaque u32 seems pretty hard > to interpret. > > Yours, > Linus Walleij A sample patch "[RFC PATCH] mmc-utils: host_caps: Add parser to read host capabilities" is submitted. Thanks, Harish Jenny K N
[PATCH] mmc: Export host capabilities to debugfs.
This patch exports the host capabilities to debugfs Signed-off-by: Andrew Gabbasov Signed-off-by: Harish Jenny K N --- drivers/mmc/core/debugfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index c51e0c0..fa2df7f 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -289,6 +289,9 @@ void mmc_add_card_debugfs(struct mmc_card *card) card->debugfs_root = root; + if (!debugfs_create_x32("host_caps", S_IRUSR, root, (u32 *)&host->caps)) + goto err; + if (!debugfs_create_x32("state", S_IRUSR, root, &card->state)) goto err; -- 1.9.1
Re: [PATCH] mmc: card: Don't show eMMC RPMB and BOOT areas in /proc/partitions
On Tuesday 27 February 2018 08:28 PM, Alex Lemberg wrote: > Hi Andrew, > > While RPMB partition requires special IOCTL, the boot partition is only > requires "switch partition", which is not unusual operation in eMMC. > Why to prevent users access boot partition? > > Thanks, > Alex The main intention of the patch was to not have RPMB device in /proc/partitions. Boot partitions are also unlikely to have any partitioning, so it made sense to treat them the same way as RPMB and not list in /proc/partitions. Now I see that RPMB is converted to a character device and this change may not be required for RPMB. Correct me if I am wrong. Also any comments are welcome. Thanks, Harish Jenny K N
[PATCH] mmc: Export card RCA register to sysfs.
This patch exports RCA register to sysfs which will help in reading the disk identification information. Signed-off-by: Harish Jenny K N --- drivers/mmc/core/mmc.c | 2 ++ drivers/mmc/core/sd.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 208a762..d45a244 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -792,6 +792,7 @@ static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width) MMC_DEV_ATTR(raw_rpmb_size_mult, "%#x\n", card->ext_csd.raw_rpmb_size_mult); MMC_DEV_ATTR(rel_sectors, "%#x\n", card->ext_csd.rel_sectors); MMC_DEV_ATTR(ocr, "0x%08x\n", card->ocr); +MMC_DEV_ATTR(rca, "0x%x\n", card->rca); MMC_DEV_ATTR(cmdq_en, "%d\n", card->ext_csd.cmdq_en); static ssize_t mmc_fwrev_show(struct device *dev, @@ -848,6 +849,7 @@ static ssize_t mmc_dsr_show(struct device *dev, &dev_attr_raw_rpmb_size_mult.attr, &dev_attr_rel_sectors.attr, &dev_attr_ocr.attr, + &dev_attr_rca.attr, &dev_attr_dsr.attr, &dev_attr_cmdq_en.attr, NULL, diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 62b84dd..17d9005 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -676,6 +676,7 @@ static int mmc_sd_init_uhs_card(struct mmc_card *card) MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid); MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial); MMC_DEV_ATTR(ocr, "0x%08x\n", card->ocr); +MMC_DEV_ATTR(rca, "0x%x\n", card->rca); static ssize_t mmc_dsr_show(struct device *dev, @@ -709,6 +710,7 @@ static ssize_t mmc_dsr_show(struct device *dev, &dev_attr_oemid.attr, &dev_attr_serial.attr, &dev_attr_ocr.attr, + &dev_attr_rca.attr, &dev_attr_dsr.attr, NULL, }; -- 1.9.1
[PATCH] mmc: card: Don't show eMMC RPMB and BOOT areas in /proc/partitions
From: Andrew Gabbasov Since RPMB area is accessible via special ioctl only and boot areas are unlikely to contain any partitions, exclude them all from listing in /proc/partitions. This will hide them from various user-level software (e.g. fdisk), thus avoiding unnecessary access attempts. Signed-off-by: Andrew Gabbasov Signed-off-by: Harish Jenny K N --- drivers/mmc/core/block.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 20135a5..376e47e 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -2341,7 +2341,8 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, set_disk_ro(md->disk, md->read_only || default_ro); md->disk->flags = GENHD_FL_EXT_DEVT; if (area_type & (MMC_BLK_DATA_AREA_RPMB | MMC_BLK_DATA_AREA_BOOT)) - md->disk->flags |= GENHD_FL_NO_PART_SCAN; + md->disk->flags |= GENHD_FL_NO_PART_SCAN + | GENHD_FL_SUPPRESS_PARTITION_INFO; /* * As discussed on lkml, GENHD_FL_REMOVABLE should: -- 1.9.1
[PATCH v2 1/3] usb: gadget: NCM: link socket buffers to the device for tx packets
From: Torsten Polle Socket buffers should be linked to the (network) device that allocated the buffers. Signed-off-by: Torsten Polle Signed-off-by: Harish Jenny K N --- drivers/usb/gadget/function/f_ncm.c |3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c index 6396037..b6771ad 100644 --- a/drivers/usb/gadget/function/f_ncm.c +++ b/drivers/usb/gadget/function/f_ncm.c @@ -1078,6 +1078,7 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port, if (!ncm->skb_tx_data) goto err; + ncm->skb_tx_data->dev = ncm->netdev; ntb_data = (void *) skb_put(ncm->skb_tx_data, ncb_len); memset(ntb_data, 0, ncb_len); /* dwSignature */ @@ -1096,6 +1097,8 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port, GFP_ATOMIC); if (!ncm->skb_tx_ndp) goto err; + + ncm->skb_tx_ndp->dev = ncm->netdev; ntb_ndp = (void *) skb_put(ncm->skb_tx_ndp, opts->ndp_size); memset(ntb_ndp, 0, ncb_len); -- 1.7.9.5
[PATCH v2 2/3] usb: gadget: u_ether: link socket buffers to the device for received packets
From: Torsten Polle Socket buffers should be linked to the (network) device that allocated the buffers. __netdev_alloc_skb performs this task. Signed-off-by: Torsten Polle Signed-off-by: Jim Baxter Signed-off-by: Harish Jenny K N --- Change from v1 to v2 Subject line changed drivers/usb/gadget/function/u_ether.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c index 8cb0803..d8593c7 100644 --- a/drivers/usb/gadget/function/u_ether.c +++ b/drivers/usb/gadget/function/u_ether.c @@ -224,7 +224,7 @@ static void defer_kevent(struct eth_dev *dev, int flag) if (dev->port_usb->is_fixed) size = max_t(size_t, size, dev->port_usb->fixed_out_len); - skb = alloc_skb(size + NET_IP_ALIGN, gfp_flags); + skb = __netdev_alloc_skb(dev->net, size + NET_IP_ALIGN, gfp_flags); if (skb == NULL) { DBG(dev, "no rx skb\n"); goto enomem; -- 1.7.9.5
[PATCH v2 3/3] usb: gadget: NCM: differentiate consumed packets from dropped packets
From: Torsten Polle dev_kfree_skb_any() is used to free packets that are dropped by the network stack. Therefore the function should not be used for packets that have been successfully processed by the network stack. Instead dev_consume_skb_any() has to be used for such consumed packets. This separation helps to identify dropped packets. Signed-off-by: Torsten Polle Signed-off-by: Harish Jenny K N --- drivers/usb/gadget/function/f_ncm.c |8 drivers/usb/gadget/function/u_ether.c |3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c index b6771ad..e8008fa 100644 --- a/drivers/usb/gadget/function/f_ncm.c +++ b/drivers/usb/gadget/function/f_ncm.c @@ -998,7 +998,7 @@ static struct sk_buff *package_for_tx(struct f_ncm *ncm) /* Merge the skbs */ swap(skb2, ncm->skb_tx_data); if (ncm->skb_tx_data) { - dev_kfree_skb_any(ncm->skb_tx_data); + dev_consume_skb_any(ncm->skb_tx_data); ncm->skb_tx_data = NULL; } @@ -1009,7 +1009,7 @@ static struct sk_buff *package_for_tx(struct f_ncm *ncm) /* Copy NTB across. */ ntb_iter = (void *) skb_put(skb2, ncm->skb_tx_ndp->len); memcpy(ntb_iter, ncm->skb_tx_ndp->data, ncm->skb_tx_ndp->len); - dev_kfree_skb_any(ncm->skb_tx_ndp); + dev_consume_skb_any(ncm->skb_tx_ndp); ncm->skb_tx_ndp = NULL; /* Insert zero'd datagram. */ @@ -1136,7 +1136,7 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port, memset(ntb_data, 0, dgram_pad); ntb_data = (void *) skb_put(ncm->skb_tx_data, skb->len); memcpy(ntb_data, skb->data, skb->len); - dev_kfree_skb_any(skb); + dev_consume_skb_any(skb); skb = NULL; } else if (ncm->skb_tx_data && ncm->timer_force_tx) { @@ -1332,7 +1332,7 @@ static int ncm_unwrap_ntb(struct gether *port, } while (ndp_len > 2 * (opts->dgram_item_len * 2)); } while (ndp_index); - dev_kfree_skb_any(skb); + dev_consume_skb_any(skb); VDBG(port->func.config->cdev, "Parsed NTB with %d frames\n", dgram_counter); diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c index d8593c7..8a6be06 100644 --- a/drivers/usb/gadget/function/u_ether.c +++ b/drivers/usb/gadget/function/u_ether.c @@ -455,16 +455,17 @@ static void tx_complete(struct usb_ep *ep, struct usb_request *req) /* FALLTHROUGH */ case -ECONNRESET: /* unlink */ case -ESHUTDOWN:/* disconnect etc */ + dev_kfree_skb_any(skb); break; case 0: dev->net->stats.tx_bytes += skb->len; + dev_consume_skb_any(skb); } dev->net->stats.tx_packets++; spin_lock(&dev->req_lock); list_add(&req->list, &dev->tx_reqs); spin_unlock(&dev->req_lock); - dev_kfree_skb_any(skb); atomic_dec(&dev->tx_qlen); if (netif_carrier_ok(dev->net)) -- 1.7.9.5
[PATCH v2 0/3] Usb gadget ncm code cleanup
This patchset consists of some code cleanup in usb gadget ncm code. Note: Testing has only been done on an ARM i.MX6 based platform. --- Change from v1 to v2 Subject line changed on Patch 2. Torsten Polle (3): usb: gadget: NCM: link socket buffers to the device for tx packets usb: gadget: u_ether: link socket buffers to the device for received packets usb: gadget: NCM: differentiate consumed packets from dropped packets drivers/usb/gadget/function/f_ncm.c | 11 +++ drivers/usb/gadget/function/u_ether.c |5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) -- 1.7.9.5
Re: [PATCH v1 2/3] usb: gadget: NCM: link socket buffers to the device for received packets
>>>>> On Thursday 15 September 2016 08:35 PM, Yauheni Kaliuta wrote: >Is subject a bit misleading, it's more generic, then NCM? Agreed. I will submit v2 patchset. WBR, Harish Jenny K N
[PATCH v1 2/3] usb: gadget: NCM: link socket buffers to the device for received packets
From: Torsten Polle Socket buffers should be linked to the (network) device that allocated the buffers. __netdev_alloc_skb performs this task. Signed-off-by: Torsten Polle Signed-off-by: Jim Baxter Signed-off-by: Harish Jenny K N --- drivers/usb/gadget/function/u_ether.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c index 8cb0803..d8593c7 100644 --- a/drivers/usb/gadget/function/u_ether.c +++ b/drivers/usb/gadget/function/u_ether.c @@ -224,7 +224,7 @@ static void defer_kevent(struct eth_dev *dev, int flag) if (dev->port_usb->is_fixed) size = max_t(size_t, size, dev->port_usb->fixed_out_len); - skb = alloc_skb(size + NET_IP_ALIGN, gfp_flags); + skb = __netdev_alloc_skb(dev->net, size + NET_IP_ALIGN, gfp_flags); if (skb == NULL) { DBG(dev, "no rx skb\n"); goto enomem; -- 1.7.9.5
[PATCH v1 3/3] usb: gadget: NCM: differentiate consumed packets from dropped packets
From: Torsten Polle dev_kfree_skb_any() is used to free packets that are dropped by the network stack. Therefore the function should not be used for packets that have been successfully processed by the network stack. Instead dev_consume_skb_any() has to be used for such consumed packets. This separation helps to identify dropped packets. Signed-off-by: Torsten Polle Signed-off-by: Harish Jenny K N --- drivers/usb/gadget/function/f_ncm.c |8 drivers/usb/gadget/function/u_ether.c |3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c index b6771ad..e8008fa 100644 --- a/drivers/usb/gadget/function/f_ncm.c +++ b/drivers/usb/gadget/function/f_ncm.c @@ -998,7 +998,7 @@ static struct sk_buff *package_for_tx(struct f_ncm *ncm) /* Merge the skbs */ swap(skb2, ncm->skb_tx_data); if (ncm->skb_tx_data) { - dev_kfree_skb_any(ncm->skb_tx_data); + dev_consume_skb_any(ncm->skb_tx_data); ncm->skb_tx_data = NULL; } @@ -1009,7 +1009,7 @@ static struct sk_buff *package_for_tx(struct f_ncm *ncm) /* Copy NTB across. */ ntb_iter = (void *) skb_put(skb2, ncm->skb_tx_ndp->len); memcpy(ntb_iter, ncm->skb_tx_ndp->data, ncm->skb_tx_ndp->len); - dev_kfree_skb_any(ncm->skb_tx_ndp); + dev_consume_skb_any(ncm->skb_tx_ndp); ncm->skb_tx_ndp = NULL; /* Insert zero'd datagram. */ @@ -1136,7 +1136,7 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port, memset(ntb_data, 0, dgram_pad); ntb_data = (void *) skb_put(ncm->skb_tx_data, skb->len); memcpy(ntb_data, skb->data, skb->len); - dev_kfree_skb_any(skb); + dev_consume_skb_any(skb); skb = NULL; } else if (ncm->skb_tx_data && ncm->timer_force_tx) { @@ -1332,7 +1332,7 @@ static int ncm_unwrap_ntb(struct gether *port, } while (ndp_len > 2 * (opts->dgram_item_len * 2)); } while (ndp_index); - dev_kfree_skb_any(skb); + dev_consume_skb_any(skb); VDBG(port->func.config->cdev, "Parsed NTB with %d frames\n", dgram_counter); diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c index d8593c7..8a6be06 100644 --- a/drivers/usb/gadget/function/u_ether.c +++ b/drivers/usb/gadget/function/u_ether.c @@ -455,16 +455,17 @@ static void tx_complete(struct usb_ep *ep, struct usb_request *req) /* FALLTHROUGH */ case -ECONNRESET: /* unlink */ case -ESHUTDOWN:/* disconnect etc */ + dev_kfree_skb_any(skb); break; case 0: dev->net->stats.tx_bytes += skb->len; + dev_consume_skb_any(skb); } dev->net->stats.tx_packets++; spin_lock(&dev->req_lock); list_add(&req->list, &dev->tx_reqs); spin_unlock(&dev->req_lock); - dev_kfree_skb_any(skb); atomic_dec(&dev->tx_qlen); if (netif_carrier_ok(dev->net)) -- 1.7.9.5
[PATCH v1 1/3] usb: gadget: NCM: link socket buffers to the device for tx packets
From: Torsten Polle Socket buffers should be linked to the (network) device that allocated the buffers. Signed-off-by: Torsten Polle Signed-off-by: Harish Jenny K N --- drivers/usb/gadget/function/f_ncm.c |3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c index 6396037..b6771ad 100644 --- a/drivers/usb/gadget/function/f_ncm.c +++ b/drivers/usb/gadget/function/f_ncm.c @@ -1078,6 +1078,7 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port, if (!ncm->skb_tx_data) goto err; + ncm->skb_tx_data->dev = ncm->netdev; ntb_data = (void *) skb_put(ncm->skb_tx_data, ncb_len); memset(ntb_data, 0, ncb_len); /* dwSignature */ @@ -1096,6 +1097,8 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port, GFP_ATOMIC); if (!ncm->skb_tx_ndp) goto err; + + ncm->skb_tx_ndp->dev = ncm->netdev; ntb_ndp = (void *) skb_put(ncm->skb_tx_ndp, opts->ndp_size); memset(ntb_ndp, 0, ncb_len); -- 1.7.9.5
[PATCH v1 0/3] Usb gadget ncm code cleanup
This patchset consists of some code cleanup in usb gadget ncm code. Note: Testing has only been done on an ARM i.MX6 based platform. Torsten Polle (3): usb: gadget: NCM: link socket buffers to the device for tx packets usb: gadget: NCM: link socket buffers to the device for received packets usb: gadget: NCM: differentiate consumed packets from dropped packets drivers/usb/gadget/function/f_ncm.c | 11 +++ drivers/usb/gadget/function/u_ether.c |5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) -- 1.7.9.5
[PATCH v1 2/2] usb: gadget: NCM: Protect dev->port_usb using dev->lock
This commit incorporates findings from https://lkml.org/lkml/2016/4/25/594 The function has been modified to make sure we hold the dev lock when accessing the net device pointer. Acked-by: Jim Baxter Signed-off-by: Harish Jenny K N --- drivers/usb/gadget/function/u_ether.c |7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c index 9c8c9ed..8cb0803 100644 --- a/drivers/usb/gadget/function/u_ether.c +++ b/drivers/usb/gadget/function/u_ether.c @@ -553,14 +553,16 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb, spin_lock_irqsave(&dev->lock, flags); if (dev->port_usb) skb = dev->wrap(dev->port_usb, skb); - spin_unlock_irqrestore(&dev->lock, flags); if (!skb) { /* Multi frame CDC protocols may store the frame for * later which is not a dropped frame. */ if (dev->port_usb && - dev->port_usb->supports_multi_frame) + dev->port_usb->supports_multi_frame) { + spin_unlock_irqrestore(&dev->lock, flags); goto multiframe; + } + spin_unlock_irqrestore(&dev->lock, flags); goto drop; } } @@ -578,6 +580,7 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb, req->zero = 0; else req->zero = 1; + spin_unlock_irqrestore(&dev->lock, flags); /* use zlp framing on tx for strict CDC-Ether conformance, * though any robust network rx path ignores extra padding. -- 1.7.9.5
[PATCH v1 1/2] usb: gadget: u_ether: fix another dereference after null check
dev->port_usb is checked for null pointer previously, so dev->port_usb might be null during no zlp check, fix it by adding null pointer check. Acked-by: Jim Baxter Signed-off-by: Harish Jenny K N --- drivers/usb/gadget/function/u_ether.c |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c index 3be4b93..9c8c9ed 100644 --- a/drivers/usb/gadget/function/u_ether.c +++ b/drivers/usb/gadget/function/u_ether.c @@ -571,7 +571,8 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb, req->complete = tx_complete; /* NCM requires no zlp if transfer is dwNtbInMaxSize */ - if (dev->port_usb->is_fixed && + if (dev->port_usb && + dev->port_usb->is_fixed && length == dev->port_usb->fixed_in_len && (length % in->maxpacket) == 0) req->zero = 0; -- 1.7.9.5
[PATCH v1 0/2] usb: gadget: NCM: NULL pointer dereference in eth_start_xmit
This patchset incorporates findings from https://lkml.org/lkml/2016/4/25/690 When submitting patch https://lkml.org/lkml/2016/4/25/594, few observations from Alan from https://lkml.org/lkml/2016/4/25/690 needed to be incorporated. We find that the changes are already taken to linux-next repo by another commit 88c09eacf560c3303d0ee8cf91b8b7ff7f000350. Hence this patchset only adds the remaining findings. Harish Jenny K N (2): usb: gadget: u_ether: fix another dereference after null check usb: gadget: NCM: Protect dev->port_usb using dev->lock drivers/usb/gadget/function/u_ether.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 1.7.9.5
[PATCH v1 1/1] usb: gadget: f_fs: Stop ffs_closed NULL pointers.
From: Jim Baxter The struct ffs_data::private_data has a pointer to ffs_dev stored in it during the ffs_fs_mount() function however it is not cleared when the ffs_dev is freed later which causes the ffs_closed function to crash with "Unable to handle kernel NULL pointer dereference" error when using the data in ffs_data::private_data. This clears this pointer during the ffs_free_dev clean up function. Signed-off-by: Jim Baxter Signed-off-by: Jiada Wang Signed-off-by: Harish Jenny K N --- drivers/usb/gadget/function/f_fs.c |5 + 1 file changed, 5 insertions(+) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 5c8429f..b309650 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -3470,6 +3470,11 @@ static void _ffs_free_dev(struct ffs_dev *dev) list_del(&dev->entry); if (dev->name_allocated) kfree(dev->name); + + /* Clear the private_data pointer to stop incorrect dev access */ + if (dev->ffs_data) + dev->ffs_data->private_data = NULL; + kfree(dev); if (list_empty(&ffs_devices)) functionfs_cleanup(); -- 1.7.9.5
[PATCH v1 0/1] usb: gadget: f_fs: Stop ffs_closed NULL pointers
This patchset fixes the crash in ffs_closed during a disconnect of a USB composite FFS session. The issue was caused by the use of an outdated pointer in ffs_closed which had been deleted and not Nulled. Note: Testing has only been done on an ARM i.MX6 based platform. Jim Baxter (1): usb: gadget: f_fs: Stop ffs_closed NULL pointers. drivers/usb/gadget/function/f_fs.c |5 + 1 file changed, 5 insertions(+) -- 1.7.9.5
[PATCH] Bluetooth: Fix use after free in l2cap_chan_timeout
There is a potential use after free in bt_sock_poll when a socket gets killed without getting unlinked from accept_q. Hence added code to unlink from accpept_q by calling teardown before freeing the socket for channel type L2CAP_CHAN_CONN_ORIENTED. Signed-off-by: Harish Jenny K N --- net/bluetooth/l2cap_core.c |5 + 1 file changed, 5 insertions(+) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 6ba33f9..c6955fb 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -415,6 +415,11 @@ static void l2cap_chan_timeout(struct work_struct *work) l2cap_chan_close(chan, reason); + if ((chan->state == BT_CONNECTED || chan->state == BT_CONFIG) && + chan->chan_type == L2CAP_CHAN_CONN_ORIENTED) { + chan->ops->teardown(chan, 0); + } + l2cap_chan_unlock(chan); chan->ops->close(chan); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] Bluetooth: Fix use after free in l2cap_chan_timeout
There is a potential use after free in bt_sock_poll when a socket gets killed without getting unlinked from accept_q. Hence added code to unlink from accpept_q by calling teardown before freeing the socket for channel type L2CAP_CHAN_CONN_ORIENTED. Signed-off-by: Harish Jenny K N --- net/bluetooth/l2cap_core.c |5 + 1 file changed, 5 insertions(+) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 6ba33f9..3c3421e 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -415,6 +415,11 @@ static void l2cap_chan_timeout(struct work_struct *work) l2cap_chan_close(chan, reason); + if (((chan->state == BT_CONNECTED) || (chan->state == BT_CONFIG)) && + chan->chan_type == L2CAP_CHAN_CONN_ORIENTED) { + chan->ops->teardown(chan, 0); + } + l2cap_chan_unlock(chan); chan->ops->close(chan); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/