All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] USB printer gadget (usb_f_printer) to use default q_len value
@ 2020-12-28 16:25 Michael Sweet
  2020-12-28 16:44 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Sweet @ 2020-12-28 16:25 UTC (permalink / raw)
  To: linux-usb; +Cc: Greg Kroah-Hartman

[Resending as requested]

Hi,

I've been doing some work on Linux-based printer firmware lately (https://www.msweet.org/pappl) and part of that includes support for USB printer gadgets - right now the legacy printer class 1/2 stuff, but soon class 4 IPP-USB.  Since I also want to support functions other than printing (serial for debugging, mass storage for access to SD cards, etc.) I've been working to configure the printer gadget using configfs. After spending a few days puzzling over why the legacy g_printer gadget worked but usb_f_printer didn't I discovered that the default q_len value for the new driver is *0*, which prevents any IO from occurring!  Moreover, once you've configured things and assigned the UDC it is basically impossible to change q_len, so if your Linux distro of choice does any "helpful" initialization for you then you are out of luck...

The following patch uses a default q_len value of 10 (which is what the legacy g_printer driver uses) to minimize the possibility that you end up with a non-working printer gadget.


diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c
index 9c7ed2539ff7..4f3161005e4f 100644
--- a/drivers/usb/gadget/function/f_printer.c
+++ b/drivers/usb/gadget/function/f_printer.c
@@ -50,6 +50,8 @@
#define GET_PORT_STATUS		1
#define SOFT_RESET		2

+#define DEFAULT_Q_LEN		10 /* same as legacy g_printer gadget */
+
static int major, minors;
static struct class *usb_gadget_class;
static DEFINE_IDA(printer_ida);
@@ -1317,6 +1319,9 @@ static struct usb_function_instance *gprinter_alloc_inst(void)
	opts->func_inst.free_func_inst = gprinter_free_inst;
	ret = &opts->func_inst;

