linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: linux-kernel@vger.kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>, Karsten Keil <isdn@linux-pingi.de>,
	netdev@vger.kernel.org
Subject: [PATCH 13/16] isdn: hisax/elsa: fix sleep_on race in elsa FSM
Date: Wed, 26 Feb 2014 12:01:53 +0100	[thread overview]
Message-ID: <1393412516-3762435-14-git-send-email-arnd@arndb.de> (raw)
In-Reply-To: <1393412516-3762435-1-git-send-email-arnd@arndb.de>

The state machine code in the elsa driver uses interruptible_sleep_on
to wait for state changes, which is racy. A closer look at the possible
states reveals that it is always used to wait for getting back into
ARCOFI_NOP, so we can use wait_event_interruptible instead.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Karsten Keil <isdn@linux-pingi.de>
Cc: netdev@vger.kernel.org
---
 drivers/isdn/hisax/elsa.c     | 9 ++++++---
 drivers/isdn/hisax/elsa_ser.c | 3 ++-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
index 2be1c8a..d8ef64d 100644
--- a/drivers/isdn/hisax/elsa.c
+++ b/drivers/isdn/hisax/elsa.c
@@ -509,7 +509,8 @@ static void
 set_arcofi(struct IsdnCardState *cs, int bc) {
 	cs->dc.isac.arcofi_bc = bc;
 	arcofi_fsm(cs, ARCOFI_START, &ARCOFI_COP_5);
-	interruptible_sleep_on(&cs->dc.isac.arcofi_wait);
+	wait_event_interruptible(cs->dc.isac.arcofi_wait,
+				 cs->dc.isac.arcofi_state == ARCOFI_NOP);
 }
 
 static int
@@ -528,7 +529,8 @@ check_arcofi(struct IsdnCardState *cs)
 		}
 	cs->dc.isac.arcofi_bc = 0;
 	arcofi_fsm(cs, ARCOFI_START, &ARCOFI_VERSION);
-	interruptible_sleep_on(&cs->dc.isac.arcofi_wait);
+	wait_event_interruptible(cs->dc.isac.arcofi_wait,
+				 cs->dc.isac.arcofi_state == ARCOFI_NOP);
 	if (!test_and_clear_bit(FLG_ARCOFI_ERROR, &cs->HW_Flags)) {
 		debugl1(cs, "Arcofi response received %d bytes", cs->dc.isac.mon_rxp);
 		p = cs->dc.isac.mon_rx;
@@ -595,7 +597,8 @@ check_arcofi(struct IsdnCardState *cs)
 			       Elsa_Types[cs->subtyp],
 			       cs->hw.elsa.base + 8);
 		arcofi_fsm(cs, ARCOFI_START, &ARCOFI_XOP_0);
-		interruptible_sleep_on(&cs->dc.isac.arcofi_wait);
+		wait_event_interruptible(cs->dc.isac.arcofi_wait,
+				 cs->dc.isac.arcofi_state == ARCOFI_NOP);
 		return (1);
 	}
 	return (0);
diff --git a/drivers/isdn/hisax/elsa_ser.c b/drivers/isdn/hisax/elsa_ser.c
index 3f84dd8..a2a358c 100644
--- a/drivers/isdn/hisax/elsa_ser.c
+++ b/drivers/isdn/hisax/elsa_ser.c
@@ -573,7 +573,8 @@ modem_l2l1(struct PStack *st, int pr, void *arg)
 		test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag);
 		bcs->cs->dc.isac.arcofi_bc = st->l1.bc;
 		arcofi_fsm(bcs->cs, ARCOFI_START, &ARCOFI_XOP_0);
-		interruptible_sleep_on(&bcs->cs->dc.isac.arcofi_wait);
+		wait_event_interruptible(bcs->cs->dc.isac.arcofi_wait,
+				 bcs->cs->dc.isac.arcofi_state == ARCOFI_NOP);
 		bcs->cs->hw.elsa.MFlag = 1;
 	} else {
 		printk(KERN_WARNING "ElsaSer: unknown pr %x\n", pr);
-- 
1.8.3.2


  parent reply	other threads:[~2014-02-26 11:06 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-26 11:01 [PATCH 00/16] sleep_on removal, second try Arnd Bergmann
2014-02-26 11:01 ` [PATCH 01/16] ataflop: fix sleep_on races Arnd Bergmann
2014-02-26 11:01 ` [PATCH 02/16] scsi: atari_scsi: fix sleep_on race Arnd Bergmann
2014-02-27  7:58   ` Michael Schmitz
2014-02-27 20:44     ` Arnd Bergmann
2014-03-01  0:24       ` Michael Schmitz
2014-02-26 11:01 ` [PATCH 03/16] DAC960: remove sleep_on usage Arnd Bergmann
2014-02-26 11:01 ` [PATCH 04/16] swim3: fix interruptible_sleep_on race Arnd Bergmann
2014-02-26 11:01 ` [PATCH 05/16] [media] omap_vout: avoid sleep_on race Arnd Bergmann
2014-02-26 11:01 ` [PATCH 06/16] [media] usbvision: drop unused define USBVISION_SAY_AND_WAIT Arnd Bergmann
2014-02-26 11:01 ` [PATCH 07/16] [media] radio-cadet: avoid interruptible_sleep_on race Arnd Bergmann
2014-02-26 11:01 ` [PATCH 08/16] [media] arv: fix sleep_on race Arnd Bergmann
2014-02-26 11:01 ` [PATCH 09/16] parport: fix interruptible_sleep_on race Arnd Bergmann
2014-02-26 11:01 ` [PATCH 10/16] atm: nicstar: remove interruptible_sleep_on_timeout Arnd Bergmann
2014-02-26 16:06   ` David Miller
2014-02-27 18:51     ` [PATCH v3] " Arnd Bergmann
2014-02-27 20:23       ` David Miller
2014-02-26 11:01 ` [PATCH 11/16] atm: firestream: fix interruptible_sleep_on race Arnd Bergmann
2014-02-26 21:08   ` David Miller
2014-02-26 11:01 ` [PATCH 12/16] isdn: pcbit: " Arnd Bergmann
2014-02-26 21:08   ` David Miller
2014-02-26 11:01 ` Arnd Bergmann [this message]
2014-02-26 21:08   ` [PATCH 13/16] isdn: hisax/elsa: fix sleep_on race in elsa FSM David Miller
2014-02-26 11:01 ` [PATCH 14/16] isdn: divert, hysdn: fix interruptible_sleep_on race Arnd Bergmann
2014-02-26 21:08   ` David Miller
2014-02-26 11:01 ` [PATCH 15/16] isdn: fix multiple sleep_on races Arnd Bergmann
2014-02-26 21:08   ` David Miller
2014-02-26 11:01 ` [PATCH 16/16] NOTYET: sched: remove sleep_on() and friends Arnd Bergmann
2014-02-26 17:36 ` [PATCH 00/16] sleep_on removal, second try Jens Axboe
2014-02-27  6:37 ` Michael Schmitz
2014-02-27 11:55   ` Geert Uytterhoeven
2014-02-28  8:53 ` Karsten Keil

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=1393412516-3762435-14-git-send-email-arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=isdn@linux-pingi.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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).