Viewing many gadgets in error under Windows with mass storage function and configfs

2015-07-02 Thread Gregory CLEMENT
Hello,

When I use configs to configure the mass storage function for the
gadget, and when the device is plugged under Windows, then the
partition that I expose is well managed, but I also see 7 other gadget
in the device manager with error.

This seven bogus gadget seems to be the 7 other LUN that are not
used. Indeed if I apply this dirty patch:

diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
b/drivers/usb/gadget/function/f_mass_storage.c
index 3cc109f..2b4ae98 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -3511,7 +3511,8 @@ static struct usb_function_instance *fsg_alloc_inst(void)
rc = PTR_ERR(opts-common);
goto release_opts;
}
-   rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
+// rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
+   rc = fsg_common_set_nluns(opts-common, 1);
if (rc)
goto release_opts;

Then there is no more gadget error under Windows. As the value of
FSG_MAX_LUNS is 8 and in my configuration I only use one partition,
then it makes sens that I see 7 bogus gadgets.

I also saw that in the legacy driver, it was possible to modify the
number of LUN using the module parameter file_count.

There is no such parameter when using configfs.

What would be the correct way to fix it?

I thought about enumerate how many LUN where configured through
configfs and then setting the exact number using fsg_common_set_nluns.

There is no problem at all under Linux so maybe it is jut the way how
the gadget is exposed through USB.

I tested it on the kernel 3.17 and 4.1 using the musb of the SoC
AM335x.

Thanks for your feedback.

Gregory

-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Viewing many gadgets in error under Windows with mass storage function and configfs

2015-07-02 Thread Felipe Balbi
Hi,

On Thu, Jul 02, 2015 at 12:51:54PM +0200, Gregory CLEMENT wrote:
 Hello,
 
 When I use configs to configure the mass storage function for the
 gadget, and when the device is plugged under Windows, then the
 partition that I expose is well managed, but I also see 7 other gadget
 in the device manager with error.
 
 This seven bogus gadget seems to be the 7 other LUN that are not
 used. Indeed if I apply this dirty patch:
 
 diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
 b/drivers/usb/gadget/function/f_mass_storage.c
 index 3cc109f..2b4ae98 100644
 --- a/drivers/usb/gadget/function/f_mass_storage.c
 +++ b/drivers/usb/gadget/function/f_mass_storage.c
 @@ -3511,7 +3511,8 @@ static struct usb_function_instance 
 *fsg_alloc_inst(void)
 rc = PTR_ERR(opts-common);
 goto release_opts;
 }
 -   rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
 +// rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
 +   rc = fsg_common_set_nluns(opts-common, 1);
 if (rc)
 goto release_opts;
 
 Then there is no more gadget error under Windows. As the value of
 FSG_MAX_LUNS is 8 and in my configuration I only use one partition,
 then it makes sens that I see 7 bogus gadgets.
 
 I also saw that in the legacy driver, it was possible to modify the
 number of LUN using the module parameter file_count.

This has been reported. Michal was working on a fix, but the patch
hasn't been applied yet.

 There is no such parameter when using configfs.
 
 What would be the correct way to fix it?

Making sure you don't lie to the other side of the cable :-)

 I thought about enumerate how many LUN where configured through
 configfs and then setting the exact number using fsg_common_set_nluns.

yeah, that should be the way.

 There is no problem at all under Linux so maybe it is jut the way how
 the gadget is exposed through USB.

no, we shouldn't really lie, this really needs fixing.

 
 I tested it on the kernel 3.17 and 4.1 using the musb of the SoC
 AM335x.
 
 Thanks for your feedback.
 
 Gregory
 
 -- 
 Gregory Clement, Free Electrons
 Kernel, drivers, real-time and embedded Linux
 development, consulting, training and support.
 http://free-electrons.com

-- 
balbi


signature.asc
Description: Digital signature


Re: Viewing many gadgets in error under Windows with mass storage function and configfs