+	/* Make sure q_len is initialized, otherwise the bound device can't support read/write! */
+	opts->q_len = DEFAULT_Q_LEN;
+
	mutex_lock(&printer_ida_lock);

	if (ida_is_empty(&printer_ida)) {


________________________
Michael Sweet




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

* Re: [PATCH] USB printer gadget (usb_f_printer) to use default q_len value
  2020-12-28 16:25 [PATCH] USB printer gadget (usb_f_printer) to use default q_len value Michael Sweet
@ 2020-12-28 16:44 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2020-12-28 16:44 UTC (permalink / raw)
  To: Michael Sweet; +Cc: linux-usb

On Mon, Dec 28, 2020 at 11:25:18AM -0500, Michael Sweet wrote:
> [Resending as requested]
> 
> Hi,
> 
> I've been doing some work on Linux-based printer firmware lately (https://www.msweet.org/pappl) and part of that includes support for USB printer gadgets - right now the legacy printer class 1/2 stuff, but soon class 4 IPP-USB.  Since I also want to support functions other than printing (serial for debugging, mass storage for access to SD cards, etc.) I've been working to configure the printer gadget using configfs. After spending a few days puzzling over why the legacy g_printer gadget worked but usb_f_printer didn't I discovered that the default q_len value for the new driver is *0*, which prevents any IO from occurring!  Moreover, once you've configured things and assigned the UDC it is basically impossible to change q_len, so if your Linux distro of choice does any "helpful" initialization for you then you are out of luck...
> 
> The following patch uses a default q_len value of 10 (which is what the legacy g_printer driver uses) to minimize the possibility that you end up with a non-working printer gadget.
> 
> 
> diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c
> index 9c7ed2539ff7..4f3161005e4f 100644
> --- a/drivers/usb/gadget/function/f_printer.c
> +++ b/drivers/usb/gadget/function/f_printer.c
> @@ -50,6 +50,8 @@
> #define GET_PORT_STATUS		1
> #define SOFT_RESET		2
> 
> +#define DEFAULT_Q_LEN		10 /* same as legacy g_printer gadget */
> +
> static int major, minors;
> static struct class *usb_gadget_class;
> static DEFINE_IDA(printer_ida);
> @@ -1317,6 +1319,9 @@ static struct usb_function_instance *gprinter_alloc_inst(void)
> 	opts->func_inst.free_func_inst = gprinter_free_inst;
> 	ret = &opts->func_inst;
> 
> +	/* Make sure q_len is initialized, otherwise the bound device can't support read/write! */
> +	opts->q_len = DEFAULT_Q_LEN;
> +
> 	mutex_lock(&printer_ida_lock);
> 
> 	if (ida_is_empty(&printer_ida)) {
> 
> 
> ________________________
> Michael Sweet
> 
> 
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch is malformed (tabs converted to spaces, linewrapped, etc.)
  and can not be applied.  Please read the file,
  Documentation/email-clients.txt in order to fix this.

- Your patch does not have a Signed-off-by: line.  Please read the
  kernel file, Documentation/SubmittingPatches and resend it after
  adding that line.  Note, the line needs to be in the body of the
  email, before the patch, not at the bottom of the patch or in the
  email signature.

- You did not specify a description of why the patch is needed, or
  possibly, any description at all, in the email body.  Please read the
  section entitled "The canonical patch format" in the kernel file,
  Documentation/SubmittingPatches for what is needed in order to
  properly describe the change.

- You did not write a descriptive Subject: for the patch, allowing Greg,
  and everyone else, to know what this patch is all about.  Please read
  the section entitled "The canonical patch format" in the kernel file,
  Documentation/SubmittingPatches for what a proper Subject: line should
  look like.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

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

* Re: [PATCH] USB printer gadget (usb_f_printer) to use default q_len value
  2020-10-29 13:54 Michael Sweet
@ 2020-10-30 10:57 ` Peter Chen
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Chen @ 2020-10-30 10:57 UTC (permalink / raw)
  To: Michael Sweet; +Cc: linux-usb

On 20-10-29 09:54:05, Michael Sweet wrote:
> Hi,
> 
> I've been doing some work on Linux-based printer firmware lately (https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.msweet.org%2Fpappl&data=04%7C01%7Cpeter.chen%40nxp.com%7C4de2e2c683e24d14316908d87c132af4%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C1%7C637395769063475191%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=K5bQiNEcMDJ0dCNNvsmG%2B3Hs0KfeBc1wS9rQoxe4R4g%3D&reserved=0) and part of that includes support for USB printer gadgets - right now the legacy printer class 1/2 stuff, but soon class 4 IPP-USB.  Since I also want to support functions other than printing (serial for debugging, mass storage for access to SD cards, etc.) I've been working to configure the printer gadget using configfs. After spending a few days puzzling over why the legacy g_printer gadget worked but usb_f_printer didn't I discovered that the default q_len value for the new driver is *0*, which prevents any IO from occurring!  Moreover, once you've configured things and assigned the UDC it is basically impossible to change q_len, so if your Linux distro of choice does any "helpful" initialization for you then you are out of luck...
> 
> The following patch uses a default q_len value of 10 (which is what the legacy g_printer driver uses) to minimize the possibility that you end up with a non-working printer gadget.
> 
> 
> diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c
> index 9c7ed2539ff7..4f3161005e4f 100644
> --- a/drivers/usb/gadget/function/f_printer.c
> +++ b/drivers/usb/gadget/function/f_printer.c
> @@ -50,6 +50,8 @@
>  #define GET_PORT_STATUS		1
>  #define SOFT_RESET		2
>  
> +#define DEFAULT_Q_LEN		10 /* same as legacy g_printer gadget */
> +
>  static int major, minors;
>  static struct class *usb_gadget_class;
>  static DEFINE_IDA(printer_ida);
> @@ -1317,6 +1319,9 @@ static struct usb_function_instance *gprinter_alloc_inst(void)
>  	opts->func_inst.free_func_inst = gprinter_free_inst;
>  	ret = &opts->func_inst;
>  
> +	/* Make sure q_len is initialized, otherwise the bound device can't support read/write! */
> +	opts->q_len = DEFAULT_Q_LEN;
> +
>  	mutex_lock(&printer_ida_lock);
>  
>  	if (ida_is_empty(&printer_ida)) {

This change is ok, You may generate a formal patch, and send it out.

-- 

Thanks,
Peter Chen

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

* [PATCH] USB printer gadget (usb_f_printer) to use default q_len value
@ 2020-10-29 13:54 Michael Sweet
  2020-10-30 10:57 ` Peter Chen
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Sweet @ 2020-10-29 13:54 UTC (permalink / raw)
  To: linux-usb

Hi,

I've been doing some work on Linux-based printer firmware lately (https://www.msweet.org/pappl) and part of that includes support for USB printer gadgets - right now the legacy printer class 1/2 stuff, but soon class 4 IPP-USB.  Since I also want to support functions other than printing (serial for debugging, mass storage for access to SD cards, etc.) I've been working to configure the printer gadget using configfs. After spending a few days puzzling over why the legacy g_printer gadget worked but usb_f_printer didn't I discovered that the default q_len value for the new driver is *0*, which prevents any IO from occurring!  Moreover, once you've configured things and assigned the UDC it is basically impossible to change q_len, so if your Linux distro of choice does any "helpful" initialization for you then you are out of luck...

The following patch uses a default q_len value of 10 (which is what the legacy g_printer driver uses) to minimize the possibility that you end up with a non-working printer gadget.


diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c
index 9c7ed2539ff7..4f3161005e4f 100644
--- a/drivers/usb/gadget/function/f_printer.c
+++ b/drivers/usb/gadget/function/f_printer.c
@@ -50,6 +50,8 @@
 #define GET_PORT_STATUS		1
 #define SOFT_RESET		2
 
+#define DEFAULT_Q_LEN		10 /* same as legacy g_printer gadget */
+
 static int major, minors;
 static struct class *usb_gadget_class;
 static DEFINE_IDA(printer_ida);
@@ -1317,6 +1319,9 @@ static struct usb_function_instance *gprinter_alloc_inst(void)
 	opts->func_inst.free_func_inst = gprinter_free_inst;
 	ret = &opts->func_inst;
 
+	/* Make sure q_len is initialized, otherwise the bound device can't support read/write! */
+	opts->q_len = DEFAULT_Q_LEN;
+
 	mutex_lock(&printer_ida_lock);
 
 	if (ida_is_empty(&printer_ida)) {


________________________
Michael Sweet




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

end of thread, other threads:[~2020-12-28 16:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-28 16:25 [PATCH] USB printer gadget (usb_f_printer) to use default q_len value Michael Sweet
2020-12-28 16:44 ` Greg Kroah-Hartman
  -- strict thread matches above, loose matches on Subject: below --
2020-10-29 13:54 Michael Sweet
2020-10-30 10:57 ` Peter Chen

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