linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] USB: dummy-hcd: some updates
@ 2019-10-21 14:20 Andrey Konovalov
  2019-10-21 14:20 ` [PATCH v2 1/2] USB: dummy-hcd: increase max number of devices to 32 Andrey Konovalov
  2019-10-21 14:20 ` [PATCH v2 2/2] USB: dummy-hcd: use usb_urb_dir_in instead of usb_pipein Andrey Konovalov
  0 siblings, 2 replies; 3+ messages in thread
From: Andrey Konovalov @ 2019-10-21 14:20 UTC (permalink / raw)
  To: linux-usb, linux-kernel, Greg Kroah-Hartman, Alan Stern
  Cc: Felipe Balbi, Chunfeng Yun, Jacky . Cao @ sony . com,
	Dmitry Vyukov, Alexander Potapenko, Marco Elver,
	Andrey Konovalov

Changes in v2:
- Added missing Signed-off-by.
- Added better explanation as to why we need more Dummy devices.

Andrey Konovalov (2):
  USB: dummy-hcd: increase max number of devices to 32
  USB: dummy-hcd: use usb_urb_dir_in instead of usb_pipein

 drivers/usb/gadget/udc/dummy_hcd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

-- 
2.23.0.866.gb869b98d4c-goog


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

* [PATCH v2 1/2] USB: dummy-hcd: increase max number of devices to 32
  2019-10-21 14:20 [PATCH v2 0/2] USB: dummy-hcd: some updates Andrey Konovalov
@ 2019-10-21 14:20 ` Andrey Konovalov
  2019-10-21 14:20 ` [PATCH v2 2/2] USB: dummy-hcd: use usb_urb_dir_in instead of usb_pipein Andrey Konovalov
  1 sibling, 0 replies; 3+ messages in thread
From: Andrey Konovalov @ 2019-10-21 14:20 UTC (permalink / raw)
  To: linux-usb, linux-kernel, Greg Kroah-Hartman, Alan Stern
  Cc: Felipe Balbi, Chunfeng Yun, Jacky . Cao @ sony . com,
	Dmitry Vyukov, Alexander Potapenko, Marco Elver,
	Andrey Konovalov

When fuzzing the USB subsystem with syzkaller, we currently use 8 testing
processes within one VM. To isolate testing processes from one another it
is desirable to assign a dedicated USB bus to each of those, which means
we need at least 8 Dummy UDC/HCD devices.

This patch increases the maximum number of Dummy UDC/HCD devices to 32
(more than 8 in case we need more of them in the future).

Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
---
 drivers/usb/gadget/udc/dummy_hcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
index 3d499d93c083..a8f1e5707c14 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -2725,7 +2725,7 @@ static struct platform_driver dummy_hcd_driver = {
 };
 
 /*-------------------------------------------------------------------------*/
-#define MAX_NUM_UDC	2
+#define MAX_NUM_UDC	32
 static struct platform_device *the_udc_pdev[MAX_NUM_UDC];
 static struct platform_device *the_hcd_pdev[MAX_NUM_UDC];
 
-- 
2.23.0.866.gb869b98d4c-goog


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

* [PATCH v2 2/2] USB: dummy-hcd: use usb_urb_dir_in instead of usb_pipein
  2019-10-21 14:20 [PATCH v2 0/2] USB: dummy-hcd: some updates Andrey Konovalov
  2019-10-21 14:20 ` [PATCH v2 1/2] USB: dummy-hcd: increase max number of devices to 32 Andrey Konovalov
@ 2019-10-21 14:20 ` Andrey Konovalov
  1 sibling, 0 replies; 3+ messages in thread
From: Andrey Konovalov @ 2019-10-21 14:20 UTC (permalink / raw)
  To: linux-usb, linux-kernel, Greg Kroah-Hartman, Alan Stern
  Cc: Felipe Balbi, Chunfeng Yun, Jacky . Cao @ sony . com,
	Dmitry Vyukov, Alexander Potapenko, Marco Elver,
	Andrey Konovalov

Commit fea3409112a9 ("USB: add direction bit to urb->transfer_flags") has
added a usb_urb_dir_in() helper function that can be used to determine
the direction of the URB. With that patch USB_DIR_IN control requests with
wLength == 0 are considered out requests by real USB HCDs. This patch
changes dummy-hcd to use the usb_urb_dir_in() helper to match that
behavior.

Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
---
 drivers/usb/gadget/udc/dummy_hcd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
index a8f1e5707c14..4c9d1e49d5ed 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -1321,7 +1321,7 @@ static int dummy_perform_transfer(struct urb *urb, struct dummy_request *req,
 	u32 this_sg;
 	bool next_sg;
 
-	to_host = usb_pipein(urb->pipe);
+	to_host = usb_urb_dir_in(urb);
 	rbuf = req->req.buf + req->req.actual;
 
 	if (!urb->num_sgs) {
@@ -1409,7 +1409,7 @@ static int transfer(struct dummy_hcd *dum_hcd, struct urb *urb,
 
 		/* FIXME update emulated data toggle too */
 
-		to_host = usb_pipein(urb->pipe);
+		to_host = usb_urb_dir_in(urb);
 		if (unlikely(len == 0))
 			is_short = 1;
 		else {
@@ -1830,7 +1830,7 @@ static void dummy_timer(struct timer_list *t)
 
 		/* find the gadget's ep for this request (if configured) */
 		address = usb_pipeendpoint (urb->pipe);
-		if (usb_pipein(urb->pipe))
+		if (usb_urb_dir_in(urb))
 			address |= USB_DIR_IN;
 		ep = find_endpoint(dum, address);
 		if (!ep) {
@@ -2385,7 +2385,7 @@ static inline ssize_t show_urb(char *buf, size_t size, struct urb *urb)
 			s = "?";
 			break;
 		 } s; }),
-		ep, ep ? (usb_pipein(urb->pipe) ? "in" : "out") : "",
+		ep, ep ? (usb_urb_dir_in(urb) ? "in" : "out") : "",
 		({ char *s; \
 		switch (usb_pipetype(urb->pipe)) { \
 		case PIPE_CONTROL: \
-- 
2.23.0.866.gb869b98d4c-goog


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

end of thread, other threads:[~2019-10-21 14:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-21 14:20 [PATCH v2 0/2] USB: dummy-hcd: some updates Andrey Konovalov
2019-10-21 14:20 ` [PATCH v2 1/2] USB: dummy-hcd: increase max number of devices to 32 Andrey Konovalov
2019-10-21 14:20 ` [PATCH v2 2/2] USB: dummy-hcd: use usb_urb_dir_in instead of usb_pipein Andrey Konovalov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).