2015-07-02 Thread Felipe Balbi
On Thu, Jul 02, 2015 at 02:55:34PM +0200, Krzysztof Opasiak wrote:
 
 
 On 07/02/2015 02:45 PM, Michal Nazarewicz wrote:
 On Thu, Jul 02, 2015 at 12:51:54PM +0200, Gregory CLEMENT wrote:
 When I use configs to configure the mass storage function for the
 gadget, and when the device is plugged under Windows, then the
 partition that I expose is well managed, but I also see 7 other gadget
 in the device manager with error.
 
 This seven bogus gadget seems to be the 7 other LUN that are not
 used. Indeed if I apply this dirty patch:
 
 diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
 b/drivers/usb/gadget/function/f_mass_storage.c
 index 3cc109f..2b4ae98 100644
 --- a/drivers/usb/gadget/function/f_mass_storage.c
 +++ b/drivers/usb/gadget/function/f_mass_storage.c
 @@ -3511,7 +3511,8 @@ static struct usb_function_instance 
 *fsg_alloc_inst(void)
  rc = PTR_ERR(opts-common);
  goto release_opts;
  }
 -   rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
 +// rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
 +   rc = fsg_common_set_nluns(opts-common, 1);
  if (rc)
  goto release_opts;
 
 Then there is no more gadget error under Windows. As the value of
 FSG_MAX_LUNS is 8 and in my configuration I only use one partition,
 then it makes sens that I see 7 bogus gadgets.
 
 I also saw that in the legacy driver, it was possible to modify the
 number of LUN using the module parameter file_count.
 
 On Thu, Jul 02 2015, Felipe Balbi wrote:
 This has been reported. Michal was working on a fix, but the patch
 hasn't been applied yet.
 
 I’ve came up with [1], which you should feel free to test, but then
 Krzysztof came along with [2], which among other things addressed the
 LUN count issue, and I kind of stopped working on the issue waiting for
 his follow up.
 
 Sorry that it took so much time. I have been quite busy with some other
 things. I will send fixed version of that series in a few hours.

I'm taking Michal's patch as a quick fix for the -rc though. That patch
is simple enough to get in and solves the issue at hand.

-- 
balbi


signature.asc
Description: Digital signature


Re: Viewing many gadgets in error under Windows with mass storage function and configfs

2015-07-02 Thread Krzysztof Opasiak



On 07/02/2015 02:45 PM, Michal Nazarewicz wrote:

On Thu, Jul 02, 2015 at 12:51:54PM +0200, Gregory CLEMENT wrote:

When I use configs to configure the mass storage function for the
gadget, and when the device is plugged under Windows, then the
partition that I expose is well managed, but I also see 7 other gadget
in the device manager with error.

This seven bogus gadget seems to be the 7 other LUN that are not
used. Indeed if I apply this dirty patch:

diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
b/drivers/usb/gadget/function/f_mass_storage.c
index 3cc109f..2b4ae98 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -3511,7 +3511,8 @@ static struct usb_function_instance *fsg_alloc_inst(void)
 rc = PTR_ERR(opts-common);
 goto release_opts;
 }
-   rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
+// rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
+   rc = fsg_common_set_nluns(opts-common, 1);
 if (rc)
 goto release_opts;

Then there is no more gadget error under Windows. As the value of
FSG_MAX_LUNS is 8 and in my configuration I only use one partition,
then it makes sens that I see 7 bogus gadgets.

I also saw that in the legacy driver, it was possible to modify the
number of LUN using the module parameter file_count.


On Thu, Jul 02 2015, Felipe Balbi wrote:

This has been reported. Michal was working on a fix, but the patch
hasn't been applied yet.


I’ve came up with [1], which you should feel free to test, but then
Krzysztof came along with [2], which among other things addressed the
LUN count issue, and I kind of stopped working on the issue waiting for
his follow up.


Sorry that it took so much time. I have been quite busy with some other 
things. I will send fixed version of that series in a few hours.



--
Krzysztof Opasiak
Samsung RD Institute Poland
Samsung Electronics
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Viewing many gadgets in error under Windows with mass storage function and configfs

2015-07-02 Thread Felipe Balbi
Hi,

