Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1350519 > unrolled thread

Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes

Started byFelipe Ferreri Tonello <eu@felipetonello.com>
First post2016-03-04 19:50 +0100
Last post2016-03-08 16:30 +0100
Articles 13 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes Felipe Ferreri Tonello <eu@felipetonello.com> - 2016-03-04 19:50 +0100
    Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes Felipe Balbi <balbi@kernel.org> - 2016-03-07 08:40 +0100
      Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on  bmAttributes Felipe Ferreri Tonello <eu@felipetonello.com> - 2016-03-07 10:40 +0100
        Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes Felipe Balbi <balbi@kernel.org> - 2016-03-07 12:10 +0100
          Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on  bmAttributes Felipe Ferreri Tonello <eu@felipetonello.com> - 2016-03-07 12:20 +0100
            Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes Felipe Balbi <balbi@kernel.org> - 2016-03-08 08:50 +0100
              Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on  bmAttributes Krzysztof Opasiak <k.opasiak@samsung.com> - 2016-03-08 11:20 +0100
                Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes Felipe Balbi <balbi@kernel.org> - 2016-03-08 11:40 +0100
              Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on  bmAttributes Felipe Ferreri Tonello <eu@felipetonello.com> - 2016-03-08 15:00 +0100
                Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes Felipe Balbi <balbi@kernel.org> - 2016-03-08 15:10 +0100
                Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on  bmAttributes Krzysztof Opasiak <k.opasiak@samsung.com> - 2016-03-08 15:20 +0100
                  Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes Felipe Balbi <balbi@kernel.org> - 2016-03-08 15:30 +0100
                    Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on  bmAttributes Felipe Ferreri Tonello <eu@felipetonello.com> - 2016-03-08 16:30 +0100

#1350519 — Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes

FromFelipe Ferreri Tonello <eu@felipetonello.com>
Date2016-03-04 19:50 +0100
SubjectRe: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes
Message-ID<r92Xz-2wT-107@gated-at.bofh.it>
Hi Balbi, 

