From: syzbot <syzbot+f342ea16c9d06d80b585@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] Re: [syzbot] [usb?] INFO: task hung in usb_port_suspend
Date: Sun, 13 Oct 2024 18:24:32 -0700 [thread overview]
Message-ID: <670c72d0.050a0220.4cbc0.003d.GAE@google.com> (raw)
In-Reply-To: <6709234e.050a0220.3e960.0011.GAE@google.com>
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: Re: [syzbot] [usb?] INFO: task hung in usb_port_suspend
Author: stern@rowland.harvard.edu
On Sun, Oct 13, 2024 at 01:34:05PM -0700, syzbot wrote:
> Hello,
>
> syzbot has tested the proposed patch but the reproducer is still triggering an issue:
Okay, that's more like it. This exercise has focused my mind on one
particular spot in the code, and I believe I see the problem. The
driver needs to do a more careful job keeping track of whether the
hrtimer callback is pending; neither hrtimer_active() nor
dum_hcd->rh_state is quite the right thing to test. In particular, the
root hub can be in the DUMMY_RH_RUNNING state without the timer being
active.
This patch adds a flag for a pending timer callback, on top of all the
other debugging material. Let's see if it fixes the problem.
Alan Stern
#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
usb-testing
Index: usb-devel/drivers/usb/gadget/udc/dummy_hcd.c
===================================================================
--- usb-devel.orig/drivers/usb/gadget/udc/dummy_hcd.c
+++ usb-devel/drivers/usb/gadget/udc/dummy_hcd.c
@@ -50,7 +50,7 @@
#define POWER_BUDGET 500 /* in mA; use 8 for low-power port testing */
#define POWER_BUDGET_3 900 /* in mA */
-#define DUMMY_TIMER_INT_NSECS 125000 /* 1 microframe */
+#define DUMMY_INT_KTIME ns_to_ktime(125000) /* 1 microframe */
static const char driver_name[] = "dummy_hcd";
static const char driver_desc[] = "USB Host+Gadget Emulator";
@@ -254,9 +254,12 @@ struct dummy_hcd {
u32 stream_en_ep;
u8 num_stream[30 / 2];
+ unsigned timer_pending:1;
unsigned active:1;
unsigned old_active:1;
unsigned resuming:1;
+
+ bool alanflag;
};
struct dummy {
@@ -1303,9 +1306,11 @@ static int dummy_urb_enqueue(
urb->error_count = 1; /* mark as a new urb */
/* kick the scheduler, it'll do the rest */
- if (!hrtimer_active(&dum_hcd->timer))
- hrtimer_start(&dum_hcd->timer, ns_to_ktime(DUMMY_TIMER_INT_NSECS),
+ if (!dum_hcd->timer_pending) {
+ hrtimer_start(&dum_hcd->timer, DUMMY_INT_KTIME,
HRTIMER_MODE_REL_SOFT);
+ dum_hcd->timer_pending = 1;
+ }
done:
spin_unlock_irqrestore(&dum_hcd->dum->lock, flags);
@@ -1324,10 +1329,17 @@ static int dummy_urb_dequeue(struct usb_
spin_lock_irqsave(&dum_hcd->dum->lock, flags);
rc = usb_hcd_check_unlink_urb(hcd, urb, status);
- if (!rc && dum_hcd->rh_state != DUMMY_RH_RUNNING &&
- !list_empty(&dum_hcd->urbp_list))
- hrtimer_start(&dum_hcd->timer, ns_to_ktime(0), HRTIMER_MODE_REL_SOFT);
-
+ if (!rc && !dum_hcd->timer_pending &&
+ !list_empty(&dum_hcd->urbp_list)) {
+ dev_info(dummy_dev(dum_hcd), "Dequeue restart %p\n", urb);
+ hrtimer_start(&dum_hcd->timer, DUMMY_INT_KTIME,
+ HRTIMER_MODE_REL_SOFT);
+ dum_hcd->timer_pending = 1;
+ } else {
+ dev_info(dummy_dev(dum_hcd), "Dequeue norestart: %d %p\n",
+ rc, urb);
+ }
+ dum_hcd->alanflag = true;
spin_unlock_irqrestore(&dum_hcd->dum->lock, flags);
return rc;
}
@@ -1813,6 +1825,9 @@ static enum hrtimer_restart dummy_timer(
/* look at each urb queued by the host side driver */
spin_lock_irqsave(&dum->lock, flags);
+ dum_hcd->timer_pending = 0;
+ if (dum_hcd->alanflag)
+ dev_info(dummy_dev(dum_hcd), "Timer handler\n");
if (!dum_hcd->udev) {
dev_err(dummy_dev(dum_hcd),
@@ -1984,6 +1999,8 @@ return_urb:
ep->already_seen = ep->setup_stage = 0;
usb_hcd_unlink_urb_from_ep(dummy_hcd_to_hcd(dum_hcd), urb);
+ if (dum_hcd->alanflag)
+ dev_info(dummy_dev(dum_hcd), "Giveback %p\n", urb);
spin_unlock(&dum->lock);
usb_hcd_giveback_urb(dummy_hcd_to_hcd(dum_hcd), urb, status);
spin_lock(&dum->lock);
@@ -1995,11 +2012,12 @@ return_urb:
usb_put_dev(dum_hcd->udev);
dum_hcd->udev = NULL;
} else if (dum_hcd->rh_state == DUMMY_RH_RUNNING) {
- /* want a 1 msec delay here */
- hrtimer_start(&dum_hcd->timer, ns_to_ktime(DUMMY_TIMER_INT_NSECS),
+ hrtimer_start(&dum_hcd->timer, DUMMY_INT_KTIME,
HRTIMER_MODE_REL_SOFT);
+ dum_hcd->timer_pending = 1;
}
+ dum_hcd->alanflag = false;
spin_unlock_irqrestore(&dum->lock, flags);
return HRTIMER_NORESTART;
@@ -2390,8 +2408,11 @@ static int dummy_bus_resume(struct usb_h
} else {
dum_hcd->rh_state = DUMMY_RH_RUNNING;
set_link_state(dum_hcd);
- if (!list_empty(&dum_hcd->urbp_list))
- hrtimer_start(&dum_hcd->timer, ns_to_ktime(0), HRTIMER_MODE_REL_SOFT);
+ if (!list_empty(&dum_hcd->urbp_list)) {
+ hrtimer_start(&dum_hcd->timer, DUMMY_INT_KTIME,
+ HRTIMER_MODE_REL_SOFT);
+ dum_hcd->timer_pending = 1;
+ }
hcd->state = HC_STATE_RUNNING;
}
spin_unlock_irq(&dum_hcd->dum->lock);
@@ -2522,6 +2543,7 @@ static void dummy_stop(struct usb_hcd *h
struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd);
hrtimer_cancel(&dum_hcd->timer);
+ dum_hcd->timer_pending = 0;
device_remove_file(dummy_dev(dum_hcd), &dev_attr_urbs);
dev_info(dummy_dev(dum_hcd), "stopped\n");
}
next prev parent reply other threads:[~2024-10-14 1:24 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-11 13:08 [syzbot] [usb?] INFO: task hung in usb_port_suspend syzbot
2024-10-11 14:08 ` Alan Stern
2024-10-11 14:35 ` syzbot
2024-10-11 14:55 ` Alan Stern
2024-10-11 15:00 ` syzbot
2024-10-11 15:17 ` Alan Stern
2024-10-11 15:45 ` syzbot
2024-10-12 0:48 ` Alan Stern
2024-10-12 1:14 ` syzbot
2024-10-13 1:09 ` Alan Stern
2024-10-13 2:10 ` syzbot
2024-10-13 2:43 ` Alan Stern
2024-10-13 3:05 ` syzbot
2024-10-13 14:30 ` Alan Stern
2024-10-13 15:02 ` syzbot
2024-10-13 15:45 ` Alan Stern
2024-10-13 16:14 ` syzbot
2024-10-13 18:02 ` Alan Stern
2024-10-13 18:38 ` syzbot
2024-10-13 19:24 ` Alan Stern
2024-10-13 20:34 ` syzbot
2024-10-14 1:24 ` syzbot [this message]
2024-10-20 16:38 ` syzbot
2024-10-21 8:04 ` Oliver Neukum
2024-10-21 13:37 ` Alan Stern
2024-10-22 11:42 ` Hillf Danton
2024-10-22 10:46 ` Hillf Danton
2024-10-22 11:29 ` syzbot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=670c72d0.050a0220.4cbc0.003d.GAE@google.com \
--to=syzbot+f342ea16c9d06d80b585@syzkaller.appspotmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox