From: Oliver Neukum <oliver@neukum.org>
To: Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
Cc: netdev@vger.kernel.org, linux-usb@vger.kernel.org
Subject: Re: [RFC] Patch to option HSO driver to the kernel
Date: Thu, 17 Apr 2008 16:32:12 +0200 [thread overview]
Message-ID: <200804171632.12972.oliver@neukum.org> (raw)
In-Reply-To: <48060536.60005@teltonika.lt>
Am Mittwoch, 16. April 2008 15:55:02 schrieb Paulius Zaleckas:
> Oliver Neukum wrote:
> > Am Mittwoch, 16. April 2008 14:12:06 schrieb Paulius Zaleckas:
> >> I always get crash when closing serial terminal application. I will
> >> post dump in couple minutes.
> >
> > Does this fix it?
> >
>
> Yes, it does! Thank you.
Hi,
can you test this one as well. The method used to determine whether
a device is asleep is racy. This introduces a private test.
Regards
Oliver
---
--- linux-2.6.25hso/drivers/net/usb/hso.c.alt2 2008-04-17 14:15:32.000000000 +0200
+++ linux-2.6.25hso/drivers/net/usb/hso.c 2008-04-17 16:11:50.000000000 +0200
@@ -242,6 +242,7 @@ struct hso_device {
u8 is_active;
u8 suspend_disabled;
u8 usb_gone;
+ u8 sleeping;
struct work_struct async_get_intf;
struct work_struct async_put_intf;
@@ -252,6 +253,7 @@ struct hso_device {
struct device *dev;
struct kref ref;
struct mutex mutex;
+ spinlock_t lock;
/* TODO: Not sure about the ones below */
struct proc_dir_entry *ourproc;
@@ -2184,6 +2186,7 @@ static struct hso_device *hso_create_dev
hso_dev->interface = intf;
kref_init(&hso_dev->ref);
mutex_init(&hso_dev->mutex);
+ spin_lock_init(&hso_dev->lock);
INIT_WORK(&hso_dev->async_get_intf, async_get_intf);
INIT_WORK(&hso_dev->async_put_intf, async_put_intf);
@@ -2757,12 +2760,16 @@ static void async_put_intf(struct work_s
static int hso_get_activity(struct hso_device *hso_dev)
{
- if (hso_dev->usb->state == USB_STATE_SUSPENDED) {
+ unsigned long flags;
+
+ spin_lock_irqsave(&hso_dev->lock, flags);
+ if (hso_dev->sleeping) {
if (!hso_dev->is_active) {
hso_dev->is_active = 1;
schedule_work(&hso_dev->async_get_intf);
}
}
+ spin_unlock_irqrestore(&hso_dev->lock, flags);
if (hso_dev->usb->state != USB_STATE_CONFIGURED)
return -EAGAIN;
@@ -2774,22 +2781,32 @@ static int hso_get_activity(struct hso_d
static int hso_put_activity(struct hso_device *hso_dev)
{
- if (hso_dev->usb->state != USB_STATE_SUSPENDED) {
+ unsigned long flags;
+
+ spin_lock_irqsave(&hso_dev->lock, flags);
+ if (hso_dev->sleeping) {
if (hso_dev->is_active) {
hso_dev->is_active = 0;
schedule_work(&hso_dev->async_put_intf);
+ spin_unlock_irqrestore(&hso_dev->lock, flags);
return -EAGAIN;
}
}
hso_dev->is_active = 0;
+ spin_unlock_irqrestore(&hso_dev->lock, flags);
return 0;
}
/* called by kernel when we need to suspend device */
static int hso_suspend(struct usb_interface *iface, pm_message_t message)
{
+ struct hso_device *hso_dev = usb_get_intfdata(iface);
int i, result = 0;
+ spin_lock_irq(&hso_dev->lock);
+ hso_dev->sleeping = 1;
+ spin_unlock_irq(&hso_dev->lock);
+
/* Stop all serial ports */
for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
if (serial_table[i] && (serial_table[i]->interface == iface)) {
@@ -2816,9 +2833,14 @@ out:
/* called by kernel when we need to resume device */
static int hso_resume(struct usb_interface *iface)
{
+ struct hso_device *hso_dev = usb_get_intfdata(iface);
int i, result = 0;
struct hso_net *hso_net;
+ spin_lock_irq(&hso_dev->lock);
+ hso_dev->sleeping = 0;
+ spin_unlock_irq(&hso_dev->lock);
+
/* Start all serial ports */
for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
if (serial_table[i] && (serial_table[i]->interface == iface)) {
next prev parent reply other threads:[~2008-04-17 14:23 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-14 21:32 [RFC] Patch to option HSO driver to the kernel Greg KH
2008-04-15 4:30 ` Oliver Hartkopp
[not found] ` <48042F7F.8030608-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
2008-04-15 16:11 ` Greg KH
[not found] ` <20080415161158.GE9704-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2008-04-15 17:53 ` Oliver Hartkopp
[not found] ` <20080414213238.GB28833-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2008-04-14 21:59 ` Matthew Dharm
2008-04-14 22:42 ` Andrew Bird (Sphere Systems)
2008-04-14 23:03 ` Greg KH
[not found] ` <20080414230309.GA1672-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2008-04-15 8:01 ` Filip Aben
2008-04-15 15:40 ` Greg KH
2008-04-14 23:20 ` Paulius Zaleckas
2008-04-15 8:10 ` Oliver Neukum
[not found] ` <200804151010.33688.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2008-04-15 8:58 ` Paulius Zaleckas
[not found] ` <48046E4A.3060901-Ft0m5Q12RQ9xBelEqimL3w@public.gmane.org>
2008-04-15 15:39 ` Greg KH
2008-04-15 11:44 ` Oliver Neukum
[not found] ` <200804151344.42085.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2008-04-15 16:06 ` Greg KH
2008-04-15 13:06 ` Oliver Neukum
[not found] ` <200804151506.21856.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2008-04-15 16:08 ` Greg KH
2008-04-15 16:08 ` Greg KH
2008-04-15 13:25 ` Oliver Neukum
2008-04-15 14:12 ` Filip Aben
2008-04-15 14:14 ` Oliver Neukum
2008-04-15 15:03 ` Filip Aben
2008-04-15 15:34 ` Greg KH
[not found] ` <20080415153408.GB7996-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2008-04-15 16:24 ` Filip Aben
2008-04-15 17:58 ` Oliver Neukum
2008-04-15 18:46 ` Oliver Neukum
[not found] ` <200804152046.44018.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2008-04-15 19:00 ` Greg KH
2008-04-15 19:14 ` Stephen Hemminger
2008-04-15 19:27 ` Greg KH
2008-04-15 20:17 ` Oliver Neukum
[not found] ` <200804152217.25451.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2008-04-15 22:18 ` Greg KH
2008-04-17 12:15 ` Oliver Neukum
2008-04-17 21:35 ` Greg KH
2008-04-15 22:49 ` Paulius Zaleckas
[not found] ` <480530E6.8020700-Ft0m5Q12RQ9xBelEqimL3w@public.gmane.org>
2008-04-16 9:18 ` Paulius Zaleckas
[not found] ` <4805C469.7050408-Ft0m5Q12RQ9xBelEqimL3w@public.gmane.org>
2008-04-16 11:54 ` Paulius Zaleckas
[not found] ` <4805E8E1.3090200-Ft0m5Q12RQ9xBelEqimL3w@public.gmane.org>
2008-04-16 12:03 ` Oliver Neukum
[not found] ` <200804161403.20955.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2008-04-16 12:12 ` Paulius Zaleckas
[not found] ` <4805ED16.3080104-Ft0m5Q12RQ9xBelEqimL3w@public.gmane.org>
2008-04-16 13:43 ` Oliver Neukum
[not found] ` <200804161543.23584.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2008-04-16 13:55 ` Paulius Zaleckas
2008-04-17 14:32 ` Oliver Neukum [this message]
[not found] ` <200804171632.12972.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2008-04-17 21:47 ` Paulius Zaleckas
[not found] ` <4807C56F.5060804-Ft0m5Q12RQ9xBelEqimL3w@public.gmane.org>
2008-04-17 22:31 ` Chetty, Jay
2008-04-18 6:51 ` Oliver Neukum
2008-04-18 15:18 ` Paulius Zaleckas
2008-04-21 11:45 ` Oliver Neukum
2008-04-21 12:38 ` Paulius Zaleckas
[not found] ` <480C8AD8.9050609-Ft0m5Q12RQ9xBelEqimL3w@public.gmane.org>
2008-04-21 12:50 ` Oliver Neukum
[not found] ` <200804211450.27093.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2008-04-21 13:00 ` Paulius Zaleckas
2008-04-17 21:33 ` Greg KH
2008-04-16 15:15 ` Paulius Zaleckas
2008-04-16 13:11 ` Paulius Zaleckas
2008-04-15 13:55 ` Oliver Neukum
2008-04-15 16:10 ` Greg KH
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=200804171632.12972.oliver@neukum.org \
--to=oliver@neukum.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=paulius.zaleckas@teltonika.lt \
/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;
as well as URLs for NNTP newsgroup(s).