On Thu, Jul 02, 2015 at 01:58:44PM +0200, Gregory CLEMENT wrote:
 Hi Felipe,
 
 thanks for you prompt feedback.
 
 On 02/07/2015 13:45, Felipe Balbi wrote:
  Hi,
  
  On Thu, Jul 02, 2015 at 12:51:54PM +0200, Gregory CLEMENT wrote:
  Hello,
 
  When I use configs to configure the mass storage function for the
  gadget, and when the device is plugged under Windows, then the
  partition that I expose is well managed, but I also see 7 other gadget
  in the device manager with error.
 
  This seven bogus gadget seems to be the 7 other LUN that are not
  used. Indeed if I apply this dirty patch:
 
  diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
  b/drivers/usb/gadget/function/f_mass_storage.c
  index 3cc109f..2b4ae98 100644
  --- a/drivers/usb/gadget/function/f_mass_storage.c
  +++ b/drivers/usb/gadget/function/f_mass_storage.c
  @@ -3511,7 +3511,8 @@ static struct usb_function_instance 
  *fsg_alloc_inst(void)
  rc = PTR_ERR(opts-common);
  goto release_opts;
  }
  -   rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
  +// rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
  +   rc = fsg_common_set_nluns(opts-common, 1);
  if (rc)
  goto release_opts;
 
  Then there is no more gadget error under Windows. As the value of
  FSG_MAX_LUNS is 8 and in my configuration I only use one partition,
  then it makes sens that I see 7 bogus gadgets.
 
  I also saw that in the legacy driver, it was possible to modify the
  number of LUN using the module parameter file_count.
  
  This has been reported. Michal was working on a fix, but the patch
  hasn't been applied yet.
 
 Oh sorry to not have finding the thread about it.
 
  
  There is no such parameter when using configfs.
 
  What would be the correct way to fix it?
  
  Making sure you don't lie to the other side of the cable :-)
  
  I thought about enumerate how many LUN where configured through
  configfs and then setting the exact number using fsg_common_set_nluns.
  
  yeah, that should be the way.
  
  There is no problem at all under Linux so maybe it is jut the way how
  the gadget is exposed through USB.
  
  no, we shouldn't really lie, this really needs fixing.
 
 Ok so don't hesitate to ask me to test or if you need any help.

sure thing, here's the thread if you want to chip in:

http://www.spinics.net/lists/linux-usb/msg126284.html

-- 
balbi


signature.asc
Description: Digital signature


Re: Viewing many gadgets in error under Windows with mass storage function and configfs

2015-07-02 Thread Krzysztof Opasiak



On 07/02/2015 03:14 PM, Felipe Balbi wrote:

On Thu, Jul 02, 2015 at 02:55:34PM +0200, Krzysztof Opasiak wrote:



On 07/02/2015 02:45 PM, Michal Nazarewicz wrote:

On Thu, Jul 02, 2015 at 12:51:54PM +0200, Gregory CLEMENT wrote:

When I use configs to configure the mass storage function for the
gadget, and when the device is plugged under Windows, then the
partition that I expose is well managed, but I also see 7 other gadget
in the device manager with error.

This seven bogus gadget seems to be the 7 other LUN that are not
used. Indeed if I apply this dirty patch:

diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
b/drivers/usb/gadget/function/f_mass_storage.c
index 3cc109f..2b4ae98 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -3511,7 +3511,8 @@ static struct usb_function_instance *fsg_alloc_inst(void)
 rc = PTR_ERR(opts-common);
 goto release_opts;
 }
-   rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
+// rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
+   rc = fsg_common_set_nluns(opts-common, 1);
 if (rc)
 goto release_opts;

Then there is no more gadget error under Windows. As the value of
FSG_MAX_LUNS is 8 and in my configuration I only use one partition,
then it makes sens that I see 7 bogus gadgets.

I also saw that in the legacy driver, it was possible to modify the
number of LUN using the module parameter file_count.


On Thu, Jul 02 2015, Felipe Balbi wrote:

This has been reported. Michal was working on a fix, but the patch
hasn't been applied yet.


I’ve came up with [1], which you should feel free to test, but then
Krzysztof came along with [2], which among other things addressed the
LUN count issue, and I kind of stopped working on the issue waiting for
his follow up.


Sorry that it took so much time. I have been quite busy with some other
things. I will send fixed version of that series in a few hours.