On March 4, 2016 7:16:42 AM GMT+00:00, Felipe Balbi <balbi@kernel.org> wrote:
>
>Hi,
>
>"Felipe F. Tonello" <eu@felipetonello.com> writes:
>> [ text/plain ]
>> This gadget uses a bmAttributes and MaxPower that requires the USB
>bus to be
>> powered from the host, which is not correct because this
>configuration is device
>> specific, not a USB-MIDI requirement.
>>
>> This patch adds two modules parameters, bmAttributes and MaxPower,
>that allows
>> the user to set those flags. The default values are what the gadget
>used to use
>> for backward compatibility.
>>
>> Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
>> ---
>>  drivers/usb/gadget/legacy/gmidi.c | 14 ++++++++++++--
>>  1 file changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/legacy/gmidi.c
>b/drivers/usb/gadget/legacy/gmidi.c
>> index fc2ac150f5ff..0553435cc360 100644
>> --- a/drivers/usb/gadget/legacy/gmidi.c
>> +++ b/drivers/usb/gadget/legacy/gmidi.c
>> @@ -63,6 +63,14 @@ static unsigned int out_ports = 1;
>>  module_param(out_ports, uint, S_IRUGO);
>>  MODULE_PARM_DESC(out_ports, "Number of MIDI output ports");
>>  
>> +static unsigned int bmAttributes = USB_CONFIG_ATT_ONE;
>> +module_param(bmAttributes, uint, S_IRUGO);
>> +MODULE_PARM_DESC(bmAttributes, "Configuration Descriptor's
>bmAttributes parameter");
>> +
>> +static unsigned int MaxPower = CONFIG_USB_GADGET_VBUS_DRAW;
>> +module_param(MaxPower, uint, S_IRUGO);
>> +MODULE_PARM_DESC(MaxPower, "Used to calculate Configuration
>Descriptor's bMaxPower parameter");
>
>you didn't run checkpatch, did you ? Also, are you sure you will need
>to
>change this by simply reloading the module ? I'm not convinced.

Yes I always run checkpatch :) 

What do you mean by reloading the module? 

>
>> @@ -119,8 +127,8 @@ static struct usb_configuration midi_config = {
>>  	.label		= "MIDI Gadget",
>>  	.bConfigurationValue = 1,
>>  	/* .iConfiguration = DYNAMIC */
>> -	.bmAttributes	= USB_CONFIG_ATT_ONE,
>
>nack, nackety nack nack nack :-)
>
>USB_CONFIG_ATT_ONE *must* always be set. With your module parameter you
>give users the oportunity to violate USB spec.

You are right. It needs to check the value before it assigns to bmAttributes. 

Felipe 

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

[toc] | [next] | [standalone]


#1351343

FromFelipe Balbi <balbi@kernel.org>
Date2016-03-07 08:40 +0100
Message-ID<r9XVL-8i3-5@gated-at.bofh.it>
In reply to#1350519

[Multipart message — attachments visible in raw view] — view raw

Hi,

Felipe Ferreri Tonello <eu@felipetonello.com> writes:
> [ text/plain ]
> Hi Balbi, 
>
> On March 4, 2016 7:16:42 AM GMT+00:00, Felipe Balbi <balbi@kernel.org> wrote:
>>
>>Hi,
>>
>>"Felipe F. Tonello" <eu@felipetonello.com> writes:
>>> [ text/plain ]
>>> This gadget uses a bmAttributes and MaxPower that requires the USB
>>bus to be
>>> powered from the host, which is not correct because this
>>configuration is device
>>> specific, not a USB-MIDI requirement.
>>>
>>> This patch adds two modules parameters, bmAttributes and MaxPower,
>>that allows
>>> the user to set those flags. The default values are what the gadget
>>used to use
>>> for backward compatibility.
>>>
>>> Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
>>> ---
>>>  drivers/usb/gadget/legacy/gmidi.c | 14 ++++++++++++--
>>>  1 file changed, 12 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/usb/gadget/legacy/gmidi.c
>>b/drivers/usb/gadget/legacy/gmidi.c
>>> index fc2ac150f5ff..0553435cc360 100644
>>> --- a/drivers/usb/gadget/legacy/gmidi.c
>>> +++ b/drivers/usb/gadget/legacy/gmidi.c
>>> @@ -63,6 +63,14 @@ static unsigned int out_ports = 1;
>>>  module_param(out_ports, uint, S_IRUGO);
>>>  MODULE_PARM_DESC(out_ports, "Number of MIDI output ports");
>>>  
>>> +static unsigned int bmAttributes = USB_CONFIG_ATT_ONE;
>>> +module_param(bmAttributes, uint, S_IRUGO);
>>> +MODULE_PARM_DESC(bmAttributes, "Configuration Descriptor's
>>bmAttributes parameter");
>>> +
>>> +static unsigned int MaxPower = CONFIG_USB_GADGET_VBUS_DRAW;
>>> +module_param(MaxPower, uint, S_IRUGO);
>>> +MODULE_PARM_DESC(MaxPower, "Used to calculate Configuration
>>Descriptor's bMaxPower parameter");
>>
>>you didn't run checkpatch, did you ? Also, are you sure you will need
>>to
>>change this by simply reloading the module ? I'm not convinced.
>
> Yes I always run checkpatch :)

do you really ? Why do you have a 98-character line, then ?

> What do you mean by reloading the module?

modprobe g_midi MaxPower=4
modprobe -r g_midi
modprobe g_midi MaxPower=10

I'm not convinced this is a valid use-case. Specially since you can just
provide several configurations and let the host choose the one it suits
it best.

>>> @@ -119,8 +127,8 @@ static struct usb_configuration midi_config = {
>>>  	.label		= "MIDI Gadget",
>>>  	.bConfigurationValue = 1,
>>>  	/* .iConfiguration = DYNAMIC */
>>> -	.bmAttributes	= USB_CONFIG_ATT_ONE,
>>
>>nack, nackety nack nack nack :-)
>>
>>USB_CONFIG_ATT_ONE *must* always be set. With your module parameter you
>>give users the oportunity to violate USB spec.
>
> You are right. It needs to check the value before it assigns to
> bmAttributes.

why check ? You can just unconditionally or USB_CONFIG_ATT_ONE. In any
case, I'm not convinced this is necessary at all.

-- 
balbi

[toc] | [prev] | [next] | [standalone]


#1351426 — Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes

FromFelipe Ferreri Tonello <eu@felipetonello.com>
Date2016-03-07 10:40 +0100
SubjectRe: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes
Message-ID<r9ZNT-13r-7@gated-at.bofh.it>
In reply to#1351343

[Multipart message — attachments visible in raw view] — view raw

Hi Balbi,

On 07/03/16 07:34, Felipe Balbi wrote:
> 
> Hi,
> 
> Felipe Ferreri Tonello <eu@felipetonello.com> writes:
>> [ text/plain ]
>> Hi Balbi, 
>>
>> On March 4, 2016 7:16:42 AM GMT+00:00, Felipe Balbi <balbi@kernel.org> wrote:
>>>
>>> Hi,
>>>
>>> "Felipe F. Tonello" <eu@felipetonello.com> writes:
>>>> [ text/plain ]
>>>> This gadget uses a bmAttributes and MaxPower that requires the USB
>>> bus to be
>>>> powered from the host, which is not correct because this
>>> configuration is device
>>>> specific, not a USB-MIDI requirement.
>>>>
>>>> This patch adds two modules parameters, bmAttributes and MaxPower,
>>> that allows
>>>> the user to set those flags. The default values are what the gadget
>>> used to use
>>>> for backward compatibility.
>>>>
>>>> Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
>>>> ---
>>>>  drivers/usb/gadget/legacy/gmidi.c | 14 ++++++++++++--
>>>>  1 file changed, 12 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/drivers/usb/gadget/legacy/gmidi.c
>>> b/drivers/usb/gadget/legacy/gmidi.c
>>>> index fc2ac150f5ff..0553435cc360 100644
>>>> --- a/drivers/usb/gadget/legacy/gmidi.c
>>>> +++ b/drivers/usb/gadget/legacy/gmidi.c
>>>> @@ -63,6 +63,14 @@ static unsigned int out_ports = 1;
>>>>  module_param(out_ports, uint, S_IRUGO);
>>>>  MODULE_PARM_DESC(out_ports, "Number of MIDI output ports");
>>>>  
>>>> +static unsigned int bmAttributes = USB_CONFIG_ATT_ONE;
>>>> +module_param(bmAttributes, uint, S_IRUGO);
>>>> +MODULE_PARM_DESC(bmAttributes, "Configuration Descriptor's
>>> bmAttributes parameter");
>>>> +
>>>> +static unsigned int MaxPower = CONFIG_USB_GADGET_VBUS_DRAW;
>>>> +module_param(MaxPower, uint, S_IRUGO);
>>>> +MODULE_PARM_DESC(MaxPower, "Used to calculate Configuration
>>> Descriptor's bMaxPower parameter");
>>>
>>> you didn't run checkpatch, did you ? Also, are you sure you will need
>>> to
>>> change this by simply reloading the module ? I'm not convinced.
>>
>> Yes I always run checkpatch :)
> 
> do you really ? Why do you have a 98-character line, then ?
> 
>> What do you mean by reloading the module?
> 
> modprobe g_midi MaxPower=4
> modprobe -r g_midi
> modprobe g_midi MaxPower=10
> 
> I'm not convinced this is a valid use-case. Specially since you can just
> provide several configurations and let the host choose the one it suits
> it best.

Ok, I will further test it.

> 
>>>> @@ -119,8 +127,8 @@ static struct usb_configuration midi_config = {
>>>>  	.label		= "MIDI Gadget",
>>>>  	.bConfigurationValue = 1,
>>>>  	/* .iConfiguration = DYNAMIC */
>>>> -	.bmAttributes	= USB_CONFIG_ATT_ONE,
>>>
>>> nack, nackety nack nack nack :-)
>>>
>>> USB_CONFIG_ATT_ONE *must* always be set. With your module parameter you
>>> give users the oportunity to violate USB spec.
>>
>> You are right. It needs to check the value before it assigns to
>> bmAttributes.
> 
> why check ? You can just unconditionally or USB_CONFIG_ATT_ONE. In any
> case, I'm not convinced this is necessary at all.

Right.

This is necessary because this driver is actually wrong in which is
asking for the host to power itself. This is not specified on USB-MIDI
specification, neither makes any sense since this configuration is
device specific.

What is your suggestion to make it configurable? Maybe at compile-time?
I really don't know what is the best solution if this is not something
you like it.

Felipe

[toc] | [prev] | [next] | [standalone]


#1351537

FromFelipe Balbi <balbi@kernel.org>
Date2016-03-07 12:10 +0100
Message-ID<ra1d0-24s-27@gated-at.bofh.it>
In reply to#1351426

[Multipart message — attachments visible in raw view] — view raw

Hi,

Felipe Ferreri Tonello <eu@felipetonello.com> writes:
>>>> "Felipe F. Tonello" <eu@felipetonello.com> writes:
>>>>> [ text/plain ]
>>>>> This gadget uses a bmAttributes and MaxPower that requires the USB
>>>> bus to be
>>>>> powered from the host, which is not correct because this
>>>> configuration is device
>>>>> specific, not a USB-MIDI requirement.
>>>>>
>>>>> This patch adds two modules parameters, bmAttributes and MaxPower,
>>>> that allows
>>>>> the user to set those flags. The default values are what the gadget
>>>> used to use
>>>>> for backward compatibility.
>>>>>
>>>>> Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
>>>>> ---
>>>>>  drivers/usb/gadget/legacy/gmidi.c | 14 ++++++++++++--
>>>>>  1 file changed, 12 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/drivers/usb/gadget/legacy/gmidi.c
>>>> b/drivers/usb/gadget/legacy/gmidi.c
>>>>> index fc2ac150f5ff..0553435cc360 100644
>>>>> --- a/drivers/usb/gadget/legacy/gmidi.c
>>>>> +++ b/drivers/usb/gadget/legacy/gmidi.c
>>>>> @@ -63,6 +63,14 @@ static unsigned int out_ports = 1;
>>>>>  module_param(out_ports, uint, S_IRUGO);
>>>>>  MODULE_PARM_DESC(out_ports, "Number of MIDI output ports");
>>>>>  
>>>>> +static unsigned int bmAttributes = USB_CONFIG_ATT_ONE;
>>>>> +module_param(bmAttributes, uint, S_IRUGO);
>>>>> +MODULE_PARM_DESC(bmAttributes, "Configuration Descriptor's
>>>> bmAttributes parameter");
>>>>> +
>>>>> +static unsigned int MaxPower = CONFIG_USB_GADGET_VBUS_DRAW;
>>>>> +module_param(MaxPower, uint, S_IRUGO);
>>>>> +MODULE_PARM_DESC(MaxPower, "Used to calculate Configuration
>>>> Descriptor's bMaxPower parameter");
>>>>
>>>> you didn't run checkpatch, did you ? Also, are you sure you will need
>>>> to
>>>> change this by simply reloading the module ? I'm not convinced.
>>>
>>> Yes I always run checkpatch :)
>> 
>> do you really ? Why do you have a 98-character line, then ?
>> 
>>> What do you mean by reloading the module?
>> 
>> modprobe g_midi MaxPower=4
>> modprobe -r g_midi
>> modprobe g_midi MaxPower=10
>> 
>> I'm not convinced this is a valid use-case. Specially since you can just
>> provide several configurations and let the host choose the one it suits
>> it best.
>
> Ok, I will further test it.
>
>> 
>>>>> @@ -119,8 +127,8 @@ static struct usb_configuration midi_config = {
>>>>>  	.label		= "MIDI Gadget",
>>>>>  	.bConfigurationValue = 1,
>>>>>  	/* .iConfiguration = DYNAMIC */
>>>>> -	.bmAttributes	= USB_CONFIG_ATT_ONE,
>>>>
>>>> nack, nackety nack nack nack :-)
>>>>
>>>> USB_CONFIG_ATT_ONE *must* always be set. With your module parameter you
>>>> give users the oportunity to violate USB spec.
>>>
>>> You are right. It needs to check the value before it assigns to
>>> bmAttributes.
>> 
>> why check ? You can just unconditionally or USB_CONFIG_ATT_ONE. In any
>> case, I'm not convinced this is necessary at all.
>
> Right.
>
> This is necessary because this driver is actually wrong in which is
> asking for the host to power itself. This is not specified on USB-MIDI
> specification, neither makes any sense since this configuration is
> device specific.
>
> What is your suggestion to make it configurable? Maybe at compile-time?
> I really don't know what is the best solution if this is not something
> you like it.

well, you could use our configfs-based gadget interface. You don't
really need to use gmidi.ko at all. In fact, we wanna do away with any
static modules and rely only on configfs. If configfs doesn't let you
change what you want/need, then we can talk about adding support for
those.

bMaxPower and bmAttributes sound like good things to have configurable
over configfs but beware of what the USB specification says about them,
we cannot let users violate the spec by passing bogus values on these
fields.

cheers

-- 
balbi

[toc] | [prev] | [next] | [standalone]


#1351541 — Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes

FromFelipe Ferreri Tonello <eu@felipetonello.com>
Date2016-03-07 12:20 +0100
SubjectRe: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes
Message-ID<ra1mG-27y-3@gated-at.bofh.it>
In reply to#1351537

[Multipart message — attachments visible in raw view] — view raw

Hi Balbi, how are you?

On 07/03/16 10:59, Felipe Balbi wrote:
> 
> Hi,
> 
> Felipe Ferreri Tonello <eu@felipetonello.com> writes:
>>>>> "Felipe F. Tonello" <eu@felipetonello.com> writes:
>>>>>> [ text/plain ]
>>>>>> This gadget uses a bmAttributes and MaxPower that requires the USB
>>>>> bus to be
>>>>>> powered from the host, which is not correct because this
>>>>> configuration is device
>>>>>> specific, not a USB-MIDI requirement.
>>>>>>
>>>>>> This patch adds two modules parameters, bmAttributes and MaxPower,
>>>>> that allows
>>>>>> the user to set those flags. The default values are what the gadget
>>>>> used to use
>>>>>> for backward compatibility.
>>>>>>
>>>>>> Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
>>>>>> ---
>>>>>>  drivers/usb/gadget/legacy/gmidi.c | 14 ++++++++++++--
>>>>>>  1 file changed, 12 insertions(+), 2 deletions(-)
>>>>>>
>>>>>> diff --git a/drivers/usb/gadget/legacy/gmidi.c
>>>>> b/drivers/usb/gadget/legacy/gmidi.c
>>>>>> index fc2ac150f5ff..0553435cc360 100644
>>>>>> --- a/drivers/usb/gadget/legacy/gmidi.c
>>>>>> +++ b/drivers/usb/gadget/legacy/gmidi.c
>>>>>> @@ -63,6 +63,14 @@ static unsigned int out_ports = 1;
>>>>>>  module_param(out_ports, uint, S_IRUGO);
>>>>>>  MODULE_PARM_DESC(out_ports, "Number of MIDI output ports");
>>>>>>  
>>>>>> +static unsigned int bmAttributes = USB_CONFIG_ATT_ONE;
>>>>>> +module_param(bmAttributes, uint, S_IRUGO);
>>>>>> +MODULE_PARM_DESC(bmAttributes, "Configuration Descriptor's
>>>>> bmAttributes parameter");
>>>>>> +
>>>>>> +static unsigned int MaxPower = CONFIG_USB_GADGET_VBUS_DRAW;
>>>>>> +module_param(MaxPower, uint, S_IRUGO);
>>>>>> +MODULE_PARM_DESC(MaxPower, "Used to calculate Configuration
>>>>> Descriptor's bMaxPower parameter");
>>>>>
>>>>> you didn't run checkpatch, did you ? Also, are you sure you will need
>>>>> to
>>>>> change this by simply reloading the module ? I'm not convinced.
>>>>
>>>> Yes I always run checkpatch :)
>>>
>>> do you really ? Why do you have a 98-character line, then ?
>>>
>>>> What do you mean by reloading the module?
>>>
>>> modprobe g_midi MaxPower=4
>>> modprobe -r g_midi
>>> modprobe g_midi MaxPower=10
>>>
>>> I'm not convinced this is a valid use-case. Specially since you can just
>>> provide several configurations and let the host choose the one it suits
>>> it best.
>>
>> Ok, I will further test it.
>>
>>>
>>>>>> @@ -119,8 +127,8 @@ static struct usb_configuration midi_config = {
>>>>>>  	.label		= "MIDI Gadget",
>>>>>>  	.bConfigurationValue = 1,
>>>>>>  	/* .iConfiguration = DYNAMIC */
>>>>>> -	.bmAttributes	= USB_CONFIG_ATT_ONE,
>>>>>
>>>>> nack, nackety nack nack nack :-)
>>>>>
>>>>> USB_CONFIG_ATT_ONE *must* always be set. With your module parameter you
>>>>> give users the oportunity to violate USB spec.
>>>>
>>>> You are right. It needs to check the value before it assigns to
>>>> bmAttributes.
>>>
>>> why check ? You can just unconditionally or USB_CONFIG_ATT_ONE. In any
>>> case, I'm not convinced this is necessary at all.
>>
>> Right.
>>
>> This is necessary because this driver is actually wrong in which is
>> asking for the host to power itself. This is not specified on USB-MIDI
>> specification, neither makes any sense since this configuration is
>> device specific.
>>
>> What is your suggestion to make it configurable? Maybe at compile-time?
>> I really don't know what is the best solution if this is not something
>> you like it.
> 
> well, you could use our configfs-based gadget interface. You don't
> really need to use gmidi.ko at all. In fact, we wanna do away with any
> static modules and rely only on configfs. If configfs doesn't let you
> change what you want/need, then we can talk about adding support for
> those.
> 
> bMaxPower and bmAttributes sound like good things to have configurable
> over configfs but beware of what the USB specification says about them,
> we cannot let users violate the spec by passing bogus values on these
> fields.

I agree that we should move to configfs, but the truth is that these
legacy devices are still useful. They just do one thing, mostly, but its
easy and simple to setup and use. So I think before we have some sort of
preset library of configfs-based gadget drivers, we still need these
modules.

Any suggestions on that?

Do you want to support what I am proposing for gmidi.ko or just ignore
it and move on to configfs?

Felipe

[toc] | [prev] | [next] | [standalone]


#1352688

FromFelipe Balbi <balbi@kernel.org>
Date2016-03-08 08:50 +0100
Message-ID<rakyZ-6iA-5@gated-at.bofh.it>
In reply to#1351541

[Multipart message — attachments visible in raw view] — view raw

Hi,

Felipe Ferreri Tonello <eu@felipetonello.com> writes:
>>>>>>> @@ -63,6 +63,14 @@ static unsigned int out_ports = 1;
>>>>>>>  module_param(out_ports, uint, S_IRUGO);
>>>>>>>  MODULE_PARM_DESC(out_ports, "Number of MIDI output ports");
>>>>>>>  
>>>>>>> +static unsigned int bmAttributes = USB_CONFIG_ATT_ONE;
>>>>>>> +module_param(bmAttributes, uint, S_IRUGO);
>>>>>>> +MODULE_PARM_DESC(bmAttributes, "Configuration Descriptor's
>>>>>> bmAttributes parameter");
>>>>>>> +
>>>>>>> +static unsigned int MaxPower = CONFIG_USB_GADGET_VBUS_DRAW;
>>>>>>> +module_param(MaxPower, uint, S_IRUGO);
>>>>>>> +MODULE_PARM_DESC(MaxPower, "Used to calculate Configuration
>>>>>> Descriptor's bMaxPower parameter");
>>>>>>
>>>>>> you didn't run checkpatch, did you ? Also, are you sure you will need
>>>>>> to
>>>>>> change this by simply reloading the module ? I'm not convinced.
>>>>>
>>>>> Yes I always run checkpatch :)
>>>>
>>>> do you really ? Why do you have a 98-character line, then ?

btw, you didn't reply this ^^

>>>>>>> @@ -119,8 +127,8 @@ static struct usb_configuration midi_config = {
>>>>>>>  	.label		= "MIDI Gadget",
>>>>>>>  	.bConfigurationValue = 1,
>>>>>>>  	/* .iConfiguration = DYNAMIC */
>>>>>>> -	.bmAttributes	= USB_CONFIG_ATT_ONE,
>>>>>>
>>>>>> nack, nackety nack nack nack :-)
>>>>>>
>>>>>> USB_CONFIG_ATT_ONE *must* always be set. With your module parameter you
>>>>>> give users the oportunity to violate USB spec.
>>>>>
>>>>> You are right. It needs to check the value before it assigns to
>>>>> bmAttributes.
>>>>
>>>> why check ? You can just unconditionally or USB_CONFIG_ATT_ONE. In any
>>>> case, I'm not convinced this is necessary at all.
>>>
>>> Right.
>>>
>>> This is necessary because this driver is actually wrong in which is
>>> asking for the host to power itself. This is not specified on USB-MIDI
>>> specification, neither makes any sense since this configuration is
>>> device specific.
>>>
>>> What is your suggestion to make it configurable? Maybe at compile-time?
>>> I really don't know what is the best solution if this is not something
>>> you like it.
>> 
>> well, you could use our configfs-based gadget interface. You don't
>> really need to use gmidi.ko at all. In fact, we wanna do away with any
>> static modules and rely only on configfs. If configfs doesn't let you
>> change what you want/need, then we can talk about adding support for
>> those.
>> 
>> bMaxPower and bmAttributes sound like good things to have configurable
>> over configfs but beware of what the USB specification says about them,
>> we cannot let users violate the spec by passing bogus values on these
>> fields.
>
> I agree that we should move to configfs, but the truth is that these
> legacy devices are still useful. They just do one thing, mostly, but

yes, they are useful as they are. They don't need to be changed to be
useful. Plus, you can have a gadget built with configfs that does only
one thing. And you can do that with a simple shell script.

> its easy and simple to setup and use. So I think before we have some

so is configfs.

> sort of preset library of configfs-based gadget drivers, we still need
> these modules.

there is already a library called libusbg.

> Any suggestions on that?
>
> Do you want to support what I am proposing for gmidi.ko or just ignore
> it and move on to configfs?

I prefer to not touch these gadget drivers if at all necessary. If you
fixing a bug, then sure we must fix bugs. But you're not fixing a bug
and, on top of that, you're adding regressions and violating the USB
spec. This shows that you're writing these patches without knowing
(and/or even caring about) the specification at all.

Here's some enlightening presentation you probably wanna watch:

https://www.youtube.com/watch?v=fMeH7wqOwXA

TL;DR : this project is large and you need to convince me we need your
code/patch.

-- 
balbi

[toc] | [prev] | [next] | [standalone]


#1352824 — Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes

FromKrzysztof Opasiak <k.opasiak@samsung.com>
Date2016-03-08 11:20 +0100
SubjectRe: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes
Message-ID<ramUa-7VY-3@gated-at.bofh.it>
In reply to#1352688

On 03/08/2016 08:43 AM, Felipe Balbi wrote:
(...)

>>>> This is necessary because this driver is actually wrong in which is
>>>> asking for the host to power itself. This is not specified on USB-MIDI
>>>> specification, neither makes any sense since this configuration is
>>>> device specific.
>>>>
>>>> What is your suggestion to make it configurable? Maybe at compile-time?
>>>> I really don't know what is the best solution if this is not something
>>>> you like it.
>>>
>>> well, you could use our configfs-based gadget interface. You don't
>>> really need to use gmidi.ko at all. In fact, we wanna do away with any
>>> static modules and rely only on configfs. If configfs doesn't let you
>>> change what you want/need, then we can talk about adding support for
>>> those.
>>>
>>> bMaxPower and bmAttributes sound like good things to have configurable
>>> over configfs but beware of what the USB specification says about them,
>>> we cannot let users violate the spec by passing bogus values on these
>>> fields.
>>
>> I agree that we should move to configfs, but the truth is that these
>> legacy devices are still useful. They just do one thing, mostly, but
> 
> yes, they are useful as they are. They don't need to be changed to be
> useful. Plus, you can have a gadget built with configfs that does only
> one thing. And you can do that with a simple shell script.
> 
>> its easy and simple to setup and use. So I think before we have some
> 
> so is configfs.
> 
>> sort of preset library of configfs-based gadget drivers, we still need
>> these modules.
> 
> there is already a library called libusbg.

As libusbg itself is a little bit dead there is a fork called
libusbgx[1] and it is still active;)

It already has support for f_midi so it is ready to use.

Footnotes:
1 - https://github.com/libusbgx/libusbgx

Cheers,
-- 
Krzysztof Opasiak
Samsung R&D Institute Poland
Samsung Electronics

[toc] | [prev] | [next] | [standalone]


#1352865

FromFelipe Balbi <balbi@kernel.org>
Date2016-03-08 11:40 +0100
Message-ID<randy-84x-75@gated-at.bofh.it>
In reply to#1352824

[Multipart message — attachments visible in raw view] — view raw

Hi,

Krzysztof Opasiak <k.opasiak@samsung.com> writes:
> [ text/plain ]
>
>
> On 03/08/2016 08:43 AM, Felipe Balbi wrote:
> (...)
>
>>>>> This is necessary because this driver is actually wrong in which is
>>>>> asking for the host to power itself. This is not specified on USB-MIDI
>>>>> specification, neither makes any sense since this configuration is
>>>>> device specific.
>>>>>
>>>>> What is your suggestion to make it configurable? Maybe at compile-time?
>>>>> I really don't know what is the best solution if this is not something
>>>>> you like it.
>>>>
>>>> well, you could use our configfs-based gadget interface. You don't
>>>> really need to use gmidi.ko at all. In fact, we wanna do away with any
>>>> static modules and rely only on configfs. If configfs doesn't let you
>>>> change what you want/need, then we can talk about adding support for
>>>> those.
>>>>
>>>> bMaxPower and bmAttributes sound like good things to have configurable
>>>> over configfs but beware of what the USB specification says about them,
>>>> we cannot let users violate the spec by passing bogus values on these
>>>> fields.
>>>
>>> I agree that we should move to configfs, but the truth is that these
>>> legacy devices are still useful. They just do one thing, mostly, but
>> 
>> yes, they are useful as they are. They don't need to be changed to be
>> useful. Plus, you can have a gadget built with configfs that does only
>> one thing. And you can do that with a simple shell script.
>> 
>>> its easy and simple to setup and use. So I think before we have some
>> 
>> so is configfs.
>> 
>>> sort of preset library of configfs-based gadget drivers, we still need
>>> these modules.
>> 
>> there is already a library called libusbg.
>
> As libusbg itself is a little bit dead there is a fork called
> libusbgx[1] and it is still active;)
>
> It already has support for f_midi so it is ready to use.

heh, seems like usb libraries tend to get forked with an 'x' appended to
their name. But thanks for the note.

-- 
balbi

[toc] | [prev] | [next] | [standalone]


#1353072 — Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes

FromFelipe Ferreri Tonello <eu@felipetonello.com>
Date2016-03-08 15:00 +0100
SubjectRe: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes
Message-ID<raql5-1Bi-49@gated-at.bofh.it>
In reply to#1352688

[Multipart message — attachments visible in raw view] — view raw

Hi Balbi,

On 08/03/16 07:43, Felipe Balbi wrote:
> 
> Hi,
> 
> Felipe Ferreri Tonello <eu@felipetonello.com> writes:
>>>>>>>> @@ -63,6 +63,14 @@ static unsigned int out_ports = 1;
>>>>>>>>  module_param(out_ports, uint, S_IRUGO);
>>>>>>>>  MODULE_PARM_DESC(out_ports, "Number of MIDI output ports");
>>>>>>>>  
>>>>>>>> +static unsigned int bmAttributes = USB_CONFIG_ATT_ONE;
>>>>>>>> +module_param(bmAttributes, uint, S_IRUGO);
>>>>>>>> +MODULE_PARM_DESC(bmAttributes, "Configuration Descriptor's
>>>>>>> bmAttributes parameter");
>>>>>>>> +
>>>>>>>> +static unsigned int MaxPower = CONFIG_USB_GADGET_VBUS_DRAW;
>>>>>>>> +module_param(MaxPower, uint, S_IRUGO);
>>>>>>>> +MODULE_PARM_DESC(MaxPower, "Used to calculate Configuration
>>>>>>> Descriptor's bMaxPower parameter");
>>>>>>>
>>>>>>> you didn't run checkpatch, did you ? Also, are you sure you will need
>>>>>>> to
>>>>>>> change this by simply reloading the module ? I'm not convinced.
>>>>>>
>>>>>> Yes I always run checkpatch :)
>>>>>
>>>>> do you really ? Why do you have a 98-character line, then ?
> 
> btw, you didn't reply this ^^
> 
>>>>>>>> @@ -119,8 +127,8 @@ static struct usb_configuration midi_config = {
>>>>>>>>  	.label		= "MIDI Gadget",
>>>>>>>>  	.bConfigurationValue = 1,
>>>>>>>>  	/* .iConfiguration = DYNAMIC */
>>>>>>>> -	.bmAttributes	= USB_CONFIG_ATT_ONE,
>>>>>>>
>>>>>>> nack, nackety nack nack nack :-)
>>>>>>>
>>>>>>> USB_CONFIG_ATT_ONE *must* always be set. With your module parameter you
>>>>>>> give users the oportunity to violate USB spec.
>>>>>>
>>>>>> You are right. It needs to check the value before it assigns to
>>>>>> bmAttributes.
>>>>>
>>>>> why check ? You can just unconditionally or USB_CONFIG_ATT_ONE. In any
>>>>> case, I'm not convinced this is necessary at all.
>>>>
>>>> Right.
>>>>
>>>> This is necessary because this driver is actually wrong in which is
>>>> asking for the host to power itself. This is not specified on USB-MIDI
>>>> specification, neither makes any sense since this configuration is
>>>> device specific.
>>>>
>>>> What is your suggestion to make it configurable? Maybe at compile-time?
>>>> I really don't know what is the best solution if this is not something
>>>> you like it.
>>>
>>> well, you could use our configfs-based gadget interface. You don't
>>> really need to use gmidi.ko at all. In fact, we wanna do away with any
>>> static modules and rely only on configfs. If configfs doesn't let you
>>> change what you want/need, then we can talk about adding support for
>>> those.
>>>
>>> bMaxPower and bmAttributes sound like good things to have configurable
>>> over configfs but beware of what the USB specification says about them,
>>> we cannot let users violate the spec by passing bogus values on these
>>> fields.
>>
>> I agree that we should move to configfs, but the truth is that these
>> legacy devices are still useful. They just do one thing, mostly, but
> 
> yes, they are useful as they are. They don't need to be changed to be
> useful. Plus, you can have a gadget built with configfs that does only
> one thing. And you can do that with a simple shell script.
> 
>> its easy and simple to setup and use. So I think before we have some
> 
> so is configfs.
> 
>> sort of preset library of configfs-based gadget drivers, we still need
>> these modules.
> 
> there is already a library called libusbg.

By preset library I meant scripts or little programs that implement the
legacy drivers we have.

> 
>> Any suggestions on that?
>>
>> Do you want to support what I am proposing for gmidi.ko or just ignore
>> it and move on to configfs?
> 
> I prefer to not touch these gadget drivers if at all necessary. If you
> fixing a bug, then sure we must fix bugs. But you're not fixing a bug
> and, on top of that, you're adding regressions and violating the USB
> spec. This shows that you're writing these patches without knowing
> (and/or even caring about) the specification at all.

Yes, I see your point. My mistake was to not to enforce the first bit to
be set enabling the user to break the USB spec. I didn't think of that
scenario. And that's why it's always useful to have kernel maintainers
and others to provide such insights. :)

Anyway, I see that this patch is not useful even if corrected.

> 
> Here's some enlightening presentation you probably wanna watch:
> 
> https://www.youtube.com/watch?v=fMeH7wqOwXA
> 
> TL;DR : this project is large and you need to convince me we need your
> code/patch.
> 

Felipe

[toc] | [prev] | [next] | [standalone]


#1353077

FromFelipe Balbi <balbi@kernel.org>
Date2016-03-08 15:10 +0100
Message-ID<raquL-1Uq-41@gated-at.bofh.it>
In reply to#1353072

[Multipart message — attachments visible in raw view] — view raw

Hi,

Felipe Ferreri Tonello <eu@felipetonello.com> writes:
>>> its easy and simple to setup and use. So I think before we have some
>> 
>> so is configfs.
>> 
>>> sort of preset library of configfs-based gadget drivers, we still need
>>> these modules.
>> 
>> there is already a library called libusbg.
>
> By preset library I meant scripts or little programs that implement the
> legacy drivers we have.

like this ?

https://github.com/libusbgx/libusbgx/blob/master/examples/gadget-midi.c

>>> Any suggestions on that?
>>>
>>> Do you want to support what I am proposing for gmidi.ko or just ignore
>>> it and move on to configfs?
>> 
>> I prefer to not touch these gadget drivers if at all necessary. If you
>> fixing a bug, then sure we must fix bugs. But you're not fixing a bug
>> and, on top of that, you're adding regressions and violating the USB
>> spec. This shows that you're writing these patches without knowing
>> (and/or even caring about) the specification at all.
>
> Yes, I see your point. My mistake was to not to enforce the first bit to
> be set enabling the user to break the USB spec. I didn't think of that

right, that was the problem.

> scenario. And that's why it's always useful to have kernel maintainers
> and others to provide such insights. :)

yeah, no problem ;-)

-- 
balbi

[toc] | [prev] | [next] | [standalone]


#1353093 — Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes

FromKrzysztof Opasiak <k.opasiak@samsung.com>
Date2016-03-08 15:20 +0100
SubjectRe: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes
Message-ID<raqEq-1XQ-33@gated-at.bofh.it>
In reply to#1353072

On 03/08/2016 02:54 PM, Felipe Ferreri Tonello wrote:
 (...)

>>
>>> sort of preset library of configfs-based gadget drivers, we still need
>>> these modules.
>>
>> there is already a library called libusbg.
> 
> By preset library I meant scripts or little programs that implement the
> legacy drivers we have.
> 

libusbgx implements an idea of gadget schemes[1]. That's simple
configuration files using libconfig syntax. I don't see any problems to
use it to create legacy gadget equivalents. Then you could simply load
it using usbg_import_gadget() in C code or gt[2] load from shell.

Footnotes:
1 - https://github.com/libusbgx/libusbgx/blob/master/doc/gadget_schemes.txt
2 - https://github.com/kopasiak/gt

Cheers,
-- 
Krzysztof Opasiak
Samsung R&D Institute Poland
Samsung Electronics

[toc] | [prev] | [next] | [standalone]


#1353098

FromFelipe Balbi <balbi@kernel.org>
Date2016-03-08 15:30 +0100
Message-ID<raqO6-21z-23@gated-at.bofh.it>
In reply to#1353093

[Multipart message — attachments visible in raw view] — view raw

Hi,

Krzysztof Opasiak <k.opasiak@samsung.com> writes:
> [ text/plain ]
>
>
> On 03/08/2016 02:54 PM, Felipe Ferreri Tonello wrote:
>  (...)
>
>>>
>>>> sort of preset library of configfs-based gadget drivers, we still need
>>>> these modules.
>>>
>>> there is already a library called libusbg.
>> 
>> By preset library I meant scripts or little programs that implement the
>> legacy drivers we have.
>> 
>
> libusbgx implements an idea of gadget schemes[1]. That's simple
> configuration files using libconfig syntax. I don't see any problems to
> use it to create legacy gadget equivalents. Then you could simply load
> it using usbg_import_gadget() in C code or gt[2] load from shell.

cool, bmAttributes and bMaxPower are already there. Nice.

-- 
balbi

[toc] | [prev] | [next] | [standalone]


#1353138 — Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes

FromFelipe Ferreri Tonello <eu@felipetonello.com>
Date2016-03-08 16:30 +0100
SubjectRe: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes
Message-ID<rarKa-2CK-9@gated-at.bofh.it>
In reply to#1353098

[Multipart message — attachments visible in raw view] — view raw

Hi,

On 08/03/16 14:20, Felipe Balbi wrote:
> 
> Hi,
> 
> Krzysztof Opasiak <k.opasiak@samsung.com> writes:
>> [ text/plain ]
>>
>>
>> On 03/08/2016 02:54 PM, Felipe Ferreri Tonello wrote:
>>  (...)
>>
>>>>
>>>>> sort of preset library of configfs-based gadget drivers, we still need
>>>>> these modules.
>>>>
>>>> there is already a library called libusbg.
>>>
>>> By preset library I meant scripts or little programs that implement the
>>> legacy drivers we have.
>>>
>>
>> libusbgx implements an idea of gadget schemes[1]. That's simple
>> configuration files using libconfig syntax. I don't see any problems to
>> use it to create legacy gadget equivalents. Then you could simply load
>> it using usbg_import_gadget() in C code or gt[2] load from shell.
> 
> cool, bmAttributes and bMaxPower are already there. Nice.
> 

Yes! It is pretty awesome.

-- 
Felipe

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web