All of lore.kernel.org
 help / color / mirror / Atom feed
* [LINUX PATCH] usb: gadget: Configure data verification through module parameter in gadget zero
@ 2016-09-29  8:48 Manish Narani
  2016-09-29  9:16 ` Peter Chen
  2016-09-29 11:25 ` Greg KH
  0 siblings, 2 replies; 4+ messages in thread
From: Manish Narani @ 2016-09-29  8:48 UTC (permalink / raw)
  To: balbi, gregkh, k.opasiak, r.baldyga, peter.chen, mnarani,
	John.Youn, eu, i.kotrasinsk, linux-usb, linux-kernel
  Cc: anuragku, punnaia

This patch adds support to configure data verification through
module parameter. This parameter can be used to disable data
verification in case if one wants to measure peak Bulk/Isoc-IN/OUT
performance

Signed-off-by: Manish Narani <mnarani@xilinx.com>
---
 drivers/usb/gadget/function/f_sourcesink.c | 6 ++++--
 drivers/usb/gadget/function/g_zero.h       | 3 +++
 drivers/usb/gadget/legacy/zero.c           | 5 +++++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c
index 81274ba..2328d11 100644
--- a/drivers/usb/gadget/function/f_sourcesink.c
+++ b/drivers/usb/gadget/function/f_sourcesink.c
@@ -45,6 +45,7 @@ struct f_sourcesink {
 	int			cur_alt;
 
 	unsigned pattern;
+	unsigned verify_rx_data;
 	unsigned isoc_interval;
 	unsigned isoc_maxpacket;
 	unsigned isoc_mult;
@@ -552,7 +553,7 @@ static void source_sink_complete(struct usb_ep *ep, struct usb_request *req)
 	switch (status) {
 
 	case 0:				/* normal completion? */
-		if (ep == ss->out_ep) {
+		if (ss->verify_rx_data && (ep == ss->out_ep)) {
 			check_read_data(ss, req);
 			if (ss->pattern != 2)
 				memset(req->buf, 0x55, req->length);
@@ -630,7 +631,7 @@ static int source_sink_start_ep(struct f_sourcesink *ss, bool is_in,
 		req->complete = source_sink_complete;
 		if (is_in)
 			reinit_write_data(ep, req);
-		else if (ss->pattern != 2)
+		else if (ss->verify_rx_data && (ss->pattern != 2))
 			memset(req->buf, 0x55, req->length);
 
 		status = usb_ep_queue(ep, req, GFP_ATOMIC);
@@ -866,6 +867,7 @@ static struct usb_function *source_sink_alloc_func(
 	mutex_unlock(&ss_opts->lock);
 
 	ss->pattern = ss_opts->pattern;
+	ss->verify_rx_data = ss_opts->verify_rx_data;
 	ss->isoc_interval = ss_opts->isoc_interval;
 	ss->isoc_maxpacket = ss_opts->isoc_maxpacket;
 	ss->isoc_mult = ss_opts->isoc_mult;
diff --git a/drivers/usb/gadget/function/g_zero.h b/drivers/usb/gadget/function/g_zero.h
index b3234e7..8e5d20c 100644
--- a/drivers/usb/gadget/function/g_zero.h
+++ b/drivers/usb/gadget/function/g_zero.h
@@ -6,6 +6,7 @@
 #ifndef __G_ZERO_H
 #define __G_ZERO_H
 
+#define GZERO_VERIFY_RX_DATA	1
 #define GZERO_BULK_BUFLEN	4096
 #define GZERO_QLEN		32
 #define GZERO_ISOC_INTERVAL	4
@@ -15,6 +16,7 @@
 
 struct usb_zero_options {
 	unsigned pattern;
+	unsigned verify_rx_data;
 	unsigned isoc_interval;
 	unsigned isoc_maxpacket;
 	unsigned isoc_mult;
@@ -29,6 +31,7 @@ struct usb_zero_options {
 struct f_ss_opts {
 	struct usb_function_instance func_inst;
 	unsigned pattern;
+	unsigned verify_rx_data;
 	unsigned isoc_interval;
 	unsigned isoc_maxpacket;
 	unsigned isoc_mult;
diff --git a/drivers/usb/gadget/legacy/zero.c b/drivers/usb/gadget/legacy/zero.c
index c88f5e0..0087ef8 100644
--- a/drivers/usb/gadget/legacy/zero.c
+++ b/drivers/usb/gadget/legacy/zero.c
@@ -64,6 +64,7 @@ static bool loopdefault = 0;
 module_param(loopdefault, bool, S_IRUGO|S_IWUSR);
 
 static struct usb_zero_options gzero_options = {
+	.verify_rx_data = GZERO_VERIFY_RX_DATA,
 	.isoc_interval = GZERO_ISOC_INTERVAL,
 	.isoc_maxpacket = GZERO_ISOC_MAXPACKET,
 	.bulk_buflen = GZERO_BULK_BUFLEN,
@@ -236,6 +237,9 @@ module_param_named(buflen, gzero_options.bulk_buflen, uint, 0);
 module_param_named(pattern, gzero_options.pattern, uint, S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(pattern, "0 = all zeroes, 1 = mod63, 2 = none");
 
+module_param_named(verify, gzero_options.verify_rx_data, uint, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(verify, "Verification of received data : 0 = No, 1 = Yes");
+
 module_param_named(isoc_interval, gzero_options.isoc_interval, uint,
 		S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(isoc_interval, "1 - 16");
@@ -294,6 +298,7 @@ static int zero_bind(struct usb_composite_dev *cdev)
 
 	ss_opts =  container_of(func_inst_ss, struct f_ss_opts, func_inst);
 	ss_opts->pattern = gzero_options.pattern;
+	ss_opts->verify_rx_data = gzero_options.verify_rx_data;
 	ss_opts->isoc_interval = gzero_options.isoc_interval;
 	ss_opts->isoc_maxpacket = gzero_options.isoc_maxpacket;
 	ss_opts->isoc_mult = gzero_options.isoc_mult;
-- 
2.1.1

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

* RE: [LINUX PATCH] usb: gadget: Configure data verification through module parameter in gadget zero
  2016-09-29  8:48 [LINUX PATCH] usb: gadget: Configure data verification through module parameter in gadget zero Manish Narani
@ 2016-09-29  9:16 ` Peter Chen
  2016-09-29 11:25 ` Greg KH
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Chen @ 2016-09-29  9:16 UTC (permalink / raw)
  To: Manish Narani, balbi, gregkh, k.opasiak, r.baldyga, peter.chen,
	mnarani, John.Youn, eu, i.kotrasinsk, linux-usb, linux-kernel
  Cc: anuragku, punnaia

 
>
>This patch adds support to configure data verification through module parameter.
>This parameter can be used to disable data verification in case if one wants to
>measure peak Bulk/Isoc-IN/OUT performance
>

Would configfs parameter 'pattern' can't satisfy you?

Peter

>Signed-off-by: Manish Narani <mnarani@xilinx.com>
>---
> drivers/usb/gadget/function/f_sourcesink.c | 6 ++++--
> drivers/usb/gadget/function/g_zero.h       | 3 +++
> drivers/usb/gadget/legacy/zero.c           | 5 +++++
> 3 files changed, 12 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/usb/gadget/function/f_sourcesink.c
>b/drivers/usb/gadget/function/f_sourcesink.c
>index 81274ba..2328d11 100644
>--- a/drivers/usb/gadget/function/f_sourcesink.c
>+++ b/drivers/usb/gadget/function/f_sourcesink.c
>@@ -45,6 +45,7 @@ struct f_sourcesink {
> 	int			cur_alt;
>
> 	unsigned pattern;
>+	unsigned verify_rx_data;
> 	unsigned isoc_interval;
> 	unsigned isoc_maxpacket;
> 	unsigned isoc_mult;
>@@ -552,7 +553,7 @@ static void source_sink_complete(struct usb_ep *ep, struct
>usb_request *req)
> 	switch (status) {
>
> 	case 0:				/* normal completion? */
>-		if (ep == ss->out_ep) {
>+		if (ss->verify_rx_data && (ep == ss->out_ep)) {
> 			check_read_data(ss, req);
> 			if (ss->pattern != 2)
> 				memset(req->buf, 0x55, req->length); @@ -630,7
>+631,7 @@ static int source_sink_start_ep(struct f_sourcesink *ss, bool is_in,
> 		req->complete = source_sink_complete;
> 		if (is_in)
> 			reinit_write_data(ep, req);
>-		else if (ss->pattern != 2)
>+		else if (ss->verify_rx_data && (ss->pattern != 2))
> 			memset(req->buf, 0x55, req->length);
>
> 		status = usb_ep_queue(ep, req, GFP_ATOMIC); @@ -866,6 +867,7
>@@ static struct usb_function *source_sink_alloc_func(
> 	mutex_unlock(&ss_opts->lock);
>
> 	ss->pattern = ss_opts->pattern;
>+	ss->verify_rx_data = ss_opts->verify_rx_data;
> 	ss->isoc_interval = ss_opts->isoc_interval;
> 	ss->isoc_maxpacket = ss_opts->isoc_maxpacket;
> 	ss->isoc_mult = ss_opts->isoc_mult;
>diff --git a/drivers/usb/gadget/function/g_zero.h
>b/drivers/usb/gadget/function/g_zero.h
>index b3234e7..8e5d20c 100644
>--- a/drivers/usb/gadget/function/g_zero.h
>+++ b/drivers/usb/gadget/function/g_zero.h
>@@ -6,6 +6,7 @@
> #ifndef __G_ZERO_H
> #define __G_ZERO_H
>
>+#define GZERO_VERIFY_RX_DATA	1
> #define GZERO_BULK_BUFLEN	4096
> #define GZERO_QLEN		32
> #define GZERO_ISOC_INTERVAL	4
>@@ -15,6 +16,7 @@
>
> struct usb_zero_options {
> 	unsigned pattern;
>+	unsigned verify_rx_data;
> 	unsigned isoc_interval;
> 	unsigned isoc_maxpacket;
> 	unsigned isoc_mult;
>@@ -29,6 +31,7 @@ struct usb_zero_options {  struct f_ss_opts {
> 	struct usb_function_instance func_inst;
> 	unsigned pattern;
>+	unsigned verify_rx_data;
> 	unsigned isoc_interval;
> 	unsigned isoc_maxpacket;
> 	unsigned isoc_mult;
>diff --git a/drivers/usb/gadget/legacy/zero.c b/drivers/usb/gadget/legacy/zero.c
>index c88f5e0..0087ef8 100644
>--- a/drivers/usb/gadget/legacy/zero.c
>+++ b/drivers/usb/gadget/legacy/zero.c
>@@ -64,6 +64,7 @@ static bool loopdefault = 0;  module_param(loopdefault, bool,
>S_IRUGO|S_IWUSR);
>
> static struct usb_zero_options gzero_options = {
>+	.verify_rx_data = GZERO_VERIFY_RX_DATA,
> 	.isoc_interval = GZERO_ISOC_INTERVAL,
> 	.isoc_maxpacket = GZERO_ISOC_MAXPACKET,
> 	.bulk_buflen = GZERO_BULK_BUFLEN,
>@@ -236,6 +237,9 @@ module_param_named(buflen, gzero_options.bulk_buflen,
>uint, 0);  module_param_named(pattern, gzero_options.pattern, uint,
>S_IRUGO|S_IWUSR);  MODULE_PARM_DESC(pattern, "0 = all zeroes, 1 =
>mod63, 2 = none");
>
>+module_param_named(verify, gzero_options.verify_rx_data, uint,
>+S_IRUGO|S_IWUSR); MODULE_PARM_DESC(verify, "Verification of received
>+data : 0 = No, 1 = Yes");
>+
> module_param_named(isoc_interval, gzero_options.isoc_interval, uint,
> 		S_IRUGO|S_IWUSR);
> MODULE_PARM_DESC(isoc_interval, "1 - 16"); @@ -294,6 +298,7 @@ static int
>zero_bind(struct usb_composite_dev *cdev)
>
> 	ss_opts =  container_of(func_inst_ss, struct f_ss_opts, func_inst);
> 	ss_opts->pattern = gzero_options.pattern;
>+	ss_opts->verify_rx_data = gzero_options.verify_rx_data;
> 	ss_opts->isoc_interval = gzero_options.isoc_interval;
> 	ss_opts->isoc_maxpacket = gzero_options.isoc_maxpacket;
> 	ss_opts->isoc_mult = gzero_options.isoc_mult;
>--
>2.1.1

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

* Re: [LINUX PATCH] usb: gadget: Configure data verification through module parameter in gadget zero
  2016-09-29  8:48 [LINUX PATCH] usb: gadget: Configure data verification through module parameter in gadget zero Manish Narani
  2016-09-29  9:16 ` Peter Chen
@ 2016-09-29 11:25 ` Greg KH
  2016-09-30 11:13   ` Manish Narani
  1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2016-09-29 11:25 UTC (permalink / raw)
  To: Manish Narani
  Cc: balbi, k.opasiak, r.baldyga, peter.chen, mnarani, John.Youn, eu,
	i.kotrasinsk, linux-usb, linux-kernel, anuragku, punnaia

On Thu, Sep 29, 2016 at 02:18:54PM +0530, Manish Narani wrote:
> This patch adds support to configure data verification through
> module parameter. This parameter can be used to disable data
> verification in case if one wants to measure peak Bulk/Isoc-IN/OUT
> performance
> 
> Signed-off-by: Manish Narani <mnarani@xilinx.com>

Minor question, why would this be anything other than a LINUX PATCH?  :)

Just "PATCH" is usually fine here.

And again, please no new module parameters if at all possible.

thanks,

greg k-h

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

* RE: [LINUX PATCH] usb: gadget: Configure data verification through module parameter in gadget zero
  2016-09-29 11:25 ` Greg KH
@ 2016-09-30 11:13   ` Manish Narani
  0 siblings, 0 replies; 4+ messages in thread
From: Manish Narani @ 2016-09-30 11:13 UTC (permalink / raw)
  To: Greg KH
  Cc: balbi, k.opasiak, r.baldyga, peter.chen, John.Youn, eu,
	i.kotrasinsk, linux-usb, linux-kernel, Anurag Kumar Vulisha,
	Punnaiah Choudary Kalluri

Hi Greg,

Thanks for the suggestion. I will fix it and send you in next version. :)

Regards,
Manish

-----Original Message-----
From: Greg KH [mailto:gregkh@linuxfoundation.org]
Sent: Thursday, September 29, 2016 4:56 PM
To: Manish Narani <MNARANI@xilinx.com>
Cc: balbi@kernel.org; k.opasiak@samsung.com; r.baldyga@samsung.com; peter.chen@freescale.com; Manish Narani <MNARANI@xilinx.com>; John.Youn@synopsys.com; eu@felipetonello.com; i.kotrasinsk@samsung.com; linux-usb@vger.kernel.org; linux-kernel@vger.kernel.org; Anurag Kumar Vulisha <anuragku@xilinx.com>; Punnaiah Choudary Kalluri <punnaia@xilinx.com>
Subject: Re: [LINUX PATCH] usb: gadget: Configure data verification through module parameter in gadget zero

On Thu, Sep 29, 2016 at 02:18:54PM +0530, Manish Narani wrote:
> This patch adds support to configure data verification through module
> parameter. This parameter can be used to disable data verification in
> case if one wants to measure peak Bulk/Isoc-IN/OUT performance
>
> Signed-off-by: Manish Narani <mnarani@xilinx.com>

Minor question, why would this be anything other than a LINUX PATCH?  :)

Just "PATCH" is usually fine here.

And again, please no new module parameters if at all possible.

thanks,

greg k-h


This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

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

end of thread, other threads:[~2016-09-30 11:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-29  8:48 [LINUX PATCH] usb: gadget: Configure data verification through module parameter in gadget zero Manish Narani
2016-09-29  9:16 ` Peter Chen
2016-09-29 11:25 ` Greg KH
2016-09-30 11:13   ` Manish Narani

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.