I'm taking Michal's patch as a quick fix for the -rc though. That patch
is simple enough to get in and solves the issue at hand.



Nope it doesn't. It may read past buffer in case of legacy gadgets 
please see discussion in [1]


1 - http://marc.info/?l=linux-usbm=143498343720763w=2

BR's
--
Krzysztof Opasiak
Samsung RD Institute Poland
Samsung Electronics
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Viewing many gadgets in error under Windows with mass storage function and configfs

2015-07-02 Thread Michal Nazarewicz
 On Thu, Jul 02, 2015 at 12:51:54PM +0200, Gregory CLEMENT wrote:
 When I use configs to configure the mass storage function for the
 gadget, and when the device is plugged under Windows, then the
 partition that I expose is well managed, but I also see 7 other gadget
 in the device manager with error.
 
 This seven bogus gadget seems to be the 7 other LUN that are not
 used. Indeed if I apply this dirty patch:
 
 diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
 b/drivers/usb/gadget/function/f_mass_storage.c
 index 3cc109f..2b4ae98 100644
 --- a/drivers/usb/gadget/function/f_mass_storage.c
 +++ b/drivers/usb/gadget/function/f_mass_storage.c
 @@ -3511,7 +3511,8 @@ static struct usb_function_instance 
 *fsg_alloc_inst(void)
 rc = PTR_ERR(opts-common);
 goto release_opts;
 }
 -   rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
 +// rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
 +   rc = fsg_common_set_nluns(opts-common, 1);
 if (rc)
 goto release_opts;
 
 Then there is no more gadget error under Windows. As the value of
 FSG_MAX_LUNS is 8 and in my configuration I only use one partition,
 then it makes sens that I see 7 bogus gadgets.
 
 I also saw that in the legacy driver, it was possible to modify the
 number of LUN using the module parameter file_count.

On Thu, Jul 02 2015, Felipe Balbi wrote:
 This has been reported. Michal was working on a fix, but the patch
 hasn't been applied yet.

I’ve came up with [1], which you should feel free to test, but then
Krzysztof came along with [2], which among other things addressed the
LUN count issue, and I kind of stopped working on the issue waiting for
his follow up.

Since merge window is about to close, perhaps the solution is to get [1]
merged quickly so it shows up in 4.2 and then get approaches described
in [3] for the future.

[1]
http://news.gmane.org/find-root.php?message_id=xa1toak7j1rl.fsf%40mina86.com,
patch also attached at the end of the message
[2] 
http://news.gmane.org/find-root.php?message_id=1434979163%2d5942%2d1%2dgit%2dsend%2demail%2dk.opasiak%40samsung.com
[3] 
http://news.gmane.org/find-root.php?message_id=xa1t7fqvizh0.fsf%40mina86.com

- 8 ---
From 59b6ec98aa9c638f7d140ad0b6b5a30bb2ba4145 Mon Sep 17 00:00:00 2001
From: Michal Nazarewicz min...@mina86.com
Date: Fri, 19 Jun 2015 23:56:34 +0200
Subject: [PATCH] usb: f_mass_storage: limit number of reported LUNs

Mass storage function created via configfs always reports eight LUNs
to the hosts even if only one LUN has been configured.  Adjust the
number when the USB function is allocated based on LUNs that user
has created.

Signed-off-by: Michal Nazarewicz min...@mina86.com
Cc: sta...@vger.kernel.org
---
 drivers/usb/gadget/function/f_mass_storage.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
b/drivers/usb/gadget/function/f_mass_storage.c
index 3cc109f..e1beb14 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -2796,8 +2796,6 @@ int fsg_common_set_nluns(struct fsg_common *common, int 
nluns)
common-luns = curlun;
common-nluns = nluns;
 
-   pr_info(Number of LUNs=%d\n, common-nluns);
-
return 0;
 }
 EXPORT_SYMBOL_GPL(fsg_common_set_nluns);
@@ -3563,14 +3561,26 @@ static struct usb_function *fsg_alloc(struct 
usb_function_instance *fi)
struct fsg_opts *opts = fsg_opts_from_func_inst(fi);
struct fsg_common *common = opts-common;
struct fsg_dev *fsg;
+   unsigned nluns, i;
 
fsg = kzalloc(sizeof(*fsg), GFP_KERNEL);
if (unlikely(!fsg))
return ERR_PTR(-ENOMEM);
 
mutex_lock(opts-lock);
+   if (!opts-refcnt) {
+   for (nluns = i = 0; i  FSG_MAX_LUNS; ++i)
+   if (common-luns[i])
+   nluns = i + 1;
+   if (!nluns)
+   pr_warn(No LUNS defined, continuing anyway\n);
+   else
+   common-nluns = nluns;
+   pr_info(Number of LUNs=%u\n, common-nluns);
+   }
opts-refcnt++;
mutex_unlock(opts-lock);
+
fsg-function.name  = FSG_DRIVER_DESC;
fsg-function.bind  = fsg_bind;
fsg-function.unbind= fsg_unbind;

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--m...@google.com--xmpp:min...@jabber.org--ooO--(_)--Ooo--
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Viewing many gadgets in error under Windows with mass storage function and configfs

2015-07-02 Thread Gregory CLEMENT
Hi Felipe,

On 02/07/2015 15:14, Felipe Balbi wrote:
 On Thu, Jul 02, 2015 at 02:55:34PM +0200, Krzysztof Opasiak wrote:


 On 07/02/2015 02:45 PM, Michal Nazarewicz wrote:
 On Thu, Jul 02, 2015 at 12:51:54PM +0200, Gregory CLEMENT wrote:
 When I use configs to configure the mass storage function for the
 gadget, and when the device is plugged under Windows, then the
 partition that I expose is well managed, but I also see 7 other gadget
 in the device manager with error.

 This seven bogus gadget seems to be the 7 other LUN that are not
 used. Indeed if I apply this dirty patch:

 diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
 b/drivers/usb/gadget/function/f_mass_storage.c
 index 3cc109f..2b4ae98 100644
 --- a/drivers/usb/gadget/function/f_mass_storage.c
 +++ b/drivers/usb/gadget/function/f_mass_storage.c
 @@ -3511,7 +3511,8 @@ static struct usb_function_instance 
 *fsg_alloc_inst(void)
 rc = PTR_ERR(opts-common);
 goto release_opts;
 }
 -   rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
 +// rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
 +   rc = fsg_common_set_nluns(opts-common, 1);
 if (rc)
 goto release_opts;

 Then there is no more gadget error under Windows. As the value of
 FSG_MAX_LUNS is 8 and in my configuration I only use one partition,
 then it makes sens that I see 7 bogus gadgets.

 I also saw that in the legacy driver, it was possible to modify the
 number of LUN using the module parameter file_count.

 On Thu, Jul 02 2015, Felipe Balbi wrote:
 This has been reported. Michal was working on a fix, but the patch
 hasn't been applied yet.

 I’ve came up with [1], which you should feel free to test, but then
 Krzysztof came along with [2], which among other things addressed the
 LUN count issue, and I kind of stopped working on the issue waiting for
 his follow up.

 Sorry that it took so much time. I have been quite busy with some other
 things. I will send fixed version of that series in a few hours.
 
 I'm taking Michal's patch as a quick fix for the -rc though. That patch
 is simple enough to get in and solves the issue at hand.

I would like to test the patch, is it the one included in the following email ?

http://www.spinics.net/lists/linux-usb/msg126292.html


Thanks,

Gregory


-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Viewing many gadgets in error under Windows with mass storage function and configfs

2015-07-02 Thread Felipe Balbi
On Thu, Jul 02, 2015 at 03:52:32PM +0200, Gregory CLEMENT wrote:
 Hi Felipe,
 
 On 02/07/2015 15:14, Felipe Balbi wrote:
  On Thu, Jul 02, 2015 at 02:55:34PM +0200, Krzysztof Opasiak wrote:
 
 
  On 07/02/2015 02:45 PM, Michal Nazarewicz wrote:
  On Thu, Jul 02, 2015 at 12:51:54PM +0200, Gregory CLEMENT wrote:
  When I use configs to configure the mass storage function for the
  gadget, and when the device is plugged under Windows, then the
  partition that I expose is well managed, but I also see 7 other gadget
  in the device manager with error.
 
  This seven bogus gadget seems to be the 7 other LUN that are not
  used. Indeed if I apply this dirty patch:
 
  diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
  b/drivers/usb/gadget/function/f_mass_storage.c
  index 3cc109f..2b4ae98 100644
  --- a/drivers/usb/gadget/function/f_mass_storage.c
  +++ b/drivers/usb/gadget/function/f_mass_storage.c
  @@ -3511,7 +3511,8 @@ static struct usb_function_instance 
  *fsg_alloc_inst(void)
  rc = PTR_ERR(opts-common);
  goto release_opts;
  }
  -   rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
  +// rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
  +   rc = fsg_common_set_nluns(opts-common, 1);
  if (rc)
  goto release_opts;
 
  Then there is no more gadget error under Windows. As the value of
  FSG_MAX_LUNS is 8 and in my configuration I only use one partition,
  then it makes sens that I see 7 bogus gadgets.
 
  I also saw that in the legacy driver, it was possible to modify the
  number of LUN using the module parameter file_count.
 
  On Thu, Jul 02 2015, Felipe Balbi wrote:
  This has been reported. Michal was working on a fix, but the patch
  hasn't been applied yet.
 
  I’ve came up with [1], which you should feel free to test, but then
  Krzysztof came along with [2], which among other things addressed the
  LUN count issue, and I kind of stopped working on the issue waiting for
  his follow up.
 
  Sorry that it took so much time. I have been quite busy with some other
  things. I will send fixed version of that series in a few hours.
  
  I'm taking Michal's patch as a quick fix for the -rc though. That patch
  is simple enough to get in and solves the issue at hand.
 
 I would like to test the patch, is it the one included in the following email 
 ?
 
 http://www.spinics.net/lists/linux-usb/msg126292.html

I just pushed it to my testing/fixes, if you test that, I can still add
your Tested-by, thanks

-- 
balbi


signature.asc
Description: Digital signature


Re: Viewing many gadgets in error under Windows with mass storage function and configfs

2015-07-02 Thread Gregory CLEMENT
Hi Felipe,

thanks for you prompt feedback.

On 02/07/2015 13:45, Felipe Balbi wrote:
 Hi,
 
 On Thu, Jul 02, 2015 at 12:51:54PM +0200, Gregory CLEMENT wrote:
 Hello,

 When I use configs to configure the mass storage function for the
 gadget, and when the device is plugged under Windows, then the
 partition that I expose is well managed, but I also see 7 other gadget
 in the device manager with error.

 This seven bogus gadget seems to be the 7 other LUN that are not
 used. Indeed if I apply this dirty patch:

 diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
 b/drivers/usb/gadget/function/f_mass_storage.c
 index 3cc109f..2b4ae98 100644
 --- a/drivers/usb/gadget/function/f_mass_storage.c
 +++ b/drivers/usb/gadget/function/f_mass_storage.c
 @@ -3511,7 +3511,8 @@ static struct usb_function_instance 
 *fsg_alloc_inst(void)
 rc = PTR_ERR(opts-common);
 goto release_opts;
 }
 -   rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
 +// rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
 +   rc = fsg_common_set_nluns(opts-common, 1);
 if (rc)
 goto release_opts;

 Then there is no more gadget error under Windows. As the value of
 FSG_MAX_LUNS is 8 and in my configuration I only use one partition,
 then it makes sens that I see 7 bogus gadgets.

 I also saw that in the legacy driver, it was possible to modify the
 number of LUN using the module parameter file_count.
 
 This has been reported. Michal was working on a fix, but the patch
 hasn't been applied yet.

Oh sorry to not have finding the thread about it.

 
 There is no such parameter when using configfs.

 What would be the correct way to fix it?
 
 Making sure you don't lie to the other side of the cable :-)
 
 I thought about enumerate how many LUN where configured through
 configfs and then setting the exact number using fsg_common_set_nluns.
 
 yeah, that should be the way.
 
 There is no problem at all under Linux so maybe it is jut the way how
 the gadget is exposed through USB.
 
 no, we shouldn't really lie, this really needs fixing.

Ok so don't hesitate to ask me to test or if you need any help.

Thanks,

Gregory


 

 I tested it on the kernel 3.17 and 4.1 using the musb of the SoC
 AM335x.

 Thanks for your feedback.

 Gregory

 -- 
 Gregory Clement, Free Electrons
 Kernel, drivers, real-time and embedded Linux
 development, consulting, training and support.
 http://free-electrons.com
 


-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Viewing many gadgets in error under Windows with mass storage function and configfs

2015-07-02 Thread Gregory CLEMENT
Hi Felipe,

On 02/07/2015 16:01, Felipe Balbi wrote:
 On Thu, Jul 02, 2015 at 03:52:32PM +0200, Gregory CLEMENT wrote:
 Hi Felipe,

 On 02/07/2015 15:14, Felipe Balbi wrote:
 On Thu, Jul 02, 2015 at 02:55:34PM +0200, Krzysztof Opasiak wrote:


 On 07/02/2015 02:45 PM, Michal Nazarewicz wrote:
 On Thu, Jul 02, 2015 at 12:51:54PM +0200, Gregory CLEMENT wrote:
 When I use configs to configure the mass storage function for the
 gadget, and when the device is plugged under Windows, then the
 partition that I expose is well managed, but I also see 7 other gadget
 in the device manager with error.

 This seven bogus gadget seems to be the 7 other LUN that are not
 used. Indeed if I apply this dirty patch:

 diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
 b/drivers/usb/gadget/function/f_mass_storage.c
 index 3cc109f..2b4ae98 100644
 --- a/drivers/usb/gadget/function/f_mass_storage.c
 +++ b/drivers/usb/gadget/function/f_mass_storage.c
 @@ -3511,7 +3511,8 @@ static struct usb_function_instance 
 *fsg_alloc_inst(void)
 rc = PTR_ERR(opts-common);
 goto release_opts;
 }
 -   rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
 +// rc = fsg_common_set_nluns(opts-common, FSG_MAX_LUNS);
 +   rc = fsg_common_set_nluns(opts-common, 1);
 if (rc)
 goto release_opts;

 Then there is no more gadget error under Windows. As the value of
 FSG_MAX_LUNS is 8 and in my configuration I only use one partition,
 then it makes sens that I see 7 bogus gadgets.

 I also saw that in the legacy driver, it was possible to modify the
 number of LUN using the module parameter file_count.

 On Thu, Jul 02 2015, Felipe Balbi wrote:
 This has been reported. Michal was working on a fix, but the patch
 hasn't been applied yet.

 I’ve came up with [1], which you should feel free to test, but then
 Krzysztof came along with [2], which among other things addressed the
 LUN count issue, and I kind of stopped working on the issue waiting for
 his follow up.

 Sorry that it took so much time. I have been quite busy with some other
 things. I will send fixed version of that series in a few hours.

 I'm taking Michal's patch as a quick fix for the -rc though. That patch
 is simple enough to get in and solves the issue at hand.

 I would like to test the patch, is it the one included in the following 
 email ?

 http://www.spinics.net/lists/linux-usb/msg126292.html
 
 I just pushed it to my testing/fixes, if you test that, I can still add
 your Tested-by, thanks

I've tested the patch from your testing/fixes, and I have no more the 7 others
gadget seen as bogus under Windows. You can add my

Tested-by: Gregory CLEMENT gregory.clem...@free-electrons.com

on a AM335x based board.

Thanks,

Gregory

-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Viewing many gadgets in error under Windows with mass storage function and configfs

2015-07-02 Thread Michal Nazarewicz
 On 07/02/2015 03:14 PM, Felipe Balbi wrote:
 I'm taking Michal's patch as a quick fix for the -rc though. That patch
 is simple enough to get in and solves the issue at hand.

On Thu, Jul 02 2015, Krzysztof Opasiak wrote:
 Nope it doesn't. It may read past buffer in case of legacy gadgets 
 please see discussion in [1]

 1 - http://marc.info/?l=linux-usbm=143498343720763w=2

Sorry, I’ve missed that reply before.  Let’s bring the discussion back
to the original thread.

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--m...@google.com--xmpp:min...@jabber.org--ooO--(_)--Ooo--
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html